diff --git a/doc/user_guide.pdf b/doc/user_guide.pdf index 9d7d24922c4389db5d4da282552f411c8a276da8..89d8868221345c8ab22ef416259f945dd8a164ba 100644 Binary files a/doc/user_guide.pdf and b/doc/user_guide.pdf differ diff --git a/examples/advanced/categorical/batch/runExample.log b/examples/advanced/categorical/batch/runExample.log index 543c3aaa8d44d107dbfe215862739a41c25d0335..1eb0da5d245be883b19e5aea1b9f8e5517ddf878 100644 --- a/examples/advanced/categorical/batch/runExample.log +++ b/examples/advanced/categorical/batch/runExample.log @@ -2,22 +2,24 @@ Warning: { Model use is disabled for problem with categorical variables. } Warning: { - Anisotropic mesh are not supported with categorical and binary variables. + Default anisotropic mesh is disabled with categorical and binary variables. } -NOMAD - version 3.7.1 - www.gerad.ca/nomad - -Copyright (C) 2001-2015 { - Mark A. Abramson - The Boeing Company +NOMAD - version 3.7.3 has been created by { Charles Audet - Ecole Polytechnique de Montreal - Gilles Couture - Ecole Polytechnique de Montreal - John E. Dennis, Jr. - Rice University Sebastien Le Digabel - Ecole Polytechnique de Montreal Christophe Tribes - Ecole Polytechnique de Montreal } -Funded in part by AFOSR and Exxon Mobil. +The copyright of NOMAD - version 3.7.3 is owned by { + Sebastien Le Digabel - Ecole Polytechnique de Montreal + Christophe Tribes - Ecole Polytechnique de Montreal +} + +NOMAD version 3 is a new version of Nomad v1 and v2, it has been funded by AFOSR and Exxon Mobil. +Nomad v1 and v2 were created and developed by Mark A. Abramson from The Boeing Company, Charles Audet and Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from Rice University, and were funded by AFOSR and Exxon Mobil. +Download : www.gerad.ca/nomad License : '$NOMAD_HOME/src/lgpl.txt' User guide: '$NOMAD_HOME/doc/user_guide.pdf' Examples : '$NOMAD_HOME/examples' diff --git a/examples/advanced/categorical/bi_obj/makefile b/examples/advanced/categorical/bi_obj/makefile index 914d3388b39f5cbd0a5c710947ff83e06340e703..89f48dd249cced0f4354b0aa57ec8b1e7644a87e 100644 --- a/examples/advanced/categorical/bi_obj/makefile +++ b/examples/advanced/categorical/bi_obj/makefile @@ -1,25 +1,37 @@ -EXE = categorical.exe -EXE_MPI = categorical_MPI.exe - -COMPILATOR = g++ -COMPILATOR_MPI = mpic++ -SUNAME = $(shell uname) -OSS=$(findstring MINGW32,$(SUNAME)) -ifneq "$(strip $(OSS))" "" -COMPILATOR_MPI = g++ -endif +UNAME := $(shell uname) + +EXE = categorical.exe +EXE_MPI = categorical_MPI.exe -COMPILATOR_OPTIONS = -g -ansi +COMPILATOR = g++ +COMPILATOR_MPI = mpic++ + +COMPILATOR_OPTIONS = -O2 -ansi COMPILATOR_OPTIONS_MPI = $(COMPILATOR_OPTIONS) -DUSE_MPI -L1 = $(NOMAD_HOME)/lib/nomad.a -L1_MPI = $(NOMAD_HOME)/lib/nomad.MPI.a -LIBS = $(L1) -lm -LIBS_MPI = $(L1_MPI) -lm -lmpi -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -COMPILE_MPI = $(COMPILATOR_MPI) $(COMPILATOR_OPTIONS_MPI) $(INCLUDE) -c -OBJS = categorical.o -OBJS_MPI = categorical_MPI.o + + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so +LIB_NOMAD_MPI = libnomad.MPI.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif +CXXFLAGS_MPI = $(CXXFLAGS) -DUSE_MPI + + +LDLIBS = -lm -lnomad +LDLIBS_MPI = -lm -lmpi -lnomad.MPI + +INCLUDE = -I$(NOMAD_HOME)/src -I. + +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +COMPILE_MPI = $(COMPILATOR_MPI) $(COMPILATOR_OPTIONS_MPI) $(INCLUDE) -c + +OBJS = categorical.o +OBJS_MPI = categorical_MPI.o ifndef NOMAD_HOME @@ -30,19 +42,23 @@ endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) @echo " building the scalar version ..." @echo " exe file : "$(EXE) - @$(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) - @strip $(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif -$(EXE_MPI): $(L1_MPI) $(OBJS_MPI) +$(EXE_MPI): $(OBJS_MPI) $(ECHO_NOMAD) @echo " building the MPI version ..." @echo " exe file : "$(EXE_MPI) - @$(COMPILATOR_MPI) -o $(EXE_MPI) $(OBJS_MPI) $(LIBS_MPI) $(COMPILATOR_OPTIONS_MPI) - @strip $(EXE_MPI) + @$(COMPILATOR_MPI) -o $(EXE_MPI) $(OBJS_MPI) $(LDLIBS_MPI) $(CXXFLAGS_MPI) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD_MPI) $(NOMAD_HOME)/lib/$(LIB_NOMAD_MPI) $(EXE_MPI) +endif categorical.o: categorical.cpp $(ECHO_NOMAD) @@ -50,10 +66,8 @@ categorical.o: categorical.cpp categorical_MPI.o: categorical.cpp $(ECHO_NOMAD) - @$(COMPILE_MPI) categorical.cpp -o categorical_MPI.o + @$(COMPILE_MPI) categorical.cpp -o $@ -$(L1) $(L1_MPI): ; - $(ECHO_NOMAD) mpi: $(EXE_MPI) diff --git a/examples/advanced/categorical/bi_obj/runExample.log b/examples/advanced/categorical/bi_obj/runExample.log index c73859fdd08a6e92f9df20ed127c12dea3016491..fb0204896a0c6e018c6d94c8bf2d60f2a52552cd 100644 --- a/examples/advanced/categorical/bi_obj/runExample.log +++ b/examples/advanced/categorical/bi_obj/runExample.log @@ -4,42 +4,55 @@ Warning: { Warning: { Default anisotropic mesh is disabled with categorical and binary variables. } -Warning: { - Model use is disabled in parallel mode (MPI). -} -Warning: { - Asynchronous mode is disabled in parallel mode (MPI) when dynamic directions (ortho n+1) are used. -} multi-MADS run { - MADS run 1 ...... OK [bb eval= 78] [overall bb eval= 78] [# dominant pts= 2] [# new pts= 2] [f1=52.02241823 f2=51.31041823] - MADS run 2 ...... OK [bb eval= 39] [overall bb eval= 117] [# dominant pts= 3] [# new pts= 1] [f1=52.0224221 f2=51.0754221] - MADS run 3 ...... OK [bb eval= 39] [overall bb eval= 156] [# dominant pts= 3] [# new pts= 0] [f1=52.02242186 f2=51.23342186] - MADS run 4 ...... OK [bb eval= 38] [overall bb eval= 194] [# dominant pts= 4] [# new pts= 1] [f1=52.02242186 f2=51.06242186] - MADS run 5 ...... OK [bb eval= 39] [overall bb eval= 233] [# dominant pts= 5] [# new pts= 1] [f1=52.02242186 f2=51.19342186] - MADS run 6 ...... OK [bb eval= 7] [overall bb eval= 240] [# dominant pts= 5] [# new pts= 0] [f1=52.02242186 f2=51.19342186] - MADS run 7 ...... OK [bb eval= 39] [overall bb eval= 279] [# dominant pts= 2] [# new pts= -3] [f1=45.36506988 f2=44.51306988] - MADS run 8 ...... OK [bb eval= 39] [overall bb eval= 318] [# dominant pts= 3] [# new pts= 1] [f1=45.36506988 f2=44.51306988] - MADS run 9 ...... OK [bb eval= 39] [overall bb eval= 357] [# dominant pts= 7] [# new pts= 4] [f1=44.99982416 f2=44.55082416] - MADS run 10 ...... OK [bb eval= 39] [overall bb eval= 396] [# dominant pts= 4] [# new pts= -3] [f1=44.97647101 f2=44.00347101] - MADS run 11 ...... OK [bb eval= 39] [overall bb eval= 435] [# dominant pts= 4] [# new pts= 0] [f1=44.9661848 f2=44.1371848] - MADS run 12 ...... OK [bb eval= 39] [overall bb eval= 474] [# dominant pts= 5] [# new pts= 1] [f1=44.9661848 f2=44.1371848] - MADS run 13 ...... OK [bb eval= 26] [overall bb eval= 500] [# dominant pts= 5] [# new pts= 0] [f1=44.96576761 f2=45.17076761] - -} end of run (max number of bb evaluations) - - -blackbox evaluations : 500 -number of MADS runs : 13 + MADS run 1/30 ...... OK [bb eval= 60] [overall bb eval= 60] [# dominant pts= 6] [# new pts= 6] [f1=52.02241823 f2=52.95541823] + MADS run 2/30 ...... OK [bb eval= 74] [overall bb eval= 134] [# dominant pts= 6] [# new pts= 0] [f1=52.02241826 f2=51.05441826] + MADS run 3/30 ...... OK [bb eval= 58] [overall bb eval= 192] [# dominant pts= 7] [# new pts= 1] [f1=52.02241823 f2=51.45041823] + MADS run 4/30 ...... OK [bb eval= 68] [overall bb eval= 260] [# dominant pts= 6] [# new pts= -1] [f1=52.02241823 f2=51.51641823] + MADS run 5/30 ...... OK [bb eval= 54] [overall bb eval= 314] [# dominant pts= 7] [# new pts= 1] [f1=52.02241823 f2=51.41441823] + MADS run 6/30 ...... OK [bb eval= 0] [overall bb eval= 314] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.51641823] + MADS run 7/30 ...... OK [bb eval= 0] [overall bb eval= 314] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.41441823] + MADS run 8/30 ...... OK [bb eval= 0] [overall bb eval= 314] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.51641823] + MADS run 9/30 ...... OK [bb eval= 0] [overall bb eval= 314] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.41441823] + MADS run 10/30 ...... OK [bb eval= 0] [overall bb eval= 314] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.51641823] + MADS run 11/30 ...... OK [bb eval= 0] [overall bb eval= 314] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.41441823] + MADS run 12/30 ...... OK [bb eval= 0] [overall bb eval= 314] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.51641823] + MADS run 13/30 ...... OK [bb eval= 0] [overall bb eval= 314] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.41441823] + MADS run 14/30 ...... OK [bb eval= 49] [overall bb eval= 363] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.25241823] + MADS run 15/30 ...... OK [bb eval= 57] [overall bb eval= 420] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.06141823] + MADS run 16/30 ...... OK [bb eval= 50] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.22141823] + MADS run 17/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.51641823] + MADS run 18/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.41441823] + MADS run 19/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.25241823] + MADS run 20/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.51641823] + MADS run 21/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.41441823] + MADS run 22/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.06141823] + MADS run 23/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.22141823] + MADS run 24/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.25241823] + MADS run 25/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.51641823] + MADS run 26/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.41441823] + MADS run 27/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.06141823] + MADS run 28/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.22141823] + MADS run 29/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.51641823] + MADS run 30/30 ...... OK [bb eval= 0] [overall bb eval= 470] [# dominant pts= 7] [# new pts= 0] [f1=52.02241823 f2=51.25241823] + +} end of run (max number of MADS runs) + + +blackbox evaluations : 470 +number of MADS runs : 30 Pareto front { - 44.9348019953 45.4168019953 - 44.9657676108 45.1707676108 - 44.9661847951 44.1371847951 - 44.9738637269 44.0708637269 - 44.9764710086 44.0034710086 + 52.0224182340 52.9554182340 + 52.0224182340 52.5564182340 + 52.0224182340 51.4504182340 + 52.0224182340 51.2524182340 + 52.0224182340 51.2214182340 + 52.0224182340 51.0614182340 + 52.0224182340 51.0254182340 } -number of Pareto points: 5 +number of Pareto points: 7 diff --git a/examples/advanced/categorical/single_obj/makefile b/examples/advanced/categorical/single_obj/makefile index 305e2bae57e67f5a3c1cccedd12c123be92d4001..89f48dd249cced0f4354b0aa57ec8b1e7644a87e 100644 --- a/examples/advanced/categorical/single_obj/makefile +++ b/examples/advanced/categorical/single_obj/makefile @@ -1,25 +1,37 @@ -EXE = categorical.exe -EXE_MPI = categorical_MPI.exe - -COMPILATOR = g++ -COMPILATOR_MPI = mpic++ -SUNAME = $(shell uname) -OSS=$(findstring MINGW32,$(SUNAME)) -ifneq "$(strip $(OSS))" "" -COMPILATOR_MPI = g++ -endif +UNAME := $(shell uname) + +EXE = categorical.exe +EXE_MPI = categorical_MPI.exe -COMPILATOR_OPTIONS = -O2 -ansi +COMPILATOR = g++ +COMPILATOR_MPI = mpic++ + +COMPILATOR_OPTIONS = -O2 -ansi COMPILATOR_OPTIONS_MPI = $(COMPILATOR_OPTIONS) -DUSE_MPI -L1 = $(NOMAD_HOME)/lib/nomad.a -L1_MPI = $(NOMAD_HOME)/lib/nomad.MPI.a -LIBS = $(L1) -lm -LIBS_MPI = $(L1_MPI) -lm -lmpi -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -COMPILE_MPI = $(COMPILATOR_MPI) $(COMPILATOR_OPTIONS_MPI) $(INCLUDE) -c -OBJS = categorical.o -OBJS_MPI = categorical_MPI.o + + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so +LIB_NOMAD_MPI = libnomad.MPI.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif +CXXFLAGS_MPI = $(CXXFLAGS) -DUSE_MPI + + +LDLIBS = -lm -lnomad +LDLIBS_MPI = -lm -lmpi -lnomad.MPI + +INCLUDE = -I$(NOMAD_HOME)/src -I. + +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +COMPILE_MPI = $(COMPILATOR_MPI) $(COMPILATOR_OPTIONS_MPI) $(INCLUDE) -c + +OBJS = categorical.o +OBJS_MPI = categorical_MPI.o ifndef NOMAD_HOME @@ -30,19 +42,23 @@ endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) @echo " building the scalar version ..." @echo " exe file : "$(EXE) - @$(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) - @strip $(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif -$(EXE_MPI): $(L1_MPI) $(OBJS_MPI) +$(EXE_MPI): $(OBJS_MPI) $(ECHO_NOMAD) @echo " building the MPI version ..." @echo " exe file : "$(EXE_MPI) - @$(COMPILATOR_MPI) -o $(EXE_MPI) $(OBJS_MPI) $(LIBS_MPI) $(COMPILATOR_OPTIONS_MPI) - @strip $(EXE_MPI) + @$(COMPILATOR_MPI) -o $(EXE_MPI) $(OBJS_MPI) $(LDLIBS_MPI) $(CXXFLAGS_MPI) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD_MPI) $(NOMAD_HOME)/lib/$(LIB_NOMAD_MPI) $(EXE_MPI) +endif categorical.o: categorical.cpp $(ECHO_NOMAD) @@ -50,10 +66,8 @@ categorical.o: categorical.cpp categorical_MPI.o: categorical.cpp $(ECHO_NOMAD) - @$(COMPILE_MPI) categorical.cpp -o categorical_MPI.o + @$(COMPILE_MPI) categorical.cpp -o $@ -$(L1) $(L1_MPI): ; - $(ECHO_NOMAD) mpi: $(EXE_MPI) diff --git a/examples/advanced/categorical/single_obj/runExample.log b/examples/advanced/categorical/single_obj/runExample.log index d4a89baa74bd3f7c1abacdd3e0515d145c52fd83..270473f5c679680fa6abeef93990291fa60a572a 100644 --- a/examples/advanced/categorical/single_obj/runExample.log +++ b/examples/advanced/categorical/single_obj/runExample.log @@ -2,7 +2,7 @@ Warning: { Model use is disabled for problem with categorical variables. } Warning: { - Anisotropic mesh are not supported with categorical and binary variables. + Default anisotropic mesh is disabled with categorical and binary variables. } MADS run { @@ -338,424 +338,1864 @@ MADS run { 1626+12 ( 2 0 4406.0444434766 2 5593.9555565234 ) 54.0419580454 (ExtendedPoll) 1626+13 ( 2 0 4028.7079722735 2 5971.2920277265 ) 53.7998378556 (ExtendedPoll) 1626+19 ( 2 0 4154.4867960079 2 5845.5132039921 ) 53.7918826239 (ExtendedPoll) - 1690+27 ( 2 0 4999.9918793150 2 5000.0071042165 ) 55.9016755069 (ExtendedPoll) - 1690+28 ( 2 0 4999.9675172600 2 5000.0284168659 ) 55.9016037165 (ExtendedPoll) - 1690+29 ( 2 0 4999.8700690400 2 5000.1136674635 ) 55.9013165752 (ExtendedPoll) - 1690+30 ( 2 0 4999.4802761598 2 5000.4546698539 ) 55.9001683374 (ExtendedPoll) - 1690+31 ( 2 0 4997.9211046392 2 5001.8186794156 ) 55.8955806263 (ExtendedPoll) - 1690+32 ( 2 0 4991.6844185568 2 5007.2747176624 ) 55.8773137258 (ExtendedPoll) - 1690+33 ( 2 0 4966.7376742271 2 5029.0988706497 ) 55.8055960661 (ExtendedPoll) - 1690+34 ( 2 0 4866.9506969084 2 5116.3954825988 ) 55.5407618647 (ExtendedPoll) - 1690+35 ( 2 0 4467.8027876336 2 5465.5819303951 ) 54.8617064546 (ExtendedPoll) - 1690+37 ( 2 0 4466.8269645111 2 5469.3623920026 ) 54.8295561915 (ExtendedPoll) - 1690+38 ( 2 0 4463.8994951436 2 5480.7037768250 ) 54.7333779337 (ExtendedPoll) - 1690+39 ( 2 0 4452.1896176735 2 5526.0693161146 ) 54.3527873521 (ExtendedPoll) - 1690+40 ( 2 0 4432.0999444382 2 5550.0895775916 ) 54.2727755505 (ExtendedPoll) - 1690+41 ( 2 0 4371.8309247321 2 5622.1503620228 ) 54.0490159101 (ExtendedPoll) - 1690+48 ( 2 0 4367.1633511951 2 5628.4010891571 ) 54.0259049915 (ExtendedPoll) - 1690+52 ( 2 0 4367.4363087119 2 5632.2975577092 ) 53.9839463746 (ExtendedPoll) - 1690+64 ( 2 0 4367.5173563027 2 5632.3888412069 ) 53.9823156833 (ExtendedPoll) - 1690+67 ( 2 0 4367.5750698909 2 5632.4087032645 ) 53.9816128497 (ExtendedPoll) - 1690+77 ( 2 0 4367.5769053809 2 5632.4193356014 ) 53.9814889495 (ExtendedPoll) - 1690+82 ( 2 0 4367.5805624212 2 5632.4182502476 ) 53.9814682147 (ExtendedPoll) - 1690+86 ( 2 0 4367.5821046999 2 5632.4171280385 ) 53.9814662175 (ExtendedPoll) - 1690+90 ( 2 0 4367.5818878523 2 5632.4180567321 ) 53.9814586704 (ExtendedPoll) - 1690+104 ( 2 0 4367.5819056985 2 5632.4180679393 ) 53.9814584017 (ExtendedPoll) - 1690+105 ( 2 0 4367.5819346476 2 5632.4180608593 ) 53.9814582222 (ExtendedPoll) - 1690+109 ( 2 0 4367.5819216978 2 5632.4180774844 ) 53.9814581658 (ExtendedPoll) - 1690+115 ( 2 0 4367.5819257648 2 5632.4180741356 ) 53.9814581645 (ExtendedPoll) - 1690+120 ( 2 0 4367.5819244247 2 5632.4180754292 ) 53.9814581630 (ExtendedPoll) - 1690+121 ( 2 0 4367.5819204043 2 5632.4180793101 ) 53.9814581585 (ExtendedPoll) - 1690+122 ( 2 0 4367.5819043228 2 5632.4180948339 ) 53.9814581405 (ExtendedPoll) - 1690+123 ( 2 0 4367.5818399969 2 5632.4181569287 ) 53.9814580686 (ExtendedPoll) - 1690+124 ( 2 0 4367.5815826929 2 5632.4184053083 ) 53.9814577808 (ExtendedPoll) - 1690+125 ( 2 0 4367.5805534773 2 5632.4193988263 ) 53.9814566296 (ExtendedPoll) - 1690+126 ( 2 0 4367.5764366146 2 5632.4233728987 ) 53.9814520249 (ExtendedPoll) - 1690+127 ( 2 0 4367.5599691638 2 5632.4392691879 ) 53.9814336068 (ExtendedPoll) - 1690+128 ( 2 0 4367.4940993607 2 5632.5028543451 ) 53.9813599484 (ExtendedPoll) - 1690+129 ( 2 0 4367.2306201483 2 5632.7571949737 ) 53.9810655359 (ExtendedPoll) - 1690+130 ( 2 0 4366.1767032985 2 5633.7745574881 ) 53.9798914222 (ExtendedPoll) - 1690+131 ( 2 0 4361.9610358996 2 5637.8440075457 ) 53.9752515834 (ExtendedPoll) - 1690+132 ( 2 0 4345.0983663039 2 5654.1218077760 ) 53.9576001475 (ExtendedPoll) - 1690+133 ( 2 0 4277.6476879210 2 5719.2330086971 ) 53.9016513465 (ExtendedPoll) - 1690+135 ( 2 0 4277.6290591203 2 5719.2571811144 ) 53.9015782727 (ExtendedPoll) - 1690+136 ( 2 0 4277.5731727181 2 5719.3296983663 ) 53.9013590679 (ExtendedPoll) - 1690+137 ( 2 0 4277.3496271092 2 5719.6197673739 ) 53.9004824970 (ExtendedPoll) - 1690+138 ( 2 0 4276.4554446736 2 5720.7800434043 ) 53.8969801836 (ExtendedPoll) - 1690+139 ( 2 0 4272.8787149315 2 5725.4211475259 ) 53.8830344924 (ExtendedPoll) - 1690+140 ( 2 0 4272.2449416972 2 5726.1641037669 ) 53.8813532804 (ExtendedPoll) - 1690+141 ( 2 0 4270.3436219944 2 5728.3929724899 ) 53.8763261624 (ExtendedPoll) - 1690+145 ( 2 0 4269.8544309447 2 5729.2382877997 ) 53.8723721175 (ExtendedPoll) - 1690+146 ( 2 0 4268.9604950773 2 5730.9749800002 ) 53.8632736922 (ExtendedPoll) - 1690+157 ( 2 0 4268.9281879962 2 5731.0267642928 ) 53.8630526551 (ExtendedPoll) - 1690+162 ( 2 0 4268.9081672520 2 5731.0497967493 ) 53.8630044126 (ExtendedPoll) - 1690+163 ( 2 0 4268.8481050197 2 5731.1188941187 ) 53.8628597009 (ExtendedPoll) - 1690+167 ( 2 0 4268.9130457179 2 5731.0620335227 ) 53.8628413313 (ExtendedPoll) - 1690+168 ( 2 0 4269.1078678127 2 5730.8914517347 ) 53.8627863397 (ExtendedPoll) - 1690+172 ( 2 0 4268.9798523367 2 5731.0072720873 ) 53.8627858887 (ExtendedPoll) - 1690+173 ( 2 0 4268.5958059087 2 5731.3547331451 ) 53.8627850104 (ExtendedPoll) - 1690+182 ( 2 0 4268.5734598444 2 5731.3755169174 ) 53.8627794333 (ExtendedPoll) - 1690+183 ( 2 0 4268.5064216515 2 5731.4378682344 ) 53.8627627170 (ExtendedPoll) - 1690+184 ( 2 0 4268.2382688801 2 5731.6872735026 ) 53.8626960762 (ExtendedPoll) - 1690+185 ( 2 0 4267.1656577944 2 5732.6848945752 ) 53.8624331084 (ExtendedPoll) - 1690+186 ( 2 0 4262.8752134514 2 5736.6753788658 ) 53.8614387941 (ExtendedPoll) - 1690+187 ( 2 0 4245.7134360797 2 5752.6373160280 ) 53.8583843412 (ExtendedPoll) - 1690+190 ( 2 0 4247.8459166796 2 5750.8801520137 ) 53.8564841075 (ExtendedPoll) - 1690+191 ( 2 0 4254.2433584792 2 5745.6086599708 ) 53.8509013362 (ExtendedPoll) - 1690+203 ( 2 0 4254.3648432334 2 5745.5967180794 ) 53.8499381914 (ExtendedPoll) - 1690+208 ( 2 0 4254.3884937761 2 5745.5774316250 ) 53.8499159225 (ExtendedPoll) - 1690+209 ( 2 0 4254.4594454040 2 5745.5195722617 ) 53.8498491302 (ExtendedPoll) - 1690+216 ( 2 0 4254.4747041982 2 5745.5195660142 ) 53.8497136099 (ExtendedPoll) - 1690+222 ( 2 0 4254.4785171266 2 5745.5196821982 ) 53.8496785985 (ExtendedPoll) - 1690+225 ( 2 0 4254.4745684192 2 5745.5233580070 ) 53.8496778754 (ExtendedPoll) - 1690+226 ( 2 0 4254.4627222968 2 5745.5343854333 ) 53.8496757065 (ExtendedPoll) - 1690+227 ( 2 0 4254.4153378073 2 5745.5784951385 ) 53.8496670379 (ExtendedPoll) - 1690+228 ( 2 0 4254.2257998495 2 5745.7549339594 ) 53.8496324765 (ExtendedPoll) - 1690+229 ( 2 0 4253.4676480183 2 5746.4606892429 ) 53.8494960362 (ExtendedPoll) - 1690+230 ( 2 0 4250.4350406932 2 5749.2837103771 ) 53.8489791731 (ExtendedPoll) - 1690+231 ( 2 0 4238.3046113928 2 5760.5757949136 ) 53.8473747522 (ExtendedPoll) - 1690+233 ( 2 0 4237.9514726055 2 5760.9129400964 ) 53.8472576934 (ExtendedPoll) - 1690+234 ( 2 0 4236.8920562434 2 5761.9243756450 ) 53.8469104201 (ExtendedPoll) - 1690+235 ( 2 0 4232.6543907954 2 5765.9701178391 ) 53.8455799016 (ExtendedPoll) - 1690+236 ( 2 0 4215.7037290030 2 5782.1530866154 ) 53.8411968855 (ExtendedPoll) - 1690+237 ( 2 0 4147.9010818337 2 5846.8849617209 ) 53.8388064213 (ExtendedPoll) - 1690+239 ( 2 0 4139.4939903168 2 5859.9869225266 ) 53.7929039460 (ExtendedPoll) - 1690+243 ( 2 0 4134.1713187395 2 5865.6917346274 ) 53.7882968215 (ExtendedPoll) - 1690+250 ( 2 0 4133.4948958932 2 5866.3963062176 ) 53.7879136446 (ExtendedPoll) - 1690+251 ( 2 0 4131.4656273543 2 5868.5100209882 ) 53.7867806418 (ExtendedPoll) - 1690+261 ( 2 0 4131.5933562783 2 5868.3938874275 ) 53.7866942837 (ExtendedPoll) - 1690+270 ( 2 0 4131.5998202039 2 5868.3898345950 ) 53.7866729850 (ExtendedPoll) - 1690+271 ( 2 0 4131.6192119808 2 5868.3776760976 ) 53.7866090899 (ExtendedPoll) - 1690+279 ( 2 0 4131.6209541211 2 5868.3784525807 ) 53.7865860060 (ExtendedPoll) - 1690+284 ( 2 0 4131.6214166274 2 5868.3783365570 ) 53.7865828676 (ExtendedPoll) - 1690+287 ( 2 0 4131.6210066099 2 5868.3788719382 ) 53.7865816357 (ExtendedPoll) - 1690+293 ( 2 0 4131.6209362583 2 5868.3789681750 ) 53.7865813838 (ExtendedPoll) - 1690+294 ( 2 0 4131.6207252036 2 5868.3792568852 ) 53.7865806279 (ExtendedPoll) - 1690+298 ( 2 0 4131.6206891940 2 5868.3793043828 ) 53.7865805153 (ExtendedPoll) - 1690+304 ( 2 0 4131.6206796375 2 5868.3793158160 ) 53.7865804962 (ExtendedPoll) - 1690+308 ( 2 0 4131.6206768768 2 5868.3793227362 ) 53.7865804572 (ExtendedPoll) - 1690+313 ( 2 0 4131.6206782642 2 5868.3793214934 ) 53.7865804561 (ExtendedPoll) - 1690+315 ( 2 0 4131.6206745081 2 5868.3793251876 ) 53.7865804560 (ExtendedPoll) - 1690+316 ( 2 0 4131.6206632396 2 5868.3793362702 ) 53.7865804559 (ExtendedPoll) - 1690+317 ( 2 0 4131.6206181660 2 5868.3793806004 ) 53.7865804552 (ExtendedPoll) - 1690+318 ( 2 0 4131.6204378713 2 5868.3795579212 ) 53.7865804528 (ExtendedPoll) - 1690+319 ( 2 0 4131.6197166927 2 5868.3802672046 ) 53.7865804428 (ExtendedPoll) - 1690+320 ( 2 0 4131.6168319783 2 5868.3831043383 ) 53.7865804032 (ExtendedPoll) - 1690+321 ( 2 0 4131.6052931206 2 5868.3944528729 ) 53.7865802452 (ExtendedPoll) - 1690+322 ( 2 0 4131.5591376898 2 5868.4398470112 ) 53.7865796204 (ExtendedPoll) - 1690+323 ( 2 0 4131.3745159668 2 5868.6214235646 ) 53.7865772402 (ExtendedPoll) - 1690+324 ( 2 0 4130.6360290747 2 5869.3477297782 ) 53.7865696199 (ExtendedPoll) - 1690+325 ( 2 0 4127.6820815062 2 5872.2529546326 ) 53.7865695587 (ExtendedPoll) - 1690+328 ( 2 0 4127.6840140147 2 5872.2603352230 ) 53.7864835442 (ExtendedPoll) - 1690+329 ( 2 0 4127.6898115401 2 5872.2824769939 ) 53.7862255016 (ExtendedPoll) - 1690+330 ( 2 0 4127.6796235307 2 5872.3112438240 ) 53.7860518834 (ExtendedPoll) - 1690+338 ( 2 0 4127.6784943469 2 5872.3148875688 ) 53.7860284213 (ExtendedPoll) - 1690+339 ( 2 0 4127.6750287014 2 5872.3216844082 ) 53.7859970553 (ExtendedPoll) - 1690+345 ( 2 0 4127.6738721701 2 5872.3232011194 ) 53.7859935510 (ExtendedPoll) - 1690+346 ( 2 0 4127.6704025761 2 5872.3277512530 ) 53.7859830384 (ExtendedPoll) - 1690+352 ( 2 0 4127.6704920471 2 5872.3287007212 ) 53.7859734249 (ExtendedPoll) - 1690+357 ( 2 0 4127.6702519860 2 5872.3291127215 ) 53.7859717972 (ExtendedPoll) - 1690+358 ( 2 0 4127.6695318024 2 5872.3303487226 ) 53.7859669139 (ExtendedPoll) - 1690+364 ( 2 0 4127.6693723329 2 5872.3305259594 ) 53.7859667262 (ExtendedPoll) - 1690+365 ( 2 0 4127.6688939242 2 5872.3310576698 ) 53.7859661633 (ExtendedPoll) - 1690+372 ( 2 0 4127.6688751072 2 5872.3311142263 ) 53.7859658109 (ExtendedPoll) - 1690+374 ( 2 0 4127.6689990935 2 5872.3309999936 ) 53.7859657384 (ExtendedPoll) - 1690+382 ( 2 0 4127.6690021165 2 5872.3309978166 ) 53.7859657310 (ExtendedPoll) - 2080+20 ( 2 0 4999.9878997345 2 5000.0092959702 ) 55.9016794952 (ExtendedPoll) - 2080+21 ( 2 0 4999.9515989379 2 5000.0371838810 ) 55.9016196708 (ExtendedPoll) - 2080+22 ( 2 0 4999.8063957515 2 5000.1487355238 ) 55.9013804121 (ExtendedPoll) - 2080+23 ( 2 0 4999.2255830062 2 5000.5949420954 ) 55.9004239959 (ExtendedPoll) - 2080+24 ( 2 0 4996.9023320246 2 5002.3797683814 ) 55.8966082342 (ExtendedPoll) - 2080+25 ( 2 0 4987.6093280984 2 5009.5190735258 ) 55.8815039246 (ExtendedPoll) - 2080+26 ( 2 0 4950.4373123937 2 5038.0762941031 ) 55.8236448341 (ExtendedPoll) - 2080+27 ( 2 0 4801.7492495748 2 5152.3051764124 ) 55.6343152023 (ExtendedPoll) - 2080+28 ( 2 0 4206.9969982993 2 5609.2207056496 ) 55.6253373563 (ExtendedPoll) - 2080+32 ( 2 0 4217.9971862258 2 5610.1214654550 ) 55.5187948731 (ExtendedPoll) - 2080+33 ( 2 0 4250.9977500050 2 5612.8237448711 ) 55.2000072940 (ExtendedPoll) - 2080+34 ( 2 0 4279.8220637775 2 5600.5952481192 ) 55.0710067569 (ExtendedPoll) - 2080+35 ( 2 0 4366.2950050949 2 5563.9097578633 ) 54.6951789859 (ExtendedPoll) - 2080+39 ( 2 0 4393.3723907599 2 5548.1874048965 ) 54.6249740689 (ExtendedPoll) - 2080+40 ( 2 0 4474.6045477550 2 5501.0203459961 ) 54.4266469861 (ExtendedPoll) - 2080+42 ( 2 0 4525.2654628702 2 5464.3348557403 ) 54.3900963042 (ExtendedPoll) - 2080+48 ( 2 0 4514.4563452056 2 5483.6602479286 ) 54.2742359116 (ExtendedPoll) - 2080+49 ( 2 0 4491.7462798091 2 5505.0601172445 ) 54.2385084897 (ExtendedPoll) - 2080+50 ( 2 0 4423.6160836196 2 5569.2597251923 ) 54.1460338788 (ExtendedPoll) - 2080+51 ( 2 0 4151.0952988618 2 5826.0581569833 ) 54.0054730693 (ExtendedPoll) - 2080+57 ( 2 0 4119.6505929283 2 5880.2129283134 ) 53.7862527117 (ExtendedPoll) - 2080+75 ( 2 0 4119.5665931846 2 5880.3014995623 ) 53.7862021958 (ExtendedPoll) - 2080+76 ( 2 0 4119.3145939537 2 5880.5672133090 ) 53.7860509080 (ExtendedPoll) - 2080+77 ( 2 0 4118.3065970302 2 5881.6300682960 ) 53.7854496575 (ExtendedPoll) - 2080+88 ( 2 0 4118.3108711544 2 5881.6602849630 ) 53.7851316932 (ExtendedPoll) - 2080+96 ( 2 0 4118.3198847115 2 5881.6662155602 ) 53.7849945777 (ExtendedPoll) - 2080+97 ( 2 0 4118.3348277986 2 5881.6631276284 ) 53.7848865134 (ExtendedPoll) - 2080+99 ( 2 0 4118.3462668702 2 5881.6530292707 ) 53.7848751796 (ExtendedPoll) - 2080+108 ( 2 0 4118.3455932557 2 5881.6537043543 ) 53.7848751047 (ExtendedPoll) - 2080+109 ( 2 0 4118.3435724122 2 5881.6557296052 ) 53.7848748801 (ExtendedPoll) - 2080+110 ( 2 0 4118.3354890381 2 5881.6638306090 ) 53.7848739818 (ExtendedPoll) - 2080+111 ( 2 0 4118.3031555418 2 5881.6962346240 ) 53.7848703922 (ExtendedPoll) - 2080+112 ( 2 0 4118.1738215565 2 5881.8258506839 ) 53.7848560937 (ExtendedPoll) - 2080+122 ( 2 0 4118.1735085463 2 5881.8262104036 ) 53.7848556344 (ExtendedPoll) - 2080+123 ( 2 0 4118.1725695157 2 5881.8272895629 ) 53.7848542566 (ExtendedPoll) - 2080+132 ( 2 0 4118.1726545887 2 5881.8272060557 ) 53.7848542498 (ExtendedPoll) - 2080+133 ( 2 0 4118.1729098077 2 5881.8269555344 ) 53.7848542294 (ExtendedPoll) - 2080+134 ( 2 0 4118.1739306837 2 5881.8259534489 ) 53.7848541479 (ExtendedPoll) - 2080+135 ( 2 0 4118.1780141879 2 5881.8219451070 ) 53.7848538220 (ExtendedPoll) - 2080+151 ( 2 0 4118.1780093963 2 5881.8219592167 ) 53.7848537356 (ExtendedPoll) - 2080+152 ( 2 0 4118.1779950216 2 5881.8220015460 ) 53.7848534763 (ExtendedPoll) - 2080+159 ( 2 0 4118.1779947385 2 5881.8220052606 ) 53.7848534446 (ExtendedPoll) - 2251+6 ( 2 0 4168.4622208673 2 5740.6975175468 ) 54.6654457702 (ExtendedPoll) - 2251+7 ( 2 0 3937.8677106876 2 6034.1814395937 ) 54.1025876908 (ExtendedPoll) - 2251+15 ( 2 0 3968.8756845943 2 6029.8141193251 ) 53.8471893590 (ExtendedPoll) - 2251+23 ( 2 0 3966.3440036262 2 6032.7893562581 ) 53.8453293272 (ExtendedPoll) - 2251+29 ( 2 0 3967.2852805629 2 6032.5287671287 ) 53.8387026417 (ExtendedPoll) - 2251+32 ( 2 0 3966.9613567598 2 6032.8941676795 ) 53.8385991104 (ExtendedPoll) - 2251+33 ( 2 0 3965.9895853505 2 6033.9903693319 ) 53.8382928991 (ExtendedPoll) - 2251+45 ( 2 0 3966.0039197226 2 6033.9851390276 ) 53.8382028409 (ExtendedPoll) - 2251+46 ( 2 0 3966.0291479677 2 6033.9679675607 ) 53.8381131770 (ExtendedPoll) - 2251+52 ( 2 0 3966.0378553973 2 6033.9615960721 ) 53.8380860741 (ExtendedPoll) - 2251+64 ( 2 0 3966.0380469160 2 6033.9618735742 ) 53.8380818691 (ExtendedPoll) - 2251+69 ( 2 0 3966.0381004053 2 6033.9618472758 ) 53.8380815916 (ExtendedPoll) - 2251+74 ( 2 0 3966.0381302064 2 6033.9618470067 ) 53.8380813128 (ExtendedPoll) - 2251+79 ( 2 0 3966.0381451069 2 6033.9618471499 ) 53.8380811710 (ExtendedPoll) - 2251+84 ( 2 0 3966.0381513080 2 6033.9618430199 ) 53.8380811481 (ExtendedPoll) - 2251+86 ( 2 0 3966.0381381930 2 6033.9618595149 ) 53.8380811293 (ExtendedPoll) - 2251+91 ( 2 0 3966.0381418784 2 6033.9618557502 ) 53.8380811271 (ExtendedPoll) - 2251+92 ( 2 0 3966.0381529347 2 6033.9618444560 ) 53.8380811204 (ExtendedPoll) - 2251+93 ( 2 0 3966.0381971599 2 6033.9617992793 ) 53.8380810935 (ExtendedPoll) - 2251+94 ( 2 0 3966.0383740607 2 6033.9616185725 ) 53.8380809858 (ExtendedPoll) - 2251+95 ( 2 0 3966.0390816638 2 6033.9608957451 ) 53.8380805552 (ExtendedPoll) - 2251+96 ( 2 0 3966.0419120761 2 6033.9580044356 ) 53.8380788327 (ExtendedPoll) - 2251+97 ( 2 0 3966.0532337255 2 6033.9464391976 ) 53.8380719433 (ExtendedPoll) - 2251+98 ( 2 0 3966.0985203229 2 6033.9001782457 ) 53.8380443936 (ExtendedPoll) - 2251+99 ( 2 0 3966.2796667126 2 6033.7151344380 ) 53.8379343190 (ExtendedPoll) - 2251+100 ( 2 0 3967.0042522715 2 6032.9749592074 ) 53.8374960138 (ExtendedPoll) - 2251+101 ( 2 0 3969.9025945070 2 6030.0142582847 ) 53.8357746693 (ExtendedPoll) - 2251+102 ( 2 0 3981.4959634492 2 6018.1714545940 ) 53.8293988351 (ExtendedPoll) - 2251+103 ( 2 0 4027.8694392178 2 5970.8002398312 ) 53.8120165816 (ExtendedPoll) - 2251+105 ( 2 0 4027.8996279793 2 5970.7957732839 ) 53.8117751288 (ExtendedPoll) - 2251+106 ( 2 0 4027.9901942637 2 5970.7823736422 ) 53.8110507797 (ExtendedPoll) - 2251+107 ( 2 0 4028.3524594017 2 5970.7287750751 ) 53.8081535202 (ExtendedPoll) - 2251+108 ( 2 0 4028.5782890972 2 5970.8215646372 ) 53.8052259801 (ExtendedPoll) - 2251+109 ( 2 0 4029.0659874104 2 5970.8447020517 ) 53.8004791353 (ExtendedPoll) - 2251+117 ( 2 0 4029.1224148462 2 5970.8679660822 ) 53.7997469853 (ExtendedPoll) - 2251+125 ( 2 0 4029.1289146169 2 5970.8639709871 ) 53.7997219690 (ExtendedPoll) - 2251+129 ( 2 0 4029.1327113864 2 5970.8636015775 ) 53.7996898997 (ExtendedPoll) - 2251+134 ( 2 0 4029.1345329350 2 5970.8641672091 ) 53.7996679124 (ExtendedPoll) - 2251+136 ( 2 0 4029.1361890843 2 5970.8632210851 ) 53.7996608999 (ExtendedPoll) - 2251+142 ( 2 0 4029.1366590260 2 5970.8631402857 ) 53.7996572423 (ExtendedPoll) - 2251+146 ( 2 0 4029.1368554851 2 5970.8630052034 ) 53.7996566135 (ExtendedPoll) - 2251+147 ( 2 0 4029.1372198865 2 5970.8626976562 ) 53.7996559536 (ExtendedPoll) - 2251+158 ( 2 0 4029.1372434032 2 5970.8627159631 ) 53.7996555720 (ExtendedPoll) - 2251+159 ( 2 0 4029.1372160758 2 5970.8627689341 ) 53.7996553557 (ExtendedPoll) - 2251+165 ( 2 0 4029.1372107574 2 5970.8627828538 ) 53.7996552815 (ExtendedPoll) - 2251+168 ( 2 0 4029.1372020883 2 5970.8627949737 ) 53.7996552545 (ExtendedPoll) - 2251+172 ( 2 0 4029.1371973626 2 5970.8628007338 ) 53.7996552473 (ExtendedPoll) - 2251+179 ( 2 0 4029.1371969852 2 5970.8628025579 ) 53.7996552346 (ExtendedPoll) - 2251+181 ( 2 0 4029.1372006890 2 5970.8627988111 ) 53.7996552334 (ExtendedPoll) - 2251+182 ( 2 0 4029.1372118001 2 5970.8627875709 ) 53.7996552298 (ExtendedPoll) - 2251+183 ( 2 0 4029.1372562449 2 5970.8627426102 ) 53.7996552156 (ExtendedPoll) - 2251+184 ( 2 0 4029.1374340239 2 5970.8625627674 ) 53.7996551585 (ExtendedPoll) - 2251+185 ( 2 0 4029.1381451401 2 5970.8618433959 ) 53.7996549302 (ExtendedPoll) - 2251+186 ( 2 0 4029.1409896047 2 5970.8589659099 ) 53.7996540170 (ExtendedPoll) - 2251+187 ( 2 0 4029.1523674632 2 5970.8474559659 ) 53.7996503647 (ExtendedPoll) - 2251+188 ( 2 0 4029.1978788972 2 5970.8014161900 ) 53.7996357631 (ExtendedPoll) - 2251+189 ( 2 0 4029.3799246331 2 5970.6172570866 ) 53.7995774796 (ExtendedPoll) - 2251+190 ( 2 0 4030.1081075767 2 5969.8806206727 ) 53.7993463077 (ExtendedPoll) - 2251+191 ( 2 0 4033.0208393511 2 5966.9340750174 ) 53.7984530101 (ExtendedPoll) - 2251+192 ( 2 0 4044.6717664489 2 5955.1478923961 ) 53.7953815270 (ExtendedPoll) - 2251+193 ( 2 0 4091.2754748399 2 5908.0031619108 ) 53.7910882360 (ExtendedPoll) - 2251+196 ( 2 0 4091.3024169829 2 5908.0174949293 ) 53.7907097823 (ExtendedPoll) - 2251+197 ( 2 0 4091.3832434122 2 5908.0604939849 ) 53.7895744291 (ExtendedPoll) - 2251+198 ( 2 0 4091.7065491291 2 5908.2324902073 ) 53.7850331320 (ExtendedPoll) - 2251+201 ( 2 0 4091.7062625770 2 5908.2935241345 ) 53.7844786297 (ExtendedPoll) - 2251+218 ( 2 0 4091.7061814853 2 5908.2937483387 ) 53.7844773284 (ExtendedPoll) - 2251+225 ( 2 0 4091.7061774429 2 5908.2938078061 ) 53.7844768227 (ExtendedPoll) - 2251+228 ( 2 0 4091.7061404988 2 5908.2938545806 ) 53.7844767353 (ExtendedPoll) - 2251+237 ( 2 0 4091.7061392073 2 5908.2938580748 ) 53.7844767152 (ExtendedPoll) - 2251+242 ( 2 0 4091.7061402086 2 5908.2938596455 ) 53.7844766917 (ExtendedPoll) - 2251+251 ( 2 0 4091.7061402086 2 5908.2938597496 ) 53.7844766907 (ExtendedPoll) - 2507+6 ( 2 0 4987.7715032480 2 5009.7172875975 ) 55.8778410034 (ExtendedPoll) - 2507+7 ( 2 0 4951.0860129922 2 5038.8691503901 ) 55.8090330212 (ExtendedPoll) - 2507+8 ( 2 0 4804.3440519688 2 5155.4766015605 ) 55.5765193455 (ExtendedPoll) - 2507+9 ( 2 0 4217.3762078751 2 5621.9064062421 ) 55.4051303015 (ExtendedPoll) - 2507+11 ( 2 0 4105.5728090001 2 5845.5132039921 ) 54.2371769988 (ExtendedPoll) - 2507+17 ( 2 0 4084.6096717110 2 5904.9087596444 ) 53.8806341533 (ExtendedPoll) - 2507+25 ( 2 0 4086.4930785768 2 5912.4969786111 ) 53.7940773323 (ExtendedPoll) - 2507+28 ( 2 0 4089.6866815232 2 5910.2450790976 ) 53.7852355401 (ExtendedPoll) - 2507+40 ( 2 0 4089.7473972443 2 5910.2388432578 ) 53.7847342099 (ExtendedPoll) - 2507+48 ( 2 0 4089.7542955796 2 5910.2355843266 ) 53.7847005125 (ExtendedPoll) - 2507+49 ( 2 0 4089.7673972155 2 5910.2277626627 ) 53.7846513996 (ExtendedPoll) - 2507+51 ( 2 0 4089.7801055712 2 5910.2193169774 ) 53.7846115945 (ExtendedPoll) - 2507+62 ( 2 0 4089.7805040628 2 5910.2190551032 ) 53.7846103195 (ExtendedPoll) - 2507+63 ( 2 0 4089.7816995375 2 5910.2182694805 ) 53.7846064942 (ExtendedPoll) - 2507+73 ( 2 0 4089.7816945523 2 5910.2182988629 ) 53.7846062720 (ExtendedPoll) - 2507+80 ( 2 0 4089.7816938911 2 5910.2183025290 ) 53.7846062447 (ExtendedPoll) - 2507+83 ( 2 0 4089.7816931323 2 5910.2183061762 ) 53.7846062184 (ExtendedPoll) - 2507+86 ( 2 0 4089.7816946030 2 5910.2183050332 ) 53.7846062153 (ExtendedPoll) - 2507+97 ( 2 0 4089.7816947071 2 5910.2183050332 ) 53.7846062143 (ExtendedPoll) - 2609+6 ( 2 0 4993.6127941072 2 5004.5037990269 ) 55.8961392637 (ExtendedPoll) - 2609+7 ( 2 0 4974.4511764290 2 5018.0151961078 ) 55.8801113087 (ExtendedPoll) - 2609+8 ( 2 0 4897.8047057158 2 5072.0607844311 ) 55.8259328921 (ExtendedPoll) - 2609+9 ( 2 0 4591.2188228633 2 5288.2431377246 ) 55.7773330381 (ExtendedPoll) - 2609+12 ( 2 0 4584.2311104336 2 5414.0219614589 ) 54.4414663757 (ExtendedPoll) - 2609+22 ( 2 0 4587.3564740008 2 5411.6745268146 ) 54.4410956907 (ExtendedPoll) - 2609+29 ( 2 0 4587.5587397857 2 5412.1189357716 ) 54.4345618898 (ExtendedPoll) - 2609+33 ( 2 0 4587.4405737045 2 5412.3325570157 ) 54.4332122013 (ExtendedPoll) - 2609+34 ( 2 0 4587.0527821074 2 5412.6292916912 ) 54.4331973113 (ExtendedPoll) - 2609+35 ( 2 0 4585.8894073161 2 5413.5194957176 ) 54.4331558220 (ExtendedPoll) - 2609+36 ( 2 0 4581.2359081511 2 5417.0803118233 ) 54.4330376116 (ExtendedPoll) - 2609+38 ( 2 0 4579.3525012852 2 5420.4991047210 ) 54.4114704020 (ExtendedPoll) - 2609+39 ( 2 0 4573.3201401643 2 5425.4669315265 ) 54.4076771370 (ExtendedPoll) - 2609+40 ( 2 0 4555.2230568015 2 5440.3704119429 ) 54.3971432812 (ExtendedPoll) - 2609+41 ( 2 0 4482.8347233502 2 5499.9843336087 ) 54.3678394409 (ExtendedPoll) - 2609+49 ( 2 0 4485.3459325046 2 5507.3814823136 ) 54.2681454161 (ExtendedPoll) - 2609+50 ( 2 0 4475.1919128802 2 5519.2824300454 ) 54.2285251876 (ExtendedPoll) - 2609+51 ( 2 0 4444.7298540071 2 5554.9852732408 ) 54.1136470777 (ExtendedPoll) - 2609+58 ( 2 0 4443.9800738281 2 5555.6109430488 ) 54.1135341068 (ExtendedPoll) - 2609+59 ( 2 0 4441.7307332914 2 5557.4879524728 ) 54.1132091099 (ExtendedPoll) - 2609+60 ( 2 0 4432.7333711444 2 5564.9959901689 ) 54.1121181220 (ExtendedPoll) - 2609+61 ( 2 0 4396.7439225563 2 5595.0281409531 ) 54.1111148301 (ExtendedPoll) - 2609+63 ( 2 0 4386.2623539118 2 5606.6015396648 ) 54.0828747897 (ExtendedPoll) - 2609+64 ( 2 0 4354.8176479782 2 5641.3217357998 ) 54.0021675011 (ExtendedPoll) - 2609+67 ( 2 0 4332.5443146086 2 5663.1583371426 ) 53.9763377152 (ExtendedPoll) - 2609+68 ( 2 0 4265.7243144997 2 5728.6681411709 ) 53.9145504521 (ExtendedPoll) - 2609+69 ( 2 0 3998.4443140642 2 5990.7073572841 ) 53.9107416673 (ExtendedPoll) - 2609+77 ( 2 0 3977.9179088020 2 6014.2908867343 ) 53.8968485442 (ExtendedPoll) - 2609+85 ( 2 0 3977.6108315956 2 6018.1873552864 ) 53.8658100136 (ExtendedPoll) - 2609+87 ( 2 0 3985.4720080790 2 6010.4353618097 ) 53.8594585168 (ExtendedPoll) - 2609+88 ( 2 0 4009.0555375292 2 5987.1793813797 ) 53.8425419841 (ExtendedPoll) - 2609+89 ( 2 0 4103.3896553299 2 5894.1554596595 ) 53.8066758321 (ExtendedPoll) - 2609+98 ( 2 0 4105.0239884617 2 5893.0858073906 ) 53.8015202481 (ExtendedPoll) - 2609+99 ( 2 0 4109.9269878569 2 5889.8768505839 ) 53.7861093451 (ExtendedPoll) - 2609+108 ( 2 0 4110.1419152454 2 5889.7610302313 ) 53.7852071379 (ExtendedPoll) - 2609+116 ( 2 0 4110.1058896513 2 5889.8103005292 ) 53.7850837032 (ExtendedPoll) - 2609+117 ( 2 0 4109.9978128689 2 5889.9581114227 ) 53.7847134692 (ExtendedPoll) - 2609+120 ( 2 0 4110.1308929863 2 5889.8481353998 ) 53.7845067680 (ExtendedPoll) - 2609+123 ( 2 0 4110.2185046189 2 5889.7631360559 ) 53.7844866226 (ExtendedPoll) - 2609+124 ( 2 0 4110.4813395169 2 5889.5081380242 ) 53.7844264399 (ExtendedPoll) - 2609+134 ( 2 0 4110.4929230099 2 5889.4982056417 ) 53.7844117835 (ExtendedPoll) - 2609+135 ( 2 0 4110.5276734889 2 5889.4684084945 ) 53.7843678178 (ExtendedPoll) - 2609+142 ( 2 0 4110.5308528491 2 5889.4663005158 ) 53.7843581081 (ExtendedPoll) - 2609+143 ( 2 0 4110.5369402846 2 5889.4617014955 ) 53.7843446963 (ExtendedPoll) - 2609+148 ( 2 0 4110.5385864786 2 5889.4607381551 ) 53.7843384902 (ExtendedPoll) - 2609+154 ( 2 0 4110.5389368624 2 5889.4610615818 ) 53.7843323072 (ExtendedPoll) - 2609+174 ( 2 0 4110.5389372789 2 5889.4610615818 ) 53.7843323034 (ExtendedPoll) - 2609+179 ( 2 0 4110.5389372789 2 5889.4610619983 ) 53.7843322995 (ExtendedPoll) - 2609+185 ( 2 0 4110.5389372789 2 5889.4610621024 ) 53.7843322986 (ExtendedPoll) - 2609+186 ( 2 0 4110.5389372789 2 5889.4610624148 ) 53.7843322957 (ExtendedPoll) - 2609+193 ( 2 0 4110.5389373050 2 5889.4610624148 ) 53.7843322955 (ExtendedPoll) - 2609+194 ( 2 0 4110.5389373831 2 5889.4610624148 ) 53.7843322947 (ExtendedPoll) - 2808+6 ( 2 0 4329.1796067501 2 5670.8203932499 ) 53.9289318169 (ExtendedPoll) - 2867+10 ( 2 0 4992.1115277649 2 5007.7246977250 ) 55.8685413615 (ExtendedPoll) - 2867+11 ( 2 0 4968.4461110597 2 5030.8987909000 ) 55.7705699043 (ExtendedPoll) - 2867+12 ( 2 0 4873.7844442388 2 5123.5951636001 ) 55.4016911655 (ExtendedPoll) - 2867+13 ( 2 0 4495.1377769551 2 5494.3806544003 ) 54.3231819620 (ExtendedPoll) - 2867+15 ( 2 0 4411.2852277989 2 5585.2209159863 ) 54.0868469342 (ExtendedPoll) - 2867+22 ( 2 0 4407.4365268122 2 5592.0175581542 ) 54.0499159225 (ExtendedPoll) - 2867+28 ( 2 0 4405.3364599175 2 5593.8105478426 ) 54.0495510124 (ExtendedPoll) - 2867+29 ( 2 0 4399.0362592332 2 5599.1895169077 ) 54.0485700853 (ExtendedPoll) - 2867+30 ( 2 0 4373.8354564960 2 5620.7053931683 ) 54.0463593230 (ExtendedPoll) - 2867+33 ( 2 0 4369.7137979926 2 5627.3382608261 ) 54.0145749170 (ExtendedPoll) - 2867+40 ( 2 0 4368.6287918634 2 5628.9623580510 ) 54.0074781800 (ExtendedPoll) - 2867+41 ( 2 0 4365.3737734757 2 5633.8346497256 ) 53.9862560504 (ExtendedPoll) - 2867+43 ( 2 0 4362.6919658733 2 5636.6802318381 ) 53.9806946516 (ExtendedPoll) - 2867+44 ( 2 0 4354.6465430661 2 5645.2169781755 ) 53.9642607181 (ExtendedPoll) - 2867+50 ( 2 0 4354.0247117231 2 5645.9701703234 ) 53.9620624682 (ExtendedPoll) - 2867+61 ( 2 0 4354.0368388529 2 5645.9609094433 ) 53.9620504600 (ExtendedPoll) - 2867+65 ( 2 0 4354.0401585606 2 5645.9590302273 ) 53.9620405451 (ExtendedPoll) - 2867+71 ( 2 0 4354.0409392116 2 5645.9584824325 ) 53.9620392835 (ExtendedPoll) - 2867+74 ( 2 0 4354.0405359427 2 5645.9593466482 ) 53.9620340616 (ExtendedPoll) - 2867+87 ( 2 0 4354.0405617934 2 5645.9593318187 ) 53.9620339864 (ExtendedPoll) - 2867+88 ( 2 0 4354.0406393458 2 5645.9592873300 ) 53.9620337607 (ExtendedPoll) - 2867+89 ( 2 0 4354.0407417896 2 5645.9592263700 ) 53.9620334847 (ExtendedPoll) - 2867+98 ( 2 0 4354.0407563620 2 5645.9592294825 ) 53.9620333264 (ExtendedPoll) - 2867+99 ( 2 0 4354.0407811713 2 5645.9592129695 ) 53.9620332772 (ExtendedPoll) - 2867+106 ( 2 0 4354.0407786145 2 5645.9592156788 ) 53.9620332721 (ExtendedPoll) - 2867+107 ( 2 0 4354.0407709439 2 5645.9592238067 ) 53.9620332568 (ExtendedPoll) - 2867+108 ( 2 0 4354.0407402615 2 5645.9592563181 ) 53.9620331954 (ExtendedPoll) - 2867+114 ( 2 0 4354.0407434536 2 5645.9592543977 ) 53.9620331870 (ExtendedPoll) - 2867+122 ( 2 0 4354.0407434536 2 5645.9592560637 ) 53.9620331701 (ExtendedPoll) - 2867+123 ( 2 0 4354.0407422389 2 5645.9592574757 ) 53.9620331665 (ExtendedPoll) - 3058+8 ( 2 0 4991.1561764562 2 5006.6055719062 ) 55.8895337846 (ExtendedPoll) - 3058+9 ( 2 0 4964.6247058247 2 5026.4222876248 ) 55.8543769246 (ExtendedPoll) - 3058+10 ( 2 0 4858.4988232988 2 5105.6891504990 ) 55.7342678543 (ExtendedPoll) - 3058+11 ( 2 0 4433.9952931954 2 5422.7566019961 ) 55.6083992097 (ExtendedPoll) - 3058+16 ( 2 0 4468.9338553438 2 5473.4175171113 ) 54.7683907188 (ExtendedPoll) - 3058+17 ( 2 0 4371.1058813282 2 5557.2700662675 ) 54.7224471575 (ExtendedPoll) - 3058+22 ( 2 0 4374.5997375430 2 5620.1594781347 ) 54.0452990385 (ExtendedPoll) - 3058+26 ( 2 0 4353.6366002540 2 5643.3062755580 ) 53.9923716603 (ExtendedPoll) - 3058+34 ( 2 0 4352.3741717388 2 5647.0048499105 ) 53.9659824019 (ExtendedPoll) - 3058+41 ( 2 0 4352.7757178358 2 5646.7270943123 ) 53.9652910126 (ExtendedPoll) - 3058+42 ( 2 0 4353.9803561267 2 5645.8938275179 ) 53.9632201609 (ExtendedPoll) - 3058+50 ( 2 0 4353.8820221150 2 5646.1172848288 ) 53.9618183016 (ExtendedPoll) - 3058+67 ( 2 0 4353.8828862995 2 5646.1168814928 ) 53.9618148524 (ExtendedPoll) - 3058+70 ( 2 0 4353.8819301637 2 5646.1178326989 ) 53.9618135661 (ExtendedPoll) - 3058+71 ( 2 0 4353.8790617562 2 5646.1206863173 ) 53.9618097072 (ExtendedPoll) - 3058+72 ( 2 0 4353.8675881265 2 5646.1321007910 ) 53.9617942721 (ExtendedPoll) - 3058+73 ( 2 0 4353.8216936077 2 5646.1777586857 ) 53.9617325386 (ExtendedPoll) - 3058+74 ( 2 0 4353.6381155322 2 5646.3603902646 ) 53.9614857168 (ExtendedPoll) - 3058+75 ( 2 0 4352.9038032305 2 5647.0909165803 ) 53.9605002241 (ExtendedPoll) - 3058+76 ( 2 0 4349.9665540238 2 5650.0130218428 ) 53.9565869794 (ExtendedPoll) - 3058+77 ( 2 0 4338.2175571967 2 5661.7014428928 ) 53.9413943430 (ExtendedPoll) - 3058+78 ( 2 0 4291.2215698885 2 5708.4551270929 ) 53.8880355778 (ExtendedPoll) - 3058+79 ( 2 0 4103.2376206554 2 5895.4698638933 ) 53.7960048025 (ExtendedPoll) - 3058+83 ( 2 0 4103.0824826918 2 5895.9328254315 ) 53.7931789654 (ExtendedPoll) - 3058+84 ( 2 0 4102.6170688008 2 5897.3217100462 ) 53.7847063488 (ExtendedPoll) - 3058+88 ( 2 0 4102.3017815441 2 5897.6944676551 ) 53.7841793274 (ExtendedPoll) - 3058+104 ( 2 0 4102.3028217662 2 5897.6960663778 ) 53.7841551305 (ExtendedPoll) - 3058+106 ( 2 0 4102.3045951993 2 5897.6953642985 ) 53.7841453060 (ExtendedPoll) - 3058+116 ( 2 0 4102.3046242597 2 5897.6953709067 ) 53.7841449789 (ExtendedPoll) - 3058+126 ( 2 0 4102.3046246516 2 5897.6953727277 ) 53.7841449586 (ExtendedPoll) - 3058+128 ( 2 0 4102.3046253455 2 5897.6953744562 ) 53.7841449364 (ExtendedPoll) - 3058+140 ( 2 0 4102.3046253471 2 5897.6953744562 ) 53.7841449364 (ExtendedPoll) - 3058+141 ( 2 0 4102.3046253520 2 5897.6953744562 ) 53.7841449364 (ExtendedPoll) - 3058+142 ( 2 0 4102.3046253715 2 5897.6953744562 ) 53.7841449362 (ExtendedPoll) - 3058+143 ( 2 0 4102.3046254496 2 5897.6953744562 ) 53.7841449355 (ExtendedPoll) - 3211+9 ( 2 0 4999.2843395107 2 5000.6644809549 ) 55.8991235044 (ExtendedPoll) - 3211+10 ( 2 0 4997.1373580427 2 5002.6579238197 ) 55.8914071579 (ExtendedPoll) - 3211+11 ( 2 0 4988.5494321709 2 5010.6316952788 ) 55.8607138749 (ExtendedPoll) - 3211+12 ( 2 0 4954.1977286835 2 5042.5267811150 ) 55.7407142386 (ExtendedPoll) - 3211+13 ( 2 0 4816.7909147341 2 5170.1071244602 ) 55.3063592103 (ExtendedPoll) - 3211+14 ( 2 0 4267.1636589366 2 5680.4284978408 ) 54.3782156485 (ExtendedPoll) - 3211+16 ( 2 0 4258.4290183995 2 5741.5709816005 ) 53.8530873348 (ExtendedPoll) - 3275+16 ( 2 0 4999.4544048385 2 5000.4231907750 ) 55.9007514521 (ExtendedPoll) - 3275+17 ( 2 0 4997.8176193541 2 5001.6927631002 ) 55.8979127990 (ExtendedPoll) - 3275+18 ( 2 0 4991.2704774163 2 5006.7710524007 ) 55.8866378337 (ExtendedPoll) - 3275+19 ( 2 0 4965.0819096653 2 5027.0842096030 ) 55.8428188421 (ExtendedPoll) - 3275+20 ( 2 0 4860.3276386613 2 5108.3368384118 ) 55.6884538793 (ExtendedPoll) - 3275+21 ( 2 0 4441.3105546452 2 5433.3473536473 ) 55.4321933111 (ExtendedPoll) - 3275+24 ( 2 0 4440.4370905915 2 5464.7920595809 ) 55.1023491348 (ExtendedPoll) - 3275+25 ( 2 0 4437.8166984304 2 5559.1261773817 ) 54.1296401397 (ExtendedPoll) - 3275+28 ( 2 0 4394.1434957448 2 5604.5463081746 ) 54.0358312283 (ExtendedPoll) - 3275+31 ( 2 0 4348.7233649518 2 5648.2195108602 ) 53.9855229289 (ExtendedPoll) - 3275+32 ( 2 0 4212.4629725730 2 5779.2391189168 ) 53.8982210340 (ExtendedPoll) - 3275+39 ( 2 0 4246.9648026945 2 5751.7250012249 ) 53.8561122313 (ExtendedPoll) - 3275+44 ( 2 0 4253.1063468222 2 5746.8663574261 ) 53.8487569023 (ExtendedPoll) - 3275+54 ( 2 0 4253.0200213419 2 5746.9526629144 ) 53.8486838339 (ExtendedPoll) - 3275+55 ( 2 0 4252.7610449010 2 5747.2115793792 ) 53.8484648755 (ExtendedPoll) - 3275+56 ( 2 0 4251.7251391376 2 5748.2472452386 ) 53.8475927460 (ExtendedPoll) - 3275+57 ( 2 0 4247.5815160840 2 5752.3899086759 ) 53.8441635235 (ExtendedPoll) - 3275+58 ( 2 0 4231.0070238695 2 5768.9605624254 ) 53.8313972696 (ExtendedPoll) - 3275+59 ( 2 0 4164.7090550115 2 5835.2431774231 ) 53.7956619398 (ExtendedPoll) - 3275+72 ( 2 0 4164.7639497269 2 5835.2164964256 ) 53.7954160381 (ExtendedPoll) - 3275+76 ( 2 0 4164.7917332002 2 5835.2038710575 ) 53.7952833211 (ExtendedPoll) - 3275+77 ( 2 0 4164.8360404827 2 5835.1618928437 ) 53.7952771546 (ExtendedPoll) - 3275+85 ( 2 0 4164.8422068711 2 5835.1574002652 ) 53.7952636014 (ExtendedPoll) - 3275+97 ( 2 0 4164.8424175700 2 5835.1572886885 ) 53.7952627439 (ExtendedPoll) - 3275+102 ( 2 0 4164.8423842792 2 5835.1574031550 ) 53.7952619685 (ExtendedPoll) - 3275+109 ( 2 0 4164.8424622828 2 5835.1574351058 ) 53.7952609619 (ExtendedPoll) - 3275+110 ( 2 0 4164.8424186334 2 5835.1575460363 ) 53.7952603135 (ExtendedPoll) - 3275+117 ( 2 0 4164.8424468760 2 5835.1575365215 ) 53.7952601474 (ExtendedPoll) - 3275+121 ( 2 0 4164.8424209888 2 5835.1575697812 ) 53.7952600688 (ExtendedPoll) - 3275+129 ( 2 0 4164.8424239711 2 5835.1575675489 ) 53.7952600628 (ExtendedPoll) - 3275+130 ( 2 0 4164.8424329181 2 5835.1575608518 ) 53.7952600448 (ExtendedPoll) - 3275+135 ( 2 0 4164.8424361867 2 5835.1575626390 ) 53.7952599984 (ExtendedPoll) - 3275+138 ( 2 0 4164.8424402468 2 5835.1575592816 ) 53.7952599933 (ExtendedPoll) - 3275+145 ( 2 0 4164.8424410483 2 5835.1575588074 ) 53.7952599905 (ExtendedPoll) - 3275+147 ( 2 0 4164.8424392431 2 5835.1575607257 ) 53.7952599888 (ExtendedPoll) - 3436 ( 3 0 3333.3333333333 2 3333.3333333333 1 3333.3333333333 ) 47.1682905221 + 1689+27 ( 2 0 4999.9918793150 2 5000.0071042165 ) 55.9016755069 (ExtendedPoll) + 1689+28 ( 2 0 4999.9675172600 2 5000.0284168659 ) 55.9016037165 (ExtendedPoll) + 1689+29 ( 2 0 4999.8700690400 2 5000.1136674635 ) 55.9013165752 (ExtendedPoll) + 1689+30 ( 2 0 4999.4802761598 2 5000.4546698539 ) 55.9001683374 (ExtendedPoll) + 1689+31 ( 2 0 4997.9211046392 2 5001.8186794156 ) 55.8955806263 (ExtendedPoll) + 1689+32 ( 2 0 4991.6844185568 2 5007.2747176624 ) 55.8773137258 (ExtendedPoll) + 1689+33 ( 2 0 4966.7376742271 2 5029.0988706497 ) 55.8055960661 (ExtendedPoll) + 1689+34 ( 2 0 4866.9506969084 2 5116.3954825988 ) 55.5407618647 (ExtendedPoll) + 1689+35 ( 2 0 4467.8027876336 2 5465.5819303951 ) 54.8617064546 (ExtendedPoll) + 1689+37 ( 2 0 4466.8269645111 2 5469.3623920026 ) 54.8295561915 (ExtendedPoll) + 1689+38 ( 2 0 4463.8994951436 2 5480.7037768250 ) 54.7333779337 (ExtendedPoll) + 1689+39 ( 2 0 4452.1896176735 2 5526.0693161146 ) 54.3527873521 (ExtendedPoll) + 1689+40 ( 2 0 4432.0999444382 2 5550.0895775916 ) 54.2727755505 (ExtendedPoll) + 1689+41 ( 2 0 4371.8309247321 2 5622.1503620228 ) 54.0490159101 (ExtendedPoll) + 1689+48 ( 2 0 4367.1633511951 2 5628.4010891571 ) 54.0259049915 (ExtendedPoll) + 1689+52 ( 2 0 4367.4363087119 2 5632.2975577092 ) 53.9839463746 (ExtendedPoll) + 1689+64 ( 2 0 4367.5173563027 2 5632.3888412069 ) 53.9823156833 (ExtendedPoll) + 1689+67 ( 2 0 4367.5750698909 2 5632.4087032645 ) 53.9816128497 (ExtendedPoll) + 1689+77 ( 2 0 4367.5769053809 2 5632.4193356014 ) 53.9814889495 (ExtendedPoll) + 1689+82 ( 2 0 4367.5805624212 2 5632.4182502476 ) 53.9814682147 (ExtendedPoll) + 1689+86 ( 2 0 4367.5821046999 2 5632.4171280385 ) 53.9814662175 (ExtendedPoll) + 1689+90 ( 2 0 4367.5818878523 2 5632.4180567321 ) 53.9814586704 (ExtendedPoll) + 1689+104 ( 2 0 4367.5819056985 2 5632.4180679393 ) 53.9814584017 (ExtendedPoll) + 1689+105 ( 2 0 4367.5819346476 2 5632.4180608593 ) 53.9814582222 (ExtendedPoll) + 1689+109 ( 2 0 4367.5819216978 2 5632.4180774844 ) 53.9814581658 (ExtendedPoll) + 1689+115 ( 2 0 4367.5819257648 2 5632.4180741356 ) 53.9814581645 (ExtendedPoll) + 1689+120 ( 2 0 4367.5819244247 2 5632.4180754292 ) 53.9814581630 (ExtendedPoll) + 1689+121 ( 2 0 4367.5819204043 2 5632.4180793101 ) 53.9814581585 (ExtendedPoll) + 1689+122 ( 2 0 4367.5819043228 2 5632.4180948339 ) 53.9814581405 (ExtendedPoll) + 1689+123 ( 2 0 4367.5818399969 2 5632.4181569287 ) 53.9814580686 (ExtendedPoll) + 1689+124 ( 2 0 4367.5815826929 2 5632.4184053083 ) 53.9814577808 (ExtendedPoll) + 1689+125 ( 2 0 4367.5805534773 2 5632.4193988263 ) 53.9814566296 (ExtendedPoll) + 1689+126 ( 2 0 4367.5764366146 2 5632.4233728987 ) 53.9814520249 (ExtendedPoll) + 1689+127 ( 2 0 4367.5599691638 2 5632.4392691879 ) 53.9814336068 (ExtendedPoll) + 1689+128 ( 2 0 4367.4940993607 2 5632.5028543451 ) 53.9813599484 (ExtendedPoll) + 1689+129 ( 2 0 4367.2306201483 2 5632.7571949737 ) 53.9810655359 (ExtendedPoll) + 1689+130 ( 2 0 4366.1767032985 2 5633.7745574881 ) 53.9798914222 (ExtendedPoll) + 1689+131 ( 2 0 4361.9610358996 2 5637.8440075457 ) 53.9752515834 (ExtendedPoll) + 1689+132 ( 2 0 4345.0983663039 2 5654.1218077760 ) 53.9576001475 (ExtendedPoll) + 1689+133 ( 2 0 4277.6476879210 2 5719.2330086971 ) 53.9016513465 (ExtendedPoll) + 1689+135 ( 2 0 4277.6290591203 2 5719.2571811144 ) 53.9015782727 (ExtendedPoll) + 1689+136 ( 2 0 4277.5731727181 2 5719.3296983663 ) 53.9013590679 (ExtendedPoll) + 1689+137 ( 2 0 4277.3496271092 2 5719.6197673739 ) 53.9004824970 (ExtendedPoll) + 1689+138 ( 2 0 4276.4554446736 2 5720.7800434043 ) 53.8969801836 (ExtendedPoll) + 1689+139 ( 2 0 4272.8787149315 2 5725.4211475259 ) 53.8830344924 (ExtendedPoll) + 1689+140 ( 2 0 4272.2449416972 2 5726.1641037669 ) 53.8813532804 (ExtendedPoll) + 1689+141 ( 2 0 4270.3436219944 2 5728.3929724899 ) 53.8763261624 (ExtendedPoll) + 1689+145 ( 2 0 4269.8544309447 2 5729.2382877997 ) 53.8723721175 (ExtendedPoll) + 1689+146 ( 2 0 4268.9604950773 2 5730.9749800002 ) 53.8632736922 (ExtendedPoll) + 1689+157 ( 2 0 4268.9281879962 2 5731.0267642928 ) 53.8630526551 (ExtendedPoll) + 1689+162 ( 2 0 4268.9081672520 2 5731.0497967493 ) 53.8630044126 (ExtendedPoll) + 1689+163 ( 2 0 4268.8481050197 2 5731.1188941187 ) 53.8628597009 (ExtendedPoll) + 1689+167 ( 2 0 4268.9130457179 2 5731.0620335227 ) 53.8628413313 (ExtendedPoll) + 1689+168 ( 2 0 4269.1078678127 2 5730.8914517347 ) 53.8627863397 (ExtendedPoll) + 1689+172 ( 2 0 4268.9798523367 2 5731.0072720873 ) 53.8627858887 (ExtendedPoll) + 1689+173 ( 2 0 4268.5958059087 2 5731.3547331451 ) 53.8627850104 (ExtendedPoll) + 1689+182 ( 2 0 4268.5734598444 2 5731.3755169174 ) 53.8627794333 (ExtendedPoll) + 1689+183 ( 2 0 4268.5064216515 2 5731.4378682344 ) 53.8627627170 (ExtendedPoll) + 1689+184 ( 2 0 4268.2382688801 2 5731.6872735026 ) 53.8626960762 (ExtendedPoll) + 1689+185 ( 2 0 4267.1656577944 2 5732.6848945752 ) 53.8624331084 (ExtendedPoll) + 1689+186 ( 2 0 4262.8752134514 2 5736.6753788658 ) 53.8614387941 (ExtendedPoll) + 1689+187 ( 2 0 4245.7134360797 2 5752.6373160280 ) 53.8583843412 (ExtendedPoll) + 1689+190 ( 2 0 4247.8459166796 2 5750.8801520137 ) 53.8564841075 (ExtendedPoll) + 1689+191 ( 2 0 4254.2433584792 2 5745.6086599708 ) 53.8509013362 (ExtendedPoll) + 1689+203 ( 2 0 4254.3648432334 2 5745.5967180794 ) 53.8499381914 (ExtendedPoll) + 1689+208 ( 2 0 4254.3884937761 2 5745.5774316250 ) 53.8499159225 (ExtendedPoll) + 1689+209 ( 2 0 4254.4594454040 2 5745.5195722617 ) 53.8498491302 (ExtendedPoll) + 1689+216 ( 2 0 4254.4747041982 2 5745.5195660142 ) 53.8497136099 (ExtendedPoll) + 1689+222 ( 2 0 4254.4785171266 2 5745.5196821982 ) 53.8496785985 (ExtendedPoll) + 1689+225 ( 2 0 4254.4745684192 2 5745.5233580070 ) 53.8496778754 (ExtendedPoll) + 1689+226 ( 2 0 4254.4627222968 2 5745.5343854333 ) 53.8496757065 (ExtendedPoll) + 1689+227 ( 2 0 4254.4153378073 2 5745.5784951385 ) 53.8496670379 (ExtendedPoll) + 1689+228 ( 2 0 4254.2257998495 2 5745.7549339594 ) 53.8496324765 (ExtendedPoll) + 1689+229 ( 2 0 4253.4676480183 2 5746.4606892429 ) 53.8494960362 (ExtendedPoll) + 1689+230 ( 2 0 4250.4350406932 2 5749.2837103771 ) 53.8489791731 (ExtendedPoll) + 1689+231 ( 2 0 4238.3046113928 2 5760.5757949136 ) 53.8473747522 (ExtendedPoll) + 1689+233 ( 2 0 4237.9514726055 2 5760.9129400964 ) 53.8472576934 (ExtendedPoll) + 1689+234 ( 2 0 4236.8920562434 2 5761.9243756450 ) 53.8469104201 (ExtendedPoll) + 1689+235 ( 2 0 4232.6543907954 2 5765.9701178391 ) 53.8455799016 (ExtendedPoll) + 1689+236 ( 2 0 4215.7037290030 2 5782.1530866154 ) 53.8411968855 (ExtendedPoll) + 1689+237 ( 2 0 4147.9010818337 2 5846.8849617209 ) 53.8388064213 (ExtendedPoll) + 1689+239 ( 2 0 4139.4939903168 2 5859.9869225266 ) 53.7929039460 (ExtendedPoll) + 1689+243 ( 2 0 4134.1713187395 2 5865.6917346274 ) 53.7882968215 (ExtendedPoll) + 1689+250 ( 2 0 4133.4948958932 2 5866.3963062176 ) 53.7879136446 (ExtendedPoll) + 1689+251 ( 2 0 4131.4656273543 2 5868.5100209882 ) 53.7867806418 (ExtendedPoll) + 1689+261 ( 2 0 4131.5933562783 2 5868.3938874275 ) 53.7866942837 (ExtendedPoll) + 1689+270 ( 2 0 4131.5998202039 2 5868.3898345950 ) 53.7866729850 (ExtendedPoll) + 1689+271 ( 2 0 4131.6192119808 2 5868.3776760976 ) 53.7866090899 (ExtendedPoll) + 1689+279 ( 2 0 4131.6209541211 2 5868.3784525807 ) 53.7865860060 (ExtendedPoll) + 1689+284 ( 2 0 4131.6214166274 2 5868.3783365570 ) 53.7865828676 (ExtendedPoll) + 1689+287 ( 2 0 4131.6210066099 2 5868.3788719382 ) 53.7865816357 (ExtendedPoll) + 1689+293 ( 2 0 4131.6209362583 2 5868.3789681750 ) 53.7865813838 (ExtendedPoll) + 1689+294 ( 2 0 4131.6207252036 2 5868.3792568852 ) 53.7865806279 (ExtendedPoll) + 1689+298 ( 2 0 4131.6206891940 2 5868.3793043828 ) 53.7865805153 (ExtendedPoll) + 1689+304 ( 2 0 4131.6206796375 2 5868.3793158160 ) 53.7865804962 (ExtendedPoll) + 1689+308 ( 2 0 4131.6206768768 2 5868.3793227362 ) 53.7865804572 (ExtendedPoll) + 1689+313 ( 2 0 4131.6206782642 2 5868.3793214934 ) 53.7865804561 (ExtendedPoll) + 1689+315 ( 2 0 4131.6206745081 2 5868.3793251876 ) 53.7865804560 (ExtendedPoll) + 1689+316 ( 2 0 4131.6206632396 2 5868.3793362702 ) 53.7865804559 (ExtendedPoll) + 1689+317 ( 2 0 4131.6206181660 2 5868.3793806004 ) 53.7865804552 (ExtendedPoll) + 1689+318 ( 2 0 4131.6204378713 2 5868.3795579212 ) 53.7865804528 (ExtendedPoll) + 1689+319 ( 2 0 4131.6197166927 2 5868.3802672046 ) 53.7865804428 (ExtendedPoll) + 1689+320 ( 2 0 4131.6168319783 2 5868.3831043383 ) 53.7865804032 (ExtendedPoll) + 1689+321 ( 2 0 4131.6052931206 2 5868.3944528729 ) 53.7865802452 (ExtendedPoll) + 1689+322 ( 2 0 4131.5591376898 2 5868.4398470112 ) 53.7865796204 (ExtendedPoll) + 1689+323 ( 2 0 4131.3745159668 2 5868.6214235646 ) 53.7865772402 (ExtendedPoll) + 1689+324 ( 2 0 4130.6360290747 2 5869.3477297782 ) 53.7865696199 (ExtendedPoll) + 1689+325 ( 2 0 4127.6820815062 2 5872.2529546326 ) 53.7865695587 (ExtendedPoll) + 1689+328 ( 2 0 4127.6840140147 2 5872.2603352230 ) 53.7864835442 (ExtendedPoll) + 1689+329 ( 2 0 4127.6898115401 2 5872.2824769939 ) 53.7862255016 (ExtendedPoll) + 1689+330 ( 2 0 4127.6796235307 2 5872.3112438240 ) 53.7860518834 (ExtendedPoll) + 1689+338 ( 2 0 4127.6784943469 2 5872.3148875688 ) 53.7860284213 (ExtendedPoll) + 1689+339 ( 2 0 4127.6750287014 2 5872.3216844082 ) 53.7859970553 (ExtendedPoll) + 1689+345 ( 2 0 4127.6738721701 2 5872.3232011194 ) 53.7859935510 (ExtendedPoll) + 1689+346 ( 2 0 4127.6704025761 2 5872.3277512530 ) 53.7859830384 (ExtendedPoll) + 1689+352 ( 2 0 4127.6704920471 2 5872.3287007212 ) 53.7859734249 (ExtendedPoll) + 1689+357 ( 2 0 4127.6702519860 2 5872.3291127215 ) 53.7859717972 (ExtendedPoll) + 1689+358 ( 2 0 4127.6695318024 2 5872.3303487226 ) 53.7859669139 (ExtendedPoll) + 1689+364 ( 2 0 4127.6693723329 2 5872.3305259594 ) 53.7859667262 (ExtendedPoll) + 1689+365 ( 2 0 4127.6688939242 2 5872.3310576698 ) 53.7859661633 (ExtendedPoll) + 1689+372 ( 2 0 4127.6688751072 2 5872.3311142263 ) 53.7859658109 (ExtendedPoll) + 1689+374 ( 2 0 4127.6689990935 2 5872.3309999936 ) 53.7859657384 (ExtendedPoll) + 1689+382 ( 2 0 4127.6690021165 2 5872.3309978166 ) 53.7859657310 (ExtendedPoll) + 2076+20 ( 2 0 4999.9878997345 2 5000.0092959702 ) 55.9016794952 (ExtendedPoll) + 2076+21 ( 2 0 4999.9515989379 2 5000.0371838810 ) 55.9016196708 (ExtendedPoll) + 2076+22 ( 2 0 4999.8063957515 2 5000.1487355238 ) 55.9013804121 (ExtendedPoll) + 2076+23 ( 2 0 4999.2255830062 2 5000.5949420954 ) 55.9004239959 (ExtendedPoll) + 2076+24 ( 2 0 4996.9023320246 2 5002.3797683814 ) 55.8966082342 (ExtendedPoll) + 2076+25 ( 2 0 4987.6093280984 2 5009.5190735258 ) 55.8815039246 (ExtendedPoll) + 2076+26 ( 2 0 4950.4373123937 2 5038.0762941031 ) 55.8236448341 (ExtendedPoll) + 2076+27 ( 2 0 4801.7492495748 2 5152.3051764124 ) 55.6343152023 (ExtendedPoll) + 2076+28 ( 2 0 4206.9969982993 2 5609.2207056496 ) 55.6253373563 (ExtendedPoll) + 2076+32 ( 2 0 4217.9971862258 2 5610.1214654550 ) 55.5187948731 (ExtendedPoll) + 2076+33 ( 2 0 4250.9977500050 2 5612.8237448711 ) 55.2000072940 (ExtendedPoll) + 2076+34 ( 2 0 4279.8220637775 2 5600.5952481192 ) 55.0710067569 (ExtendedPoll) + 2076+35 ( 2 0 4366.2950050949 2 5563.9097578633 ) 54.6951789859 (ExtendedPoll) + 2076+39 ( 2 0 4393.3723907599 2 5548.1874048965 ) 54.6249740689 (ExtendedPoll) + 2076+40 ( 2 0 4474.6045477550 2 5501.0203459961 ) 54.4266469861 (ExtendedPoll) + 2076+42 ( 2 0 4525.2654628702 2 5464.3348557403 ) 54.3900963042 (ExtendedPoll) + 2076+48 ( 2 0 4514.4563452056 2 5483.6602479286 ) 54.2742359116 (ExtendedPoll) + 2076+49 ( 2 0 4491.7462798091 2 5505.0601172445 ) 54.2385084897 (ExtendedPoll) + 2076+50 ( 2 0 4423.6160836196 2 5569.2597251923 ) 54.1460338788 (ExtendedPoll) + 2076+51 ( 2 0 4151.0952988618 2 5826.0581569833 ) 54.0054730693 (ExtendedPoll) + 2076+57 ( 2 0 4119.6505929283 2 5880.2129283134 ) 53.7862527117 (ExtendedPoll) + 2076+75 ( 2 0 4119.5665931846 2 5880.3014995623 ) 53.7862021958 (ExtendedPoll) + 2076+76 ( 2 0 4119.3145939537 2 5880.5672133090 ) 53.7860509080 (ExtendedPoll) + 2076+77 ( 2 0 4118.3065970302 2 5881.6300682960 ) 53.7854496575 (ExtendedPoll) + 2076+88 ( 2 0 4118.3108711544 2 5881.6602849630 ) 53.7851316932 (ExtendedPoll) + 2076+96 ( 2 0 4118.3198847115 2 5881.6662155602 ) 53.7849945777 (ExtendedPoll) + 2076+97 ( 2 0 4118.3348277986 2 5881.6631276284 ) 53.7848865134 (ExtendedPoll) + 2076+99 ( 2 0 4118.3462668702 2 5881.6530292707 ) 53.7848751796 (ExtendedPoll) + 2076+108 ( 2 0 4118.3455932557 2 5881.6537043543 ) 53.7848751047 (ExtendedPoll) + 2076+109 ( 2 0 4118.3435724122 2 5881.6557296052 ) 53.7848748801 (ExtendedPoll) + 2076+110 ( 2 0 4118.3354890381 2 5881.6638306090 ) 53.7848739818 (ExtendedPoll) + 2076+111 ( 2 0 4118.3031555418 2 5881.6962346240 ) 53.7848703922 (ExtendedPoll) + 2076+112 ( 2 0 4118.1738215565 2 5881.8258506839 ) 53.7848560937 (ExtendedPoll) + 2076+122 ( 2 0 4118.1735085463 2 5881.8262104036 ) 53.7848556344 (ExtendedPoll) + 2076+123 ( 2 0 4118.1725695157 2 5881.8272895629 ) 53.7848542566 (ExtendedPoll) + 2076+132 ( 2 0 4118.1726545887 2 5881.8272060557 ) 53.7848542498 (ExtendedPoll) + 2076+133 ( 2 0 4118.1729098077 2 5881.8269555344 ) 53.7848542294 (ExtendedPoll) + 2076+134 ( 2 0 4118.1739306837 2 5881.8259534489 ) 53.7848541479 (ExtendedPoll) + 2076+135 ( 2 0 4118.1780141879 2 5881.8219451070 ) 53.7848538220 (ExtendedPoll) + 2076+151 ( 2 0 4118.1780093963 2 5881.8219592167 ) 53.7848537356 (ExtendedPoll) + 2076+152 ( 2 0 4118.1779950216 2 5881.8220015460 ) 53.7848534763 (ExtendedPoll) + 2076+159 ( 2 0 4118.1779947385 2 5881.8220052606 ) 53.7848534446 (ExtendedPoll) + 2244+6 ( 2 0 4168.4622208673 2 5740.6975175468 ) 54.6654457702 (ExtendedPoll) + 2244+7 ( 2 0 3937.8677106876 2 6034.1814395937 ) 54.1025876908 (ExtendedPoll) + 2244+15 ( 2 0 3968.8756845943 2 6029.8141193251 ) 53.8471893590 (ExtendedPoll) + 2244+23 ( 2 0 3966.3440036262 2 6032.7893562581 ) 53.8453293272 (ExtendedPoll) + 2244+29 ( 2 0 3967.2852805629 2 6032.5287671287 ) 53.8387026417 (ExtendedPoll) + 2244+32 ( 2 0 3966.9613567598 2 6032.8941676795 ) 53.8385991104 (ExtendedPoll) + 2244+33 ( 2 0 3965.9895853505 2 6033.9903693319 ) 53.8382928991 (ExtendedPoll) + 2244+45 ( 2 0 3966.0039197226 2 6033.9851390276 ) 53.8382028409 (ExtendedPoll) + 2244+46 ( 2 0 3966.0291479677 2 6033.9679675607 ) 53.8381131770 (ExtendedPoll) + 2244+52 ( 2 0 3966.0378553973 2 6033.9615960721 ) 53.8380860741 (ExtendedPoll) + 2244+64 ( 2 0 3966.0380469160 2 6033.9618735742 ) 53.8380818691 (ExtendedPoll) + 2244+69 ( 2 0 3966.0381004053 2 6033.9618472758 ) 53.8380815916 (ExtendedPoll) + 2244+74 ( 2 0 3966.0381302064 2 6033.9618470067 ) 53.8380813128 (ExtendedPoll) + 2244+79 ( 2 0 3966.0381451069 2 6033.9618471499 ) 53.8380811710 (ExtendedPoll) + 2244+84 ( 2 0 3966.0381513080 2 6033.9618430199 ) 53.8380811481 (ExtendedPoll) + 2244+86 ( 2 0 3966.0381381930 2 6033.9618595149 ) 53.8380811293 (ExtendedPoll) + 2244+91 ( 2 0 3966.0381418784 2 6033.9618557502 ) 53.8380811271 (ExtendedPoll) + 2244+92 ( 2 0 3966.0381529347 2 6033.9618444560 ) 53.8380811204 (ExtendedPoll) + 2244+93 ( 2 0 3966.0381971599 2 6033.9617992793 ) 53.8380810935 (ExtendedPoll) + 2244+94 ( 2 0 3966.0383740607 2 6033.9616185725 ) 53.8380809858 (ExtendedPoll) + 2244+95 ( 2 0 3966.0390816638 2 6033.9608957451 ) 53.8380805552 (ExtendedPoll) + 2244+96 ( 2 0 3966.0419120761 2 6033.9580044356 ) 53.8380788327 (ExtendedPoll) + 2244+97 ( 2 0 3966.0532337255 2 6033.9464391976 ) 53.8380719433 (ExtendedPoll) + 2244+98 ( 2 0 3966.0985203229 2 6033.9001782457 ) 53.8380443936 (ExtendedPoll) + 2244+99 ( 2 0 3966.2796667126 2 6033.7151344380 ) 53.8379343190 (ExtendedPoll) + 2244+100 ( 2 0 3967.0042522715 2 6032.9749592074 ) 53.8374960138 (ExtendedPoll) + 2244+101 ( 2 0 3969.9025945070 2 6030.0142582847 ) 53.8357746693 (ExtendedPoll) + 2244+102 ( 2 0 3981.4959634492 2 6018.1714545940 ) 53.8293988351 (ExtendedPoll) + 2244+103 ( 2 0 4027.8694392178 2 5970.8002398312 ) 53.8120165816 (ExtendedPoll) + 2244+105 ( 2 0 4027.8996279793 2 5970.7957732839 ) 53.8117751288 (ExtendedPoll) + 2244+106 ( 2 0 4027.9901942637 2 5970.7823736422 ) 53.8110507797 (ExtendedPoll) + 2244+107 ( 2 0 4028.3524594017 2 5970.7287750751 ) 53.8081535202 (ExtendedPoll) + 2244+108 ( 2 0 4028.5782890972 2 5970.8215646372 ) 53.8052259801 (ExtendedPoll) + 2244+109 ( 2 0 4029.0659874104 2 5970.8447020517 ) 53.8004791353 (ExtendedPoll) + 2244+117 ( 2 0 4029.1224148462 2 5970.8679660822 ) 53.7997469853 (ExtendedPoll) + 2244+125 ( 2 0 4029.1289146169 2 5970.8639709871 ) 53.7997219690 (ExtendedPoll) + 2244+129 ( 2 0 4029.1327113864 2 5970.8636015775 ) 53.7996898997 (ExtendedPoll) + 2244+134 ( 2 0 4029.1345329350 2 5970.8641672091 ) 53.7996679124 (ExtendedPoll) + 2244+136 ( 2 0 4029.1361890843 2 5970.8632210851 ) 53.7996608999 (ExtendedPoll) + 2244+142 ( 2 0 4029.1366590260 2 5970.8631402857 ) 53.7996572423 (ExtendedPoll) + 2244+146 ( 2 0 4029.1368554851 2 5970.8630052034 ) 53.7996566135 (ExtendedPoll) + 2244+147 ( 2 0 4029.1372198865 2 5970.8626976562 ) 53.7996559536 (ExtendedPoll) + 2244+158 ( 2 0 4029.1372434032 2 5970.8627159631 ) 53.7996555720 (ExtendedPoll) + 2244+159 ( 2 0 4029.1372160758 2 5970.8627689341 ) 53.7996553557 (ExtendedPoll) + 2244+165 ( 2 0 4029.1372107574 2 5970.8627828538 ) 53.7996552815 (ExtendedPoll) + 2244+168 ( 2 0 4029.1372020883 2 5970.8627949737 ) 53.7996552545 (ExtendedPoll) + 2244+172 ( 2 0 4029.1371973626 2 5970.8628007338 ) 53.7996552473 (ExtendedPoll) + 2244+179 ( 2 0 4029.1371969852 2 5970.8628025579 ) 53.7996552346 (ExtendedPoll) + 2244+181 ( 2 0 4029.1372006890 2 5970.8627988111 ) 53.7996552334 (ExtendedPoll) + 2244+182 ( 2 0 4029.1372118001 2 5970.8627875709 ) 53.7996552298 (ExtendedPoll) + 2244+183 ( 2 0 4029.1372562449 2 5970.8627426102 ) 53.7996552156 (ExtendedPoll) + 2244+184 ( 2 0 4029.1374340239 2 5970.8625627674 ) 53.7996551585 (ExtendedPoll) + 2244+185 ( 2 0 4029.1381451401 2 5970.8618433959 ) 53.7996549302 (ExtendedPoll) + 2244+186 ( 2 0 4029.1409896047 2 5970.8589659099 ) 53.7996540170 (ExtendedPoll) + 2244+187 ( 2 0 4029.1523674632 2 5970.8474559659 ) 53.7996503647 (ExtendedPoll) + 2244+188 ( 2 0 4029.1978788972 2 5970.8014161900 ) 53.7996357631 (ExtendedPoll) + 2244+189 ( 2 0 4029.3799246331 2 5970.6172570866 ) 53.7995774796 (ExtendedPoll) + 2244+190 ( 2 0 4030.1081075767 2 5969.8806206727 ) 53.7993463077 (ExtendedPoll) + 2244+191 ( 2 0 4033.0208393511 2 5966.9340750174 ) 53.7984530101 (ExtendedPoll) + 2244+192 ( 2 0 4044.6717664489 2 5955.1478923961 ) 53.7953815270 (ExtendedPoll) + 2244+193 ( 2 0 4091.2754748399 2 5908.0031619108 ) 53.7910882360 (ExtendedPoll) + 2244+196 ( 2 0 4091.3024169829 2 5908.0174949293 ) 53.7907097823 (ExtendedPoll) + 2244+197 ( 2 0 4091.3832434122 2 5908.0604939849 ) 53.7895744291 (ExtendedPoll) + 2244+198 ( 2 0 4091.7065491291 2 5908.2324902073 ) 53.7850331320 (ExtendedPoll) + 2244+201 ( 2 0 4091.7062625770 2 5908.2935241345 ) 53.7844786297 (ExtendedPoll) + 2244+218 ( 2 0 4091.7061814853 2 5908.2937483387 ) 53.7844773284 (ExtendedPoll) + 2244+225 ( 2 0 4091.7061774429 2 5908.2938078061 ) 53.7844768227 (ExtendedPoll) + 2244+228 ( 2 0 4091.7061404988 2 5908.2938545806 ) 53.7844767353 (ExtendedPoll) + 2244+237 ( 2 0 4091.7061392073 2 5908.2938580748 ) 53.7844767152 (ExtendedPoll) + 2244+242 ( 2 0 4091.7061402086 2 5908.2938596455 ) 53.7844766917 (ExtendedPoll) + 2494+9 ( 2 0 4996.9428758120 2 5002.4361458373 ) 55.8956087809 (ExtendedPoll) + 2494+10 ( 2 0 4987.7715032480 2 5009.7445833492 ) 55.8775091797 (ExtendedPoll) + 2494+11 ( 2 0 4951.0860129922 2 5038.9783333968 ) 55.8077152532 (ExtendedPoll) + 2494+12 ( 2 0 4804.3440519688 2 5155.9133335874 ) 55.5714059083 (ExtendedPoll) + 2494+13 ( 2 0 4217.3762078751 2 5623.6533343496 ) 55.3875012518 (ExtendedPoll) + 2494+15 ( 2 0 4161.4745084376 2 5735.4567332245 ) 54.7792090326 (ExtendedPoll) + 2494+19 ( 2 0 4301.2287570313 2 5616.6656219199 ) 54.7199123025 (ExtendedPoll) + 2494+25 ( 2 0 4362.3712407911 2 5630.6410467792 ) 54.0447637843 (ExtendedPoll) + 2494+30 ( 2 0 4360.6789041870 2 5638.2565614975 ) 53.9822178137 (ExtendedPoll) + 2494+34 ( 2 0 4357.7855545091 2 5640.8837775966 ) 53.9807745427 (ExtendedPoll) + 2494+35 ( 2 0 4349.1055054753 2 5648.7654258937 ) 53.9766818176 (ExtendedPoll) + 2494+36 ( 2 0 4314.3853093403 2 5680.2920190824 ) 53.9638836443 (ExtendedPoll) + 2494+38 ( 2 0 4293.8589040781 2 5703.8755485326 ) 53.9100589240 (ExtendedPoll) + 2494+44 ( 2 0 4288.6181197559 2 5709.6895436401 ) 53.8988093078 (ExtendedPoll) + 2494+48 ( 2 0 4286.0250233464 2 5712.6101890697 ) 53.8928738710 (ExtendedPoll) + 2494+49 ( 2 0 4278.2457341180 2 5721.3721253585 ) 53.8753278023 (ExtendedPoll) + 2494+58 ( 2 0 4278.6875840983 2 5721.1643151240 ) 53.8734640832 (ExtendedPoll) + 2494+62 ( 2 0 4278.5548371810 2 5721.3692198536 ) 53.8726233086 (ExtendedPoll) + 2494+70 ( 2 0 4278.5803407327 2 5721.3524598889 ) 53.8725625799 (ExtendedPoll) + 2494+71 ( 2 0 4278.6568513877 2 5721.3021799948 ) 53.8723804067 (ExtendedPoll) + 2494+76 ( 2 0 4278.6854324587 2 5721.3128786333 ) 53.8720225267 (ExtendedPoll) + 2494+84 ( 2 0 4278.6872107890 2 5721.3121890539 ) 53.8720135829 (ExtendedPoll) + 2494+86 ( 2 0 4278.6834607716 2 5721.3160673533 ) 53.8720086108 (ExtendedPoll) + 2494+87 ( 2 0 4278.6722107195 2 5721.3277022515 ) 53.8719936947 (ExtendedPoll) + 2494+96 ( 2 0 4278.6723989724 2 5721.3275559496 ) 53.8719934685 (ExtendedPoll) + 2494+98 ( 2 0 4278.6719110434 2 5721.3280214306 ) 53.8719932064 (ExtendedPoll) + 2494+99 ( 2 0 4278.6704472565 2 5721.3294178739 ) 53.8719924200 (ExtendedPoll) + 2494+100 ( 2 0 4278.6645921088 2 5721.3350036468 ) 53.8719892745 (ExtendedPoll) + 2494+101 ( 2 0 4278.6411715181 2 5721.3573467387 ) 53.8719766944 (ExtendedPoll) + 2494+102 ( 2 0 4278.5474891555 2 5721.4467191061 ) 53.8719264022 (ExtendedPoll) + 2494+103 ( 2 0 4278.1727597049 2 5721.8042085755 ) 53.8717256857 (ExtendedPoll) + 2494+104 ( 2 0 4276.6738419026 2 5723.2341664534 ) 53.8709300560 (ExtendedPoll) + 2494+105 ( 2 0 4270.6781706935 2 5728.9539979649 ) 53.8678634044 (ExtendedPoll) + 2494+106 ( 2 0 4246.6954858570 2 5751.8333240110 ) 53.8574561057 (ExtendedPoll) + 2494+107 ( 2 0 4150.7647465111 2 5843.3506281954 ) 53.8459142947 (ExtendedPoll) + 2494+110 ( 2 0 4151.0319463303 2 5843.7593181024 ) 53.8396594450 (ExtendedPoll) + 2494+111 ( 2 0 4151.8335457878 2 5844.9853878233 ) 53.8208980002 (ExtendedPoll) + 2494+112 ( 2 0 4153.3279881922 2 5846.2426983850 ) 53.7955624715 (ExtendedPoll) + 2494+116 ( 2 0 4153.1058903377 2 5846.6776178033 ) 53.7935050825 (ExtendedPoll) + 2494+118 ( 2 0 4152.8591623323 2 5847.0989959699 ) 53.7917987292 (ExtendedPoll) + 2494+127 ( 2 0 4152.8542659569 2 5847.1291180913 ) 53.7915611730 (ExtendedPoll) + 2494+129 ( 2 0 4152.9186835311 2 5847.0716643992 ) 53.7915145196 (ExtendedPoll) + 2494+133 ( 2 0 4152.8895239414 2 5847.1034820926 ) 53.7914812417 (ExtendedPoll) + 2494+138 ( 2 0 4152.8811001224 2 5847.1162049217 ) 53.7914385729 (ExtendedPoll) + 2494+141 ( 2 0 4152.8973868388 2 5847.1020486033 ) 53.7914233161 (ExtendedPoll) + 2494+150 ( 2 0 4152.8955121262 2 5847.1039880394 ) 53.7914221706 (ExtendedPoll) + 2494+151 ( 2 0 4152.8898879885 2 5847.1098063475 ) 53.7914187344 (ExtendedPoll) + 2494+159 ( 2 0 4152.8896638419 2 5847.1102272180 ) 53.7914168283 (ExtendedPoll) + 2494+168 ( 2 0 4152.8897034201 2 5847.1102717856 ) 53.7914160520 (ExtendedPoll) + 2494+172 ( 2 0 4152.8897151731 2 5847.1102626252 ) 53.7914160311 (ExtendedPoll) + 2494+173 ( 2 0 4152.8897504319 2 5847.1102351440 ) 53.7914159684 (ExtendedPoll) + 2494+177 ( 2 0 4152.8897404990 2 5847.1102462518 ) 53.7914159546 (ExtendedPoll) + 2494+178 ( 2 0 4152.8897107004 2 5847.1102795751 ) 53.7914159130 (ExtendedPoll) + 2494+182 ( 2 0 4152.8897044864 2 5847.1102931188 ) 53.7914158426 (ExtendedPoll) + 2494+188 ( 2 0 4152.8897024353 2 5847.1102962286 ) 53.7914158321 (ExtendedPoll) + 2494+193 ( 2 0 4152.8897041880 2 5847.1102955980 ) 53.7914158221 (ExtendedPoll) + 2494+202 ( 2 0 4152.8897041652 2 5847.1102957121 ) 53.7914158212 (ExtendedPoll) + 2494+205 ( 2 0 4152.8897042523 2 5847.1102956349 ) 53.7914158212 (ExtendedPoll) + 2494+206 ( 2 0 4152.8897045137 2 5847.1102954032 ) 53.7914158210 (ExtendedPoll) + 2494+207 ( 2 0 4152.8897048775 2 5847.1102951127 ) 53.7914158204 (ExtendedPoll) + 2761 ( 3 0 3333.3333333249 2 3333.3333333165 1 3333.3333333555 ) 47.1682905221 + 2762 ( 3 0 3333.3333332996 2 3333.3333332658 1 3333.3333334220 ) 47.1682905221 + 2763 ( 3 0 3333.3333331985 2 3333.3333330633 1 3333.3333336880 ) 47.1682905221 + 2764 ( 3 0 3333.3333327939 2 3333.3333322533 1 3333.3333347518 ) 47.1682905219 + 2765 ( 3 0 3333.3333311757 2 3333.3333290134 1 3333.3333390073 ) 47.1682905212 + 2766 ( 3 0 3333.3333247026 2 3333.3333160534 1 3333.3333560290 ) 47.1682905185 + 2767 ( 3 0 3333.3332988105 2 3333.3332642138 1 3333.3334241161 ) 47.1682905075 + 2768 ( 3 0 3333.3331952421 2 3333.3330568551 1 3333.3336964646 ) 47.1682904637 + 2769 ( 3 0 3333.3327809684 2 3333.3322274206 1 3333.3347858583 ) 47.1682902884 + 2770 ( 3 0 3333.3311238738 2 3333.3289096824 1 3333.3391434333 ) 47.1682895873 + 2771 ( 3 0 3333.3244954951 2 3333.3156387294 1 3333.3565737331 ) 47.1682867830 + 2772 ( 3 0 3333.2979819803 2 3333.2625549176 1 3333.4262949324 ) 47.1682755667 + 2773 ( 3 0 3333.1919279212 2 3333.0502196704 1 3333.7051797296 ) 47.1682307194 + 2774 ( 3 0 3332.7677116849 2 3332.2008786818 1 3334.8207189184 ) 47.1680516124 + 2775 ( 3 0 3331.0708467397 2 3328.8035147270 1 3339.2828756735 ) 47.1673397044 + 2776 ( 3 0 3324.2833869587 2 3315.2140589080 1 3357.1315026938 ) 47.1645644377 + 2777 ( 3 0 3297.1335478348 2 3260.8562356320 1 3428.5260107754 ) 47.1546240959 + 2778 ( 3 0 3188.5341913391 2 3043.4249425281 1 3714.1040431015 ) 47.1336301248 + 2783 ( 3 0 3188.5440963277 2 3043.4291749044 1 3714.1116982164 ) 47.1334189419 + 2784 ( 3 0 3188.5738112936 2 3043.4418720333 1 3714.1346635611 ) 47.1327853954 + 2785 ( 3 0 3188.6926711573 2 3043.4926605491 1 3714.2265249397 ) 47.1302512441 + 2786 ( 3 0 3189.1681106120 2 3043.6958146122 1 3714.5939704540 ) 47.1201151932 + 2787 ( 3 0 3191.0698684310 2 3044.5084308647 1 3716.0637525116 ) 47.0795798665 + 2788 ( 3 0 3198.6768997067 2 3047.7588958743 1 3721.9428807416 ) 46.9175811367 + 2789 ( 3 0 3198.8948848743 2 3047.5863280381 1 3722.3442473958 ) 46.9131329647 + 2790 ( 3 0 3199.5488403769 2 3047.0686245294 1 3723.5483473581 ) 46.8997895433 + 2791 ( 3 0 3202.1646623876 2 3044.9978104945 1 3728.3647472073 ) 46.8464322782 + 2792 ( 3 0 3212.6279504301 2 3036.7145543550 1 3747.6303466044 ) 46.6332660653 + 2797+6 ( 2 0 4900.6584516792 2 5075.3512624213 ) 55.7642295241 (ExtendedPoll) + 2797+7 ( 2 0 4607.1745296323 2 5305.9457726010 ) 55.4472050367 (ExtendedPoll) + 2797+13 ( 2 0 4509.3465556167 2 5389.7983217572 ) 55.3312037272 (ExtendedPoll) + 2797+14 ( 2 0 4215.8626335698 2 5641.3559692260 ) 55.2227885943 (ExtendedPoll) + 2797+16 ( 2 0 3880.4524369449 2 6088.5695647259 ) 54.1867250496 (ExtendedPoll) + 2797+25 ( 2 0 3865.6035480318 2 6116.0836824178 ) 54.0994049526 (ExtendedPoll) + 2797+30 ( 2 0 3858.1791035753 2 6129.8407412638 ) 54.0570067200 (ExtendedPoll) + 2797+35 ( 2 0 3865.9856885553 2 6129.2948262302 ) 53.9862513494 (ExtendedPoll) + 2797+41 ( 2 0 3867.9219809400 2 6129.0355165892 ) 53.9697415456 (ExtendedPoll) + 2797+42 ( 2 0 3871.2247668931 2 6126.9473915858 ) 53.9552082161 (ExtendedPoll) + 2797+47 ( 2 0 3872.9461052333 2 6126.0261599667 ) 53.9462662728 (ExtendedPoll) + 2797+51 ( 2 0 3873.9223548519 2 6126.0547352067 ) 53.9366367060 (ExtendedPoll) + 2797+63 ( 2 0 3873.9150839053 2 6126.0681502590 ) 53.9365956057 (ExtendedPoll) + 2797+64 ( 2 0 3873.9023656577 2 6126.0958912493 ) 53.9364883221 (ExtendedPoll) + 2797+71 ( 2 0 3873.8992381518 2 6126.1002869850 ) 53.9364820231 (ExtendedPoll) + 2797+82 ( 2 0 3873.8993365564 2 6126.1005041485 ) 53.9364792786 (ExtendedPoll) + 2797+86 ( 2 0 3873.8994440785 2 6126.1004526718 ) 53.9364786703 (ExtendedPoll) + 2797+89 ( 2 0 3873.8995441434 2 6126.1003878808 ) 53.9364782440 (ExtendedPoll) + 2797+90 ( 2 0 3873.8997141999 2 6126.1002207754 ) 53.9364779912 (ExtendedPoll) + 2797+91 ( 2 0 3873.9002243693 2 6126.0997194591 ) 53.9364772329 (ExtendedPoll) + 2797+92 ( 2 0 3873.9022650468 2 6126.0977141941 ) 53.9364741996 (ExtendedPoll) + 2797+99 ( 2 0 3873.9023564295 2 6126.0976376432 ) 53.9364739541 (ExtendedPoll) + 2797+108 ( 2 0 3873.9023666523 2 6126.0976268016 ) 53.9364739455 (ExtendedPoll) + 2797+109 ( 2 0 3873.9023973206 2 6126.0975942769 ) 53.9364739197 (ExtendedPoll) + 2797+110 ( 2 0 3873.9025199938 2 6126.0974641781 ) 53.9364738164 (ExtendedPoll) + 2797+111 ( 2 0 3873.9030106867 2 6126.0969437827 ) 53.9364734034 (ExtendedPoll) + 2797+112 ( 2 0 3873.9049734581 2 6126.0948622015 ) 53.9364717515 (ExtendedPoll) + 2797+113 ( 2 0 3873.9128245438 2 6126.0865358764 ) 53.9364651438 (ExtendedPoll) + 2797+114 ( 2 0 3873.9442288869 2 6126.0532305760 ) 53.9364387171 (ExtendedPoll) + 2797+115 ( 2 0 3874.0698462589 2 6125.9200093744 ) 53.9363330745 (ExtendedPoll) + 2797+116 ( 2 0 3874.5723157471 2 6125.3871245682 ) 53.9359115277 (ExtendedPoll) + 2797+117 ( 2 0 3876.5821937000 2 6123.2555853431 ) 53.9342417174 (ExtendedPoll) + 2797+118 ( 2 0 3884.6217055116 2 6114.7294284431 ) 53.9278243645 (ExtendedPoll) + 2797+119 ( 2 0 3916.7797527577 2 6080.6248008429 ) 53.9063357782 (ExtendedPoll) + 2797+120 ( 2 0 4045.4119417422 2 5944.2062904420 ) 53.8866188839 (ExtendedPoll) + 2797+123 ( 2 0 4045.5215045970 2 5944.2601089211 ) 53.8851192623 (ExtendedPoll) + 2797+124 ( 2 0 4045.8501931615 2 5944.4215643586 ) 53.8806205222 (ExtendedPoll) + 2797+125 ( 2 0 4047.1649474193 2 5945.0673861082 ) 53.8626274298 (ExtendedPoll) + 2797+126 ( 2 0 4048.1386380613 2 5945.1403169447 ) 53.8529449201 (ExtendedPoll) + 2797+127 ( 2 0 4051.0597099870 2 5945.3591094543 ) 53.8239051878 (ExtendedPoll) + 2797+130 ( 2 0 4052.9055851942 2 5944.7227772433 ) 53.8125206018 (ExtendedPoll) + 2797+135 ( 2 0 4053.8541125651 2 5944.9547911326 ) 53.8016493716 (ExtendedPoll) + 2797+138 ( 2 0 4054.7420774868 2 5944.5483403302 ) 53.7970783073 (ExtendedPoll) + 2797+144 ( 2 0 4055.1565250914 2 5944.8064771068 ) 53.7909201097 (ExtendedPoll) + 2797+153 ( 2 0 4055.1705529195 2 5944.8124812684 ) 53.7907362425 (ExtendedPoll) + 2797+158 ( 2 0 4055.1759264999 2 5944.8178972016 ) 53.7906378043 (ExtendedPoll) + 2797+159 ( 2 0 4055.1662131965 2 5944.8296651001 ) 53.7906219881 (ExtendedPoll) + 2797+163 ( 2 0 4055.1612269352 2 5944.8354395879 ) 53.7906162644 (ExtendedPoll) + 2797+164 ( 2 0 4055.1462681513 2 5944.8527630512 ) 53.7905990941 (ExtendedPoll) + 2797+170 ( 2 0 4055.1439936051 2 5944.8558254594 ) 53.7905926341 (ExtendedPoll) + 2797+176 ( 2 0 4055.1459887350 2 5944.8540101306 ) 53.7905904735 (ExtendedPoll) + 2797+198 ( 2 0 4055.1459891780 2 5944.8540106179 ) 53.7905904650 (ExtendedPoll) + 2797+200 ( 2 0 4055.1459895782 2 5944.8540103798 ) 53.7905904635 (ExtendedPoll) + 2797+211 ( 2 0 4055.1459895943 2 5944.8540104040 ) 53.7905904631 (ExtendedPoll) + 3014 ( 3 0 3210.5286604494 2 3038.4216692843 1 3750.4447793258 ) 46.6015154107 + 3019+6 ( 2 0 4692.2382076236 2 5223.3043522798 ) 55.6902400114 (ExtendedPoll) + 3019+14 ( 2 0 4751.6337632759 2 5242.5205614614 ) 54.9900785314 (ExtendedPoll) + 3019+23 ( 2 0 4744.8371211080 2 5251.2279062468 ) 54.9451839171 (ExtendedPoll) + 3019+24 ( 2 0 4735.4473825306 2 5263.6747690122 ) 54.8789033947 (ExtendedPoll) + 3019+33 ( 2 0 4734.9854872326 2 5264.5350116862 ) 54.8728327514 (ExtendedPoll) + 3019+34 ( 2 0 4733.7844741588 2 5266.0755156716 ) 54.8649914704 (ExtendedPoll) + 3019+39 ( 2 0 4733.0120896855 2 5266.6730367357 ) 54.8644320425 (ExtendedPoll) + 3019+40 ( 2 0 4730.6949362657 2 5268.4655999279 ) 54.8627657851 (ExtendedPoll) + 3019+41 ( 2 0 4721.4263225864 2 5275.6358526969 ) 54.8562814361 (ExtendedPoll) + 3019+42 ( 2 0 4684.3518678691 2 5304.3168637731 ) 54.8332529571 (ExtendedPoll) + 3019+43 ( 2 0 4536.0540490000 2 5419.0409080777 ) 54.7888275928 (ExtendedPoll) + 3019+46 ( 2 0 4533.8703888657 2 5450.0488819844 ) 54.4714998393 (ExtendedPoll) + 3019+49 ( 2 0 4509.4133953618 2 5469.7018231929 ) 54.4660067399 (ExtendedPoll) + 3019+50 ( 2 0 4436.0424148501 2 5528.6606468184 ) 54.4633610125 (ExtendedPoll) + 3019+53 ( 2 0 4390.6222840571 2 5570.5869213965 ) 54.4160608763 (ExtendedPoll) + 3019+54 ( 2 0 4254.3618916782 2 5696.3657451309 ) 54.3333134172 (ExtendedPoll) + 3019+58 ( 2 0 4163.5216300923 2 5787.2060067168 ) 54.2619287838 (ExtendedPoll) + 3019+64 ( 2 0 4151.2931333404 2 5848.3484904766 ) 53.7943165716 (ExtendedPoll) + 3019+80 ( 2 0 4151.1660641526 2 5848.5569671112 ) 53.7935193903 (ExtendedPoll) + 3019+81 ( 2 0 4150.7848565894 2 5849.1823970151 ) 53.7911289956 (ExtendedPoll) + 3019+86 ( 2 0 4150.6155109737 2 5849.3582466966 ) 53.7910215159 (ExtendedPoll) + 3019+87 ( 2 0 4150.1074741268 2 5849.8857957410 ) 53.7907001042 (ExtendedPoll) + 3019+102 ( 2 0 4150.1089861817 2 5849.8869583539 ) 53.7906755049 (ExtendedPoll) + 3019+103 ( 2 0 4150.1127107275 2 5849.8861339310 ) 53.7906493993 (ExtendedPoll) + 3019+107 ( 2 0 4150.1143060889 2 5849.8850885612 ) 53.7906446904 (ExtendedPoll) + 3019+108 ( 2 0 4150.1171485655 2 5849.8825445004 ) 53.7906426731 (ExtendedPoll) + 3019+114 ( 2 0 4150.1178834653 2 5849.8819367039 ) 53.7906416845 (ExtendedPoll) + 3019+125 ( 2 0 4150.1179323692 2 5849.8819026286 ) 53.7906415591 (ExtendedPoll) + 3019+126 ( 2 0 4150.1180790807 2 5849.8818004026 ) 53.7906411831 (ExtendedPoll) + 3019+127 ( 2 0 4150.1182616331 2 5849.8816470466 ) 53.7906409597 (ExtendedPoll) + 3019+128 ( 2 0 4150.1188092902 2 5849.8811869788 ) 53.7906402897 (ExtendedPoll) + 3019+142 ( 2 0 4150.1188123412 2 5849.8811848413 ) 53.7906402820 (ExtendedPoll) + 3019+143 ( 2 0 4150.1188214943 2 5849.8811784287 ) 53.7906402588 (ExtendedPoll) + 3019+153 ( 2 0 4150.1188216858 2 5849.8811782962 ) 53.7906402583 (ExtendedPoll) + 3181+18 ( 2 0 4999.8309411913 2 5000.1672333819 ) 55.9009656850 (ExtendedPoll) + 3181+20 ( 2 0 4999.4491205399 2 5000.4715383635 ) 55.9002031428 (ExtendedPoll) + 3181+21 ( 2 0 4998.3036585857 2 5001.3844533083 ) 55.8979182003 (ExtendedPoll) + 3181+22 ( 2 0 4993.7218107688 2 5005.0361130876 ) 55.8888187275 (ExtendedPoll) + 3181+23 ( 2 0 4975.3944195012 2 5019.6427522045 ) 55.8530679233 (ExtendedPoll) + 3181+24 ( 2 0 4902.0848544307 2 5078.0693086723 ) 55.7205670458 (ExtendedPoll) + 3181+25 ( 2 0 4608.8465941490 2 5311.7755345433 ) 55.3681229992 (ExtendedPoll) + 3181+27 ( 2 0 4583.9528686182 2 5330.5550116980 ) 55.3637996156 (ExtendedPoll) + 3181+28 ( 2 0 4509.2716920260 2 5386.8934431624 ) 55.3635911500 (ExtendedPoll) + 3181+30 ( 2 0 4432.4068552994 2 5484.7214171780 ) 54.9584061960 (ExtendedPoll) + 3181+31 ( 2 0 4201.8123451197 2 5778.2053392249 ) 54.0036331278 (ExtendedPoll) + 3181+43 ( 2 0 4200.8569938110 2 5785.9573327015 ) 53.9378132020 (ExtendedPoll) + 3181+44 ( 2 0 4192.2315362806 2 5799.0592935072 ) 53.8900546358 (ExtendedPoll) + 3181+52 ( 2 0 4194.7836890625 2 5802.0140586264 ) 53.8389301385 (ExtendedPoll) + 3181+54 ( 2 0 4192.4430783561 2 5805.1394221936 ) 53.8302201837 (ExtendedPoll) + 3181+55 ( 2 0 4185.4212462368 2 5814.5155128951 ) 53.8043694686 (ExtendedPoll) + 3181+71 ( 2 0 4185.4407963358 2 5814.5389460247 ) 53.8039710219 (ExtendedPoll) + 3181+77 ( 2 0 4185.4480076188 2 5814.5364550417 ) 53.8039296544 (ExtendedPoll) + 3181+78 ( 2 0 4185.4696414679 2 5814.5289820924 ) 53.8038055528 (ExtendedPoll) + 3181+81 ( 2 0 4185.4807342197 2 5814.5185044072 ) 53.8038049529 (ExtendedPoll) + 3181+90 ( 2 0 4185.4816714853 2 5814.5183282598 ) 53.8037981763 (ExtendedPoll) + 3181+108 ( 2 0 4185.4816706336 2 5814.5183292645 ) 53.8037981745 (ExtendedPoll) + 3181+112 ( 2 0 4185.4816710094 2 5814.5183289895 ) 53.8037981737 (ExtendedPoll) + 3304+6 ( 2 0 4901.8695805142 2 5076.5623912563 ) 55.7402643064 (ExtendedPoll) + 3304+7 ( 2 0 4608.3856584673 2 5307.1569014360 ) 55.4236611469 (ExtendedPoll) + 3304+15 ( 2 0 4606.6387303599 2 5338.1648753428 ) 55.0917439291 (ExtendedPoll) + 3304+16 ( 2 0 4589.1694492857 2 5397.5604309951 ) 54.5804183615 (ExtendedPoll) + 3304+22 ( 2 0 4562.9655276744 2 5433.3724571972 ) 54.4082368778 (ExtendedPoll) + 3304+23 ( 2 0 4514.0515406666 2 5471.8048755605 ) 54.4043973012 (ExtendedPoll) + 3304+30 ( 2 0 4527.6994165058 2 5464.1620650905 ) 54.3714868324 (ExtendedPoll) + 3304+37 ( 2 0 4526.1776783497 2 5467.7582803742 ) 54.3456878637 (ExtendedPoll) + 3304+38 ( 2 0 4521.0733727858 2 5473.6814584884 ) 54.3251632561 (ExtendedPoll) + 3304+39 ( 2 0 4505.7604560942 2 5491.4509928311 ) 54.2645642604 (ExtendedPoll) + 3304+43 ( 2 0 4501.4477273290 2 5497.9746774822 ) 54.2316163720 (ExtendedPoll) + 3304+45 ( 2 0 4495.7156194766 2 5503.2973490595 ) 54.2235944245 (ExtendedPoll) + 3304+46 ( 2 0 4478.5192959191 2 5519.2653637914 ) 54.2004433791 (ExtendedPoll) + 3304+47 ( 2 0 4409.7340016894 2 5583.1374227190 ) 54.1217038236 (ExtendedPoll) + 3304+48 ( 2 0 4134.5928247705 2 5838.6256584295 ) 54.0371198163 (ExtendedPoll) + 3304+50 ( 2 0 4057.7279880439 2 5936.4536324451 ) 53.8423122971 (ExtendedPoll) + 3304+55 ( 2 0 4036.3281187280 2 5959.1636978416 ) 53.8369788559 (ExtendedPoll) + 3304+63 ( 2 0 4033.2436987883 2 5966.3424805330 ) 53.8016467560 (ExtendedPoll) + 3304+73 ( 2 0 4033.3453648009 2 5966.5644451074 ) 53.7987246325 (ExtendedPoll) + 3304+77 ( 2 0 4033.4533282953 2 5966.5074812194 ) 53.7982274597 (ExtendedPoll) + 3304+84 ( 2 0 4033.4322917074 2 5966.5295898786 ) 53.7982263075 (ExtendedPoll) + 3304+85 ( 2 0 4033.3691819436 2 5966.5959158563 ) 53.7982228672 (ExtendedPoll) + 3304+86 ( 2 0 4033.1167428886 2 5966.8612197669 ) 53.7982093544 (ExtendedPoll) + 3304+94 ( 2 0 4033.1071823367 2 5966.8731120948 ) 53.7981924297 (ExtendedPoll) + 3304+95 ( 2 0 4033.0785006809 2 5966.9087890783 ) 53.7981416597 (ExtendedPoll) + 3304+100 ( 2 0 4033.0925954613 2 5966.9029438115 ) 53.7980625663 (ExtendedPoll) + 3304+105 ( 2 0 4033.0991795212 2 5966.8990892331 ) 53.7980356267 (ExtendedPoll) + 3304+115 ( 2 0 4033.0989658428 2 5966.8995155138 ) 53.7980338197 (ExtendedPoll) + 3304+116 ( 2 0 4033.0983248077 2 5966.9007943557 ) 53.7980283990 (ExtendedPoll) + 3304+119 ( 2 0 4033.0980226539 2 5966.9016988988 ) 53.7980231575 (ExtendedPoll) + 3304+127 ( 2 0 4033.0981418065 2 5966.9016952224 ) 53.7980220818 (ExtendedPoll) + 3304+129 ( 2 0 4033.0982490223 2 5966.9016431107 ) 53.7980215482 (ExtendedPoll) + 3304+133 ( 2 0 4033.0983032868 2 5966.9016184516 ) 53.7980212629 (ExtendedPoll) + 3304+134 ( 2 0 4033.0983898253 2 5966.9015364642 ) 53.7980211876 (ExtendedPoll) + 3304+135 ( 2 0 4033.0986494409 2 5966.9012905019 ) 53.7980209620 (ExtendedPoll) + 3304+136 ( 2 0 4033.0996879031 2 5966.9003066526 ) 53.7980200592 (ExtendedPoll) + 3304+144 ( 2 0 4033.0996674107 2 5966.9003282915 ) 53.7980200572 (ExtendedPoll) + 3304+145 ( 2 0 4033.0996059334 2 5966.9003932080 ) 53.7980200513 (ExtendedPoll) + 3304+160 ( 2 0 4033.0996058034 2 5966.9003936551 ) 53.7980200485 (ExtendedPoll) + 3304+167 ( 2 0 4033.0996061081 2 5966.9003937799 ) 53.7980200446 (ExtendedPoll) + 3304+171 ( 2 0 4033.0996062242 2 5966.9003937721 ) 53.7980200436 (ExtendedPoll) + 3483 ( 3 0 3210.2889578675 2 3039.3458759311 1 3750.2389595149 ) 46.5961289316 + 3488+3 ( 2 0 4552.7233011568 2 5335.3470932817 ) 55.5692389089 (ExtendedPoll) + 3488+7 ( 2 0 4440.9199022818 2 5558.9538910317 ) 54.1048755479 (ExtendedPoll) + 3488+29 ( 2 0 4440.9496420561 2 5559.0071913847 ) 54.1040659660 (ExtendedPoll) + 3488+33 ( 2 0 4440.9365610370 2 5559.0347632759 ) 54.1038907469 (ExtendedPoll) + 3488+34 ( 2 0 4440.8905377740 2 5559.0748522452 ) 54.1038670525 (ExtendedPoll) + 3488+35 ( 2 0 4440.7524679852 2 5559.1951191530 ) 54.1037960247 (ExtendedPoll) + 3488+36 ( 2 0 4440.2001888298 2 5559.6761867843 ) 54.1035127440 (ExtendedPoll) + 3488+37 ( 2 0 4437.9910722084 2 5561.6004573097 ) 54.1023929098 (ExtendedPoll) + 3488+38 ( 2 0 4429.1546057226 2 5569.2975394109 ) 54.0981264568 (ExtendedPoll) + 3488+39 ( 2 0 4393.8087397796 2 5600.0858678158 ) 54.0844835555 (ExtendedPoll) + 3488+42 ( 2 0 4394.2113521169 2 5603.9686884921 ) 54.0411680120 (ExtendedPoll) + 3488+43 ( 2 0 4388.9432720429 2 5609.7553878479 ) 54.0274056417 (ExtendedPoll) + 3488+48 ( 2 0 4388.0032745945 2 5611.4664902813 ) 54.0180260116 (ExtendedPoll) + 3488+51 ( 2 0 4386.7886136448 2 5612.9967583598 ) 54.0128824739 (ExtendedPoll) + 3488+57 ( 2 0 4386.4467770046 2 5613.3454189378 ) 54.0122750804 (ExtendedPoll) + 3488+58 ( 2 0 4385.4212670842 2 5614.3914006721 ) 54.0104567213 (ExtendedPoll) + 3488+59 ( 2 0 4381.3192274022 2 5618.5753276090 ) 54.0032406382 (ExtendedPoll) + 3488+62 ( 2 0 4380.5784036418 2 5619.2116598200 ) 54.0031640007 (ExtendedPoll) + 3488+63 ( 2 0 4378.3559323606 2 5621.1206564531 ) 54.0029484717 (ExtendedPoll) + 3488+64 ( 2 0 4369.4660472359 2 5628.7566429851 ) 54.0023023644 (ExtendedPoll) + 3488+72 ( 2 0 4369.5969815447 2 5629.7243626813 ) 53.9913292971 (ExtendedPoll) + 3488+75 ( 2 0 4369.6824940167 2 5630.2051304326 ) 53.9857012024 (ExtendedPoll) + 3488+82 ( 2 0 4369.6472614388 2 5630.3220036975 ) 53.9848193694 (ExtendedPoll) + 3488+85 ( 2 0 4369.6050333250 2 5630.3660727419 ) 53.9847380922 (ExtendedPoll) + 3488+86 ( 2 0 4369.4783489833 2 5630.4982798750 ) 53.9844943213 (ExtendedPoll) + 3488+87 ( 2 0 4368.9716116168 2 5631.0271084078 ) 53.9835201449 (ExtendedPoll) + 3488+91 ( 2 0 4368.8845997443 2 5631.1127275039 ) 53.9834056991 (ExtendedPoll) + 3488+92 ( 2 0 4368.6235641269 2 5631.3695847921 ) 53.9830625988 (ExtendedPoll) + 3488+93 ( 2 0 4367.5794216571 2 5632.3970139452 ) 53.9816937566 (ExtendedPoll) + 3488+94 ( 2 0 4363.4028517782 2 5636.5067305573 ) 53.9762753650 (ExtendedPoll) + 3488+95 ( 2 0 4346.6965722627 2 5652.9455970056 ) 53.9555155106 (ExtendedPoll) + 3488+96 ( 2 0 4279.8714542003 2 5718.7010627990 ) 53.8872266051 (ExtendedPoll) + 3488+97 ( 2 0 4012.5709819511 2 5981.7229259727 ) 53.8578815474 (ExtendedPoll) + 3488+99 ( 2 0 4003.8363414140 2 5994.7157037717 ) 53.8249871296 (ExtendedPoll) + 3488+107 ( 2 0 4003.0106449257 2 5996.4848096773 ) 53.8171655728 (ExtendedPoll) + 3488+110 ( 2 0 4002.3593853505 2 5997.2124120580 ) 53.8168706752 (ExtendedPoll) + 3488+111 ( 2 0 4000.4056066249 2 5999.3952192000 ) 53.8160033453 (ExtendedPoll) + 3488+119 ( 2 0 4000.3383801740 2 5999.4971117887 ) 53.8157389067 (ExtendedPoll) + 3488+120 ( 2 0 4000.1367008212 2 5999.8027895547 ) 53.8149458834 (ExtendedPoll) + 3488+126 ( 2 0 4000.1340485485 2 5999.8637668378 ) 53.8144356991 (ExtendedPoll) + 3488+134 ( 2 0 4000.1293216626 2 5999.8697555108 ) 53.8144274351 (ExtendedPoll) + 3488+142 ( 2 0 4000.1301279381 2 5999.8692461828 ) 53.8144243508 (ExtendedPoll) + 3488+146 ( 2 0 4000.1294111560 2 5999.8703886418 ) 53.8144210416 (ExtendedPoll) + 3488+148 ( 2 0 4000.1312576800 2 5999.8684223480 ) 53.8144209958 (ExtendedPoll) + 3488+149 ( 2 0 4000.1367972520 2 5999.8625234666 ) 53.8144208588 (ExtendedPoll) + 3488+150 ( 2 0 4000.1589555398 2 5999.8389279410 ) 53.8144203127 (ExtendedPoll) + 3488+151 ( 2 0 4000.2475886910 2 5999.7445458387 ) 53.8144181595 (ExtendedPoll) + 3488+152 ( 2 0 4000.6021212960 2 5999.3670174292 ) 53.8144100483 (ExtendedPoll) + 3488+153 ( 2 0 4002.0202517159 2 5997.8569037914 ) 53.8143856278 (ExtendedPoll) + 3488+155 ( 2 0 4002.1422495983 2 5997.8527654463 ) 53.8132795659 (ExtendedPoll) + 3488+164 ( 2 0 4002.1489902101 2 5997.8491916670 ) 53.8132478315 (ExtendedPoll) + 3488+169 ( 2 0 4002.1460036830 2 5997.8536843822 ) 53.8132363424 (ExtendedPoll) + 3488+176 ( 2 0 4002.1464898557 2 5997.8532170669 ) 53.8132358938 (ExtendedPoll) + 3488+177 ( 2 0 4002.1479483737 2 5997.8518151211 ) 53.8132345481 (ExtendedPoll) + 3488+178 ( 2 0 4002.1537824458 2 5997.8462073379 ) 53.8132291653 (ExtendedPoll) + 3488+194 ( 2 0 4002.1537952967 2 5997.8461997948 ) 53.8132291112 (ExtendedPoll) + 3488+205 ( 2 0 4002.1537979211 2 5997.8462000219 ) 53.8132290846 (ExtendedPoll) + 3488+207 ( 2 0 4002.1537995406 2 5997.8461991017 ) 53.8132290775 (ExtendedPoll) + 3488+208 ( 2 0 4002.1538022459 2 5997.8461965406 ) 53.8132290747 (ExtendedPoll) + 3488+209 ( 2 0 4002.1538103616 2 5997.8461888572 ) 53.8132290662 (ExtendedPoll) + 3488+218 ( 2 0 4002.1538099327 2 5997.8461896839 ) 53.8132290629 (ExtendedPoll) + 3488+226 ( 2 0 4002.1538099976 2 5997.8461897805 ) 53.8132290615 (ExtendedPoll) + 3488+229 ( 2 0 4002.1538101107 2 5997.8461898084 ) 53.8132290602 (ExtendedPoll) + 3488+234 ( 2 0 4002.1538101371 2 5997.8461898603 ) 53.8132290595 (ExtendedPoll) + 3729+22 ( 2 0 4999.8953615990 2 4999.9816204393 ) 55.9027305088 (ExtendedPoll) + 3729+23 ( 2 0 4999.7707564260 2 5000.1157917870 ) 55.9020567360 (ExtendedPoll) + 3729+24 ( 2 0 4999.2723357338 2 5000.6524771780 ) 55.8993623523 (ExtendedPoll) + 3729+27 ( 2 0 4999.1349773271 2 5000.8543164668 ) 55.8979629118 (ExtendedPoll) + 3729+34 ( 2 0 4999.0739417340 2 5000.9153520600 ) 55.8976901754 (ExtendedPoll) + 3729+35 ( 2 0 4998.8908349545 2 5001.0984588395 ) 55.8968720583 (ExtendedPoll) + 3729+36 ( 2 0 4998.1584078364 2 5001.8308859575 ) 55.8936009704 (ExtendedPoll) + 3729+37 ( 2 0 4995.2286993643 2 5004.7605944297 ) 55.8805387184 (ExtendedPoll) + 3729+38 ( 2 0 4983.5098654757 2 5016.4794283182 ) 55.8286442151 (ExtendedPoll) + 3729+39 ( 2 0 4936.6345299214 2 5063.3547638726 ) 55.6267962813 (ExtendedPoll) + 3729+40 ( 2 0 4749.1331877041 2 5250.8561060898 ) 54.9147822323 (ExtendedPoll) + 3729+41 ( 2 0 3999.1278188349 2 6000.8614749590 ) 53.8151109452 (ExtendedPoll) + 3729+58 ( 2 0 3999.1207593662 2 6000.8750024663 ) 53.8150584528 (ExtendedPoll) + 3729+65 ( 2 0 3999.1195214058 2 6000.8764534763 ) 53.8150573268 (ExtendedPoll) + 3729+66 ( 2 0 3999.1158075247 2 6000.8808065061 ) 53.8150539489 (ExtendedPoll) + 3729+67 ( 2 0 3999.1009520003 2 6000.8982186254 ) 53.8150404383 (ExtendedPoll) + 3729+77 ( 2 0 3999.1012090993 2 6000.8986202144 ) 53.8150345073 (ExtendedPoll) + 3729+84 ( 2 0 3999.1012443818 2 6000.8986682546 ) 53.8150337554 (ExtendedPoll) + 3729+85 ( 2 0 3999.1011692098 2 6000.8987607750 ) 53.8150336483 (ExtendedPoll) + 3729+86 ( 2 0 3999.1009436941 2 6000.8990383364 ) 53.8150333272 (ExtendedPoll) + 3729+96 ( 2 0 3999.1009378077 2 6000.8990520256 ) 53.8150332623 (ExtendedPoll) + 3729+100 ( 2 0 3999.1009370763 2 6000.8990594402 ) 53.8150332041 (ExtendedPoll) + 3729+103 ( 2 0 3999.1009434424 2 6000.8990555693 ) 53.8150331784 (ExtendedPoll) + 3729+109 ( 2 0 3999.1009426080 2 6000.8990572346 ) 53.8150331716 (ExtendedPoll) + 3729+113 ( 2 0 3999.1009445289 2 6000.8990554321 ) 53.8150331694 (ExtendedPoll) + 3857+21 ( 2 0 4999.7695768976 2 5000.1146922267 ) 55.9020792324 (ExtendedPoll) + 3857+22 ( 2 0 4999.2676176204 2 5000.6480789368 ) 55.8994523349 (ExtendedPoll) + 3857+26 ( 2 0 4999.0614867145 2 5000.9250615107 ) 55.8976679710 (ExtendedPoll) + 3857+37 ( 2 0 4999.0655499855 2 5000.9315188764 ) 55.8975579561 (ExtendedPoll) + 3857+39 ( 2 0 4999.0601491243 2 5000.9369076070 ) 55.8975339712 (ExtendedPoll) + 3857+40 ( 2 0 4999.0439465409 2 5000.9530737988 ) 55.8974620175 (ExtendedPoll) + 3857+41 ( 2 0 4998.9791362072 2 5001.0177385657 ) 55.8971742134 (ExtendedPoll) + 3857+42 ( 2 0 4998.7198948722 2 5001.2763976335 ) 55.8960231692 (ExtendedPoll) + 3857+43 ( 2 0 4997.6829295325 2 5002.3110339045 ) 55.8914217511 (ExtendedPoll) + 3857+44 ( 2 0 4993.5350681737 2 5006.4495789887 ) 55.8730602592 (ExtendedPoll) + 3857+45 ( 2 0 4976.9436227384 2 5023.0037593255 ) 55.8003237383 (ExtendedPoll) + 3857+46 ( 2 0 4910.5778409973 2 5089.2204806727 ) 55.5208926377 (ExtendedPoll) + 3857+47 ( 2 0 4645.1147140329 2 5354.0873660614 ) 54.5978092091 (ExtendedPoll) + 3857+49 ( 2 0 4641.9961744036 2 5356.4416246436 ) 54.5973154410 (ExtendedPoll) + 3857+50 ( 2 0 4632.6405555159 2 5363.5044003904 ) 54.5960322314 (ExtendedPoll) + 3857+51 ( 2 0 4595.2180799647 2 5391.7555033777 ) 54.5938886963 (ExtendedPoll) + 3857+54 ( 2 0 4589.5405636156 2 5406.2768432706 ) 54.4819217775 (ExtendedPoll) + 3857+59 ( 2 0 4586.8655799511 2 5409.1224253831 ) 54.4730509300 (ExtendedPoll) + 3857+60 ( 2 0 4578.8406289576 2 5417.6591717205 ) 54.4466693127 (ExtendedPoll) + 3857+61 ( 2 0 4546.7408249837 2 5451.8061570703 ) 54.3446263871 (ExtendedPoll) + 3857+67 ( 2 0 4544.4002142773 2 5454.9315206375 ) 54.3305581908 (ExtendedPoll) + 3857+70 ( 2 0 4543.3834475273 2 5456.5982674743 ) 54.3211315639 (ExtendedPoll) + 3857+84 ( 2 0 4543.3817833230 2 5456.6057131428 ) 54.3210653441 (ExtendedPoll) + 3857+87 ( 2 0 4543.3799196151 2 5456.6131114083 ) 54.3210013080 (ExtendedPoll) + 3857+88 ( 2 0 4543.3724892530 2 5456.6264388915 ) 54.3209201075 (ExtendedPoll) + 3857+99 ( 2 0 4543.3733273061 2 5456.6259837410 ) 54.3209179808 (ExtendedPoll) + 3857+101 ( 2 0 4543.3714783336 2 5456.6279477327 ) 54.3209123378 (ExtendedPoll) + 3857+102 ( 2 0 4543.3659314160 2 5456.6338397077 ) 54.3208954091 (ExtendedPoll) + 3857+112 ( 2 0 4543.3658531448 2 5456.6339296214 ) 54.3208950973 (ExtendedPoll) + 3857+113 ( 2 0 4543.3656183312 2 5456.6341993626 ) 54.3208941618 (ExtendedPoll) + 3857+114 ( 2 0 4543.3646790771 2 5456.6352783273 ) 54.3208904201 (ExtendedPoll) + 3857+118 ( 2 0 4543.3645278465 2 5456.6354626442 ) 54.3208897035 (ExtendedPoll) + 3857+127 ( 2 0 4543.3645352524 2 5456.6354634587 ) 54.3208896327 (ExtendedPoll) + 3857+131 ( 2 0 4543.3645324236 2 5456.6354658827 ) 54.3208896303 (ExtendedPoll) + 3857+132 ( 2 0 4543.3645239373 2 5456.6354731547 ) 54.3208896231 (ExtendedPoll) + 3857+133 ( 2 0 4543.3644899919 2 5456.6355022427 ) 54.3208895946 (ExtendedPoll) + 3857+134 ( 2 0 4543.3643542104 2 5456.6356185947 ) 54.3208894804 (ExtendedPoll) + 3857+135 ( 2 0 4543.3638110842 2 5456.6360840029 ) 54.3208890235 (ExtendedPoll) + 3857+136 ( 2 0 4543.3616385797 2 5456.6379456356 ) 54.3208871959 (ExtendedPoll) + 3857+137 ( 2 0 4543.3529485614 2 5456.6453921663 ) 54.3208798860 (ExtendedPoll) + 3857+138 ( 2 0 4543.3181884885 2 5456.6751782893 ) 54.3208506492 (ExtendedPoll) + 3857+139 ( 2 0 4543.1791481970 2 5456.7943227813 ) 54.3207337517 (ExtendedPoll) + 3857+140 ( 2 0 4542.6229870307 2 5457.2709007492 ) 54.3202669568 (ExtendedPoll) + 3857+141 ( 2 0 4540.3983423657 2 5459.1772126208 ) 54.3184125004 (ExtendedPoll) + 3857+142 ( 2 0 4531.4997637056 2 5466.8024601073 ) 54.3111985229 (ExtendedPoll) + 3857+143 ( 2 0 4495.9054490650 2 5497.3034500534 ) 54.2856217202 (ExtendedPoll) + 3857+144 ( 2 0 4353.5281905028 2 5619.3074098378 ) 54.2368825197 (ExtendedPoll) + 3857+146 ( 2 0 4353.5041867680 2 5619.3635257316 ) 54.2365196285 (ExtendedPoll) + 3857+147 ( 2 0 4353.4321755638 2 5619.5318734129 ) 54.2354310246 (ExtendedPoll) + 3857+148 ( 2 0 4353.1441307467 2 5620.2052641384 ) 54.2310776574 (ExtendedPoll) + 3857+149 ( 2 0 4351.9919514786 2 5622.8988270401 ) 54.2136809672 (ExtendedPoll) + 3857+150 ( 2 0 4347.3832344061 2 5633.6730786469 ) 54.1443630877 (ExtendedPoll) + 3857+151 ( 2 0 4346.4159412060 2 5635.3688272200 ) 54.1355996268 (ExtendedPoll) + 3857+152 ( 2 0 4343.5140616057 2 5640.4560729390 ) 54.1093792188 (ExtendedPoll) + 3857+153 ( 2 0 4331.9065432045 2 5660.8050558153 ) 54.0055500944 (ExtendedPoll) + 3857+156 ( 2 0 4329.8320660769 2 5668.3386832786 ) 53.9480883416 (ExtendedPoll) + 3857+162 ( 2 0 4334.3358651038 2 5665.1314324564 ) 53.9408691910 (ExtendedPoll) + 3857+170 ( 2 0 4334.7698249059 2 5664.9075219934 ) 53.9393230537 (ExtendedPoll) + 3857+174 ( 2 0 4335.0132475664 2 5664.9262078546 ) 53.9370077879 (ExtendedPoll) + 3857+178 ( 2 0 4335.0593141454 2 5664.8861671994 ) 53.9370070214 (ExtendedPoll) + 3857+179 ( 2 0 4335.1975138822 2 5664.7660452336 ) 53.9370047791 (ExtendedPoll) + 3857+185 ( 2 0 4335.2265889224 2 5664.7567731080 ) 53.9368437214 (ExtendedPoll) + 3857+191 ( 2 0 4335.2341353579 2 5664.7556510827 ) 53.9367890253 (ExtendedPoll) + 3857+193 ( 2 0 4335.2400852963 2 5664.7508755444 ) 53.9367849554 (ExtendedPoll) + 3857+194 ( 2 0 4335.2579351117 2 5664.7365489296 ) 53.9367727467 (ExtendedPoll) + 3857+197 ( 2 0 4335.2420401136 2 5664.7511438225 ) 53.9367651768 (ExtendedPoll) + 3857+198 ( 2 0 4335.1943551193 2 5664.7949285015 ) 53.9367424744 (ExtendedPoll) + 3857+199 ( 2 0 4335.0036151422 2 5664.9700672173 ) 53.9366517744 (ExtendedPoll) + 3857+200 ( 2 0 4334.2406552335 2 5665.6706220803 ) 53.9362907282 (ExtendedPoll) + 3857+201 ( 2 0 4331.1888155990 2 5668.4728415326 ) 53.9348746183 (ExtendedPoll) + 3857+202 ( 2 0 4318.9814570610 2 5679.6817193417 ) 53.9296600779 (ExtendedPoll) + 3857+203 ( 2 0 4270.1520229090 2 5724.5172305782 ) 53.9160449943 (ExtendedPoll) + 3857+206 ( 2 0 4270.2287922106 2 5726.4688768232 ) 53.8962132135 (ExtendedPoll) + 3857+209 ( 2 0 4269.9967783213 2 5728.4085811769 ) 53.8792448146 (ExtendedPoll) + 3857+210 ( 2 0 4267.4719212911 2 5731.3906420478 ) 53.8723914551 (ExtendedPoll) + 3857+213 ( 2 0 4266.5745734546 2 5733.1256282638 ) 53.8633577202 (ExtendedPoll) + 3857+222 ( 2 0 4266.4308176062 2 5733.3229626873 ) 53.8627005560 (ExtendedPoll) + 3857+223 ( 2 0 4265.9995500609 2 5733.9149659579 ) 53.8607301402 (ExtendedPoll) + 3857+227 ( 2 0 4265.8268724443 2 5734.0875636064 ) 53.8605721022 (ExtendedPoll) + 3857+228 ( 2 0 4265.3088395946 2 5734.6053565521 ) 53.8600989724 (ExtendedPoll) + 3857+229 ( 2 0 4263.2367081957 2 5736.6765283347 ) 53.8582212182 (ExtendedPoll) + 3857+230 ( 2 0 4254.9481826001 2 5744.9612154653 ) 53.8509466860 (ExtendedPoll) + 3857+231 ( 2 0 4221.7940802176 2 5778.0999639874 ) 53.8256476388 (ExtendedPoll) + 3857+232 ( 2 0 4089.1776706878 2 5910.6549580759 ) 53.7861774796 (ExtendedPoll) + 3857+247 ( 2 0 4089.1136696138 2 5910.7589031772 ) 53.7858180957 (ExtendedPoll) + 3857+248 ( 2 0 4088.9216663918 2 5911.0707384809 ) 53.7847402348 (ExtendedPoll) + 3857+252 ( 2 0 4088.8359939837 2 5911.1576970414 ) 53.7847351920 (ExtendedPoll) + 3857+253 ( 2 0 4088.5789767594 2 5911.4185727227 ) 53.7847203220 (ExtendedPoll) + 3857+266 ( 2 0 4088.5833028094 2 5911.4153495129 ) 53.7847099233 (ExtendedPoll) + 3857+273 ( 2 0 4088.5841710836 2 5911.4149550584 ) 53.7847055346 (ExtendedPoll) + 3857+276 ( 2 0 4088.5850132823 2 5911.4145076255 ) 53.7847018687 (ExtendedPoll) + 3857+280 ( 2 0 4088.5854359861 2 5911.4142869556 ) 53.7846999932 (ExtendedPoll) + 3857+283 ( 2 0 4088.5850617172 2 5911.4148479102 ) 53.7846983212 (ExtendedPoll) + 3857+291 ( 2 0 4088.5850276880 2 5911.4148968462 ) 53.7846981880 (ExtendedPoll) + 3857+292 ( 2 0 4088.5849256003 2 5911.4150436540 ) 53.7846977884 (ExtendedPoll) + 3857+297 ( 2 0 4088.5849005844 2 5911.4150977550 ) 53.7846975253 (ExtendedPoll) + 3857+308 ( 2 0 4088.5849003997 2 5911.4150986678 ) 53.7846975187 (ExtendedPoll) + 3857+309 ( 2 0 4088.5848992968 2 5911.4151001689 ) 53.7846975151 (ExtendedPoll) + 3857+313 ( 2 0 4088.5848988407 2 5911.4151009808 ) 53.7846975119 (ExtendedPoll) + 3857+316 ( 2 0 4088.5848979979 2 5911.4151019930 ) 53.7846975104 (ExtendedPoll) + 4187+1 ( 2 0 4105.5097056568 2 5894.3640876566 ) 53.7853303801 (ExtendedPoll) + 4187+33 ( 2 0 4105.5249912111 2 5894.4490403525 ) 53.7844103322 (ExtendedPoll) + 4187+38 ( 2 0 4105.5402085635 2 5894.4501641740 ) 53.7842605703 (ExtendedPoll) + 4187+42 ( 2 0 4105.5590123984 2 5894.4395775740 ) 53.7841854603 (ExtendedPoll) + 4187+50 ( 2 0 4105.5607070024 2 5894.4387021916 ) 53.7841779690 (ExtendedPoll) + 4187+51 ( 2 0 4105.5636102425 2 5894.4362276993 ) 53.7841740843 (ExtendedPoll) + 4187+61 ( 2 0 4105.5638149153 2 5894.4361054192 ) 53.7841733315 (ExtendedPoll) + 4187+65 ( 2 0 4105.5638612668 2 5894.4360679458 ) 53.7841732508 (ExtendedPoll) + 4187+66 ( 2 0 4105.5640003213 2 5894.4359555257 ) 53.7841730088 (ExtendedPoll) + 4187+72 ( 2 0 4105.5640265310 2 5894.4359413401 ) 53.7841728988 (ExtendedPoll) + 4187+79 ( 2 0 4105.5640472452 2 5894.4359452146 ) 53.7841726734 (ExtendedPoll) + 4187+85 ( 2 0 4105.5640494603 2 5894.4359482098 ) 53.7841726256 (ExtendedPoll) + 4187+91 ( 2 0 4105.5640494863 2 5894.4359491407 ) 53.7841726169 (ExtendedPoll) + 4187+92 ( 2 0 4105.5640486402 2 5894.4359508001 ) 53.7841726094 (ExtendedPoll) + 4187+98 ( 2 0 4105.5640493116 2 5894.4359501547 ) 53.7841726092 (ExtendedPoll) + 4187+99 ( 2 0 4105.5640513257 2 5894.4359482183 ) 53.7841726085 (ExtendedPoll) + 4187+100 ( 2 0 4105.5640593820 2 5894.4359404726 ) 53.7841726058 (ExtendedPoll) + 4187+112 ( 2 0 4105.5640593940 2 5894.4359405296 ) 53.7841726051 (ExtendedPoll) + 4187+113 ( 2 0 4105.5640595037 2 5894.4359404905 ) 53.7841726045 (ExtendedPoll) + 4310+8 ( 2 0 4986.7257528443 2 5008.3439881737 ) 55.9026187973 (ExtendedPoll) + 4310+12 ( 2 0 4975.6982691662 2 5019.3714718518 ) 55.8540052955 (ExtendedPoll) + 4310+13 ( 2 0 4942.6158181319 2 5052.4539228861 ) 55.7112095080 (ExtendedPoll) + 4310+14 ( 2 0 4810.2860139947 2 5184.7837270233 ) 55.1870194047 (ExtendedPoll) + 4310+15 ( 2 0 4280.9667974460 2 5714.1029435721 ) 53.9228267897 (ExtendedPoll) + 4310+31 ( 2 0 4282.9099137686 2 5713.8982254345 ) 53.9076802800 (ExtendedPoll) + 4310+34 ( 2 0 4283.1982251457 2 5715.8293998657 ) 53.8861047342 (ExtendedPoll) + 4310+37 ( 2 0 4285.4740084419 2 5714.2633061132 ) 53.8814393469 (ExtendedPoll) + 4310+44 ( 2 0 4285.1205497824 2 5714.8564555920 ) 53.8787142179 (ExtendedPoll) + 4310+55 ( 2 0 4285.1005852658 2 5714.8795367790 ) 53.8786630424 (ExtendedPoll) + 4310+56 ( 2 0 4285.0406917160 2 5714.9487803400 ) 53.8785095322 (ExtendedPoll) + 4310+58 ( 2 0 4285.0005710927 2 5714.9947752809 ) 53.8784105470 (ExtendedPoll) + 4310+70 ( 2 0 4285.0007834768 2 5714.9966707681 ) 53.8783899929 (ExtendedPoll) + 4310+71 ( 2 0 4284.9983617564 2 5714.9996181702 ) 53.8783823323 (ExtendedPoll) + 4310+72 ( 2 0 4284.9910965952 2 5715.0084603766 ) 53.8783593509 (ExtendedPoll) + 4310+76 ( 2 0 4284.9884190656 2 5715.0111774997 ) 53.8783562185 (ExtendedPoll) + 4310+77 ( 2 0 4284.9803864769 2 5715.0193288691 ) 53.8783468217 (ExtendedPoll) + 4310+93 ( 2 0 4284.9804412318 2 5715.0194883169 ) 53.8783447670 (ExtendedPoll) + 4310+98 ( 2 0 4284.9804170022 2 5715.0195427745 ) 53.8783444443 (ExtendedPoll) + 4310+105 ( 2 0 4284.9804316104 2 5715.0195457146 ) 53.8783442863 (ExtendedPoll) + 4310+107 ( 2 0 4284.9804399767 2 5715.0195580455 ) 53.8783440910 (ExtendedPoll) + 4310+114 ( 2 0 4284.9804363154 2 5715.0195618337 ) 53.8783440860 (ExtendedPoll) + 4310+115 ( 2 0 4284.9804253315 2 5715.0195731983 ) 53.8783440710 (ExtendedPoll) + 4310+123 ( 2 0 4284.9804248959 2 5715.0195740214 ) 53.8783440667 (ExtendedPoll) + 4310+124 ( 2 0 4284.9804240703 2 5715.0195756911 ) 53.8783440575 (ExtendedPoll) + 4310+134 ( 2 0 4284.9804241092 2 5715.0195758008 ) 53.8783440561 (ExtendedPoll) + 4310+139 ( 2 0 4284.9804241503 2 5715.0195758421 ) 53.8783440553 (ExtendedPoll) + 4454 ( 3 0 3210.2718306224 2 3039.4036796793 1 3750.2294356176 ) 46.5957725777 + 4455 ( 3 0 3210.2204488871 2 3039.5770909239 1 3750.2008639259 ) 46.5947035783 + 4459+17 ( 2 0 4999.8234054990 2 5000.1686007961 ) 55.9010071498 (ExtendedPoll) + 4459+18 ( 2 0 4999.2960163907 2 5000.6767975791 ) 55.8988833670 (ExtendedPoll) + 4459+19 ( 2 0 4997.1864599572 2 5002.7095847109 ) 55.8903991267 (ExtendedPoll) + 4459+20 ( 2 0 4988.7482342235 2 5010.8407332383 ) 55.8566367335 (ExtendedPoll) + 4459+21 ( 2 0 4954.9953312886 2 5043.3653273476 ) 55.7244004145 (ExtendedPoll) + 4459+22 ( 2 0 4819.9837195490 2 5173.4637037851 ) 55.2417552587 (ExtendedPoll) + 4459+23 ( 2 0 4279.9372725906 2 5693.8572095350 ) 54.1320597545 (ExtendedPoll) + 4459+25 ( 2 0 4260.7210634090 2 5718.3142030389 ) 54.0605176484 (ExtendedPoll) + 4459+26 ( 2 0 4203.0724358640 2 5791.6851835507 ) 53.8630778677 (ExtendedPoll) + 4459+35 ( 2 0 4211.2611613676 2 5784.2607390941 ) 53.8607636217 (ExtendedPoll) + 4459+36 ( 2 0 4235.8273378782 2 5761.9874057245 ) 53.8557950144 (ExtendedPoll) + 4459+41 ( 2 0 4239.2666025897 2 5760.1381185483 ) 53.8430394257 (ExtendedPoll) + 4459+48 ( 2 0 4238.4020949545 2 5761.2154477473 ) 53.8403110732 (ExtendedPoll) + 4459+49 ( 2 0 4236.9895398051 2 5762.5631754865 ) 53.8398579750 (ExtendedPoll) + 4459+50 ( 2 0 4232.7518743570 2 5766.6063587038 ) 53.8385611120 (ExtendedPoll) + 4459+51 ( 2 0 4215.8012125647 2 5782.7790915733 ) 53.8343120215 (ExtendedPoll) + 4459+52 ( 2 0 4147.9985653954 2 5847.4700230513 ) 53.8324459450 (ExtendedPoll) + 4459+58 ( 2 0 4142.8942598315 2 5853.3659054138 ) 53.8237142063 (ExtendedPoll) + 4459+59 ( 2 0 4127.5813431399 2 5871.0535525015 ) 53.7986042338 (ExtendedPoll) + 4459+68 ( 2 0 4129.7411194915 2 5869.3305081768 ) 53.7948876409 (ExtendedPoll) + 4459+73 ( 2 0 4130.5591390496 2 5868.7973880268 ) 53.7923765042 (ExtendedPoll) + 4459+78 ( 2 0 4131.0192217390 2 5868.6337201408 ) 53.7897014772 (ExtendedPoll) + 4459+79 ( 2 0 4131.7293377788 2 5867.9632682402 ) 53.7894517155 (ExtendedPoll) + 4459+80 ( 2 0 4133.8596858981 2 5865.9519125383 ) 53.7887184190 (ExtendedPoll) + 4459+85 ( 2 0 4134.5843028059 2 5865.2972409942 ) 53.7882006022 (ExtendedPoll) + 4459+88 ( 2 0 4134.9640976007 2 5864.9903770359 ) 53.7875931645 (ExtendedPoll) + 4459+96 ( 2 0 4134.9859247059 2 5864.9690484814 ) 53.7875925935 (ExtendedPoll) + 4459+97 ( 2 0 4135.0514060213 2 5864.9050628179 ) 53.7875908962 (ExtendedPoll) + 4459+98 ( 2 0 4135.3133312830 2 5864.6491201639 ) 53.7875843437 (ExtendedPoll) + 4459+99 ( 2 0 4136.3610323297 2 5863.6253495479 ) 53.7875619231 (ExtendedPoll) + 4459+112 ( 2 0 4136.3648032632 2 5863.6247733590 ) 53.7875329472 (ExtendedPoll) + 4459+113 ( 2 0 4136.3761160637 2 5863.6230447924 ) 53.7874460195 (ExtendedPoll) + 4459+119 ( 2 0 4136.3737259452 2 5863.6260178809 ) 53.7874401351 (ExtendedPoll) + 4459+133 ( 2 0 4136.3738000302 2 5863.6261693177 ) 53.7874380524 (ExtendedPoll) + 4459+138 ( 2 0 4136.3737497999 2 5863.6262370108 ) 53.7874378803 (ExtendedPoll) + 4459+140 ( 2 0 4136.3737091508 2 5863.6262806039 ) 53.7874378451 (ExtendedPoll) + 4459+141 ( 2 0 4136.3735872034 2 5863.6264113833 ) 53.7874377393 (ExtendedPoll) + 4459+150 ( 2 0 4136.3735928884 2 5863.6264065675 ) 53.7874377323 (ExtendedPoll) + 4459+157 ( 2 0 4136.3735936795 2 5863.6264060760 ) 53.7874377297 (ExtendedPoll) + 4459+158 ( 2 0 4136.3735950382 2 5863.6264048019 ) 53.7874377291 (ExtendedPoll) + 4459+167 ( 2 0 4136.3735951385 2 5863.6264047429 ) 53.7874377288 (ExtendedPoll) + 4459+171 ( 2 0 4136.3735950627 2 5863.6264048312 ) 53.7874377287 (ExtendedPoll) + 4459+172 ( 2 0 4136.3735948352 2 5863.6264050962 ) 53.7874377283 (ExtendedPoll) + 4459+181 ( 2 0 4136.3735948402 2 5863.6264051370 ) 53.7874377278 (ExtendedPoll) + 4646+2 ( 2 0 4105.5720108686 2 5894.4263928684 ) 53.7841874022 (ExtendedPoll) + 4646+29 ( 2 0 4105.5833069765 2 5894.4161347829 ) 53.7841780742 (ExtendedPoll) + 4646+42 ( 2 0 4105.5835293721 2 5894.4160488549 ) 53.7841768253 (ExtendedPoll) + 4646+43 ( 2 0 4105.5841965588 2 5894.4157910708 ) 53.7841730784 (ExtendedPoll) + 4646+48 ( 2 0 4105.5842867579 2 5894.4157131287 ) 53.7841729675 (ExtendedPoll) + 4646+67 ( 2 0 4105.5842868659 2 5894.4157130854 ) 53.7841729669 (ExtendedPoll) + 4646+74 ( 2 0 4105.5842868950 2 5894.4157130859 ) 53.7841729666 (ExtendedPoll) + 4725+19 ( 2 0 4999.8031735893 2 5000.1447170134 ) 55.9014542318 (ExtendedPoll) + 4725+20 ( 2 0 4999.2150887519 2 5000.5812624482 ) 55.9006716187 (ExtendedPoll) + 4725+21 ( 2 0 4996.8627494022 2 5002.3274441874 ) 55.8975509135 (ExtendedPoll) + 4725+22 ( 2 0 4987.4533920033 2 5009.3121711443 ) 55.8852243268 (ExtendedPoll) + 4725+23 ( 2 0 4949.8159624076 2 5037.2510789717 ) 55.8384358459 (ExtendedPoll) + 4725+24 ( 2 0 4799.2662440251 2 5149.0067102812 ) 55.6927299999 (ExtendedPoll) + 4725+27 ( 2 0 4798.1744139579 2 5164.6198802413 ) 55.5187163710 (ExtendedPoll) + 4725+28 ( 2 0 4798.1744139579 2 5196.0645861749 ) 55.1525452486 (ExtendedPoll) + 4725+33 ( 2 0 4792.1420528370 2 5201.0324129804 ) 55.1431419649 (ExtendedPoll) + 4725+34 ( 2 0 4774.0449694742 2 5215.9358933968 ) 55.1157026271 (ExtendedPoll) + 4725+35 ( 2 0 4701.6566360229 2 5275.5498150626 ) 55.0176540485 (ExtendedPoll) + 4725+36 ( 2 0 4412.1033022177 2 5514.0055017256 ) 54.8221696457 (ExtendedPoll) + 4725+40 ( 2 0 4371.9239557470 2 5561.1725606260 ) 54.6749065998 (ExtendedPoll) + 4725+41 ( 2 0 4251.3859163349 2 5702.6737373272 ) 54.2973393293 (ExtendedPoll) + 4725+44 ( 2 0 4391.1401649287 2 5590.8703384522 ) 54.2022453171 (ExtendedPoll) + 4725+50 ( 2 0 4362.3158511562 2 5624.4987045201 ) 54.1076851285 (ExtendedPoll) + 4725+55 ( 2 0 4358.6036289279 2 5639.6751424533 ) 53.9858955384 (ExtendedPoll) + 4725+60 ( 2 0 4355.6625116846 2 5642.2409431111 ) 53.9855132092 (ExtendedPoll) + 4725+61 ( 2 0 4346.8391599545 2 5649.9383450844 ) 53.9845992440 (ExtendedPoll) + 4725+62 ( 2 0 4311.5457530343 2 5680.7279529777 ) 53.9844549147 (ExtendedPoll) + 4725+67 ( 2 0 4308.5432203496 2 5687.9340314208 ) 53.9390274262 (ExtendedPoll) + 4725+71 ( 2 0 4307.7243477993 2 5691.7554366558 ) 53.9082186256 (ExtendedPoll) + 4725+83 ( 2 0 4308.0052488063 2 5691.9562363603 ) 53.9037540967 (ExtendedPoll) + 4725+87 ( 2 0 4308.1049356103 2 5691.8857845325 ) 53.9035781830 (ExtendedPoll) + 4725+93 ( 2 0 4308.1185770304 2 5691.8789477872 ) 53.9035262437 (ExtendedPoll) + 4725+96 ( 2 0 4308.1246647783 2 5691.8743491833 ) 53.9035184462 (ExtendedPoll) + 4725+100 ( 2 0 4308.1208413138 2 5691.8781550898 ) 53.9035142224 (ExtendedPoll) + 4725+101 ( 2 0 4308.1093709201 2 5691.8895728093 ) 53.9035015515 (ExtendedPoll) + 4725+102 ( 2 0 4308.0634893453 2 5691.9352436871 ) 53.9034508749 (ExtendedPoll) + 4725+103 ( 2 0 4307.8799630460 2 5692.1179271984 ) 53.9032482824 (ExtendedPoll) + 4725+104 ( 2 0 4307.1458578490 2 5692.8486612434 ) 53.9024397326 (ExtendedPoll) + 4725+105 ( 2 0 4304.2094370610 2 5695.7715974237 ) 53.8992346674 (ExtendedPoll) + 4725+106 ( 2 0 4292.4637539088 2 5707.4633421446 ) 53.8868812553 (ExtendedPoll) + 4725+107 ( 2 0 4245.4810213003 2 5754.2303210285 ) 53.8449818536 (ExtendedPoll) + 4725+108 ( 2 0 4057.5500908662 2 5941.2982365638 ) 53.8003145611 (ExtendedPoll) + 4725+112 ( 2 0 4057.3125325273 2 5942.2454844463 ) 53.7939890318 (ExtendedPoll) + 4725+119 ( 2 0 4057.4393884670 2 5942.4540943610 ) 53.7909379794 (ExtendedPoll) + 4725+120 ( 2 0 4057.1333775009 2 5942.8346355240 ) 53.7903471560 (ExtendedPoll) + 4725+123 ( 2 0 4057.6371760427 2 5942.3623976952 ) 53.7899322822 (ExtendedPoll) + 4725+143 ( 2 0 4057.6378562203 2 5942.3617292243 ) 53.7899320010 (ExtendedPoll) + 4725+144 ( 2 0 4057.6398967532 2 5942.3597238116 ) 53.7899311575 (ExtendedPoll) + 4725+145 ( 2 0 4057.6480588849 2 5942.3517021609 ) 53.7899277838 (ExtendedPoll) + 4725+154 ( 2 0 4057.6479540349 2 5942.3519162868 ) 53.7899268277 (ExtendedPoll) + 4725+158 ( 2 0 4057.6478865326 2 5942.3520145431 ) 53.7899265685 (ExtendedPoll) + 4725+159 ( 2 0 4057.6476840256 2 5942.3523093118 ) 53.7899257907 (ExtendedPoll) + 4725+171 ( 2 0 4057.6476847788 2 5942.3523129602 ) 53.7899257509 (ExtendedPoll) + 4725+175 ( 2 0 4057.6476860982 2 5942.3523116454 ) 53.7899257506 (ExtendedPoll) + 4725+176 ( 2 0 4057.6476900565 2 5942.3523077012 ) 53.7899257494 (ExtendedPoll) + 4725+177 ( 2 0 4057.6477058896 2 5942.3522919242 ) 53.7899257448 (ExtendedPoll) + 4725+178 ( 2 0 4057.6477692222 2 5942.3522288165 ) 53.7899257264 (ExtendedPoll) + 4725+179 ( 2 0 4057.6480225525 2 5942.3519763854 ) 53.7899256529 (ExtendedPoll) + 4725+190 ( 2 0 4057.6480214853 2 5942.3519779120 ) 53.7899256490 (ExtendedPoll) + 4725+197 ( 2 0 4057.6480212763 2 5942.3519783281 ) 53.7899256472 (ExtendedPoll) + 4725+200 ( 2 0 4057.6480210350 2 5942.3519787264 ) 53.7899256458 (ExtendedPoll) + 4725+203 ( 2 0 4057.6480213991 2 5942.3519784360 ) 53.7899256451 (ExtendedPoll) + 4725+207 ( 2 0 4057.6480219221 2 5942.3519780358 ) 53.7899256438 (ExtendedPoll) + 4725+211 ( 2 0 4057.6480221025 2 5942.3519778887 ) 53.7899256435 (ExtendedPoll) + 4725+216 ( 2 0 4057.6480219897 2 5942.3519780086 ) 53.7899256435 (ExtendedPoll) + 4725+221 ( 2 0 4057.6480219698 2 5942.3519780298 ) 53.7899256435 (ExtendedPoll) + 4950 ( 3 0 3210.2137213322 2 3039.6012428177 1 3750.1834642275 ) 46.5946997610 + 4951 ( 3 0 3210.1935386677 2 3039.6736984988 1 3750.1312651323 ) 46.5946883143 + 4952 ( 3 0 3210.1128080096 2 3039.9635212235 1 3749.9224687515 ) 46.5946426050 + 4953 ( 3 0 3209.7898853771 2 3041.1228121224 1 3749.0872832281 ) 46.5944610083 + 4957+21 ( 2 0 4999.9515314082 2 5000.0370988583 ) 55.9016212277 (ExtendedPoll) + 4957+22 ( 2 0 4999.8061545413 2 5000.1484243416 ) 55.9013860644 (ExtendedPoll) + 4957+23 ( 2 0 4999.2246470737 2 5000.5937262748 ) 55.9004460290 (ExtendedPoll) + 4957+24 ( 2 0 4996.8986172034 2 5002.3749340079 ) 55.8966957757 (ExtendedPoll) + 4957+25 ( 2 0 4987.5944977221 2 5009.4997649402 ) 55.8818532664 (ExtendedPoll) + 4957+26 ( 2 0 4950.3780197968 2 5037.9990886692 ) 55.8250376177 (ExtendedPoll) + 4957+27 ( 2 0 4801.5121080959 2 5151.9963835853 ) 55.6398202521 (ExtendedPoll) + 4957+29 ( 2 0 4799.9016587469 2 5159.6391940553 ) 55.5631771412 (ExtendedPoll) + 4957+30 ( 2 0 4795.0703106998 2 5182.5676254652 ) 55.3341978198 (ExtendedPoll) + 4957+31 ( 2 0 4780.2214217867 2 5210.0817431571 ) 55.1338115001 (ExtendedPoll) + 4957+36 ( 2 0 4799.2192649549 2 5198.7267104589 ) 55.1133076930 (ExtendedPoll) + 4957+47 ( 2 0 4800.1328196439 2 5199.0717458199 ) 55.1020064789 (ExtendedPoll) + 4957+51 ( 2 0 4800.6067634573 2 5199.1893521250 ) 55.0968559487 (ExtendedPoll) + 4957+57 ( 2 0 4800.7025918042 2 5199.2649685543 ) 55.0952132428 (ExtendedPoll) + 4957+63 ( 2 0 4800.7285047755 2 5199.2488491668 ) 55.0951932210 (ExtendedPoll) + 4957+65 ( 2 0 4800.7568088740 2 5199.2374387295 ) 55.0950994742 (ExtendedPoll) + 4957+69 ( 2 0 4800.7456186612 2 5199.2478121856 ) 55.0950685340 (ExtendedPoll) + 4957+70 ( 2 0 4800.7120480229 2 5199.2789325537 ) 55.0949757164 (ExtendedPoll) + 4957+71 ( 2 0 4800.5777654696 2 5199.4034140262 ) 55.0946044924 (ExtendedPoll) + 4957+72 ( 2 0 4800.0406352565 2 5199.9013399163 ) 55.0931203333 (ExtendedPoll) + 4957+73 ( 2 0 4797.8921144041 2 5201.8930434766 ) 55.0871954955 (ExtendedPoll) + 4957+74 ( 2 0 4789.2980309945 2 5209.8598577177 ) 55.0636852238 (ExtendedPoll) + 4957+75 ( 2 0 4754.9216973563 2 5241.7271146822 ) 54.9726888507 (ExtendedPoll) + 4957+76 ( 2 0 4617.4163628032 2 5369.1961425400 ) 54.6586519092 (ExtendedPoll) + 4957+77 ( 2 0 4067.3950245908 2 5879.0722539713 ) 54.2760732951 (ExtendedPoll) + 4957+81 ( 2 0 4078.4498040205 2 5879.1268454747 ) 54.1738605186 (ExtendedPoll) + 4957+82 ( 2 0 4111.6141423099 2 5879.2906199847 ) 53.8682373433 (ExtendedPoll) + 4957+83 ( 2 0 4135.6344037869 2 5859.2009467494 ) 53.8353496249 (ExtendedPoll) + 4957+91 ( 2 0 4139.1419078776 2 5857.4881383315 ) 53.8193865804 (ExtendedPoll) + 4957+96 ( 2 0 4141.0884361692 2 5857.6587367795 ) 53.8000899204 (ExtendedPoll) + 4957+101 ( 2 0 4141.5688840483 2 5857.7459552361 ) 53.7949073397 (ExtendedPoll) + 4957+104 ( 2 0 4141.9346044712 2 5857.4223513050 ) 53.7945977867 (ExtendedPoll) + 4957+105 ( 2 0 4143.0317657398 2 5856.4515395119 ) 53.7936730233 (ExtendedPoll) + 4957+106 ( 2 0 4147.4204108144 2 5852.5682923396 ) 53.7900323766 (ExtendedPoll) + 4957+117 ( 2 0 4147.4162293615 2 5852.5829669923 ) 53.7899332894 (ExtendedPoll) + 4957+128 ( 2 0 4147.4160645968 2 5852.5834144589 ) 53.7899306065 (ExtendedPoll) + 4957+129 ( 2 0 4147.4153897141 2 5852.5840882751 ) 53.7899304432 (ExtendedPoll) + 4957+130 ( 2 0 4147.4133650660 2 5852.5861097238 ) 53.7899299534 (ExtendedPoll) + 4957+131 ( 2 0 4147.4052664734 2 5852.5941955188 ) 53.7899279944 (ExtendedPoll) + 4957+132 ( 2 0 4147.3728721030 2 5852.6265386988 ) 53.7899201620 (ExtendedPoll) + 4957+133 ( 2 0 4147.2432946213 2 5852.7559114185 ) 53.7898888919 (ExtendedPoll) + 4957+134 ( 2 0 4146.7249846949 2 5853.2734022975 ) 53.7897647629 (ExtendedPoll) + 4957+135 ( 2 0 4144.6517449892 2 5855.3433658132 ) 53.7892834747 (ExtendedPoll) + 4957+136 ( 2 0 4136.3587861663 2 5863.6232198764 ) 53.7876021773 (ExtendedPoll) + 4957+137 ( 2 0 4103.1869508749 2 5896.7426361291 ) 53.7847922558 (ExtendedPoll) + 4957+145 ( 2 0 4103.1682983337 2 5896.8007512235 ) 53.7844302124 (ExtendedPoll) + 4957+150 ( 2 0 4103.1669213843 2 5896.8312377825 ) 53.7841632090 (ExtendedPoll) + 4957+157 ( 2 0 4103.1650483182 2 5896.8345609654 ) 53.7841499007 (ExtendedPoll) + 4957+160 ( 2 0 4103.1624316887 2 5896.8373367825 ) 53.7841484300 (ExtendedPoll) + 4957+170 ( 2 0 4103.1626410673 2 5896.8372227473 ) 53.7841475564 (ExtendedPoll) + 4957+174 ( 2 0 4103.1625629696 2 5896.8373128117 ) 53.7841474463 (ExtendedPoll) + 4957+175 ( 2 0 4103.1623286764 2 5896.8375830050 ) 53.7841471160 (ExtendedPoll) + 4957+184 ( 2 0 4103.1623613751 2 5896.8376095974 ) 53.7841465724 (ExtendedPoll) + 4957+185 ( 2 0 4103.1623318769 2 5896.8376613910 ) 53.7841463677 (ExtendedPoll) + 4957+189 ( 2 0 4103.1623225735 2 5896.8376730311 ) 53.7841463463 (ExtendedPoll) + 4957+199 ( 2 0 4103.1623243672 2 5896.8376725291 ) 53.7841463344 (ExtendedPoll) + 4957+202 ( 2 0 4103.1623260046 2 5896.8376734171 ) 53.7841463113 (ExtendedPoll) + 4957+206 ( 2 0 4103.1623267413 2 5896.8376728473 ) 53.7841463097 (ExtendedPoll) + 4957+214 ( 2 0 4103.1623267301 2 5896.8376730798 ) 53.7841463077 (ExtendedPoll) + 4957+216 ( 2 0 4103.1623264493 2 5896.8376734513 ) 53.7841463069 (ExtendedPoll) + 4957+221 ( 2 0 4103.1623262249 2 5896.8376736923 ) 53.7841463067 (ExtendedPoll) + 4957+222 ( 2 0 4103.1623255517 2 5896.8376744152 ) 53.7841463063 (ExtendedPoll) + 4957+228 ( 2 0 4103.1623256446 2 5896.8376743450 ) 53.7841463061 (ExtendedPoll) + 5195+2 ( 2 0 4552.7863948639 2 5335.4101869888 ) 55.5680147602 (ExtendedPoll) + 5195+12 ( 2 0 4572.0026040455 2 5394.8057426411 ) 54.7532818545 (ExtendedPoll) + 5195+14 ( 2 0 4528.3294013600 2 5438.4789453267 ) 54.6428900648 (ExtendedPoll) + 5195+15 ( 2 0 4397.3097933033 2 5569.4985533833 ) 54.3697111024 (ExtendedPoll) + 5195+16 ( 2 0 3873.2313610768 2 6093.5769856098 ) 54.2139782157 (ExtendedPoll) + 5195+25 ( 2 0 3901.1822107956 2 6079.1648287236 ) 54.0675524851 (ExtendedPoll) + 5195+30 ( 2 0 3904.6760670104 2 6094.4504496635 ) 53.9053251878 (ExtendedPoll) + 5195+38 ( 2 0 3905.5158378706 2 6093.9518756993 ) 53.9014892203 (ExtendedPoll) + 5195+42 ( 2 0 3905.9712291027 2 6093.7758394257 ) 53.8986171016 (ExtendedPoll) + 5195+47 ( 2 0 3906.2152648514 2 6093.7828499557 ) 53.8962262883 (ExtendedPoll) + 5195+53 ( 2 0 3906.2570598051 2 6093.7383694092 ) 53.8962008251 (ExtendedPoll) + 5195+54 ( 2 0 3906.3824446664 2 6093.6049277697 ) 53.8961245036 (ExtendedPoll) + 5195+55 ( 2 0 3906.8839841115 2 6093.0711612115 ) 53.8958202370 (ExtendedPoll) + 5195+56 ( 2 0 3908.8901418918 2 6090.9360949789 ) 53.8946194836 (ExtendedPoll) + 5195+57 ( 2 0 3916.9147730132 2 6082.3958300485 ) 53.8900773214 (ExtendedPoll) + 5195+58 ( 2 0 3949.0132974987 2 6048.2347703268 ) 53.8760722747 (ExtendedPoll) + 5195+60 ( 2 0 3952.3160834518 2 6046.1534692613 ) 53.8626856098 (ExtendedPoll) + 5195+68 ( 2 0 3953.1776056142 2 6046.6132320786 ) 53.8505840740 (ExtendedPoll) + 5195+71 ( 2 0 3953.5789384631 2 6046.3350499844 ) 53.8491773294 (ExtendedPoll) + 5195+80 ( 2 0 3953.6091921986 2 6046.3390542165 ) 53.8488567166 (ExtendedPoll) + 5195+81 ( 2 0 3953.6616312293 2 6046.3078233717 ) 53.8486289876 (ExtendedPoll) + 5195+82 ( 2 0 3953.7497026781 2 6046.2232971719 ) 53.8485221437 (ExtendedPoll) + 5195+83 ( 2 0 3954.0139170244 2 6045.9697185726 ) 53.8482018728 (ExtendedPoll) + 5195+94 ( 2 0 3954.0185845590 2 6045.9794463233 ) 53.8480741214 (ExtendedPoll) + 5195+100 ( 2 0 3954.0184347508 2 6045.9813477797 ) 53.8480591976 (ExtendedPoll) + 5195+112 ( 2 0 3954.0185244766 2 6045.9812692933 ) 53.8480590234 (ExtendedPoll) + 5195+113 ( 2 0 3954.0187936542 2 6045.9810338338 ) 53.8480585006 (ExtendedPoll) + 5195+114 ( 2 0 3954.0198703645 2 6045.9800919962 ) 53.8480564096 (ExtendedPoll) + 5195+119 ( 2 0 3954.0199556739 2 6045.9800087306 ) 53.8480563182 (ExtendedPoll) + 5195+120 ( 2 0 3954.0202116021 2 6045.9797589338 ) 53.8480560440 (ExtendedPoll) + 5195+121 ( 2 0 3954.0212353150 2 6045.9787597466 ) 53.8480549472 (ExtendedPoll) + 5195+131 ( 2 0 3954.0212561678 2 6045.9787384550 ) 53.8480549329 (ExtendedPoll) + 5195+132 ( 2 0 3954.0213187265 2 6045.9786745799 ) 53.8480548901 (ExtendedPoll) + 5195+133 ( 2 0 3954.0215689610 2 6045.9784190796 ) 53.8480547188 (ExtendedPoll) + 5195+134 ( 2 0 3954.0225698990 2 6045.9773970786 ) 53.8480540335 (ExtendedPoll) + 5195+135 ( 2 0 3954.0265736512 2 6045.9733090745 ) 53.8480512924 (ExtendedPoll) + 5195+136 ( 2 0 3954.0425886598 2 6045.9569570580 ) 53.8480403289 (ExtendedPoll) + 5195+137 ( 2 0 3954.1066486941 2 6045.8915489921 ) 53.8479964904 (ExtendedPoll) + 5195+138 ( 2 0 3954.3628888317 2 6045.6299167285 ) 53.8478213863 (ExtendedPoll) + 5195+139 ( 2 0 3955.3878493820 2 6044.5833876740 ) 53.8471249631 (ExtendedPoll) + 5195+140 ( 2 0 3959.4876915833 2 6040.3972714563 ) 53.8444031448 (ExtendedPoll) + 5195+141 ( 2 0 3975.8870603884 2 6023.6528065852 ) 53.8345365224 (ExtendedPoll) + 5195+142 ( 2 0 4041.4845356089 2 5956.6749471009 ) 53.8113115046 (ExtendedPoll) + 5195+145 ( 2 0 4041.6035546824 2 5956.7020629246 ) 53.8099638531 (ExtendedPoll) + 5195+146 ( 2 0 4041.9606119028 2 5956.7834103954 ) 53.8059210158 (ExtendedPoll) + 5195+147 ( 2 0 4042.3009558066 2 5957.1335637099 ) 53.7996303534 (ExtendedPoll) + 5195+148 ( 2 0 4043.0741932721 2 5956.5373221342 ) 53.7977822528 (ExtendedPoll) + 5195+151 ( 2 0 4043.9165231091 2 5956.0430131312 ) 53.7943836123 (ExtendedPoll) + 5195+153 ( 2 0 4044.5989169010 2 5955.3444124866 ) 53.7942993075 (ExtendedPoll) + 5195+154 ( 2 0 4046.6460982769 2 5953.2486105531 ) 53.7940631506 (ExtendedPoll) + 5195+155 ( 2 0 4054.8348237804 2 5944.8654028188 ) 53.7933696899 (ExtendedPoll) + 5195+166 ( 2 0 4055.0724354313 2 5944.9214870586 ) 53.7906651766 (ExtendedPoll) + 5195+176 ( 2 0 4055.0761548684 2 5944.9206398974 ) 53.7906383460 (ExtendedPoll) + 5195+180 ( 2 0 4055.0778890903 2 5944.9198458871 ) 53.7906294220 (ExtendedPoll) + 5195+181 ( 2 0 4055.0811305415 2 5944.9178346926 ) 53.7906174793 (ExtendedPoll) + 5195+184 ( 2 0 4055.0777945058 2 5944.9220743514 ) 53.7906102701 (ExtendedPoll) + 5195+198 ( 2 0 4055.0778330577 2 5944.9221198097 ) 53.7906095046 (ExtendedPoll) + 5195+199 ( 2 0 4055.0777705351 2 5944.9222213074 ) 53.7906091714 (ExtendedPoll) + 5195+201 ( 2 0 4055.0780084500 2 5944.9219823862 ) 53.7906091154 (ExtendedPoll) + 5195+202 ( 2 0 4055.0787221949 2 5944.9212656228 ) 53.7906089474 (ExtendedPoll) + 5195+203 ( 2 0 4055.0815771745 2 5944.9183985692 ) 53.7906082755 (ExtendedPoll) + 5195+204 ( 2 0 4055.0929970928 2 5944.9069303548 ) 53.7906055884 (ExtendedPoll) + 5195+205 ( 2 0 4055.1386767659 2 5944.8610574972 ) 53.7905948477 (ExtendedPoll) + 5195+206 ( 2 0 4055.3213954584 2 5944.6775660669 ) 53.7905520064 (ExtendedPoll) + 5195+207 ( 2 0 4056.0522702285 2 5943.9436003453 ) 53.7903825885 (ExtendedPoll) + 5195+208 ( 2 0 4058.9757693086 2 5941.0077374592 ) 53.7897360619 (ExtendedPoll) + 5195+209 ( 2 0 4070.6697656292 2 5929.2642859147 ) 53.7876477253 (ExtendedPoll) + 5195+210 ( 2 0 4117.4457509116 2 5882.2904797367 ) 53.7872228417 (ExtendedPoll) + 5195+213 ( 2 0 4117.6891202600 2 5882.3097520301 ) 53.7848204977 (ExtendedPoll) + 5195+228 ( 2 0 4117.6899942270 2 5882.3093703541 ) 53.7848160313 (ExtendedPoll) + 5195+229 ( 2 0 4117.6915671836 2 5882.3082915651 ) 53.7848116087 (ExtendedPoll) + 5195+235 ( 2 0 4117.6919572521 2 5882.3080173020 ) 53.7848105741 (ExtendedPoll) + 5195+242 ( 2 0 4117.6920091373 2 5882.3079879653 ) 53.7848103706 (ExtendedPoll) + 5195+245 ( 2 0 4117.6920521121 2 5882.3079466630 ) 53.7848103589 (ExtendedPoll) + 5195+253 ( 2 0 4117.6920497867 2 5882.3079495734 ) 53.7848103533 (ExtendedPoll) + 5195+263 ( 2 0 4117.6920499996 2 5882.3079496675 ) 53.7848103505 (ExtendedPoll) + 5195+266 ( 2 0 4117.6920502143 2 5882.3079495774 ) 53.7848103493 (ExtendedPoll) + 5195+269 ( 2 0 4117.6920504410 2 5882.3079495242 ) 53.7848103478 (ExtendedPoll) + 5195+275 ( 2 0 4117.6920503703 2 5882.3079496167 ) 53.7848103475 (ExtendedPoll) + 5478+3 ( 2 0 4909.1597287779 2 5083.8525395201 ) 55.5960691542 (ExtendedPoll) + 5478+4 ( 2 0 4636.6389440201 2 5335.4101869888 ) 54.8753885588 (ExtendedPoll) + 5478+13 ( 2 0 4690.7937153502 2 5303.9654810552 ) 54.7846942177 (ExtendedPoll) + 5478+15 ( 2 0 4565.0148916158 2 5429.7443047896 ) 54.4304906658 (ExtendedPoll) + 5478+16 ( 2 0 4187.6784204127 2 5807.0807759926 ) 53.8546415124 (ExtendedPoll) + 5478+28 ( 2 0 4195.7852586612 2 5799.5744442811 ) 53.8531825911 (ExtendedPoll) + 5478+29 ( 2 0 4220.1057734067 2 5777.0554491463 ) 53.8508015438 (ExtendedPoll) + 5478+31 ( 2 0 4231.5699891117 2 5766.4646974951 ) 53.8504789320 (ExtendedPoll) + 5478+34 ( 2 0 4237.6296459843 2 5761.5514621930 ) 53.8439440609 (ExtendedPoll) + 5478+41 ( 2 0 4239.1257943732 2 5760.2958576158 ) 53.8427664280 (ExtendedPoll) + 5478+46 ( 2 0 4239.9101207378 2 5759.7136904120 ) 53.8414160967 (ExtendedPoll) + 5478+50 ( 2 0 4239.7094543134 2 5760.1588457372 ) 53.8388916705 (ExtendedPoll) + 5478+54 ( 2 0 4239.2194102715 2 5760.6452645620 ) 53.8385475799 (ExtendedPoll) + 5478+55 ( 2 0 4237.7492781460 2 5762.1045210365 ) 53.8375232191 (ExtendedPoll) + 5478+56 ( 2 0 4231.8687496437 2 5767.9415469345 ) 53.8335445270 (ExtendedPoll) + 5478+57 ( 2 0 4208.3466356348 2 5791.2896505265 ) 53.8195350703 (ExtendedPoll) + 5478+58 ( 2 0 4114.2581795991 2 5884.6820648944 ) 53.7943112519 (ExtendedPoll) + 5478+71 ( 2 0 4114.9485701934 2 5884.6988048671 ) 53.7878427663 (ExtendedPoll) + 5478+74 ( 2 0 4115.3912731659 2 5884.4929138652 ) 53.7856923145 (ExtendedPoll) + 5478+80 ( 2 0 4115.5104388474 2 5884.4664511137 ) 53.7848465681 (ExtendedPoll) + 5478+86 ( 2 0 4115.5040354705 2 5884.4803013045 ) 53.7847774342 (ExtendedPoll) + 5478+92 ( 2 0 4115.5085943246 2 5884.4864188582 ) 53.7846793465 (ExtendedPoll) + 5478+94 ( 2 0 4115.5038751700 2 5884.4924136225 ) 53.7846672332 (ExtendedPoll) + 5478+99 ( 2 0 4115.5033916134 2 5884.4961975456 ) 53.7846367702 (ExtendedPoll) + 5478+108 ( 2 0 4115.5032700638 2 5884.4964026531 ) 53.7846359908 (ExtendedPoll) + 5478+109 ( 2 0 4115.5029054151 2 5884.4970179759 ) 53.7846336525 (ExtendedPoll) + 5478+117 ( 2 0 4115.5029626983 2 5884.4970015034 ) 53.7846332805 (ExtendedPoll) + 5478+121 ( 2 0 4115.5030374021 2 5884.4969624551 ) 53.7846329574 (ExtendedPoll) + 5478+142 ( 2 0 4115.5030374174 2 5884.4969625705 ) 53.7846329562 (ExtendedPoll) + 5629+9 ( 2 0 4975.5429968599 2 5019.6529315723 ) 55.8517940762 (ExtendedPoll) + 5629+10 ( 2 0 4902.1720163482 2 5078.6117551978 ) 55.7134020563 (ExtendedPoll) + 5629+11 ( 2 0 4608.6880943013 2 5314.4470496997 ) 55.3395226272 (ExtendedPoll) + 5629+15 ( 2 0 4552.7863948639 2 5426.2504485747 ) 54.5705629398 (ExtendedPoll) + 5629+20 ( 2 0 4591.6555452540 2 5405.2873112856 ) 54.4751741266 (ExtendedPoll) + 5629+33 ( 2 0 4592.5840273072 2 5406.3096224852 ) 54.4562806449 (ExtendedPoll) + 5629+37 ( 2 0 4592.3579843636 2 5406.7424094230 ) 54.4534252540 (ExtendedPoll) + 5629+38 ( 2 0 4591.6798555328 2 5408.0407702362 ) 54.4448631609 (ExtendedPoll) + 5629+44 ( 2 0 4591.6012203107 2 5408.2719044772 ) 54.4429899385 (ExtendedPoll) + 5629+48 ( 2 0 4591.5696196138 2 5408.3898106624 ) 54.4419637140 (ExtendedPoll) + 5629+52 ( 2 0 4591.5680918914 2 5408.4202901410 ) 54.4416432602 (ExtendedPoll) + 5629+58 ( 2 0 4591.5700204171 2 5408.4276717726 ) 54.4415465559 (ExtendedPoll) + 5629+60 ( 2 0 4591.5654575021 2 5408.4337863066 ) 54.4415176321 (ExtendedPoll) + 5629+67 ( 2 0 4591.5646332830 2 5408.4348538518 ) 54.4415128113 (ExtendedPoll) + 5629+71 ( 2 0 4591.5645519834 2 5408.4353237071 ) 54.4415083512 (ExtendedPoll) + 5629+79 ( 2 0 4591.5646115597 2 5408.4353255431 ) 54.4415078361 (ExtendedPoll) + 5629+84 ( 2 0 4591.5645990175 2 5408.4353525777 ) 54.4415076449 (ExtendedPoll) + 5629+85 ( 2 0 4591.5645613907 2 5408.4354336816 ) 54.4415070710 (ExtendedPoll) + 5629+94 ( 2 0 4591.5645699689 2 5408.4354275629 ) 54.4415070666 (ExtendedPoll) + 5629+101 ( 2 0 4591.5645717027 2 5408.4354268822 ) 54.4415070596 (ExtendedPoll) + 5629+103 ( 2 0 4591.5645704450 2 5408.4354282562 ) 54.4415070551 (ExtendedPoll) + 5629+104 ( 2 0 4591.5645666721 2 5408.4354323781 ) 54.4415070414 (ExtendedPoll) + 5629+109 ( 2 0 4591.5645657541 2 5408.4354339988 ) 54.4415070313 (ExtendedPoll) + 5629+119 ( 2 0 4591.5645658577 2 5408.4354341268 ) 54.4415070290 (ExtendedPoll) + 5755+17 ( 2 0 4999.4391479660 2 5000.4028159491 ) 55.9011173930 (ExtendedPoll) + 5755+18 ( 2 0 4997.7566207727 2 5001.6112927051 ) 55.8993758016 (ExtendedPoll) + 5755+19 ( 2 0 4991.0265119995 2 5006.4451997289 ) 55.8924862980 (ExtendedPoll) + 5755+20 ( 2 0 4964.1060769066 2 5025.7808278241 ) 55.8661643975 (ExtendedPoll) + 5755+21 ( 2 0 4856.4243365351 2 5103.1233402051 ) 55.7810605478 (ExtendedPoll) + 5755+24 ( 2 0 4863.9579639983 2 5116.7712160443 ) 55.5599122421 (ExtendedPoll) + 5755+25 ( 2 0 4848.2356110316 2 5143.8486017093 ) 55.3646109717 (ExtendedPoll) + 5755+31 ( 2 0 4842.8037564475 2 5149.4715265551 ) 55.3415309539 (ExtendedPoll) + 5755+32 ( 2 0 4826.5081926955 2 5166.3403010924 ) 55.2731138922 (ExtendedPoll) + 5755+33 ( 2 0 4761.3259376873 2 5233.8153992415 ) 55.0119577195 (ExtendedPoll) + 5755+36 ( 2 0 4739.4893363446 2 5256.0887326112 ) 54.9328003343 (ExtendedPoll) + 5755+37 ( 2 0 4673.9795323162 2 5322.9087327200 ) 54.7090508194 (ExtendedPoll) + 5755+39 ( 2 0 4628.5594015233 2 5364.8350072982 ) 54.6149385255 (ExtendedPoll) + 5755+40 ( 2 0 4492.2990091444 2 5490.6138310325 ) 54.3872651867 (ExtendedPoll) + 5755+41 ( 2 0 3947.2574396288 2 5993.7291259700 ) 54.3655883138 (ExtendedPoll) + 5755+49 ( 2 0 3928.0412304472 2 6053.1246816223 ) 54.0330892795 (ExtendedPoll) + 5755+58 ( 2 0 3929.8700458096 2 6060.7129005889 ) 53.9508748031 (ExtendedPoll) + 5755+60 ( 2 0 3925.2024722726 2 6066.9909234750 ) 53.9417691814 (ExtendedPoll) + 5755+61 ( 2 0 3911.1997516616 2 6085.8249921331 ) 53.9156381344 (ExtendedPoll) + 5755+66 ( 2 0 3919.7706176886 2 6078.8372797034 ) 53.8929555395 (ExtendedPoll) + 5755+74 ( 2 0 3920.5459876347 2 6078.2435971044 ) 53.8905945920 (ExtendedPoll) + 5755+75 ( 2 0 3922.8720974731 2 6076.4625493074 ) 53.8835272419 (ExtendedPoll) + 5755+81 ( 2 0 3922.0826531550 2 6077.5957494982 ) 53.8814445368 (ExtendedPoll) + 5755+87 ( 2 0 3922.3040046412 2 6077.4927773412 ) 53.8802087502 (ExtendedPoll) + 5755+90 ( 2 0 3922.2317402049 2 6077.7259640948 ) 53.8789219399 (ExtendedPoll) + 5755+100 ( 2 0 3922.2265169811 2 6077.7403010701 ) 53.8788502601 (ExtendedPoll) + 5755+101 ( 2 0 3922.2108473095 2 6077.7833119959 ) 53.8786352255 (ExtendedPoll) + 5755+107 ( 2 0 3922.2085611664 2 6077.7905908301 ) 53.8785953531 (ExtendedPoll) + 5755+113 ( 2 0 3922.2107347292 2 6077.7889934610 ) 53.8785881820 (ExtendedPoll) + 5755+122 ( 2 0 3922.2108535295 2 6077.7889835942 ) 53.8785871342 (ExtendedPoll) + 5755+123 ( 2 0 3922.2110146221 2 6077.7888078314 ) 53.8785870886 (ExtendedPoll) + 5755+124 ( 2 0 3922.2114979001 2 6077.7882805429 ) 53.8785869518 (ExtendedPoll) + 5755+125 ( 2 0 3922.2134310120 2 6077.7861713891 ) 53.8785864048 (ExtendedPoll) + 5755+126 ( 2 0 3922.2211634595 2 6077.7777347737 ) 53.8785842169 (ExtendedPoll) + 5755+127 ( 2 0 3922.2520932495 2 6077.7439883121 ) 53.8785754693 (ExtendedPoll) + 5755+128 ( 2 0 3922.3758124097 2 6077.6090024659 ) 53.8785405430 (ExtendedPoll) + 5755+129 ( 2 0 3922.8706890504 2 6077.0690590808 ) 53.8784018624 (ExtendedPoll) + 5755+130 ( 2 0 3924.8501956130 2 6074.9092855406 ) 53.8778635334 (ExtendedPoll) + 5755+131 ( 2 0 3932.7682218633 2 6066.2701913799 ) 53.8759723517 (ExtendedPoll) + 5755+132 ( 2 0 3964.4403268649 2 6031.7138147370 ) 53.8725913899 (ExtendedPoll) + 5755+134 ( 2 0 3964.6765257473 2 6031.6520794236 ) 53.8708963698 (ExtendedPoll) + 5755+135 ( 2 0 3965.3851223947 2 6031.4668734835 ) 53.8658119765 (ExtendedPoll) + 5755+136 ( 2 0 3968.2195089840 2 6030.7260497231 ) 53.8454844045 (ExtendedPoll) + 5755+138 ( 2 0 3966.5220544265 2 6032.9062978884 ) 53.8426385768 (ExtendedPoll) + 5755+139 ( 2 0 3964.0381410238 2 6035.9224784489 ) 53.8400218659 (ExtendedPoll) + 5755+154 ( 2 0 3964.1134625710 2 6035.8803219730 ) 53.8396748316 (ExtendedPoll) + 5755+157 ( 2 0 3964.1376216602 2 6035.8616765123 ) 53.8396077632 (ExtendedPoll) + 5755+166 ( 2 0 3964.1391333458 2 6035.8605134178 ) 53.8396035356 (ExtendedPoll) + 5755+171 ( 2 0 3964.1395137360 2 6035.8602258817 ) 53.8396024275 (ExtendedPoll) + 5755+175 ( 2 0 3964.1397422881 2 6035.8601580043 ) 53.8396008562 (ExtendedPoll) + 5755+176 ( 2 0 3964.1401032802 2 6035.8598464624 ) 53.8396001384 (ExtendedPoll) + 5755+184 ( 2 0 3964.1401437730 2 6035.8598027239 ) 53.8396001338 (ExtendedPoll) + 5755+185 ( 2 0 3964.1402652513 2 6035.8596715087 ) 53.8396001200 (ExtendedPoll) + 5755+186 ( 2 0 3964.1407511646 2 6035.8591466477 ) 53.8396000647 (ExtendedPoll) + 5755+187 ( 2 0 3964.1426948176 2 6035.8570472037 ) 53.8395998438 (ExtendedPoll) + 5755+188 ( 2 0 3964.1504694296 2 6035.8486494278 ) 53.8395989603 (ExtendedPoll) + 5755+189 ( 2 0 3964.1815678778 2 6035.8150583240 ) 53.8395954303 (ExtendedPoll) + 5755+190 ( 2 0 3964.3059616705 2 6035.6806939089 ) 53.8395813737 (ExtendedPoll) + 5755+191 ( 2 0 3964.8035368415 2 6035.1432362487 ) 53.8395261614 (ExtendedPoll) + 5755+192 ( 2 0 3966.7938375252 2 6032.9934056075 ) 53.8393215384 (ExtendedPoll) + 5755+193 ( 2 0 3974.7550402603 2 6024.3940830430 ) 53.8387624914 (ExtendedPoll) + 5755+195 ( 2 0 3974.8020931115 2 6024.3552069220 ) 53.8386567319 (ExtendedPoll) + 5755+196 ( 2 0 3974.9432516652 2 6024.2385785592 ) 53.8383395150 (ExtendedPoll) + 5755+197 ( 2 0 3975.5078858801 2 6023.7720651080 ) 53.8370715717 (ExtendedPoll) + 5755+198 ( 2 0 3977.7664227394 2 6021.9060113031 ) 53.8320145804 (ExtendedPoll) + 5755+201 ( 2 0 3978.1694615728 2 6021.6302815615 ) 53.8306170085 (ExtendedPoll) + 5755+206 ( 2 0 3978.2884006782 2 6021.6028192098 ) 53.8297362750 (ExtendedPoll) + 5755+211 ( 2 0 3978.3433620337 2 6021.5762764903 ) 53.8294496693 (ExtendedPoll) + 5755+214 ( 2 0 3978.4034030246 2 6021.5653058772 ) 53.8289799544 (ExtendedPoll) + 5755+218 ( 2 0 3978.4320361581 2 6021.5547475992 ) 53.8288022372 (ExtendedPoll) + 5755+219 ( 2 0 3978.4762518106 2 6021.5126727574 ) 53.8287517449 (ExtendedPoll) + 5755+220 ( 2 0 3978.6088987679 2 6021.3864482319 ) 53.8286003328 (ExtendedPoll) + 5755+224 ( 2 0 3978.6514101019 2 6021.3426524116 ) 53.8285808779 (ExtendedPoll) + 5755+225 ( 2 0 3978.7789441037 2 6021.2112649506 ) 53.8285225798 (ExtendedPoll) + 5755+226 ( 2 0 3979.2890801112 2 6020.6857151068 ) 53.8282903842 (ExtendedPoll) + 5755+227 ( 2 0 3981.3296241412 2 6018.5835157314 ) 53.8273775476 (ExtendedPoll) + 5755+228 ( 2 0 3989.4918002613 2 6010.1747182300 ) 53.8239811631 (ExtendedPoll) + 5755+229 ( 2 0 4022.1405047416 2 5976.5395282242 ) 53.8144637068 (ExtendedPoll) + 5755+234 ( 2 0 4020.7893650335 2 5978.9483783098 ) 53.8057221545 (ExtendedPoll) + 5755+239 ( 2 0 4021.8359865119 2 5978.0476185044 ) 53.8039392071 (ExtendedPoll) + 5755+248 ( 2 0 4021.8964440029 2 5978.0392385221 ) 53.8034496620 (ExtendedPoll) + 5755+251 ( 2 0 4021.9498759700 2 5978.0097369858 ) 53.8032127550 (ExtendedPoll) + 5755+255 ( 2 0 4021.9714769156 2 5977.9881793562 ) 53.8032023063 (ExtendedPoll) + 5755+256 ( 2 0 4022.0362797523 2 5977.9235064675 ) 53.8031709766 (ExtendedPoll) + 5755+257 ( 2 0 4022.2954910992 2 5977.6648149127 ) 53.8030459025 (ExtendedPoll) + 5755+258 ( 2 0 4023.3323364869 2 5976.6300486937 ) 53.8025495188 (ExtendedPoll) + 5755+259 ( 2 0 4027.4797180376 2 5972.4909838173 ) 53.8006265679 (ExtendedPoll) + 5755+272 ( 2 0 4027.4926149637 2 5972.4991384731 ) 53.8004340240 (ExtendedPoll) + 5755+274 ( 2 0 4027.4867594927 2 5972.5132290886 ) 53.8003634319 (ExtendedPoll) + 5755+291 ( 2 0 4027.4868017206 2 5972.5131870229 ) 53.8003634121 (ExtendedPoll) + 5755+292 ( 2 0 4027.4869284044 2 5972.5130608261 ) 53.8003633529 (ExtendedPoll) + 5755+293 ( 2 0 4027.4874351394 2 5972.5125560387 ) 53.8003631157 (ExtendedPoll) + 5755+294 ( 2 0 4027.4894620797 2 5972.5105368890 ) 53.8003621672 (ExtendedPoll) + 5755+309 ( 2 0 4027.4894630105 2 5972.5105368589 ) 53.8003621588 (ExtendedPoll) + 5755+315 ( 2 0 4027.4894632002 2 5972.5105367239 ) 53.8003621582 (ExtendedPoll) + 5755+320 ( 2 0 4027.4894631259 2 5972.5105368136 ) 53.8003621581 (ExtendedPoll) + 5755+321 ( 2 0 4027.4894629032 2 5972.5105370826 ) 53.8003621578 (ExtendedPoll) + 5755+329 ( 2 0 4027.4894628766 2 5972.5105371140 ) 53.8003621577 (ExtendedPoll) + 6087+4 ( 2 0 4748.4423428951 2 5251.5576378325 ) 54.9123291399 (ExtendedPoll) + 6087+5 ( 2 0 3993.7694004889 2 6006.2305802387 ) 53.8183151870 (ExtendedPoll) + 6087+44 ( 2 0 3993.7694619626 2 6006.2305225636 ) 53.8183151149 (ExtendedPoll) + 6087+45 ( 2 0 3993.7696463836 2 6006.2303495384 ) 53.8183148988 (ExtendedPoll) + 6087+56 ( 2 0 3993.7696499094 2 6006.2303483359 ) 53.8183148762 (ExtendedPoll) + 6087+64 ( 2 0 3993.7696494122 2 6006.2303491234 ) 53.8183148740 (ExtendedPoll) + 6087+65 ( 2 0 3993.7696479206 2 6006.2303514859 ) 53.8183148673 (ExtendedPoll) + 6087+70 ( 2 0 3993.7696473156 2 6006.2303521939 ) 53.8183148668 (ExtendedPoll) + 6087+71 ( 2 0 3993.7696455004 2 6006.2303543179 ) 53.8183148653 (ExtendedPoll) + 6087+80 ( 2 0 3993.7696457355 2 6006.2303540873 ) 53.8183148651 (ExtendedPoll) + 6087+81 ( 2 0 3993.7696464408 2 6006.2303533957 ) 53.8183148645 (ExtendedPoll) + 6087+82 ( 2 0 3993.7696492618 2 6006.2303506290 ) 53.8183148623 (ExtendedPoll) + 6087+85 ( 2 0 3993.7696499024 2 6006.2303499530 ) 53.8183148622 (ExtendedPoll) + 6087+86 ( 2 0 3993.7696518242 2 6006.2303479249 ) 53.8183148619 (ExtendedPoll) + 6087+87 ( 2 0 3993.7696595112 2 6006.2303398127 ) 53.8183148607 (ExtendedPoll) + 6087+88 ( 2 0 3993.7696902595 2 6006.2303073636 ) 53.8183148562 (ExtendedPoll) + 6087+89 ( 2 0 3993.7698132527 2 6006.2301775672 ) 53.8183148381 (ExtendedPoll) + 6087+90 ( 2 0 3993.7703052255 2 6006.2296583817 ) 53.8183147657 (ExtendedPoll) + 6087+91 ( 2 0 3993.7722731166 2 6006.2275816398 ) 53.8183144759 (ExtendedPoll) + 6087+92 ( 2 0 3993.7801446810 2 6006.2192746722 ) 53.8183133172 (ExtendedPoll) + 6087+93 ( 2 0 3993.8116309384 2 6006.1860468016 ) 53.8183086862 (ExtendedPoll) + 6087+94 ( 2 0 3993.9375759683 2 6006.0531353193 ) 53.8182902249 (ExtendedPoll) + 6087+95 ( 2 0 3994.4413560878 2 6005.5214893902 ) 53.8182173813 (ExtendedPoll) + 6087+96 ( 2 0 3996.4564765659 2 6003.3949056739 ) 53.8179420284 (ExtendedPoll) + 6087+97 ( 2 0 4004.5169584783 2 5994.8885708083 ) 53.8170967872 (ExtendedPoll) + 6087+99 ( 2 0 4004.5245453924 2 5994.8877669371 ) 53.8170328494 (ExtendedPoll) + 6087+100 ( 2 0 4004.5473061346 2 5994.8853553233 ) 53.8168410364 (ExtendedPoll) + 6087+101 ( 2 0 4004.6383491034 2 5994.8757088682 ) 53.8160737928 (ExtendedPoll) + 6087+102 ( 2 0 4005.0025209789 2 5994.8371230479 ) 53.8130049524 (ExtendedPoll) + 6087+105 ( 2 0 4005.0443542507 2 5994.7926791534 ) 53.8130042923 (ExtendedPoll) + 6087+106 ( 2 0 4005.1698540660 2 5994.6593474699 ) 53.8130023789 (ExtendedPoll) + 6087+107 ( 2 0 4005.6718533272 2 5994.1260207358 ) 53.8129957265 (ExtendedPoll) + 6087+108 ( 2 0 4007.6798503720 2 5991.9927137997 ) 53.8129851374 (ExtendedPoll) + 6087+113 ( 2 0 4007.2403461204 2 5992.5254074536 ) 53.8124063797 (ExtendedPoll) + 6087+117 ( 2 0 4007.7373207242 2 5992.0459191907 ) 53.8119791690 (ExtendedPoll) + 6087+118 ( 2 0 4009.2282445356 2 5990.6074544020 ) 53.8107058155 (ExtendedPoll) + 6087+126 ( 2 0 4009.3503023939 2 5990.6056218015 ) 53.8095807273 (ExtendedPoll) + 6087+128 ( 2 0 4009.4380806266 2 5990.5207890577 ) 53.8095074272 (ExtendedPoll) + 6087+129 ( 2 0 4009.7014153247 2 5990.2662908261 ) 53.8092877859 (ExtendedPoll) + 6087+136 ( 2 0 4009.7506106525 2 5990.2301636059 ) 53.8091461907 (ExtendedPoll) + 6087+143 ( 2 0 4009.7635053921 2 5990.2220054099 ) 53.8090975243 (ExtendedPoll) + 6087+144 ( 2 0 4009.8021896106 2 5990.1975308217 ) 53.8089515284 (ExtendedPoll) + 6087+154 ( 2 0 4009.8017843826 2 5990.1980698371 ) 53.8089505672 (ExtendedPoll) + 6087+161 ( 2 0 4009.8017202471 2 5990.1981703234 ) 53.8089502814 (ExtendedPoll) + 6087+162 ( 2 0 4009.8015278408 2 5990.1984717824 ) 53.8089494238 (ExtendedPoll) + 6087+177 ( 2 0 4009.8015265652 2 5990.1984731397 ) 53.8089494237 (ExtendedPoll) + 6087+178 ( 2 0 4009.8015227385 2 5990.1984772118 ) 53.8089494236 (ExtendedPoll) + 6087+182 ( 2 0 4009.8015264517 2 5990.1984734744 ) 53.8089494218 (ExtendedPoll) + 6087+183 ( 2 0 4009.8015375912 2 5990.1984622623 ) 53.8089494165 (ExtendedPoll) + 6087+184 ( 2 0 4009.8015821493 2 5990.1984174139 ) 53.8089493951 (ExtendedPoll) + 6087+185 ( 2 0 4009.8017603815 2 5990.1982380201 ) 53.8089493096 (ExtendedPoll) + 6087+186 ( 2 0 4009.8024733106 2 5990.1975204453 ) 53.8089489676 (ExtendedPoll) + 6087+187 ( 2 0 4009.8053250269 2 5990.1946501458 ) 53.8089475994 (ExtendedPoll) + 6087+188 ( 2 0 4009.8167318920 2 5990.1831689481 ) 53.8089421273 (ExtendedPoll) + 6087+189 ( 2 0 4009.8623593525 2 5990.1372441570 ) 53.8089202465 (ExtendedPoll) + 6087+190 ( 2 0 4010.0448691945 2 5989.9535449926 ) 53.8088328461 (ExtendedPoll) + 6087+191 ( 2 0 4010.7749085625 2 5989.2187483350 ) 53.8084852115 (ExtendedPoll) + 6087+192 ( 2 0 4013.6950660346 2 5986.2795617047 ) 53.8071261335 (ExtendedPoll) + 6087+193 ( 2 0 4025.3756959228 2 5974.5228151836 ) 53.8021926744 (ExtendedPoll) + 6087+194 ( 2 0 4072.0982154756 2 5927.4958290993 ) 53.7904707641 (ExtendedPoll) + 6087+196 ( 2 0 4072.1230863636 2 5927.4781440878 ) 53.7904013936 (ExtendedPoll) + 6087+197 ( 2 0 4072.1976990276 2 5927.4250890534 ) 53.7901932963 (ExtendedPoll) + 6087+198 ( 2 0 4072.4961496835 2 5927.2128689157 ) 53.7893611206 (ExtendedPoll) + 6087+201 ( 2 0 4072.6142224687 2 5927.1818879709 ) 53.7885522474 (ExtendedPoll) + 6087+205 ( 2 0 4072.7124431924 2 5927.2543656553 ) 53.7869896937 (ExtendedPoll) + 6087+206 ( 2 0 4072.8894390822 2 5927.0862195600 ) 53.7868793477 (ExtendedPoll) + 6087+212 ( 2 0 4072.8331432603 2 5927.1516517284 ) 53.7868061997 (ExtendedPoll) + 6087+222 ( 2 0 4072.8364485532 2 5927.1585279631 ) 53.7867134349 (ExtendedPoll) + 6087+225 ( 2 0 4072.8360952700 2 5927.1623262685 ) 53.7866822980 (ExtendedPoll) + 6087+231 ( 2 0 4072.8355323017 2 5927.1630960486 ) 53.7866805212 (ExtendedPoll) + 6087+232 ( 2 0 4072.8338433970 2 5927.1654053888 ) 53.7866751908 (ExtendedPoll) + 6087+236 ( 2 0 4072.8348036881 2 5927.1644583778 ) 53.7866749068 (ExtendedPoll) + 6087+237 ( 2 0 4072.8376845612 2 5927.1616173446 ) 53.7866740546 (ExtendedPoll) + 6087+238 ( 2 0 4072.8492080538 2 5927.1502532121 ) 53.7866706465 (ExtendedPoll) + 6087+239 ( 2 0 4072.8546839370 2 5927.1449407271 ) 53.7866682334 (ExtendedPoll) + 6087+251 ( 2 0 4072.8548902901 2 5927.1448213042 ) 53.7866674110 (ExtendedPoll) + 6087+252 ( 2 0 4072.8555093493 2 5927.1444630354 ) 53.7866649438 (ExtendedPoll) + 6087+257 ( 2 0 4072.8556843793 2 5927.1443011469 ) 53.7866647950 (ExtendedPoll) + 6087+265 ( 2 0 4072.8556567359 2 5927.1443329620 ) 53.7866647619 (ExtendedPoll) + 6087+271 ( 2 0 4072.8556523714 2 5927.1443390004 ) 53.7866647475 (ExtendedPoll) + 6087+272 ( 2 0 4072.8556392781 2 5927.1443571157 ) 53.7866647042 (ExtendedPoll) + 6087+277 ( 2 0 4072.8556357434 2 5927.1443636744 ) 53.7866646774 (ExtendedPoll) + 6087+284 ( 2 0 4072.8556351991 2 5927.1443644301 ) 53.7866646756 (ExtendedPoll) + 6087+289 ( 2 0 4072.8556348885 2 5927.1443647771 ) 53.7866646753 (ExtendedPoll) + 6087+290 ( 2 0 4072.8556339570 2 5927.1443658182 ) 53.7866646745 (ExtendedPoll) + 6087+291 ( 2 0 4072.8556327029 2 5927.1443671954 ) 53.7866646736 (ExtendedPoll) + 6087+300 ( 2 0 4072.8556329763 2 5927.1443670119 ) 53.7866646727 (ExtendedPoll) + 6399+7 ( 2 0 4954.5798595708 2 5043.6731930494 ) 55.7239163641 (ExtendedPoll) + 6399+8 ( 2 0 4818.3194671920 2 5174.6928011060 ) 55.2406520186 (ExtendedPoll) + 6399+9 ( 2 0 4273.2778976764 2 5698.7712333325 ) 54.1421761447 (ExtendedPoll) + 6399+20 ( 2 0 4267.0544662937 2 5713.0742072120 ) 54.0559868372 (ExtendedPoll) + 6399+22 ( 2 0 4305.9236166838 2 5692.5478019498 ) 53.9161736343 (ExtendedPoll) + 6399+38 ( 2 0 4306.4284814658 2 5693.0189735384 ) 53.9070540230 (ExtendedPoll) + 6399+39 ( 2 0 4307.3369182014 2 5692.6607167976 ) 53.9026276457 (ExtendedPoll) + 6399+55 ( 2 0 4307.3366998789 2 5692.6626116095 ) 53.9026107377 (ExtendedPoll) + 6399+61 ( 2 0 4307.3371752453 2 5692.6626490319 ) 53.9026061874 (ExtendedPoll) + 6399+63 ( 2 0 4307.3375784896 2 5692.6623945369 ) 53.9026051716 (ExtendedPoll) + 6399+76 ( 2 0 4307.3375909856 2 5692.6624026545 ) 53.9026049811 (ExtendedPoll) + 6399+81 ( 2 0 4307.3375975611 2 5692.6623991511 ) 53.9026049581 (ExtendedPoll) + 6399+89 ( 2 0 4307.3375983269 2 5692.6623986211 ) 53.9026049566 (ExtendedPoll) + 6399+90 ( 2 0 4307.3376006244 2 5692.6623970312 ) 53.9026049522 (ExtendedPoll) + 6399+92 ( 2 0 4307.3375976707 2 5692.6624013936 ) 53.9026049349 (ExtendedPoll) + 6399+97 ( 2 0 4307.3375969844 2 5692.6624020232 ) 53.9026049346 (ExtendedPoll) + 6399+98 ( 2 0 4307.3375949256 2 5692.6624039121 ) 53.9026049340 (ExtendedPoll) + 6399+99 ( 2 0 4307.3375866905 2 5692.6624114674 ) 53.9026049313 (ExtendedPoll) + 6399+100 ( 2 0 4307.3375537500 2 5692.6624416886 ) 53.9026049205 (ExtendedPoll) + 6399+101 ( 2 0 4307.3374219878 2 5692.6625625735 ) 53.9026048776 (ExtendedPoll) + 6399+102 ( 2 0 4307.3368949392 2 5692.6630461130 ) 53.9026047059 (ExtendedPoll) + 6399+103 ( 2 0 4307.3347867446 2 5692.6649802712 ) 53.9026040190 (ExtendedPoll) + 6399+104 ( 2 0 4307.3263539663 2 5692.6727169040 ) 53.9026012717 (ExtendedPoll) + 6399+105 ( 2 0 4307.2926228530 2 5692.7036634351 ) 53.9025902858 (ExtendedPoll) + 6399+106 ( 2 0 4307.1576983999 2 5692.8274495597 ) 53.9025463974 (ExtendedPoll) + 6399+107 ( 2 0 4306.6180005874 2 5693.3225940580 ) 53.9023717283 (ExtendedPoll) + 6399+108 ( 2 0 4304.4592093375 2 5695.3031720513 ) 53.9016872027 (ExtendedPoll) + 6399+109 ( 2 0 4295.8240443380 2 5703.2254840245 ) 53.8991757562 (ExtendedPoll) + 6399+110 ( 2 0 4261.2833843400 2 5734.9147319171 ) 53.8927720075 (ExtendedPoll) + 6399+113 ( 2 0 4261.2854283144 2 5734.9298531621 ) 53.8926060076 (ExtendedPoll) + 6399+114 ( 2 0 4261.2915602373 2 5734.9752168971 ) 53.8921080120 (ExtendedPoll) + 6399+115 ( 2 0 4261.3160879292 2 5735.1566718371 ) 53.8901160910 (ExtendedPoll) + 6399+116 ( 2 0 4261.4141986968 2 5735.8824915973 ) 53.8821493903 (ExtendedPoll) + 6399+117 ( 2 0 4261.5839708086 2 5736.0579414386 ) 53.8789281638 (ExtendedPoll) + 6399+118 ( 2 0 4262.0932871439 2 5736.5842909627 ) 53.8692650726 (ExtendedPoll) + 6399+119 ( 2 0 4262.1303923063 2 5737.5601140852 ) 53.8593995884 (ExtendedPoll) + 6399+127 ( 2 0 4262.0592807423 2 5737.6593344091 ) 53.8590609755 (ExtendedPoll) + 6399+128 ( 2 0 4261.8459460503 2 5737.9569953809 ) 53.8580454076 (ExtendedPoll) + 6399+133 ( 2 0 4261.8066484312 2 5738.0725691654 ) 53.8572649584 (ExtendedPoll) + 6399+134 ( 2 0 4261.6592140538 2 5738.2671580201 ) 53.8566720935 (ExtendedPoll) + 6399+139 ( 2 0 4261.6094206317 2 5738.3786067875 ) 53.8560252022 (ExtendedPoll) + 6399+146 ( 2 0 4261.6039575038 2 5738.3928541111 ) 53.8559345028 (ExtendedPoll) + 6399+147 ( 2 0 4261.5822528497 2 5738.4143071991 ) 53.8559175202 (ExtendedPoll) + 6399+148 ( 2 0 4261.5171388874 2 5738.4786664632 ) 53.8558665878 (ExtendedPoll) + 6399+149 ( 2 0 4261.2566830381 2 5738.7361035197 ) 53.8556630883 (ExtendedPoll) + 6399+150 ( 2 0 4260.2148596411 2 5739.7658517453 ) 53.8548527711 (ExtendedPoll) + 6399+151 ( 2 0 4256.0475660528 2 5743.8848446480 ) 53.8516704284 (ExtendedPoll) + 6399+152 ( 2 0 4239.3783916996 2 5760.3608162588 ) 53.8398857910 (ExtendedPoll) + 6399+153 ( 2 0 4172.7016942871 2 5826.2647027020 ) 53.8079830812 (ExtendedPoll) + 6399+159 ( 2 0 4172.3873666467 2 5827.1893462901 ) 53.8020966299 (ExtendedPoll) + 6399+161 ( 2 0 4171.7493284512 2 5827.9288905621 ) 53.8008851851 (ExtendedPoll) + 6399+162 ( 2 0 4169.8352138647 2 5830.1475233783 ) 53.7972677698 (ExtendedPoll) + 6399+173 ( 2 0 4169.8728479823 2 5830.1263964098 ) 53.7971266241 (ExtendedPoll) + 6399+180 ( 2 0 4169.8744650652 2 5830.1253849637 ) 53.7971215364 (ExtendedPoll) + 6399+188 ( 2 0 4169.8742332961 2 5830.1256298513 ) 53.7971213238 (ExtendedPoll) + 6399+189 ( 2 0 4169.8735379888 2 5830.1263645140 ) 53.7971206859 (ExtendedPoll) + 6399+197 ( 2 0 4169.8735402993 2 5830.1264240738 ) 53.7971201036 (ExtendedPoll) + 6399+202 ( 2 0 4169.8735394760 2 5830.1264538648 ) 53.7971198303 (ExtendedPoll) + 6399+207 ( 2 0 4169.8735316923 2 5830.1264665714 ) 53.7971197809 (ExtendedPoll) + 6399+208 ( 2 0 4169.8735105156 2 5830.1264875411 ) 53.7971197747 (ExtendedPoll) + 6399+209 ( 2 0 4169.8734469856 2 5830.1265504500 ) 53.7971197562 (ExtendedPoll) + 6399+210 ( 2 0 4169.8731928654 2 5830.1268020859 ) 53.7971196820 (ExtendedPoll) + 6399+211 ( 2 0 4169.8721763846 2 5830.1278086295 ) 53.7971193855 (ExtendedPoll) + 6399+212 ( 2 0 4169.8681104615 2 5830.1318348037 ) 53.7971181995 (ExtendedPoll) + 6399+213 ( 2 0 4169.8518467691 2 5830.1479395006 ) 53.7971134562 (ExtendedPoll) + 6399+214 ( 2 0 4169.7867919994 2 5830.2123582880 ) 53.7970944980 (ExtendedPoll) + 6399+215 ( 2 0 4169.5265729207 2 5830.4700334377 ) 53.7970189008 (ExtendedPoll) + 6399+216 ( 2 0 4168.4856966058 2 5831.5007340364 ) 53.7967202870 (ExtendedPoll) + 6399+217 ( 2 0 4164.3221913464 2 5835.6235364314 ) 53.7955862535 (ExtendedPoll) + 6399+218 ( 2 0 4147.6681703088 2 5852.1147460114 ) 53.7920186238 (ExtendedPoll) + 6399+220 ( 2 0 4147.6602068265 2 5852.1752601464 ) 53.7915256228 (ExtendedPoll) + 6399+221 ( 2 0 4147.6363163798 2 5852.3568025514 ) 53.7900466951 (ExtendedPoll) + 6399+229 ( 2 0 4147.6523233123 2 5852.3423304219 ) 53.7900364877 (ExtendedPoll) + 6399+230 ( 2 0 4147.7003441098 2 5852.2989140332 ) 53.7900058731 (ExtendedPoll) + 6399+244 ( 2 0 4147.7008030485 2 5852.2990434509 ) 53.7900004953 (ExtendedPoll) + 6399+246 ( 2 0 4147.7011719978 2 5852.2987413745 ) 53.7899999659 (ExtendedPoll) + 6399+252 ( 2 0 4147.7010771141 2 5852.2988807259 ) 53.7899995260 (ExtendedPoll) + 6399+259 ( 2 0 4147.7010935191 2 5852.2989056067 ) 53.7899991446 (ExtendedPoll) + 6399+268 ( 2 0 4147.7010938504 2 5852.2989059339 ) 53.7899991385 (ExtendedPoll) + 6399+271 ( 2 0 4147.7010940528 2 5852.2989058189 ) 53.7899991377 (ExtendedPoll) + 6399+275 ( 2 0 4147.7010940473 2 5852.2989059352 ) 53.7899991367 (ExtendedPoll) + 6399+282 ( 2 0 4147.7010940274 2 5852.2989059712 ) 53.7899991366 (ExtendedPoll) + 6685+2 ( 2 0 4105.5727993639 2 5894.4271813637 ) 53.7841729375 (ExtendedPoll) + 6685+41 ( 2 0 4105.5727574055 2 5894.4272236982 ) 53.7841729333 (ExtendedPoll) + 6685+42 ( 2 0 4105.5726315303 2 5894.4273507015 ) 53.7841729207 (ExtendedPoll) + 6685+43 ( 2 0 4105.5721280294 2 5894.4278587149 ) 53.7841728703 (ExtendedPoll) + 6685+53 ( 2 0 4105.5721311970 2 5894.4278654586 ) 53.7841727793 (ExtendedPoll) + 6685+57 ( 2 0 4105.5721285679 2 5894.4278680979 ) 53.7841727792 (ExtendedPoll) + 6685+58 ( 2 0 4105.5721206809 2 5894.4278760159 ) 53.7841727787 (ExtendedPoll) + 6685+59 ( 2 0 4105.5720891326 2 5894.4279076878 ) 53.7841727770 (ExtendedPoll) + 6685+60 ( 2 0 4105.5719629396 2 5894.4280343754 ) 53.7841727702 (ExtendedPoll) + 6685+61 ( 2 0 4105.5714581674 2 5894.4285411256 ) 53.7841727431 (ExtendedPoll) + 6685+74 ( 2 0 4105.5714585929 2 5894.4285413146 ) 53.7841727374 (ExtendedPoll) + 6685+81 ( 2 0 4105.5714586508 2 5894.4285413214 ) 53.7841727368 (ExtendedPoll) + 6774+17 ( 2 0 4999.8038288046 2 5000.1453455727 ) 55.9014415188 (ExtendedPoll) + 6774+18 ( 2 0 4999.2153441271 2 5000.5814111994 ) 55.9006678364 (ExtendedPoll) + 6774+19 ( 2 0 4996.8614054169 2 5002.3256737060 ) 55.8975828466 (ExtendedPoll) + 6774+20 ( 2 0 4987.4456505762 2 5009.3027237327 ) 55.8853990072 (ExtendedPoll) + 6774+21 ( 2 0 4949.7826312134 2 5037.2109238395 ) 55.8391796750 (ExtendedPoll) + 6774+22 ( 2 0 4799.1305537620 2 5148.8437242665 ) 55.6957204380 (ExtendedPoll) + 6774+24 ( 2 0 4791.8152923122 2 5162.6007831124 ) 55.5930004110 (ExtendedPoll) + 6774+25 ( 2 0 4769.8695079627 2 5203.8719596503 ) 55.2886042603 (ExtendedPoll) + 6774+27 ( 2 0 4753.7104229690 2 5230.5126132884 ) 55.1111870096 (ExtendedPoll) + 6774+28 ( 2 0 4703.0495078538 2 5267.1981035443 ) 55.1012158213 (ExtendedPoll) + 6774+34 ( 2 0 4699.1189196121 2 5298.2060774510 ) 54.7818521507 (ExtendedPoll) + 6774+37 ( 2 0 4689.4016320146 2 5310.4345742030 ) 54.7232027437 (ExtendedPoll) + 6774+38 ( 2 0 4665.3813705375 2 5330.5242474383 ) 54.6941438059 (ExtendedPoll) + 6774+39 ( 2 0 4593.3205861064 2 5390.7932671444 ) 54.6201919010 (ExtendedPoll) + 6774+40 ( 2 0 4305.0774483818 2 5631.8693459686 ) 54.5320542946 (ExtendedPoll) + 6774+45 ( 2 0 4291.1020235224 2 5693.0118297283 ) 54.0420071399 (ExtendedPoll) + 6774+50 ( 2 0 4279.6378078175 2 5703.6025813796 ) 54.0382097940 (ExtendedPoll) + 6774+51 ( 2 0 4245.2451607026 2 5735.3748363333 ) 54.0307112653 (ExtendedPoll) + 6774+58 ( 2 0 4249.5032979644 2 5750.4420912598 ) 53.8459996564 (ExtendedPoll) + 6774+69 ( 2 0 4249.5962541266 2 5750.3629695656 ) 53.8459422263 (ExtendedPoll) + 6774+76 ( 2 0 4249.6238551729 2 5750.3759885262 ) 53.8455701397 (ExtendedPoll) + 6774+80 ( 2 0 4249.6129514080 2 5750.3866626954 ) 53.8455633271 (ExtendedPoll) + 6774+81 ( 2 0 4249.5802401136 2 5750.4186852027 ) 53.8455428930 (ExtendedPoll) + 6774+82 ( 2 0 4249.4493949358 2 5750.5467752323 ) 53.8454612142 (ExtendedPoll) + 6774+83 ( 2 0 4248.9260142245 2 5751.0591353504 ) 53.8451354192 (ExtendedPoll) + 6774+84 ( 2 0 4246.8324913796 2 5753.1085758229 ) 53.8438469662 (ExtendedPoll) + 6774+85 ( 2 0 4238.4583999999 2 5761.3063377130 ) 53.8389290219 (ExtendedPoll) + 6774+86 ( 2 0 4204.9620344812 2 5794.0973852733 ) 53.8230461425 (ExtendedPoll) + 6774+87 ( 2 0 4070.9765724063 2 5925.2615755146 ) 53.8210579913 (ExtendedPoll) + 6774+92 ( 2 0 4071.7886210187 2 5927.0375053582 ) 53.7974776434 (ExtendedPoll) + 6774+98 ( 2 0 4072.0432392023 2 5927.4540854434 ) 53.7913560161 (ExtendedPoll) + 6774+100 ( 2 0 4071.7200617674 2 5927.8201257384 ) 53.7910242574 (ExtendedPoll) + 6774+101 ( 2 0 4070.7505294627 2 5928.9182466233 ) 53.7900332794 (ExtendedPoll) + 6774+110 ( 2 0 4070.7703482043 2 5929.0386984572 ) 53.7887604316 (ExtendedPoll) + 6774+112 ( 2 0 4070.7520288631 2 5929.1593835311 ) 53.7878375424 (ExtendedPoll) + 6774+114 ( 2 0 4070.6714077684 2 5929.2510402129 ) 53.7877524096 (ExtendedPoll) + 6774+115 ( 2 0 4070.4295444844 2 5929.5260102582 ) 53.7874972799 (ExtendedPoll) + 6774+123 ( 2 0 4070.4383638744 2 5929.5552256590 ) 53.7871515709 (ExtendedPoll) + 6774+129 ( 2 0 4070.4346738395 2 5929.5619033272 ) 53.7871252238 (ExtendedPoll) + 6774+135 ( 2 0 4070.4365087991 2 5929.5624238125 ) 53.7871035769 (ExtendedPoll) + 6774+139 ( 2 0 4070.4373937138 2 5929.5620682560 ) 53.7870986249 (ExtendedPoll) + 6774+141 ( 2 0 4070.4382753416 2 5929.5617046258 ) 53.7870937763 (ExtendedPoll) + 6774+149 ( 2 0 4070.4383956527 2 5929.5615865285 ) 53.7870937340 (ExtendedPoll) + 6774+150 ( 2 0 4070.4387565859 2 5929.5612322368 ) 53.7870936074 (ExtendedPoll) + 6774+158 ( 2 0 4070.4387684909 2 5929.5612232749 ) 53.7870935786 (ExtendedPoll) + 6774+161 ( 2 0 4070.4387865750 2 5929.5612124557 ) 53.7870935095 (ExtendedPoll) + 6774+169 ( 2 0 4070.4387882509 2 5929.5612116428 ) 53.7870935014 (ExtendedPoll) + 6774+177 ( 2 0 4070.4387881954 2 5929.5612117452 ) 53.7870935010 (ExtendedPoll) + 6774+179 ( 2 0 4070.4387882946 2 5929.5612116843 ) 53.7870935006 (ExtendedPoll) + 6961+15 ( 2 0 4999.8058280052 2 5000.1479845174 ) 55.9013939424 (ExtendedPoll) + 6961+16 ( 2 0 4999.2233409293 2 5000.5919669783 ) 55.9004775395 (ExtendedPoll) + 6961+17 ( 2 0 4996.8933926259 2 5002.3678968219 ) 55.8968217946 (ExtendedPoll) + 6961+18 ( 2 0 4987.5735994122 2 5009.4716161962 ) 55.8823569716 (ExtendedPoll) + 6961+19 ( 2 0 4950.2944265573 2 5037.8864936935 ) 55.8270464781 (ExtendedPoll) + 6961+20 ( 2 0 4801.1777351379 2 5151.5460036826 ) 55.6477582520 (ExtendedPoll) + 6961+23 ( 2 0 4799.7583560506 2 5167.1591736427 ) 55.4764322556 (ExtendedPoll) + 6961+26 ( 2 0 4792.1155455806 2 5180.8070494820 ) 55.3782799039 (ExtendedPoll) + 6961+27 ( 2 0 4769.1871141707 2 5221.7506769997 ) 55.0876212670 (ExtendedPoll) + 6961+31 ( 2 0 4761.8718527209 2 5235.6169188523 ) 54.9868701218 (ExtendedPoll) + 6961+34 ( 2 0 4749.6433559689 2 5245.3342064498 ) 54.9738791762 (ExtendedPoll) + 6961+35 ( 2 0 4712.9578657131 2 5274.4860692424 ) 54.9380022491 (ExtendedPoll) + 6961+36 ( 2 0 4566.2159046897 2 5391.0935204128 ) 54.8421122279 (ExtendedPoll) + 6961+38 ( 2 0 4475.3756431037 2 5474.9460695691 ) 54.6975024335 (ExtendedPoll) + 6961+39 ( 2 0 4202.8548583459 2 5726.5037170378 ) 54.4953088368 (ExtendedPoll) + 6961+50 ( 2 0 4223.8179956350 2 5749.6505144612 ) 54.0825598595 (ExtendedPoll) + 6961+52 ( 2 0 4202.8548583459 2 5772.7973118845 ) 54.0462974249 (ExtendedPoll) + 6961+53 ( 2 0 4139.9654464788 2 5842.2377041545 ) 53.9544164694 (ExtendedPoll) + 6961+59 ( 2 0 4139.3103484385 2 5857.8508741146 ) 53.8144735666 (ExtendedPoll) + 6961+66 ( 2 0 4138.2372842006 2 5859.4835012619 ) 53.8090274109 (ExtendedPoll) + 6961+67 ( 2 0 4135.0180914870 2 5864.3813827037 ) 53.7927617458 (ExtendedPoll) + 6961+75 ( 2 0 4135.1400160653 2 5864.5928981232 ) 53.7896852883 (ExtendedPoll) + 6961+77 ( 2 0 4135.3836253179 2 5864.5767445826 ) 53.7876169219 (ExtendedPoll) + 6961+86 ( 2 0 4135.3975076833 2 5864.5830777793 ) 53.7874316321 (ExtendedPoll) + 6961+87 ( 2 0 4135.4221274217 2 5864.5650445737 ) 53.7873750497 (ExtendedPoll) + 6961+91 ( 2 0 4135.4358288178 2 5864.5583287176 ) 53.7873127014 (ExtendedPoll) + 6961+96 ( 2 0 4135.4417746173 2 5864.5535479991 ) 53.7873029931 (ExtendedPoll) + 6961+97 ( 2 0 4135.4596120157 2 5864.5392058436 ) 53.7872738692 (ExtendedPoll) + 6961+108 ( 2 0 4135.4600654422 2 5864.5390582696 ) 53.7872711118 (ExtendedPoll) + 6961+109 ( 2 0 4135.4609366779 2 5864.5386703998 ) 53.7872667832 (ExtendedPoll) + 6961+114 ( 2 0 4135.4606620754 2 5864.5390602294 ) 53.7872656603 (ExtendedPoll) + 6961+119 ( 2 0 4135.4605743562 2 5864.5392819246 ) 53.7872643984 (ExtendedPoll) + 6961+121 ( 2 0 4135.4610972036 2 5864.5388560396 ) 53.7872635958 (ExtendedPoll) + 6961+126 ( 2 0 4135.4612010194 2 5864.5387974466 ) 53.7872631950 (ExtendedPoll) + 6961+137 ( 2 0 4135.4612024119 2 5864.5387962096 ) 53.7872631938 (ExtendedPoll) + 6961+138 ( 2 0 4135.4612065894 2 5864.5387924983 ) 53.7872631903 (ExtendedPoll) + 6961+145 ( 2 0 4135.4612070035 2 5864.5387922853 ) 53.7872631885 (ExtendedPoll) + 6961+146 ( 2 0 4135.4612082457 2 5864.5387916463 ) 53.7872631831 (ExtendedPoll) + 6961+156 ( 2 0 4135.4612082147 2 5864.5387916956 ) 53.7872631829 (ExtendedPoll) + 6961+157 ( 2 0 4135.4612081217 2 5864.5387918434 ) 53.7872631824 (ExtendedPoll) + 6961+163 ( 2 0 4135.4612081460 2 5864.5387918272 ) 53.7872631824 (ExtendedPoll) + 6961+164 ( 2 0 4135.4612082186 2 5864.5387917788 ) 53.7872631821 (ExtendedPoll) + 7131+3 ( 2 0 4874.2211666294 2 5125.7788140982 ) 55.3724275680 (ExtendedPoll) + 7131+4 ( 2 0 4496.8846954264 2 5503.1152853013 ) 54.2156316564 (ExtendedPoll) + 7131+39 ( 2 0 4496.8846529014 2 5503.1153270666 ) 54.2156315732 (ExtendedPoll) + 7131+40 ( 2 0 4496.8845253266 2 5503.1154523626 ) 54.2156313235 (ExtendedPoll) + 7131+41 ( 2 0 4496.8840150275 2 5503.1159535467 ) 54.2156303249 (ExtendedPoll) + 7131+42 ( 2 0 4496.8819738307 2 5503.1179582832 ) 54.2156263303 (ExtendedPoll) + 7131+43 ( 2 0 4496.8738090439 2 5503.1259772290 ) 54.2156103523 (ExtendedPoll) + 7131+44 ( 2 0 4496.8411498966 2 5503.1580530122 ) 54.2155464435 (ExtendedPoll) + 7131+45 ( 2 0 4496.7105133072 2 5503.2863561450 ) 54.2152908615 (ExtendedPoll) + 7131+46 ( 2 0 4496.1879669499 2 5503.7995686762 ) 54.2142693849 (ExtendedPoll) + 7131+47 ( 2 0 4494.0977815204 2 5505.8524188009 ) 54.2101971068 (ExtendedPoll) + 7131+48 ( 2 0 4485.7370398025 2 5514.0638192997 ) 54.1941263256 (ExtendedPoll) + 7131+49 ( 2 0 4452.2940729307 2 5546.9094212948 ) 54.1333544119 (ExtendedPoll) + 7131+50 ( 2 0 4318.5222054439 2 5678.2918292755 ) 53.9475643989 (ExtendedPoll) + 7131+53 ( 2 0 4318.5963891128 2 5678.5244295969 ) 53.9445911411 (ExtendedPoll) + 7131+54 ( 2 0 4318.8189401194 2 5679.2222305612 ) 53.9356722784 (ExtendedPoll) + 7131+55 ( 2 0 4318.7890853910 2 5680.1984801799 ) 53.9261887566 (ExtendedPoll) + 7131+56 ( 2 0 4317.9105033838 2 5681.9437023028 ) 53.9164801493 (ExtendedPoll) + 7131+63 ( 2 0 4317.7577644608 2 5682.1341594764 ) 53.9159200953 (ExtendedPoll) + 7131+69 ( 2 0 4317.7221920188 2 5682.1837563103 ) 53.9157374211 (ExtendedPoll) + 7131+70 ( 2 0 4317.6154746928 2 5682.3325468122 ) 53.9151894649 (ExtendedPoll) + 7131+74 ( 2 0 4317.6823945996 2 5682.2780286129 ) 53.9151462258 (ExtendedPoll) + 7131+75 ( 2 0 4317.8831543201 2 5682.1144740148 ) 53.9150166207 (ExtendedPoll) + 7131+87 ( 2 0 4317.8850608152 2 5682.1144169722 ) 53.9150004675 (ExtendedPoll) + 7131+92 ( 2 0 4317.8855375905 2 5682.1144246562 ) 53.9149962090 (ExtendedPoll) + 7131+100 ( 2 0 4317.8855643890 2 5682.1144116170 ) 53.9149961040 (ExtendedPoll) + 7131+105 ( 2 0 4317.8855791781 2 5682.1144097931 ) 53.9149959925 (ExtendedPoll) + 7131+107 ( 2 0 4317.8855925920 2 5682.1144033038 ) 53.9149959395 (ExtendedPoll) + 7131+111 ( 2 0 4317.8855821380 2 5682.1144139226 ) 53.9149959253 (ExtendedPoll) + 7131+112 ( 2 0 4317.8855507760 2 5682.1144457789 ) 53.9149958826 (ExtendedPoll) + 7131+113 ( 2 0 4317.8854253280 2 5682.1145732043 ) 53.9149957120 (ExtendedPoll) + 7131+120 ( 2 0 4317.8854184488 2 5682.1145811854 ) 53.9149956927 (ExtendedPoll) + 7131+129 ( 2 0 4317.8854186637 2 5682.1145810957 ) 53.9149956917 (ExtendedPoll) + 7131+136 ( 2 0 4317.8854187880 2 5682.1145812036 ) 53.9149956895 (ExtendedPoll) + 7275+1 ( 2 0 4664.5897937388 2 5335.4101869888 ) 54.6460177074 (ExtendedPoll) + 7275+2 ( 2 0 3658.3592038639 2 6341.6407768637 ) 54.3665218070 (ExtendedPoll) + 7275+37 ( 2 0 3658.3592901848 2 6341.6406946471 ) 54.3665215475 (ExtendedPoll) + 7275+38 ( 2 0 3658.3595491473 2 6341.6404479973 ) 54.3665207691 (ExtendedPoll) + 7275+39 ( 2 0 3658.3598690753 2 6341.6400944160 ) 54.3665201699 (ExtendedPoll) + 7275+40 ( 2 0 3658.3608288593 2 6341.6390336723 ) 54.3665183724 (ExtendedPoll) + 7275+41 ( 2 0 3658.3646679955 2 6341.6347906973 ) 54.3665111823 (ExtendedPoll) + 7275+42 ( 2 0 3658.3800245403 2 6341.6178187975 ) 54.3664824230 (ExtendedPoll) + 7275+43 ( 2 0 3658.4414507195 2 6341.5499311982 ) 54.3663674021 (ExtendedPoll) + 7275+44 ( 2 0 3658.6871554362 2 6341.2783808011 ) 54.3659075842 (ExtendedPoll) + 7275+45 ( 2 0 3659.6699743029 2 6340.1921792124 ) 54.3640725584 (ExtendedPoll) + 7275+46 ( 2 0 3663.6012497698 2 6335.8473728577 ) 54.3568003795 (ExtendedPoll) + 7275+47 ( 2 0 3679.3263516374 2 6318.4681474388 ) 54.3287978530 (ExtendedPoll) + 7275+48 ( 2 0 3742.2267591076 2 6248.9512457632 ) 54.2341245206 (ExtendedPoll) + 7275+49 ( 2 0 3993.8283889887 2 5970.8836390611 ) 54.1291421044 (ExtendedPoll) + 7275+51 ( 2 0 3994.6101563766 2 5970.2984863845 ) 54.1270135487 (ExtendedPoll) + 7275+52 ( 2 0 3996.9554585404 2 5968.5430283547 ) 54.1206429804 (ExtendedPoll) + 7275+53 ( 2 0 4006.3366671954 2 5961.5211962354 ) 54.0953869891 (ExtendedPoll) + 7275+54 ( 2 0 4043.8615018154 2 5933.4338677582 ) 53.9979707862 (ExtendedPoll) + 7275+55 ( 2 0 4058.8195737352 2 5928.7389984696 ) 53.9018789159 (ExtendedPoll) + 7275+56 ( 2 0 4085.0234953465 2 5911.2697173953 ) 53.8187819628 (ExtendedPoll) + 7275+62 ( 2 0 4079.2095002390 2 5920.6867517244 ) 53.7866402997 (ExtendedPoll) + 7275+75 ( 2 0 4079.1688898115 2 5920.8018656928 ) 53.7859692077 (ExtendedPoll) + 7275+79 ( 2 0 4079.1419239280 2 5920.8566204642 ) 53.7857204969 (ExtendedPoll) + 7275+92 ( 2 0 4079.1420265196 2 5920.8575686043 ) 53.7857109426 (ExtendedPoll) + 7275+94 ( 2 0 4079.1415632502 2 5920.8584021968 ) 53.7857076422 (ExtendedPoll) + 7275+101 ( 2 0 4079.1418084008 2 5920.8581707058 ) 53.7857074853 (ExtendedPoll) + 7275+109 ( 2 0 4079.1417949665 2 5920.8581973084 ) 53.7857073675 (ExtendedPoll) + 7275+116 ( 2 0 4079.1417913882 2 5920.8582038435 ) 53.7857073412 (ExtendedPoll) + 7275+120 ( 2 0 4079.1417981276 2 5920.8582006667 ) 53.7857073079 (ExtendedPoll) + 7275+130 ( 2 0 4079.1417985233 2 5920.8582009121 ) 53.7857073020 (ExtendedPoll) + 7275+131 ( 2 0 4079.1417993958 2 5920.8582005863 ) 53.7857072969 (ExtendedPoll) + 7275+139 ( 2 0 4079.1417992378 2 5920.8582007573 ) 53.7857072968 (ExtendedPoll) + 7423+14 ( 2 0 4999.1900742320 2 5000.5459053974 ) 55.9012953652 (ExtendedPoll) + 7423+15 ( 2 0 4996.7603258365 2 5002.1836504981 ) 55.9000925053 (ExtendedPoll) + 7423+16 ( 2 0 4987.0413322545 2 5008.7346309009 ) 55.8954303274 (ExtendedPoll) + 7423+17 ( 2 0 4948.1653579264 2 5034.9385525122 ) 55.8791873269 (ExtendedPoll) + 7423+18 ( 2 0 4792.6614606142 2 5139.7542389575 ) 55.8538338094 (ExtendedPoll) + 7423+20 ( 2 0 4775.1921795400 2 5165.9581605689 ) 55.6864877206 (ExtendedPoll) + 7423+21 ( 2 0 4722.7843363173 2 5244.5699254029 ) 55.1994445339 (ExtendedPoll) + 7423+26 ( 2 0 4722.3476042905 2 5276.0146313364 ) 54.8445124513 (ExtendedPoll) + 7423+29 ( 2 0 4697.8906107866 2 5295.6675725449 ) 54.8205115310 (ExtendedPoll) + 7423+30 ( 2 0 4624.5196302749 2 5354.6263961704 ) 54.7613812550 (ExtendedPoll) + 7423+31 ( 2 0 4331.0357082280 2 5590.4616906724 ) 54.7273149903 (ExtendedPoll) + 7423+36 ( 2 0 4308.3256428315 2 5648.1103182173 ) 54.3396439948 (ExtendedPoll) + 7423+38 ( 2 0 4455.0676038550 2 5543.2946317720 ) 54.1475041698 (ExtendedPoll) + 7423+47 ( 2 0 4447.5339763917 2 5551.3741742688 ) 54.1273594464 (ExtendedPoll) + 7423+58 ( 2 0 4447.2091995963 2 5551.7388284514 ) 54.1263276850 (ExtendedPoll) + 7423+59 ( 2 0 4446.2348692102 2 5552.8327909991 ) 54.1232362635 (ExtendedPoll) + 7423+60 ( 2 0 4442.3375476659 2 5557.2086411901 ) 54.1109285550 (ExtendedPoll) + 7423+69 ( 2 0 4442.5740664204 2 5557.2691503271 ) 54.1082748289 (ExtendedPoll) + 7423+73 ( 2 0 4442.6925323818 2 5557.2986052154 ) 54.1069545527 (ExtendedPoll) + 7423+79 ( 2 0 4442.7168164211 2 5557.2801226062 ) 54.1069394344 (ExtendedPoll) + 7423+82 ( 2 0 4442.7071793373 2 5557.2919529796 ) 54.1068985868 (ExtendedPoll) + 7423+86 ( 2 0 4442.7017183179 2 5557.2972807450 ) 54.1068897802 (ExtendedPoll) + 7423+87 ( 2 0 4442.6853352597 2 5557.3132640411 ) 54.1068633612 (ExtendedPoll) + 7423+88 ( 2 0 4442.6198030272 2 5557.3771972256 ) 54.1067576985 (ExtendedPoll) + 7423+89 ( 2 0 4442.3576740969 2 5557.6329299635 ) 54.1063352645 (ExtendedPoll) + 7423+90 ( 2 0 4441.3091583760 2 5558.6558609153 ) 54.1046489915 (ExtendedPoll) + 7423+91 ( 2 0 4437.1150954922 2 5562.7475847223 ) 54.0979593435 (ExtendedPoll) + 7423+92 ( 2 0 4420.3388439569 2 5579.1144799504 ) 54.0720900340 (ExtendedPoll) + 7423+93 ( 2 0 4353.2338378159 2 5644.5820608629 ) 53.9829787440 (ExtendedPoll) + 7423+94 ( 2 0 4084.8138132516 2 5906.4523845126 ) 53.8646582524 (ExtendedPoll) + 7423+96 ( 2 0 4082.5755616140 2 5909.6528113969 ) 53.8560492754 (ExtendedPoll) + 7423+97 ( 2 0 4075.8608067011 2 5919.2540920498 ) 53.8305130308 (ExtendedPoll) + 7423+98 ( 2 0 4066.9078001506 2 5932.0285038353 ) 53.7973908395 (ExtendedPoll) + 7423+110 ( 2 0 4066.8994834762 2 5932.5167352687 ) 53.7930561968 (ExtendedPoll) + 7423+113 ( 2 0 4066.7294181484 2 5932.9744722294 ) 53.7904920157 (ExtendedPoll) + 7423+115 ( 2 0 4066.4042148569 2 5933.3386999159 ) 53.7902064369 (ExtendedPoll) + 7423+116 ( 2 0 4065.4286049825 2 5934.4313829753 ) 53.7893539893 (ExtendedPoll) + 7423+122 ( 2 0 4065.9681225742 2 5934.0003020220 ) 53.7882608591 (ExtendedPoll) + 7423+134 ( 2 0 4065.9833434669 2 5933.9992277641 ) 53.7881299256 (ExtendedPoll) + 7423+135 ( 2 0 4066.0088195296 2 5933.9824261494 ) 53.7880462489 (ExtendedPoll) + 7423+138 ( 2 0 4066.0322468281 2 5933.9628689699 ) 53.7880063853 (ExtendedPoll) + 7423+149 ( 2 0 4066.0333397798 2 5933.9653350231 ) 53.7879740199 (ExtendedPoll) + 7423+154 ( 2 0 4066.0330666936 2 5933.9662487622 ) 53.7879682924 (ExtendedPoll) + 7423+160 ( 2 0 4066.0329389515 2 5933.9664500713 ) 53.7879676549 (ExtendedPoll) + 7423+161 ( 2 0 4066.0325557253 2 5933.9670539988 ) 53.7879657426 (ExtendedPoll) + 7423+164 ( 2 0 4066.0323799541 2 5933.9674972574 ) 53.7879633642 (ExtendedPoll) + 7423+171 ( 2 0 4066.0324936658 2 5933.9674614732 ) 53.7879626367 (ExtendedPoll) + 7423+175 ( 2 0 4066.0325420577 2 5933.9674266746 ) 53.7879625038 (ExtendedPoll) + 7423+180 ( 2 0 4066.0325530871 2 5933.9674366944 ) 53.7879623114 (ExtendedPoll) + 7423+181 ( 2 0 4066.0325776078 2 5933.9674197559 ) 53.7879622378 (ExtendedPoll) + 7423+192 ( 2 0 4066.0325784803 2 5933.9674194301 ) 53.7879622327 (ExtendedPoll) + 7423+193 ( 2 0 4066.0325810978 2 5933.9674184529 ) 53.7879622173 (ExtendedPoll) + 7423+197 ( 2 0 4066.0325804614 2 5933.9674191328 ) 53.7879622170 (ExtendedPoll) + 7423+198 ( 2 0 4066.0325785520 2 5933.9674211726 ) 53.7879622163 (ExtendedPoll) + 7423+203 ( 2 0 4066.0325782752 2 5933.9674215470 ) 53.7879622154 (ExtendedPoll) + 7423+206 ( 2 0 4066.0325779836 2 5933.9674219101 ) 53.7879622149 (ExtendedPoll) + 7423+208 ( 2 0 4066.0325777001 2 5933.9674222795 ) 53.7879622141 (ExtendedPoll) + 7423+214 ( 2 0 4066.0325779310 2 5933.9674220447 ) 53.7879622141 (ExtendedPoll) + 7423+215 ( 2 0 4066.0325786236 2 5933.9674213404 ) 53.7879622141 (ExtendedPoll) + 7423+216 ( 2 0 4066.0325813941 2 5933.9674185232 ) 53.7879622139 (ExtendedPoll) + 7423+217 ( 2 0 4066.0325924760 2 5933.9674072542 ) 53.7879622133 (ExtendedPoll) + 7423+218 ( 2 0 4066.0326368038 2 5933.9673621781 ) 53.7879622107 (ExtendedPoll) + 7423+219 ( 2 0 4066.0328141148 2 5933.9671818738 ) 53.7879622005 (ExtendedPoll) + 7423+220 ( 2 0 4066.0335233590 2 5933.9664606566 ) 53.7879621598 (ExtendedPoll) + 7423+221 ( 2 0 4066.0363603358 2 5933.9635757879 ) 53.7879619968 (ExtendedPoll) + 7423+222 ( 2 0 4066.0477082430 2 5933.9520363132 ) 53.7879613453 (ExtendedPoll) + 7423+223 ( 2 0 4066.0930998717 2 5933.9058784143 ) 53.7879587467 (ExtendedPoll) + 7423+224 ( 2 0 4066.2746663863 2 5933.7212468186 ) 53.7879484746 (ExtendedPoll) + 7423+225 ( 2 0 4067.0009324450 2 5932.9827204360 ) 53.7879093366 (ExtendedPoll) + 7423+226 ( 2 0 4069.9059966798 2 5930.0286149054 ) 53.7877839844 (ExtendedPoll) + 7423+227 ( 2 0 4081.5262536188 2 5918.2121927832 ) 53.7877812112 (ExtendedPoll) + 7423+230 ( 2 0 4081.5299687022 2 5918.2130588562 ) 53.7877391250 (ExtendedPoll) + 7423+231 ( 2 0 4081.5411139525 2 5918.2156570750 ) 53.7876128665 (ExtendedPoll) + 7423+232 ( 2 0 4081.5856949536 2 5918.2260499504 ) 53.7871078341 (ExtendedPoll) + 7423+233 ( 2 0 4081.6155830020 2 5918.2198824166 ) 53.7868886494 (ExtendedPoll) + 7423+234 ( 2 0 4081.7052471472 2 5918.2013798154 ) 53.7862311047 (ExtendedPoll) + 7423+236 ( 2 0 4081.6080460159 2 5918.3440427676 ) 53.7858294673 (ExtendedPoll) + 7423+240 ( 2 0 4081.5880590083 2 5918.4017130398 ) 53.7854893417 (ExtendedPoll) + 7423+247 ( 2 0 4081.6043092810 2 5918.3875148632 ) 53.7854687399 (ExtendedPoll) + 7423+248 ( 2 0 4081.6530600991 2 5918.3449203333 ) 53.7854069422 (ExtendedPoll) + 7423+257 ( 2 0 4081.6496579113 2 5918.3491070966 ) 53.7854002178 (ExtendedPoll) + 7423+266 ( 2 0 4081.6498661605 2 5918.3495360557 ) 53.7853944010 (ExtendedPoll) + 7423+267 ( 2 0 4081.6493358875 2 5918.3503287128 ) 53.7853920795 (ExtendedPoll) + 7423+274 ( 2 0 4081.6491972063 2 5918.3505226482 ) 53.7853915938 (ExtendedPoll) + 7423+275 ( 2 0 4081.6487811625 2 5918.3511044543 ) 53.7853901369 (ExtendedPoll) + 7423+284 ( 2 0 4081.6488121122 2 5918.3511553938 ) 53.7853893889 (ExtendedPoll) + 7423+287 ( 2 0 4081.6488409573 2 5918.3511479011 ) 53.7853891913 (ExtendedPoll) + 7423+293 ( 2 0 4081.6488473913 2 5918.3511516580 ) 53.7853890979 (ExtendedPoll) + 7423+298 ( 2 0 4081.6488480521 2 5918.3511510017 ) 53.7853890978 (ExtendedPoll) + 7423+299 ( 2 0 4081.6488500345 2 5918.3511490328 ) 53.7853890974 (ExtendedPoll) + 7423+300 ( 2 0 4081.6488579640 2 5918.3511411574 ) 53.7853890960 (ExtendedPoll) + 7423+301 ( 2 0 4081.6488896822 2 5918.3511096556 ) 53.7853890902 (ExtendedPoll) + 7423+310 ( 2 0 4081.6488900669 2 5918.3511093933 ) 53.7853890891 (ExtendedPoll) + 7423+311 ( 2 0 4081.6488912210 2 5918.3511086061 ) 53.7853890856 (ExtendedPoll) + 7423+319 ( 2 0 4081.6488912536 2 5918.3511087179 ) 53.7853890843 (ExtendedPoll) + 7423+323 ( 2 0 4081.6488912181 2 5918.3511087641 ) 53.7853890842 (ExtendedPoll) + 7752 ( 3 0 3209.7898482266 2 3041.1228583258 1 3749.0872770800 ) 46.5944609002 + 7753 ( 3 0 3209.7897367750 2 3041.1229969359 1 3749.0872586356 ) 46.5944605757 + 7758+32 ( 2 0 4999.9999577432 2 5000.0000417347 ) 55.9016992549 (ExtendedPoll) + 7758+39 ( 2 0 4999.9999505368 2 5000.0000494217 ) 55.9016992168 (ExtendedPoll) + 7758+40 ( 2 0 4999.9999398266 2 5000.0000597821 ) 55.9016991732 (ExtendedPoll) + 7758+41 ( 2 0 4999.9999076961 2 5000.0000908630 ) 55.9016990423 (ExtendedPoll) + 7758+42 ( 2 0 4999.9997791737 2 5000.0002151869 ) 55.9016985186 (ExtendedPoll) + 7758+43 ( 2 0 4999.9992650844 2 5000.0007124825 ) 55.9016964242 (ExtendedPoll) + 7758+44 ( 2 0 4999.9972087269 2 5000.0027016649 ) 55.9016880465 (ExtendedPoll) + 7758+45 ( 2 0 4999.9889832972 2 5000.0106583944 ) 55.9016545357 (ExtendedPoll) + 7758+46 ( 2 0 4999.9560815784 2 5000.0424853122 ) 55.9015204952 (ExtendedPoll) + 7758+47 ( 2 0 4999.8244747033 2 5000.1697929837 ) 55.9009843757 (ExtendedPoll) + 7758+48 ( 2 0 4999.2980472026 2 5000.6790236696 ) 55.8988405794 (ExtendedPoll) + 7758+49 ( 2 0 4997.1923371998 2 5002.7159464134 ) 55.8902763014 (ExtendedPoll) + 7758+50 ( 2 0 4988.7694971886 2 5010.8636373882 ) 55.8561940243 (ExtendedPoll) + 7758+51 ( 2 0 4955.0781371440 2 5043.4544012877 ) 55.7226824798 (ExtendedPoll) + 7758+52 ( 2 0 4820.3126969657 2 5173.8174568856 ) 55.2350077198 (ExtendedPoll) + 7758+53 ( 2 0 4281.2509362523 2 5695.2696792774 ) 54.1064641659 (ExtendedPoll) + 7758+55 ( 2 0 4281.1646507560 2 5695.4980679496 ) 54.1049615847 (ExtendedPoll) + 7758+56 ( 2 0 4280.9057942672 2 5696.1832339664 ) 54.1004549928 (ExtendedPoll) + 7758+57 ( 2 0 4279.8703683119 2 5698.9238980333 ) 54.0824459107 (ExtendedPoll) + 7758+58 ( 2 0 4275.7286644908 2 5709.8865543012 ) 54.0106865894 (ExtendedPoll) + 7758+59 ( 2 0 4276.7931988063 2 5713.6465440949 ) 53.9642063625 (ExtendedPoll) + 7758+60 ( 2 0 4274.1455108935 2 5720.9891012964 ) 53.9153574311 (ExtendedPoll) + 7758+61 ( 2 0 4264.8649553228 2 5733.5451470685 ) 53.8744070070 (ExtendedPoll) + 7758+68 ( 2 0 4267.0690872708 2 5731.8801062161 ) 53.8711681165 (ExtendedPoll) + 7758+71 ( 2 0 4268.6471229147 2 5730.7285666922 ) 53.8684637360 (ExtendedPoll) + 7758+80 ( 2 0 4268.8897458950 2 5730.7013509085 ) 53.8665809105 (ExtendedPoll) + 7758+83 ( 2 0 4269.1151490944 2 5730.6075484182 ) 53.8655030390 (ExtendedPoll) + 7758+88 ( 2 0 4269.2342348079 2 5730.5807124826 ) 53.8647110142 (ExtendedPoll) + 7758+91 ( 2 0 4269.3362140286 2 5730.5136259757 ) 53.8644648872 (ExtendedPoll) + 7758+92 ( 2 0 4269.6421516907 2 5730.3123664551 ) 53.8637267148 (ExtendedPoll) + 7758+99 ( 2 0 4269.6705853207 2 5730.3012821375 ) 53.8635834586 (ExtendedPoll) + 7758+104 ( 2 0 4269.6856215996 2 5730.3038783910 ) 53.8634248321 (ExtendedPoll) + 7758+107 ( 2 0 4269.6932509707 2 5730.3038560301 ) 53.8633574718 (ExtendedPoll) + 7758+111 ( 2 0 4269.6964158444 2 5730.3017263609 ) 53.8633503046 (ExtendedPoll) + 7758+119 ( 2 0 4269.6971078879 2 5730.3023825398 ) 53.8633377454 (ExtendedPoll) + 7758+120 ( 2 0 4269.6986534873 2 5730.3012649089 ) 53.8633350054 (ExtendedPoll) + 7758+129 ( 2 0 4269.6987532838 2 5730.3011997053 ) 53.8633347603 (ExtendedPoll) + 7758+137 ( 2 0 4269.6987734099 2 5730.3012216853 ) 53.8633343667 (ExtendedPoll) + 7758+139 ( 2 0 4269.6987532218 2 5730.3012436083 ) 53.8633343307 (ExtendedPoll) + 7758+146 ( 2 0 4269.6987565277 2 5730.3012418911 ) 53.8633343182 (ExtendedPoll) + 7758+148 ( 2 0 4269.6987598023 2 5730.3012401148 ) 53.8633343066 (ExtendedPoll) + 7758+158 ( 2 0 4269.6987598456 2 5730.3012400760 ) 53.8633343066 (ExtendedPoll) + 7758+159 ( 2 0 4269.6987599757 2 5730.3012399595 ) 53.8633343066 (ExtendedPoll) + 7758+160 ( 2 0 4269.6987604960 2 5730.3012394935 ) 53.8633343066 (ExtendedPoll) + 7928 ( 3 0 3209.7896557217 2 3041.1230842797 1 3749.0872551315 ) 46.5944603702 + 7933+5 ( 2 0 4909.1597359805 2 5083.8525467227 ) 55.5960690117 (ExtendedPoll) + 7933+6 ( 2 0 4636.6389512227 2 5335.4101941914 ) 54.8753884193 (ExtendedPoll) + 7933+10 ( 2 0 4468.9338529103 2 5503.1152925039 ) 54.4525845141 (ExtendedPoll) + 7933+11 ( 2 0 3965.8185579728 2 6006.2305874414 ) 54.0810898671 (ExtendedPoll) + 7933+19 ( 2 0 4063.6465319884 2 5929.3657507148 ) 53.8515922697 (ExtendedPoll) + 7933+32 ( 2 0 4065.8046023555 2 5931.0905010240 ) 53.8160592307 (ExtendedPoll) + 7933+33 ( 2 0 4064.4534626474 2 5934.7549556868 ) 53.7954447026 (ExtendedPoll) + 7933+39 ( 2 0 4065.1985513690 2 5934.1237414293 ) 53.7942572358 (ExtendedPoll) + 7933+40 ( 2 0 4067.4338175338 2 5932.2300986566 ) 53.7907104457 (ExtendedPoll) + 7933+47 ( 2 0 4067.6763605460 2 5932.2578742164 ) 53.7882192511 (ExtendedPoll) + 7933+56 ( 2 0 4067.6961659596 2 5932.2810920154 ) 53.7878265281 (ExtendedPoll) + 7933+64 ( 2 0 4067.7064620507 2 5932.2843178088 ) 53.7877022834 (ExtendedPoll) + 7933+68 ( 2 0 4067.7096029627 2 5932.2864826593 ) 53.7876537119 (ExtendedPoll) + 7933+69 ( 2 0 4067.7163863700 2 5932.2829908004 ) 53.7876226117 (ExtendedPoll) + 7933+81 ( 2 0 4067.7165647188 2 5932.2828325755 ) 53.7876223942 (ExtendedPoll) + 7933+82 ( 2 0 4067.7170997651 2 5932.2823579007 ) 53.7876217416 (ExtendedPoll) + 7933+83 ( 2 0 4067.7192399506 2 5932.2804592016 ) 53.7876191311 (ExtendedPoll) + 7933+86 ( 2 0 4067.7200409230 2 5932.2799415742 ) 53.7876164105 (ExtendedPoll) + 7933+101 ( 2 0 4067.7200445311 2 5932.2799480928 ) 53.7876163183 (ExtendedPoll) + 7933+105 ( 2 0 4067.7200436470 2 5932.2799517117 ) 53.7876162938 (ExtendedPoll) + 7933+110 ( 2 0 4067.7200455038 2 5932.2799515643 ) 53.7876162780 (ExtendedPoll) + 7933+111 ( 2 0 4067.7200489601 2 5932.2799501743 ) 53.7876162586 (ExtendedPoll) + 7933+119 ( 2 0 4067.7200493934 2 5932.2799500040 ) 53.7876162561 (ExtendedPoll) + 7933+122 ( 2 0 4067.7200493924 2 5932.2799504696 ) 53.7876162519 (ExtendedPoll) + 7933+129 ( 2 0 4067.7200493199 2 5932.2799505607 ) 53.7876162518 (ExtendedPoll) + 7933+130 ( 2 0 4067.7200491022 2 5932.2799508337 ) 53.7876162513 (ExtendedPoll) + 7933+141 ( 2 0 4067.7200491111 2 5932.2799508739 ) 53.7876162509 (ExtendedPoll) + 8079+2 ( 2 0 4664.5898009415 2 5335.4101941914 ) 54.6460175679 (ExtendedPoll) + 8079+3 ( 2 0 3658.3592110666 2 6341.6407840663 ) 54.3665216810 (ExtendedPoll) + 8079+47 ( 2 0 3658.3592086607 2 6341.6407911178 ) 54.3665216529 (ExtendedPoll) + 8079+49 ( 2 0 3658.3592231902 2 6341.6407758540 ) 54.3665216198 (ExtendedPoll) + 8079+50 ( 2 0 3658.3592667787 2 6341.6407300627 ) 54.3665215205 (ExtendedPoll) + 8079+51 ( 2 0 3658.3594411326 2 6341.6405468973 ) 54.3665211233 (ExtendedPoll) + 8079+52 ( 2 0 3658.3601385484 2 6341.6398142359 ) 54.3665195344 (ExtendedPoll) + 8079+53 ( 2 0 3658.3629282116 2 6341.6368835902 ) 54.3665131789 (ExtendedPoll) + 8079+54 ( 2 0 3658.3740868643 2 6341.6251610074 ) 54.3664877574 (ExtendedPoll) + 8079+55 ( 2 0 3658.4187214749 2 6341.5782706765 ) 54.3663860796 (ExtendedPoll) + 8079+56 ( 2 0 3658.5972599177 2 6341.3907093526 ) 54.3659794991 (ExtendedPoll) + 8079+57 ( 2 0 3659.3114136885 2 6340.6404640569 ) 54.3643552693 (ExtendedPoll) + 8079+58 ( 2 0 3662.1680287720 2 6337.6394828742 ) 54.3578918193 (ExtendedPoll) + 8079+59 ( 2 0 3673.5944891057 2 6325.6355581437 ) 54.3325733144 (ExtendedPoll) + 8079+60 ( 2 0 3719.3003304408 2 6277.6198592213 ) 54.2398493355 (ExtendedPoll) + 8079+61 ( 2 0 3902.1236957812 2 6085.5570635318 ) 54.0045822968 (ExtendedPoll) + 8079+63 ( 2 0 3902.2168451994 2 6085.4781750776 ) 54.0043572353 (ExtendedPoll) + 8079+64 ( 2 0 3902.4962934540 2 6085.2415097151 ) 54.0036823026 (ExtendedPoll) + 8079+65 ( 2 0 3903.6140864724 2 6084.2948482648 ) 54.0009863502 (ExtendedPoll) + 8079+66 ( 2 0 3908.0852585462 2 6080.5082024636 ) 53.9902629755 (ExtendedPoll) + 8079+67 ( 2 0 3925.9699468413 2 6065.3616192587 ) 53.9483351232 (ExtendedPoll) + 8079+68 ( 2 0 3929.8118238900 2 6064.6724015289 ) 53.9176744624 (ExtendedPoll) + 8079+71 ( 2 0 3933.6400530629 2 6065.4639783275 ) 53.8745546326 (ExtendedPoll) + 8079+74 ( 2 0 3935.2163827223 2 6064.3107328191 ) 53.8694071337 (ExtendedPoll) + 8079+80 ( 2 0 3934.4145700168 2 6065.4354030875 ) 53.8674407841 (ExtendedPoll) + 8079+86 ( 2 0 3934.3391268516 2 6065.5313647145 ) 53.8673400617 (ExtendedPoll) + 8079+87 ( 2 0 3934.1127973559 2 6065.8192495955 ) 53.8670381792 (ExtendedPoll) + 8079+97 ( 2 0 3934.1264743868 2 6065.8465307696 ) 53.8666759354 (ExtendedPoll) + 8079+99 ( 2 0 3934.1212739663 2 6065.8766020781 ) 53.8664692539 (ExtendedPoll) + 8079+109 ( 2 0 3934.1202740309 2 6065.8782263033 ) 53.8664649210 (ExtendedPoll) + 8079+113 ( 2 0 3934.1223533865 2 6065.8765080955 ) 53.8664598006 (ExtendedPoll) + 8079+114 ( 2 0 3934.1285914536 2 6065.8713534722 ) 53.8664444397 (ExtendedPoll) + 8079+118 ( 2 0 3934.1299504561 2 6065.8700151548 ) 53.8664429271 (ExtendedPoll) + 8079+132 ( 2 0 3934.1299636052 2 6065.8700081445 ) 53.8664428619 (ExtendedPoll) + 8079+133 ( 2 0 3934.1300030527 2 6065.8699871137 ) 53.8664426663 (ExtendedPoll) + 8079+138 ( 2 0 3934.1300169838 2 6065.8699818250 ) 53.8664425790 (ExtendedPoll) + 8079+144 ( 2 0 3934.1300195727 2 6065.8699791463 ) 53.8664425772 (ExtendedPoll) + 8079+145 ( 2 0 3934.1300273392 2 6065.8699711101 ) 53.8664425718 (ExtendedPoll) + 8079+146 ( 2 0 3934.1300584054 2 6065.8699389652 ) 53.8664425505 (ExtendedPoll) + 8079+147 ( 2 0 3934.1301826702 2 6065.8698103857 ) 53.8664424650 (ExtendedPoll) + 8079+148 ( 2 0 3934.1306797292 2 6065.8692960676 ) 53.8664421232 (ExtendedPoll) + 8079+149 ( 2 0 3934.1326679655 2 6065.8672387954 ) 53.8664407559 (ExtendedPoll) + 8079+150 ( 2 0 3934.1406209105 2 6065.8590097066 ) 53.8664352870 (ExtendedPoll) + 8079+151 ( 2 0 3934.1724326905 2 6065.8260933514 ) 53.8664134151 (ExtendedPoll) + 8079+152 ( 2 0 3934.2996798107 2 6065.6944279307 ) 53.8663259908 (ExtendedPoll) + 8079+153 ( 2 0 3934.8086682912 2 6065.1677662475 ) 53.8659772994 (ExtendedPoll) + 8079+154 ( 2 0 3936.8446222133 2 6063.0611195148 ) 53.8645986296 (ExtendedPoll) + 8079+155 ( 2 0 3944.9884379019 2 6054.6345325840 ) 53.8593413213 (ExtendedPoll) + 8079+156 ( 2 0 3977.5637006562 2 6020.9281848608 ) 53.8424195173 (ExtendedPoll) + 8079+157 ( 2 0 4107.8647516735 2 5886.1027939679 ) 53.8397272797 (ExtendedPoll) + 8079+160 ( 2 0 4107.9148966216 2 5886.1375900537 ) 53.8389476963 (ExtendedPoll) + 8079+161 ( 2 0 4108.0653314659 2 5886.2419783111 ) 53.8366089797 (ExtendedPoll) + 8079+162 ( 2 0 4108.6670708432 2 5886.6595313405 ) 53.8272546148 (ExtendedPoll) + 8079+163 ( 2 0 4111.0740283523 2 5888.3297434584 ) 53.7898451866 (ExtendedPoll) + 8079+164 ( 2 0 4110.6415612866 2 5889.2053399927 ) 53.7857457298 (ExtendedPoll) + 8079+169 ( 2 0 4110.3275535183 2 5889.5792704659 ) 53.7851798069 (ExtendedPoll) + 8079+177 ( 2 0 4110.3514722870 2 5889.6354230117 ) 53.7844442616 (ExtendedPoll) + 8079+179 ( 2 0 4110.3094657512 2 5889.6797036381 ) 53.7844214421 (ExtendedPoll) + 8079+180 ( 2 0 4110.1834461437 2 5889.8125455175 ) 53.7843530488 (ExtendedPoll) + 8079+189 ( 2 0 4110.1987859472 2 5889.7973681491 ) 53.7843522353 (ExtendedPoll) + 8079+190 ( 2 0 4110.2448053575 2 5889.7518360439 ) 53.7843498028 (ExtendedPoll) + 8079+191 ( 2 0 4110.4288829988 2 5889.5697076232 ) 53.7843401922 (ExtendedPoll) + 8079+198 ( 2 0 4110.4212701576 2 5889.5773535241 ) 53.7843395401 (ExtendedPoll) + 8079+199 ( 2 0 4110.3984316340 2 5889.6002912268 ) 53.7843375858 (ExtendedPoll) + 8079+200 ( 2 0 4110.3070775395 2 5889.6920420376 ) 53.7843297986 (ExtendedPoll) + 8079+213 ( 2 0 4110.3073348959 2 5889.6924434618 ) 53.7843237498 (ExtendedPoll) + 8079+218 ( 2 0 4110.3074006879 2 5889.6925428714 ) 53.7843222330 (ExtendedPoll) + 8079+220 ( 2 0 4110.3073219352 2 5889.6926323636 ) 53.7843221306 (ExtendedPoll) + 8079+221 ( 2 0 4110.3070856770 2 5889.6929008404 ) 53.7843218236 (ExtendedPoll) + 8079+229 ( 2 0 4110.3070782245 2 5889.6929137441 ) 53.7843217731 (ExtendedPoll) + 8079+234 ( 2 0 4110.3070784835 2 5889.6929211901 ) 53.7843217023 (ExtendedPoll) + 8079+244 ( 2 0 4110.3070782010 2 5889.6929215603 ) 53.7843217014 (ExtendedPoll) + 8079+248 ( 2 0 4110.3070784332 2 5889.6929215433 ) 53.7843216995 (ExtendedPoll) + 8079+255 ( 2 0 4110.3070784211 2 5889.6929215697 ) 53.7843216993 (ExtendedPoll) + 8338 ( 3 0 3209.7896175644 2 3041.1231297861 1 3749.0872500424 ) 46.5944602659 + 8342+4 ( 2 0 4720.4915015090 2 5223.6067964464 ) 55.4583179990 (ExtendedPoll) + 8342+6 ( 2 0 4385.0813048840 2 5559.0169930714 ) 54.5837536455 (ExtendedPoll) + 8342+11 ( 2 0 4580.7372529152 2 5419.2627444776 ) 54.4134065463 (ExtendedPoll) + 8342+19 ( 2 0 4558.0271875187 2 5440.6626137936 ) 54.3705316119 (ExtendedPoll) + 8342+20 ( 2 0 4489.8969913293 2 5504.8622217413 ) 54.2562699395 (ExtendedPoll) + 8342+21 ( 2 0 4217.3762065715 2 5761.6606535323 ) 54.0237236224 (ExtendedPoll) + 8342+31 ( 2 0 4224.1455529878 2 5775.7452613984 ) 53.8272825836 (ExtendedPoll) + 8342+40 ( 2 0 4224.0014506112 2 5775.9423292618 ) 53.8266734099 (ExtendedPoll) + 8342+42 ( 2 0 4224.5165513001 2 5775.4823531964 ) 53.8264974549 (ExtendedPoll) + 8342+55 ( 2 0 4224.5193698410 2 5775.4797826488 ) 53.8264970122 (ExtendedPoll) + 8342+56 ( 2 0 4224.5278254637 2 5775.4720710060 ) 53.8264956843 (ExtendedPoll) + 8342+72 ( 2 0 4224.5278620041 2 5775.4721180965 ) 53.8264949041 (ExtendedPoll) + 8342+75 ( 2 0 4224.5278401629 2 5775.4721383731 ) 53.8264949041 (ExtendedPoll) + 8342+76 ( 2 0 4224.5277746392 2 5775.4721992028 ) 53.8264949041 (ExtendedPoll) + 8342+77 ( 2 0 4224.5275125446 2 5775.4724425218 ) 53.8264949040 (ExtendedPoll) + 8342+78 ( 2 0 4224.5264641662 2 5775.4734157976 ) 53.8264949035 (ExtendedPoll) + 8342+79 ( 2 0 4224.5222706526 2 5775.4773089008 ) 53.8264949018 (ExtendedPoll) + 8342+80 ( 2 0 4224.5054965982 2 5775.4928813139 ) 53.8264948957 (ExtendedPoll) + 8342+81 ( 2 0 4224.4384003804 2 5775.5551709661 ) 53.8264948856 (ExtendedPoll) + 8342+83 ( 2 0 4224.4377205871 2 5775.5589246019 ) 53.8264648146 (ExtendedPoll) + 8342+86 ( 2 0 4224.4354746818 2 5775.5620080759 ) 53.8264551993 (ExtendedPoll) + 8342+87 ( 2 0 4224.4287369659 2 5775.5712584979 ) 53.8264263535 (ExtendedPoll) + 8342+108 ( 2 0 4224.4287371566 2 5775.5712603508 ) 53.8264263340 (ExtendedPoll) + 8342+110 ( 2 0 4224.4287369462 2 5775.5712622015 ) 53.8264263180 (ExtendedPoll) + 8342+112 ( 2 0 4224.4287384895 2 5775.5712611586 ) 53.8264263143 (ExtendedPoll) + 8342+120 ( 2 0 4224.4287387223 2 5775.5712611587 ) 53.8264263122 (ExtendedPoll) + 8342+123 ( 2 0 4224.4287389206 2 5775.5712610366 ) 53.8264263116 (ExtendedPoll) + 8342+128 ( 2 0 4224.4287388106 2 5775.5712611591 ) 53.8264263114 (ExtendedPoll) + 8342+134 ( 2 0 4224.4287388393 2 5775.5712611545 ) 53.8264263112 (ExtendedPoll) + 8479+5 ( 2 0 4748.4423512277 2 5251.5576461652 ) 54.9123289774 (ExtendedPoll) + 8479+6 ( 2 0 3993.7694088215 2 6006.2305885713 ) 53.8183150359 (ExtendedPoll) + 8479+51 ( 2 0 3993.7694094976 2 6006.2305892118 ) 53.8183150239 (ExtendedPoll) + 8479+52 ( 2 0 3993.7694111450 2 6006.2305883426 ) 53.8183150161 (ExtendedPoll) + 8479+63 ( 2 0 3993.7694114742 2 6006.2305883502 ) 53.8183150129 (ExtendedPoll) + 8479+65 ( 2 0 3993.7694113839 2 6006.2305885648 ) 53.8183150119 (ExtendedPoll) + 8479+70 ( 2 0 3993.7694115223 2 6006.2305884756 ) 53.8183150114 (ExtendedPoll) + 8557 ( 3 0 3209.7895991439 2 3041.1231230634 1 3749.0872724849 ) 46.5944602388 + 8558 ( 3 0 3209.7895438823 2 3041.1231028951 1 3749.0873398125 ) 46.5944601576 + 8559 ( 3 0 3209.7893228358 2 3041.1230222222 1 3749.0876091228 ) 46.5944598326 + 8560 ( 3 0 3209.7884386500 2 3041.1226995306 1 3749.0886863640 ) 46.5944585328 + 8561 ( 3 0 3209.7849019068 2 3041.1214087641 1 3749.0929953290 ) 46.5944533336 + 8562 ( 3 0 3209.7707549341 2 3041.1162456982 1 3749.1102311888 ) 46.5944325369 + 8563 ( 3 0 3209.7141670434 2 3041.0955934346 1 3749.1791746282 ) 46.5943493545 + 8564 ( 3 0 3209.4878154802 2 3041.0129843799 1 3749.4549483857 ) 46.5940166899 + 8565 ( 3 0 3208.5824092276 2 3040.6825481613 1 3750.5580434156 ) 46.5926870780 + 8566 ( 3 0 3204.9607842173 2 3039.3608032869 1 3754.9704235351 ) 46.5873853782 + 8567 ( 3 0 3190.4742841761 2 3034.0738237895 1 3772.6199440134 ) 46.5664471002 + 8568 ( 3 0 3132.5282840110 2 3012.9259057995 1 3843.2180259264 ) 46.4870256328 + 8569 ( 3 0 2900.7442833508 2 2928.3342338397 1 4125.6103535787 ) 46.2408879908 + 8571 ( 3 0 2900.7614274922 2 2928.3321612234 1 4125.8538859951 ) 46.2381909255 + 8572 ( 3 0 2900.8128599165 2 2928.3259433745 1 4126.5844832443 ) 46.2301005176 + 8573 ( 3 0 2901.0185896137 2 2928.3010719787 1 4129.5068722413 ) 46.1977507173 + 8574 ( 3 0 2901.8415084025 2 2928.2015863959 1 4141.1964282293 ) 46.0685414984 + 8575 ( 3 0 2900.9072090155 2 2929.0263074597 1 4144.8990220964 ) 46.0294803754 + 8576 ( 3 0 2898.1043108544 2 2931.5004706513 1 4156.0068036976 ) 45.9126009127 + 8577 ( 3 0 2893.3059337557 2 2930.6699823072 1 4170.8633174072 ) 45.8058560157 + 8578 ( 3 0 2906.2246413292 2 2906.6780968135 1 4186.3657664955 ) 45.7664430594 + 8585 ( 3 0 2885.1856032809 2 2904.8325671601 1 4209.2503341972 ) 45.7234233185 + 8586 ( 3 0 2822.0684891358 2 2899.2959782000 1 4277.9040373024 ) 45.6027586237 + 8587 ( 3 0 2569.6000325554 2 2877.1496223596 1 4552.5188497232 ) 45.2497134209 + 8604 ( 3 0 2569.6580658121 2 2876.7761909688 1 4553.4192663392 ) 45.2437144482 + 8605 ( 3 0 2570.2146083482 2 2875.2291180641 1 4554.4732367897 ) 45.2420565509 + 8619 ( 3 0 2570.1792950214 2 2875.1673676151 1 4554.5724351350 ) 45.2419430091 + 8620 ( 3 0 2570.0733550410 2 2874.9821162682 1 4554.8700301708 ) 45.2416024126 + 8621 ( 3 0 2569.6495951193 2 2874.2411108805 1 4556.0604103143 ) 45.2402404599 + 8628 ( 3 0 2569.2779660036 2 2874.5306463677 1 4556.1885520705 ) 45.2397502250 + 8645 ( 3 0 2569.2890178965 2 2874.5245089523 1 4556.1847035137 ) 45.2397436100 + 8656 ( 3 0 2569.2838215385 2 2874.5258438228 1 4556.1885598972 ) 45.2397403650 + 8657 ( 3 0 2569.2682324643 2 2874.5298484341 1 4556.2001290477 ) 45.2397306308 + 8658 ( 3 0 2569.2058761675 2 2874.5458668797 1 4556.2464056497 ) 45.2396917036 + 8659 ( 3 0 2568.9564509805 2 2874.6099406618 1 4556.4315120578 ) 45.2395361495 + 8660 ( 3 0 2567.9587502324 2 2874.8662357905 1 4557.1719376902 ) 45.2389164047 + 8661 ( 3 0 2563.9679472400 2 2875.8914163050 1 4560.1336402198 ) 45.2364769895 + 8662 ( 3 0 2548.0047352705 2 2879.9921383632 1 4571.9804503382 ) 45.2273531705 + 8663 ( 3 0 2484.1518873922 2 2896.3950265960 1 4619.3676908119 ) 45.2010503608 + 8675 ( 3 0 2484.0736686549 2 2896.3896310350 1 4619.4612514156 ) 45.2009055791 + 8676 ( 3 0 2483.8390124432 2 2896.3734443522 1 4619.7419332265 ) 45.2004713862 + 8689 ( 3 0 2483.8404577833 2 2896.3642671817 1 4619.7710023038 ) 45.2002598293 + 8696 ( 3 0 2483.8253676018 2 2896.3813588741 1 4619.7912874024 ) 45.2000581939 + 8712 ( 3 0 2483.8253703113 2 2896.3815984832 1 4619.7922104815 ) 45.2000473949 + 8714 ( 3 0 2483.8245414630 2 2896.3833077377 1 4619.7920389071 ) 45.2000420407 + 8717 ( 3 0 2483.8258603227 2 2896.3779360857 1 4619.7956529999 ) 45.2000411600 + 8718 ( 3 0 2483.8298169016 2 2896.3618211298 1 4619.8064952782 ) 45.2000385180 + 8719 ( 3 0 2483.8456432174 2 2896.2973613061 1 4619.8498643917 ) 45.2000279546 + 8720 ( 3 0 2483.9089484806 2 2896.0395220115 1 4620.0233408456 ) 45.1999857711 + 8721 ( 3 0 2484.1621695335 2 2895.0081648328 1 4620.7172466613 ) 45.1998181601 + 8722 ( 3 0 2485.1750537449 2 2890.8827361181 1 4623.4928699239 ) 45.1991656831 + 8723 ( 3 0 2489.2265905905 2 2874.3810212593 1 4634.5953629742 ) 45.1968429324 + 8724 ( 3 0 2505.4327379729 2 2808.3741618241 1 4679.0053351755 ) 45.1921264676 + 8727 ( 3 0 2505.3685769810 2 2808.4952747076 1 4679.9720755135 ) 45.1823799799 + 8728 ( 3 0 2505.1760940054 2 2808.8586133581 1 4682.8722965274 ) 45.1531602599 + 8729 ( 3 0 2503.1517786669 2 2810.5022882056 1 4685.7790057314 ) 45.1291493448 + 8738 ( 3 0 2502.1929683392 2 2809.7986800253 1 4687.3275204562 ) 45.1288718569 + 8739 ( 3 0 2499.3165373560 2 2807.6878554842 1 4691.9730646305 ) 45.1280529948 + 8740 ( 3 0 2487.8108134233 2 2799.2445573201 1 4710.5552413278 ) 45.1249818571 + 8741 ( 3 0 2441.7879176925 2 2765.4713646635 1 4784.8839481171 ) 45.1159841138 + 8744 ( 3 0 2462.0887438795 2 2743.6941147538 1 4794.1115963840 ) 45.0330234211 + 8760 ( 3 0 2462.3136002207 2 2743.6052851221 1 4794.0775784423 ) 45.0321070688 + 8776 ( 3 0 2462.3185474349 2 2743.6003098574 1 4794.0805750106 ) 45.0320771528 + 8786 ( 3 0 2462.3197386852 2 2743.5989064226 1 4794.0810742815 ) 45.0320738114 + 8793 ( 3 0 2462.3211643858 2 2743.5976465736 1 4794.0809396072 ) 45.0320731778 + 8794 ( 3 0 2462.3254414876 2 2743.5938670266 1 4794.0805355845 ) 45.0320712769 + 8812 ( 3 0 2462.3255079460 2 2743.5937832827 1 4794.0805883207 ) 45.0320709008 + 8813 ( 3 0 2462.3257073210 2 2743.5935320511 1 4794.0807465293 ) 45.0320697728 + 8826 ( 3 0 2462.3257104845 2 2743.5935091129 1 4794.0807652912 ) 45.0320697624 + 8827 ( 3 0 2462.3257199749 2 2743.5934402983 1 4794.0808215770 ) 45.0320697313 + 8828 ( 3 0 2462.3257579368 2 2743.5931650398 1 4794.0810467200 ) 45.0320696068 + 8829 ( 3 0 2462.3259097844 2 2743.5920640060 1 4794.0819472921 ) 45.0320691088 + 8830 ( 3 0 2462.3265171749 2 2743.5876598710 1 4794.0855495803 ) 45.0320671166 + 8831 ( 3 0 2462.3289467365 2 2743.5700433307 1 4794.0999587333 ) 45.0320591485 + 8832 ( 3 0 2462.3386649831 2 2743.4995771695 1 4794.1575953453 ) 45.0320272796 + 8833 ( 3 0 2462.3775379695 2 2743.2177125248 1 4794.3881417933 ) 45.0318998663 + 8834 ( 3 0 2462.5330299152 2 2742.0902539461 1 4795.3103275852 ) 45.0313912035 + 8835 ( 3 0 2463.1549976977 2 2737.5804196312 1 4798.9990707529 ) 45.0293724005 + 8836 ( 3 0 2465.6428688278 2 2719.5410823714 1 4813.7540434236 ) 45.0215504519 + 8837 ( 3 0 2475.5943533484 2 2647.3837333325 1 4872.7739341066 ) 44.9942951687 + 8838 ( 3 0 2515.4002914308 2 2358.7543371766 1 5108.8534968384 ) 44.9485005040 + 8840 ( 3 0 2515.2855315668 2 2358.6893426326 1 5109.0589561943 ) 44.9480836817 + 8841 ( 3 0 2514.9412519750 2 2358.4943590004 1 5109.6753342622 ) 44.9468335445 + 8842 ( 3 0 2513.5641336077 2 2357.7144244716 1 5112.1408465335 ) 44.9418379464 + 8843 ( 3 0 2508.0556601384 2 2354.5946863564 1 5122.0028956186 ) 44.9219348254 + 8844 ( 3 0 2486.0217662612 2 2342.1157338955 1 5161.4510919593 ) 44.8435947921 + 8845 ( 3 0 2483.0458496952 2 2338.7707113988 1 5167.8643075048 ) 44.8377804120 + 8846 ( 3 0 2474.1180999970 2 2328.7356439086 1 5187.1039541411 ) 44.8205099552 + 8847 ( 3 0 2438.4071012044 2 2288.5953739479 1 5264.0625406864 ) 44.7540328039 + 8848 ( 3 0 2295.5631060339 2 2128.0342941051 1 5571.8968868678 ) 44.5306991822 + 8855 ( 3 0 2246.8411231851 2 2159.0391922817 1 5594.0432427082 ) 44.4908538729 + 8881 ( 3 0 2246.8591149590 2 2159.0973578929 1 5594.0389538567 ) 44.4902351182 + 8890 ( 3 0 2246.8486392353 2 2159.1084209401 1 5594.0397904890 ) 44.4902262093 + 8903 ( 3 0 2246.8540260785 2 2159.1053127856 1 5594.0375595191 ) 44.4902251751 + 8904 ( 3 0 2246.8701866083 2 2159.0959883223 1 5594.0308666095 ) 44.4902220731 + 8905 ( 3 0 2246.9348287276 2 2159.0586904689 1 5594.0040949708 ) 44.4902096777 + 8906 ( 3 0 2247.1933972044 2 2158.9094990553 1 5593.8970084161 ) 44.4901602933 + 8927 ( 3 0 2247.1934312789 2 2158.9093352501 1 5593.8971782696 ) 44.4901598382 + 8933 ( 3 0 2247.1936064494 2 2158.9091736740 1 5593.8971710678 ) 44.4901597251 + 8934 ( 3 0 2247.1941319611 2 2158.9086889458 1 5593.8971494625 ) 44.4901593859 + 8944 ( 3 0 2247.1941525712 2 2158.9086089656 1 5593.8972354233 ) 44.4901591006 + 8961 ( 3 0 2247.1941592110 2 2158.9086060982 1 5593.8972336338 ) 44.4901590823 + 8969 ( 3 0 2247.1941622393 2 2158.9086061446 1 5593.8972314647 ) 44.4901590747 + 8979 ( 3 0 2247.1941629850 2 2158.9086060136 1 5593.8972309224 ) 44.4901590742 + 8988 ( 3 0 2247.1941631028 2 2158.9086062984 1 5593.8972305733 ) 44.4901590739 + 8998 ( 3 0 2247.1941631943 2 2158.9086062904 1 5593.8972305018 ) 44.4901590738 + 9011 ( 3 0 2247.1941631861 2 2158.9086062987 1 5593.8972305106 ) 44.4901590737 + 9021 ( 3 0 2247.1941631897 2 2158.9086062984 1 5593.8972305098 ) 44.4901590737 + 9027 ( 3 0 2247.1941631931 2 2158.9086062979 1 5593.8972305086 ) 44.4901590737 + 9037 ( 3 0 2247.1941631947 2 2158.9086062989 1 5593.8972305060 ) 44.4901590737 + 9047 ( 3 0 2247.1941631950 2 2158.9086062987 1 5593.8972305061 ) 44.4901590737 + 9056 ( 3 0 2247.1941631952 2 2158.9086062985 1 5593.8972305062 ) 44.4901590737 + 9065 ( 3 0 2247.1941631953 2 2158.9086062986 1 5593.8972305060 ) 44.4901590737 + 9074 ( 3 0 2247.1941631953 2 2158.9086062986 1 5593.8972305061 ) 44.4901590737 + 9091 ( 3 0 2247.1941631953 2 2158.9086062986 1 5593.8972305061 ) 44.4901590737 -} end of run (mesh size reached NOMAD precision) +} end of run (mesh index limits) -blackbox evaluations : 3436 -best feasible solution : ( 3 0 3333.333333 2 3333.333333 1 3333.333333 ) h=0 f=47.16829052 +blackbox evaluations : 9091 +best feasible solution : ( 3 0 2247.194163 2 2158.908606 1 5593.897231 ) h=0 f=44.49015907 diff --git a/examples/advanced/multi_start/best_x.txt b/examples/advanced/multi_start/best_x.txt index 7588ff3216d3708027e7f2604527f364b46422bd..821eea67409cb1cc7edaf3d706d1960974d69f33 100644 --- a/examples/advanced/multi_start/best_x.txt +++ b/examples/advanced/multi_start/best_x.txt @@ -1 +1 @@ -1.0065227779901828597530766273849 0.0061576008796691908409037807814457 0.99995827823866767491978180260048 1.0093326058145666301868459413527 1.0032484173774720570548879550188 \ No newline at end of file +0.9999740474925636890546343238384 3.9134074383641649674033663464101e-05 0.99997595080463674843684884763206 0.99999589110497688615453171223635 0.99999324108060483329296630472527 \ No newline at end of file diff --git a/examples/advanced/multi_start/makefile b/examples/advanced/multi_start/makefile index 95b3f96df67861b53b50364bf2a702fdceb10787..841008f34fe4a91382215906f2ece97cb01a4d0a 100644 --- a/examples/advanced/multi_start/makefile +++ b/examples/advanced/multi_start/makefile @@ -1,11 +1,23 @@ -EXE = multi.exe -COMPILATOR = g++ -COMPILATOR_OPTIONS = -ansi -O2 -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lm -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -OBJS = multi.o +UNAME := $(shell uname) + +EXE = multi.exe +COMPILATOR = g++ +COMPILATOR_OPTIONS = -ansi -O2 + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif + +LDLIBS = -lm -lnomad + +INCLUDE = -I$(NOMAD_HOME)/src -I. +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +OBJS = multi.o ifndef NOMAD_HOME define ECHO_NOMAD @@ -14,11 +26,15 @@ define ECHO_NOMAD endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) @echo " building the scalar version ..." @echo " exe file : "$(EXE) - $(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif + multi.o: multi.cpp $(ECHO_NOMAD) diff --git a/examples/advanced/multi_start/runExample.log b/examples/advanced/multi_start/runExample.log index 51c3fae4cd73f2db08edfd9a5272e997f4854069..ffc68d1aca8f4199467ba8ffdf5059cbaabc8f8d 100644 --- a/examples/advanced/multi_start/runExample.log +++ b/examples/advanced/multi_start/runExample.log @@ -1,5 +1,5 @@ -starting point # 0: ( 1.311638583 0.3116009987 0.9520390845 0.8088161243 1.540724398 1.619263445 0.9519058983 ) +starting point # 0: ( 0.5802249825 1.631108467 1.028915701 1.041199968 0.8987064366 1.883811294 1.475481573 ) starting point # 1: ( 4.046907118 0.2179386209 0.3995457903 2.86002185 2.869872299 1.805805862 0.9241232544 ) starting point # 2: ( 2.730496038 4.019688198 2.015450408 3.887235003 1.919237215 0.004176816764 2.788539635 ) starting point # 3: ( 1.986593711 1.814325217 1.166098379 0.9517739273 0.4086947283 3.9836116 2.239536416 ) @@ -8,14 +8,14 @@ starting point # 4: ( 1.072412482 2.713920967 3.075009451 0.3310437183 1.0323001 Warning: { Anisotropic mesh is disabled for direction types other than OrthoMads. } -run # 0: f=1.619155361 -run # 1: f=1.890750373 -run # 2: f=2.267307514 -run # 3: f=1.998968772 -run # 4: f=2.24968126 +run # 0: f=1.933149587 +run # 1: f=1.998299291 +run # 2: f=2.185446803 +run # 3: f=1.978020317 +run # 4: f=2.037153616 bb eval : 5000 -best : 1.619155361 -worst : 2.267307514 -solution: x = ( 1.310592306 0.3106177009 0.9507953978 0.8088442339 1.538847818 1.618878923 0.951419131 ) f(x) = 1.619155361 +best : 1.933149587 +worst : 2.185446803 +solution: x = ( 0.6020877754 1.616716377 1.043857108 1.033179949 0.9025516515 1.899521743 1.402861944 ) f(x) = 1.933149587 diff --git a/examples/advanced/plot/makefile b/examples/advanced/plot/makefile index 3529bc8199537cf5996da2d180b5a60c8c2c48c1..22c70e7f987bde800d26f3f3058ff0a9117c0d46 100644 --- a/examples/advanced/plot/makefile +++ b/examples/advanced/plot/makefile @@ -1,16 +1,37 @@ -EXE = nomad_plot.exe -COMPILATOR = g++ -COMPILATOR_OPTIONS = -ansi -O2 -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lc -lm -INCLUDE = -I $(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -OBJS = nomad_plot.o +UNAME := $(shell uname) + +EXE = nomad_plot.exe +COMPILATOR = g++ +COMPILATOR_OPTIONS = -ansi -O2 + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif + +LDLIBS = -lm -lnomad + + +INCLUDE = -I $(NOMAD_HOME)/src -I. +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +OBJS = nomad_plot.o $(EXE): $(OBJS) - $(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) + $(ECHO_NOMAD) + @echo " building the scalar version ..." + @echo " exe file : "$(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(LIB_DIR)/$(LIB_NOMAD) $(EXE) +endif + -nomad_plot.o: nomad_plot.cpp $(L1) +nomad_plot.o: nomad_plot.cpp + $(ECHO_NOMAD) $(COMPILE) nomad_plot.cpp clean: diff --git a/examples/advanced/restart/makefile b/examples/advanced/restart/makefile index b85123a3eb1eb8faa03373d62f0f00ea34ad63d6..a4770d4a8100ea4032c1d573c29c84610e7a0088 100644 --- a/examples/advanced/restart/makefile +++ b/examples/advanced/restart/makefile @@ -1,25 +1,34 @@ -EXE = restart.exe + +UNAME := $(shell uname) + +EXE = restart.exe EXE_MPI = restart_MPI.exe -COMPILATOR = g++ -COMPILATOR_MPI = mpic++ -SUNAME = $(shell uname) -OSS=$(findstring MINGW32,$(SUNAME)) -ifneq "$(strip $(OSS))" "" -COMPILATOR_MPI = g++ +COMPILATOR = g++ +COMPILATOR_MPI = mpic++ + +COMPILATOR_OPTIONS = -g -O2 -ansi +COMPILATOR_OPTIONS_MPI = $(COMPILATOR_OPTIONS) -DUSE_MPI + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so +LIB_NOMAD_MPI = libnomad.MPI.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi endif +CXXFLAGS_MPI = $(CXXFLAGS) -DUSE_MPI + +LDLIBS = -lm -lnomad +LDLIBS_MPI = -lm -lmpi -lnomad.MPI -COMPILATOR_OPTIONS = -O2 -ansi -COMPILATOR_OPTIONS_MPI = $(COMPILATOR_OPTIONS) -DUSE_MPI -L1 = $(NOMAD_HOME)/lib/nomad.a -L1_MPI = $(NOMAD_HOME)/lib/nomad.MPI.a -LIBS = $(L1) -lm -LIBS_MPI = $(L1_MPI) -lm -lmpi -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +INCLUDE = -I$(NOMAD_HOME)/src -I. +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c COMPILE_MPI = $(COMPILATOR_MPI) $(COMPILATOR_OPTIONS_MPI) $(INCLUDE) -c -OBJS = restart.o -OBJS_MPI = restart_MPI.o +OBJS = restart.o +OBJS_MPI = restart_MPI.o ifndef NOMAD_HOME @@ -30,19 +39,25 @@ endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) @echo " building the scalar version ..." @echo " exe file : "$(EXE) - @$(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) - @strip $(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif + -$(EXE_MPI): $(L1_MPI) $(OBJS_MPI) +$(EXE_MPI): $(OBJS_MPI) $(ECHO_NOMAD) @echo " building the MPI version ..." @echo " exe file : "$(EXE_MPI) - @$(COMPILATOR_MPI) -o $(EXE_MPI) $(OBJS_MPI) $(LIBS_MPI) $(COMPILATOR_OPTIONS_MPI) - @strip $(EXE_MPI) + @$(COMPILATOR_MPI) -o $(EXE_MPI) $(OBJS_MPI) $(LDLIBS_MPI) $(CXXFLAGS_MPI) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD_MPI) $(NOMAD_HOME)/lib/$(LIB_NOMAD_MPI) $(EXE_MPI) +endif + restart.o: restart.cpp $(ECHO_NOMAD) @@ -52,9 +67,6 @@ restart_MPI.o: restart.cpp $(ECHO_NOMAD) @$(COMPILE_MPI) restart.cpp -o restart_MPI.o -$(L1) $(L1_MPI): ; - $(ECHO_NOMAD) - mpi: $(EXE_MPI) all: $(EXE) $(EXE_MPI) diff --git a/examples/advanced/restart/restart.cpp b/examples/advanced/restart/restart.cpp index e41b0dc24feab2bc43e8b1599c1426367e4267bb..9c5c7b559bbbd9ee2ec36109169c76a47ea09b07 100644 --- a/examples/advanced/restart/restart.cpp +++ b/examples/advanced/restart/restart.cpp @@ -8,65 +8,70 @@ using namespace NOMAD; /*----------------------------------------*/ /* the problem */ /*----------------------------------------*/ -class My_Evaluator : public Evaluator { +class My_Evaluator : public Evaluator +{ private: - + + public: My_Evaluator ( const Parameters & p ) : Evaluator ( p ) { } - - ~My_Evaluator ( void ) {} - - virtual bool eval_x ( Eval_Point & x , - const Double & h_max , - bool & count_eval ) const; - - virtual void update_iteration ( success_type success , - const Stats & stats , - const Evaluator_Control & ev_control , - const Barrier & true_barrier , - const Barrier & sgte_barrier , - const Pareto_Front & pareto_front , - bool & stop ); + + ~My_Evaluator ( void ) { } + + + virtual bool eval_x ( Eval_Point & x , + const Double & h_max , + bool & count_eval ) const; + + virtual void update_iteration ( success_type success , + const Stats & stats , + const Evaluator_Control & ev_control , + const Barrier & true_barrier , + const Barrier & sgte_barrier , + const Pareto_Front & pareto_front , + bool & stop ); }; /*----------------------------------------*/ /* user-defined eval_x */ /*----------------------------------------*/ bool My_Evaluator::eval_x ( Eval_Point & x , - const Double & h_max , - bool & count_eval ) const + const Double & h_max , + bool & count_eval ) const { - Double c1 = 0.0 , c2 = 0.0; - for ( int i = 0 ; i < 5 ; i++ ) { - c1 += (x[i]-1).pow2(); - c2 += (x[i]+1).pow2(); - } - x.set_bb_output ( 0 , x[4] ); // objective value - x.set_bb_output ( 1 , c1-25 ); // constraint 1 - x.set_bb_output ( 2 , 25-c2 ); // constraint 2 - - count_eval = true; // count a black-box evaluation - - return true; // the evaluation succeeded + Double c1 = 0.0 , c2 = 0.0; + for ( int i = 0 ; i < 5 ; i++ ) + { + + c1 += (x[i]-1).pow2(); + c2 += (x[i]+1).pow2(); + } + x.set_bb_output ( 0 , x[4] ); // objective value + x.set_bb_output ( 1 , c1-25 ); // constraint 1 + x.set_bb_output ( 2 , 25-c2 ); // constraint 2 + + count_eval = true; // count a black-box evaluation + + return true; // the evaluation succeeded } /*----------------------------------------*/ /* updates at each iteration */ /*----------------------------------------*/ void My_Evaluator::update_iteration ( success_type success , - const Stats & stats , - const Evaluator_Control & ev_control , - const Barrier & true_barrier , - const Barrier & sgte_barrier , - const Pareto_Front & pareto_front , - bool & stop ) + const Stats & stats , + const Evaluator_Control & ev_control , + const Barrier & true_barrier , + const Barrier & sgte_barrier , + const Pareto_Front & pareto_front , + bool & stop ) { - if ( success == UNSUCCESSFUL ) - stop = true; + if ( success == UNSUCCESSFUL ) + stop = true; } /*------------------------------------------*/ @@ -74,112 +79,116 @@ void My_Evaluator::update_iteration ( success_type success , /*------------------------------------------*/ int main ( int argc , char ** argv ) { - // display: - Display out ( std::cout ); - out.precision ( DISPLAY_PRECISION_STD ); - - try { - - // NOMAD initializations: - begin ( argc , argv ); - - // parameters creation: - Parameters p ( out ); - - p.set_DIMENSION (5); // number of variables - - vector<bb_output_type> bbot (3); // definition of - bbot[0] = OBJ; // output types - bbot[1] = EB; - bbot[2] = EB; - p.set_BB_OUTPUT_TYPE ( bbot ); - - p.set_DISPLAY_DEGREE ( 2 ); - - p.set_DISPLAY_STATS ( "bbe ( sol ) obj" ); - - p.set_X0 ( Point ( 5 , 0.0 ) ); // starting point - - p.set_LOWER_BOUND ( Point ( 5 , -6.0 ) ); // all var. >= -6 - Point ub ( 5 ); // x_4 and x_5 have no bounds - ub[0] = 5.0; // x_1 <= 5 - ub[1] = 6.0; // x_2 <= 6 - ub[2] = 7.0; // x_3 <= 7 - p.set_UPPER_BOUND ( ub ); - - p.set_MAX_BB_EVAL (100); // the algorithm terminates after - // 100 black-box evaluations - - - - // parameters validation: - p.check(); - - OrthogonalMesh * oMesh=p.get_signature()->get_mesh(); - - // custom evaluator creation: - My_Evaluator ev ( p ); - - // best solutions: - const Point * bf = NULL , * bi = NULL; - - // algorithm creation: - Mads mads ( p , &ev ); - + // display: + Display out ( std::cout ); + out.precision ( DISPLAY_PRECISION_STD ); - // successive runs: - for ( int i = 0 ; i < 5 ; ++i ) - { - - out << endl << open_block ( "MADS run #" + NOMAD::itos(i) ); - - // not for the first run: - if ( i > 0 ) - { - - // new starting points: - p.reset_X0(); - if ( bf ) - p.set_X0 ( *bf ); - if ( bi ) - p.set_X0 ( *bi ); - - if (!bf && !bi) - p.set_LH_SEARCH(1,0); // at least one evaluation is conducted if point is bf and bi are null - else - p.set_LH_SEARCH(0,0); - - // Update the mesh for an unsuccessful iteration and put current - // mesh and poll sizes as initial mesh and poll sizes for the next start. - oMesh->update(UNSUCCESSFUL); - Point delta_0, Delta_0; - oMesh->get_delta(delta_0); - oMesh->set_delta_0(delta_0); - oMesh->get_Delta(Delta_0); - oMesh->set_Delta_0(Delta_0); - - // parameters validation: - p.check(); - - // reset the Mads object: - mads.reset ( true , true ); + try { + + // NOMAD initializations: + begin ( argc , argv ); + + // parameters creation: + Parameters p ( out ); + + p.set_DIMENSION (5); // number of variables + + vector<bb_output_type> bbot (3); // definition of + bbot[0] = OBJ; // output types + bbot[1] = EB; + bbot[2] = EB; + p.set_BB_OUTPUT_TYPE ( bbot ); + + p.set_DISPLAY_DEGREE ( 2 ); + + p.set_DISPLAY_STATS ( "bbe ( sol ) obj" ); + + p.set_X0 ( Point ( 5 , 0.0 ) ); // starting point + + p.set_LOWER_BOUND ( Point ( 5 , -6.0 ) ); // all var. >= -6 + Point ub ( 5 ); // x_4 and x_5 have no bounds + ub[0] = 5.0; // x_1 <= 5 + ub[1] = 6.0; // x_2 <= 6 + ub[2] = 7.0; // x_3 <= 7 + p.set_UPPER_BOUND ( ub ); + + + + p.set_MAX_BB_EVAL (100); // the algorithm terminates after + // 100 black-box evaluations + + // p.set_DISABLE_MODELS(); + + // parameters validation: + p.check(); + + OrthogonalMesh * oMesh=p.get_signature()->get_mesh(); + + // custom evaluator creation: + My_Evaluator ev ( p ); + + // best solutions: + const Point * bf = NULL , * bi = NULL; + + // algorithm creation: + Mads mads ( p , &ev ); + + + // successive runs: + for ( int i = 0 ; i < 6 ; ++i ) + { - } - - // the run: - mads.run(); - bf = mads.get_best_feasible(); - bi = mads.get_best_infeasible(); - - out.close_block(); + out << endl << open_block ( "MADS run #" + NOMAD::itos(i) ); + + // not for the first run: + if ( i > 0 ) + { + + // new starting points: + p.reset_X0(); + if ( bf ) + p.set_X0 ( *bf ); + if ( bi ) + p.set_X0 ( *bi ); + + if (!bf && !bi) + p.set_LH_SEARCH(1,0); // at least one evaluation is conducted if point is bf and bi are null + else + p.set_LH_SEARCH(0,0); + + // Update the mesh for an unsuccessful iteration and put current + // mesh and poll sizes as initial mesh and poll sizes for the next start. + oMesh->update(UNSUCCESSFUL); + Point delta_0, Delta_0; + oMesh->get_delta(delta_0); + oMesh->set_delta_0(delta_0); + oMesh->get_Delta(Delta_0); + oMesh->set_Delta_0(Delta_0); + + // parameters validation: + p.check(); + + // reset the Mads object: + mads.reset ( false , false ); + + } + + // the run: + mads.run(); + bf = mads.get_best_feasible(); + bi = mads.get_best_infeasible(); + + out.close_block(); + } } - } - catch ( exception & e ) { - cerr << "\nNOMAD has been interrupted (" << e.what() << ")\n\n"; - } - - Slave::stop_slaves ( out ); - end(); - - return EXIT_SUCCESS; + catch ( exception & e ) + { + + cerr << "\nNOMAD has been interrupted (" << e.what() << ")\n\n"; + } + + Slave::stop_slaves ( out ); + end(); + + return EXIT_SUCCESS; } diff --git a/examples/advanced/user_search/makefile b/examples/advanced/user_search/makefile index b84b77d3d5c9e8e04f37aac86c76a8457b04534d..4632e595909d675b1d47d4a73491caf6d57853b6 100644 --- a/examples/advanced/user_search/makefile +++ b/examples/advanced/user_search/makefile @@ -1,25 +1,35 @@ -EXE = user_search.exe +UNAME := $(shell uname) + + +EXE = user_search.exe EXE_MPI = user_search_MPI.exe -COMPILATOR = g++ -COMPILATOR_MPI = mpic++ -SUNAME = $(shell uname) -OSS=$(findstring MINGW32,$(SUNAME)) -ifneq "$(strip $(OSS))" "" -COMPILATOR_MPI = g++ +COMPILATOR = g++ +COMPILATOR_MPI = mpic++ + +COMPILATOR_OPTIONS = -O2 -ansi +COMPILATOR_OPTIONS_MPI = $(COMPILATOR_OPTIONS) -DUSE_MPI + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so +LIB_NOMAD_MPI = libnomad.MPI.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi endif +CXXFLAGS_MPI = $(CXXFLAGS) -DUSE_MPI + +LDLIBS = -lm -lnomad +LDLIBS_MPI = -lm -lmpi -lnomad.MPI -COMPILATOR_OPTIONS = -O2 -ansi -COMPILATOR_OPTIONS_MPI = $(COMPILATOR_OPTIONS) -DUSE_MPI -L1 = $(NOMAD_HOME)/lib/nomad.a -L1_MPI = $(NOMAD_HOME)/lib/nomad.MPI.a -LIBS = $(L1) -lm -LIBS_MPI = $(L1_MPI) -lm -lmpi -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +INCLUDE = -I$(NOMAD_HOME)/src -I. +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c COMPILE_MPI = $(COMPILATOR_MPI) $(COMPILATOR_OPTIONS_MPI) $(INCLUDE) -c -OBJS = user_search.o -OBJS_MPI = user_search_MPI.o + +OBJS = user_search.o +OBJS_MPI = user_search_MPI.o ifndef NOMAD_HOME @@ -30,19 +40,25 @@ endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) @echo " building the scalar version ..." @echo " exe file : "$(EXE) - @$(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) - @strip $(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif + -$(EXE_MPI): $(L1_MPI) $(OBJS_MPI) +$(EXE_MPI): $(OBJS_MPI) $(ECHO_NOMAD) @echo " building the MPI version ..." @echo " exe file : "$(EXE_MPI) - @$(COMPILATOR_MPI) -o $(EXE_MPI) $(OBJS_MPI) $(LIBS_MPI) $(COMPILATOR_OPTIONS_MPI) - @strip $(EXE_MPI) + @$(COMPILATOR_MPI) -o $(EXE_MPI) $(OBJS_MPI) $(LDLIBS_MPI) $(CXXFLAGS_MPI) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD_MPI) $(NOMAD_HOME)/lib/$(LIB_NOMAD_MPI) $(EXE_MPI) +endif + user_search.o: user_search.cpp $(ECHO_NOMAD) @@ -52,9 +68,6 @@ user_search_MPI.o: user_search.cpp $(ECHO_NOMAD) @$(COMPILE_MPI) user_search.cpp -o user_search_MPI.o -$(L1) $(L1_MPI): ; - $(ECHO_NOMAD) - mpi: $(EXE_MPI) all: $(EXE) $(EXE_MPI) diff --git a/examples/basic/batch/bi_obj/runExample.log b/examples/basic/batch/bi_obj/runExample.log index 76994f3e581a8a8d5f2f03845cba2e9a79c68144..f85624fafb6ad544805df93beb204fb306fd18cd 100644 --- a/examples/basic/batch/bi_obj/runExample.log +++ b/examples/basic/batch/bi_obj/runExample.log @@ -1,17 +1,19 @@ -NOMAD - version 3.7.2 - www.gerad.ca/nomad - -Copyright (C) 2001-2015 { - Mark A. Abramson - The Boeing Company +NOMAD - version 3.7.3 has been created by { Charles Audet - Ecole Polytechnique de Montreal - Gilles Couture - Ecole Polytechnique de Montreal - John E. Dennis, Jr. - Rice University Sebastien Le Digabel - Ecole Polytechnique de Montreal Christophe Tribes - Ecole Polytechnique de Montreal } -Funded in part by AFOSR and Exxon Mobil. +The copyright of NOMAD - version 3.7.3 is owned by { + Sebastien Le Digabel - Ecole Polytechnique de Montreal + Christophe Tribes - Ecole Polytechnique de Montreal +} + +NOMAD version 3 is a new version of Nomad v1 and v2, it has been funded by AFOSR and Exxon Mobil. +Nomad v1 and v2 were created and developed by Mark A. Abramson from The Boeing Company, Charles Audet and Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from Rice University, and were funded by AFOSR and Exxon Mobil. +Download : www.gerad.ca/nomad License : '$NOMAD_HOME/src/lgpl.txt' User guide: '$NOMAD_HOME/doc/user_guide.pdf' Examples : '$NOMAD_HOME/examples' @@ -21,21 +23,21 @@ Please report bugs to nomad@gerad.ca multi-MADS run { - MADS run 1 ...... OK [bb eval= 64] [overall bb eval= 64] [# dominant pts= 10] [# new pts= 10] [f1=0 f2=6.231313115] - MADS run 2 ...... OK [bb eval= 32] [overall bb eval= 96] [# dominant pts= 15] [# new pts= 5] [f1=0.8169729819 f2=-0.479260869] - MADS run 3 ...... OK [bb eval= 32] [overall bb eval= 128] [# dominant pts= 14] [# new pts= -1] [f1=0 f2=1] - MADS run 4 ...... OK [bb eval= 32] [overall bb eval= 160] [# dominant pts= 25] [# new pts= 11] [f1=0.5612660076 f2=0.1239843648] - MADS run 5 ...... OK [bb eval= 32] [overall bb eval= 192] [# dominant pts= 33] [# new pts= 8] [f1=0.3137786342 f2=0.5879263396] - MADS run 6 ...... OK [bb eval= 32] [overall bb eval= 224] [# dominant pts= 47] [# new pts= 14] [f1=0.7805127885 f2=-0.1507861609] - MADS run 7 ...... OK [bb eval= 32] [overall bb eval= 256] [# dominant pts= 54] [# new pts= 7] [f1=0.5299157655 f2=0.357255587] - MADS run 8 ...... OK [bb eval= 32] [overall bb eval= 288] [# dominant pts= 66] [# new pts= 12] [f1=0.07954951288 f2=0.9213144638] - MADS run 9 ...... OK [bb eval= 32] [overall bb eval= 320] [# dominant pts= 76] [# new pts= 10] [f1=0.2748325185 f2=0.7638619206] - MADS run 10 ...... OK [bb eval= 32] [overall bb eval= 352] [# dominant pts= 85] [# new pts= 9] [f1=0.5181766881 f2=0.5029223883] - MADS run 11 ...... OK [bb eval= 32] [overall bb eval= 384] [# dominant pts= 89] [# new pts= 4] [f1=0.7680831771 f2=0.07286356753] - MADS run 12 ...... OK [bb eval= 32] [overall bb eval= 416] [# dominant pts= 99] [# new pts= 10] [f1=0.5151038119 f2=0.5437967797] - MADS run 13 ...... OK [bb eval= 32] [overall bb eval= 448] [# dominant pts= 111] [# new pts= 12] [f1=0.2592955042 f2=0.8727383732] - MADS run 14 ...... OK [bb eval= 32] [overall bb eval= 480] [# dominant pts= 117] [# new pts= 6] [f1=0.5684216658 f2=0.1147587127] - MADS run 15 ...... OK [bb eval= 20] [overall bb eval= 500] [# dominant pts= 120] [# new pts= 3] [f1=0.5684216658 f2=0.1147587127] + MADS run 1 ...... OK [bb eval= 64] [overall bb eval= 64] [# dominant pts= 6] [# new pts= 6] [f1=0 f2=6.231313115] + MADS run 2 ...... OK [bb eval= 32] [overall bb eval= 96] [# dominant pts= 10] [# new pts= 4] [f1=0.8147632732 f2=-0.4772846994] + MADS run 3 ...... OK [bb eval= 32] [overall bb eval= 128] [# dominant pts= 14] [# new pts= 4] [f1=0 f2=1] + MADS run 4 ...... OK [bb eval= 32] [overall bb eval= 160] [# dominant pts= 23] [# new pts= 9] [f1=0.3158760328 f2=0.5854826675] + MADS run 5 ...... OK [bb eval= 32] [overall bb eval= 192] [# dominant pts= 31] [# new pts= 8] [f1=0.563132696 f2=0.1198200644] + MADS run 6 ...... OK [bb eval= 32] [overall bb eval= 224] [# dominant pts= 48] [# new pts= 17] [f1=0.5283988375 f2=0.3748699372] + MADS run 7 ...... OK [bb eval= 32] [overall bb eval= 256] [# dominant pts= 66] [# new pts= 18] [f1=0.7870555978 f2=-0.2509912401] + MADS run 8 ...... OK [bb eval= 32] [overall bb eval= 288] [# dominant pts= 80] [# new pts= 14] [f1=0.268022029 f2=0.8108740924] + MADS run 9 ...... OK [bb eval= 32] [overall bb eval= 320] [# dominant pts= 91] [# new pts= 11] [f1=0.5153477455 f2=0.5405240953] + MADS run 10 ...... OK [bb eval= 32] [overall bb eval= 352] [# dominant pts= 95] [# new pts= 4] [f1=0.7680831771 f2=0.07286356753] + MADS run 11 ...... OK [bb eval= 32] [overall bb eval= 384] [# dominant pts= 102] [# new pts= 7] [f1=0.5137077274 f2=0.5626056928] + MADS run 12 ...... OK [bb eval= 32] [overall bb eval= 416] [# dominant pts= 108] [# new pts= 6] [f1=0.567828327 f2=0.1148265921] + MADS run 13 ...... OK [bb eval= 32] [overall bb eval= 448] [# dominant pts= 115] [# new pts= 7] [f1=0.5682426473 f2=0.1147658278] + MADS run 14 ...... OK [bb eval= 32] [overall bb eval= 480] [# dominant pts= 121] [# new pts= 6] [f1=0.5685361243 f2=0.1147602185] + MADS run 15 ...... OK [bb eval= 20] [overall bb eval= 500] [# dominant pts= 125] [# new pts= 4] [f1=0.5685361243 f2=0.1147602185] } end of run (max number of bb evaluations) @@ -46,125 +48,130 @@ number of MADS runs : 15 Pareto front { BBE ( 0.0000000000 0.0000000000 ) 0.0000000000 1.0000000000 - BBE ( 0.0027621359 0.0000000000 ) 0.0027621359 0.9998007770 BBE ( 0.0088388348 0.0000000000 ) 0.0088388348 0.9979744889 - BBE ( 0.0132582521 0.0000000000 ) 0.0132582521 0.9954876562 - BBE ( 0.0353553391 0.0000000000 ) 0.0353553391 0.9713080680 - BBE ( 0.0441941738 0.0000000000 ) 0.0441941738 0.9584480584 - BBE ( 0.0574524260 0.0000000000 ) 0.0574524260 0.9397084727 - BBE ( 0.0618718434 0.0000000000 ) 0.0618718434 0.9343077419 + BBE ( 0.0154679608 0.0000000000 ) 0.0154679608 0.9938978580 + BBE ( 0.0176776695 0.0000000000 ) 0.0176776695 0.9920893658 + BBE ( 0.0211561362 0.0000000000 ) 0.0211561362 0.9888260567 + BBE ( 0.0530330086 0.0000000000 ) 0.0530330086 0.9456485587 BBE ( 0.0707106781 0.0000000000 ) 0.0707106781 0.9257895286 - BBE ( 0.0729203868 0.0000000000 ) 0.0729203868 0.9242486972 - BBE ( 0.0734728140 0.0000000000 ) 0.0734728140 0.9239051795 - BBE ( 0.0765111634 0.0000000000 ) 0.0765111634 0.9223298234 - BBE ( 0.0783065517 0.0000000000 ) 0.0783065517 0.9216597507 - BBE ( 0.0795495129 0.0000000000 ) 0.0795495129 0.9213144638 - BBE ( 0.0801709935 0.0000000000 ) 0.0801709935 0.9211790945 - BBE ( 0.0804989971 0.0000000000 ) 0.0804989971 0.9211178038 - BBE ( 0.0814830080 0.0000000000 ) 0.0814830080 0.9209765043 - BBE ( 0.0839689303 0.0000000000 ) 0.0839689303 0.9209099136 - BBE ( 0.2546689267 0.0000000000 ) 0.2546689267 0.9053286734 - BBE ( 0.2554285140 0.0000000000 ) 0.2554285140 0.9000152969 - BBE ( 0.2559809412 0.0000000000 ) 0.2559809412 0.8961400979 - BBE ( 0.2592955042 0.0000000000 ) 0.2592955042 0.8727383732 - BBE ( 0.2601241450 0.0002762136 ) 0.2601241450 0.8698079048 - BBE ( 0.2624029071 0.0011048543 ) 0.2624029071 0.8624679573 - BBE ( 0.2633006012 0.0008286408 ) 0.2633006012 0.8531427520 - BBE ( 0.2634387080 0.0001898968 ) 0.2634387080 0.8453357823 - BBE ( 0.2635077614 0.0000000000 ) 0.2635077614 0.8428146572 - BBE ( 0.2643364022 0.0000000000 ) 0.2643364022 0.8369299127 - BBE ( 0.2673747516 0.0000000000 ) 0.2673747516 0.8154302217 - BBE ( 0.2679271788 0.0000000000 ) 0.2679271788 0.8115410603 - BBE ( 0.2695844603 0.0000000000 ) 0.2695844603 0.7999251464 - BBE ( 0.2740038777 0.0022097087 ) 0.2740038777 0.7931862207 - BBE ( 0.2748325185 0.0000000000 ) 0.2748325185 0.7638619206 - BBE ( 0.2762135864 0.0002762136 ) 0.2762135864 0.7575848978 - BBE ( 0.2773184407 0.0000000000 ) 0.2773184407 0.7473019205 - BBE ( 0.2828427125 0.0000000000 ) 0.2828427125 0.7121565043 - BBE ( 0.2872621299 0.0000000000 ) 0.2872621299 0.6860941024 - BBE ( 0.2900242657 0.0000000000 ) 0.2900242657 0.6709156096 - BBE ( 0.2961009646 0.0000000000 ) 0.2961009646 0.6410185691 - BBE ( 0.3005203820 0.0000000000 ) 0.3005203820 0.6226855524 - BBE ( 0.3016252363 0.0000000000 ) 0.3016252363 0.6185926969 - BBE ( 0.3088067896 0.0000000000 ) 0.3088067896 0.5971609072 - BBE ( 0.3093592168 0.0000000000 ) 0.3093592168 0.5959009619 - BBE ( 0.3137786342 0.0000000000 ) 0.3137786342 0.5879263396 - BBE ( 0.3165407700 0.0000000000 ) 0.3165407700 0.5848920973 - BBE ( 0.3167479302 0.0000000000 ) 0.3167479302 0.5847262751 - BBE ( 0.3176456244 0.0000000000 ) 0.3176456244 0.5841081818 - BBE ( 0.3181980515 0.0000000000 ) 0.3181980515 0.5838092475 - BBE ( 0.3226174689 0.0000000000 ) 0.3226174689 0.5836743517 - BBE ( 0.5127214698 0.0000000000 ) 0.5127214698 0.5759653136 - BBE ( 0.5137572707 0.0002762136 ) 0.5137572707 0.5654252540 - BBE ( 0.5140334843 0.0000000000 ) 0.5140334843 0.5582055541 - BBE ( 0.5150347585 0.0000172633 ) 0.5150347585 0.5449424207 - BBE ( 0.5151038119 0.0000000000 ) 0.5151038119 0.5437967797 - BBE ( 0.5153886572 0.0000000000 ) 0.5153886572 0.5399756398 - BBE ( 0.5165194066 0.0000000000 ) 0.5165194066 0.5248681601 - BBE ( 0.5169337269 0.0000000000 ) 0.5169337269 0.5193587219 - BBE ( 0.5173135206 0.0000000000 ) 0.5173135206 0.5143215129 - BBE ( 0.5179004745 0.0002762136 ) 0.5179004745 0.5100634344 - BBE ( 0.5181076347 0.0000690534 ) 0.5181076347 0.5047074913 - BBE ( 0.5181766881 0.0000000000 ) 0.5181766881 0.5029223883 - BBE ( 0.5183147949 0.0000000000 ) 0.5183147949 0.5011051160 - BBE ( 0.5192124890 0.0000000000 ) 0.5192124890 0.4893395607 - BBE ( 0.5203173434 0.0002762136 ) 0.5203173434 0.4784843660 - BBE ( 0.5211459841 0.0010358009 ) 0.5211459841 0.4774378717 - BBE ( 0.5214912511 0.0000000000 ) 0.5214912511 0.4598694955 - BBE ( 0.5228723191 0.0000000000 ) 0.5228723191 0.4423168011 - BBE ( 0.5261868821 0.0000000000 ) 0.5261868821 0.4012836645 - BBE ( 0.5272917364 0.0000000000 ) 0.5272917364 0.3879862090 - BBE ( 0.5292252315 0.0000000000 ) 0.5292252315 0.3652213546 - BBE ( 0.5299157655 0.0000000000 ) 0.5299157655 0.3572555870 - BBE ( 0.5303300859 0.0000000000 ) 0.5303300859 0.3525194343 - BBE ( 0.5317111538 0.0000000000 ) 0.5317111538 0.3369744453 - BBE ( 0.5350257169 0.0000000000 ) 0.5350257169 0.3012827434 - BBE ( 0.5358543576 0.0000000000 ) 0.5358543576 0.2927387374 - BBE ( 0.5361305712 0.0000000000 ) 0.5361305712 0.2899259708 - BBE ( 0.5391689207 0.0000000000 ) 0.5391689207 0.2601947270 - BBE ( 0.5480077554 0.0000000000 ) 0.5480077554 0.1876299330 - BBE ( 0.5513223185 0.0000000000 ) 0.5513223185 0.1663336683 - BBE ( 0.5535320271 0.0000000000 ) 0.5535320271 0.1540707094 - BBE ( 0.5557417358 0.0000000000 ) 0.5557417358 0.1434067848 - BBE ( 0.5568465902 0.0000000000 ) 0.5568465902 0.1386867395 - BBE ( 0.5590562989 0.0000000000 ) 0.5590562989 0.1304923502 - BBE ( 0.5604373668 0.0000000000 ) 0.5604373668 0.1262254672 - BBE ( 0.5612660076 0.0000000000 ) 0.5612660076 0.1239843648 - BBE ( 0.5620687533 0.0000000000 ) 0.5620687533 0.1220429764 - BBE ( 0.5640022484 0.0000000000 ) 0.5640022484 0.1183011565 - BBE ( 0.5645805706 0.0000000000 ) 0.5645805706 0.1174398964 - BBE ( 0.5652020512 0.0000000000 ) 0.5652020512 0.1166473780 - BBE ( 0.5654092114 0.0000000000 ) 0.5654092114 0.1164138826 - BBE ( 0.5656854249 0.0000000000 ) 0.5656854249 0.1161264470 - BBE ( 0.5659616385 0.0000000000 ) 0.5659616385 0.1158663392 - BBE ( 0.5666866992 0.0000000000 ) 0.5666866992 0.1153137493 - BBE ( 0.5669024911 0.0000000000 ) 0.5669024911 0.1151857400 - BBE ( 0.5674462866 0.0000000000 ) 0.5674462866 0.1149374124 - BBE ( 0.5684216658 0.0000000000 ) 0.5684216658 0.1147587127 + BBE ( 0.2562138982 0.0000000000 ) 0.2562138982 0.8945033812 + BBE ( 0.2608404757 0.0000000000 ) 0.2608404758 0.8617719752 + BBE ( 0.2619453301 0.0000000000 ) 0.2619453301 0.8539197314 + BBE ( 0.2622905971 0.0000000000 ) 0.2622905971 0.8514653467 + BBE ( 0.2651217863 0.0003064244 ) 0.2651217863 0.8346375232 + BBE ( 0.2655361067 0.0000000000 ) 0.2655361067 0.8284226452 + BBE ( 0.2680220290 0.0000000000 ) 0.2680220290 0.8108740924 + BBE ( 0.2686435096 0.0000000000 ) 0.2686435096 0.8065101303 + BBE ( 0.2691268833 0.0000000000 ) 0.2691268833 0.8031238337 + BBE ( 0.2696793105 0.0000000000 ) 0.2696793105 0.7992629776 + BBE ( 0.2710603784 0.0003193720 ) 0.2710603784 0.7930864044 + BBE ( 0.2727867134 0.0000000000 ) 0.2727867134 0.7777651163 + BBE ( 0.2741677813 0.0000000000 ) 0.2741677813 0.7683544484 + BBE ( 0.2749964221 0.0002762136 ) 0.2749964221 0.7657285747 + BBE ( 0.2754797958 0.0000000000 ) 0.2754797958 0.7595122877 + BBE ( 0.2819017617 0.0000000000 ) 0.2819017617 0.7179584250 + BBE ( 0.2995794312 0.0000000000 ) 0.2995794312 0.6263296155 + BBE ( 0.3039988486 0.0000000000 ) 0.3039988486 0.6104981808 + BBE ( 0.3059323437 0.0000000000 ) 0.3059323437 0.6046312984 + BBE ( 0.3062085573 0.0000000000 ) 0.3062085573 0.6038477544 + BBE ( 0.3117328290 0.0000000000 ) 0.3117328290 0.5911477575 + BBE ( 0.3158760328 0.0000000000 ) 0.3158760328 0.5854826675 + BBE ( 0.3172571008 0.0000000000 ) 0.3172571008 0.5843556236 + BBE ( 0.3202954502 0.0000000000 ) 0.3202954502 0.5832430145 + BBE ( 0.5134487771 0.0000000000 ) 0.5134487771 0.5661080224 + BBE ( 0.5137077274 0.0000000000 ) 0.5137077274 0.5626056928 + BBE ( 0.5137940441 0.0000000000 ) 0.5137940441 0.5614391407 + BBE ( 0.5150715320 0.0000000000 ) 0.5150715320 0.5442301804 + BBE ( 0.5152786921 0.0000000000 ) 0.5152786921 0.5414500948 + BBE ( 0.5153477455 0.0000000000 ) 0.5153477455 0.5405240953 + BBE ( 0.5158224876 0.0003107403 ) 0.5158224876 0.5380991695 + BBE ( 0.5160987012 0.0005481113 ) 0.5160987012 0.5374102768 + BBE ( 0.5162799664 0.0000000000 ) 0.5162799664 0.5280587044 + BBE ( 0.5168841836 0.0000000000 ) 0.5168841836 0.5200167511 + BBE ( 0.5181098814 0.0000000000 ) 0.5181098814 0.5038021282 + BBE ( 0.5186623086 0.0000000000 ) 0.5186623086 0.4965407236 + BBE ( 0.5192147358 0.0000000000 ) 0.5192147358 0.4893102188 + BBE ( 0.5193183158 0.0000000000 ) 0.5193183158 0.4879580513 + BBE ( 0.5217006580 0.0000000000 ) 0.5217006580 0.4571922658 + BBE ( 0.5220804517 0.0000000000 ) 0.5220804517 0.4523508179 + BBE ( 0.5228055124 0.0000000000 ) 0.5228055124 0.4431601076 + BBE ( 0.5250152211 0.0000000000 ) 0.5250152211 0.4156003506 + BBE ( 0.5252914347 0.0000000000 ) 0.5252914347 0.4122059478 + BBE ( 0.5263962890 0.0000000000 ) 0.5263962890 0.3987478889 + BBE ( 0.5283988375 0.0000000000 ) 0.5283988375 0.3748699372 + BBE ( 0.5302632792 0.0000000000 ) 0.5302632792 0.3532808843 + BBE ( 0.5303323326 0.0000000000 ) 0.5303323326 0.3524938416 + BBE ( 0.5313681336 0.0007595874 ) 0.5313681336 0.3505244083 + BBE ( 0.5317134005 0.0002373711 ) 0.5317134005 0.3399926818 + BBE ( 0.5319205607 0.0000000000 ) 0.5319205607 0.3346507552 + BBE ( 0.5328873083 0.0000000000 ) 0.5328873083 0.3240405720 + BBE ( 0.5335087888 0.0002287394 ) 0.5335087888 0.3202607108 + BBE ( 0.5338540558 0.0000000000 ) 0.5338540558 0.3136280970 + BBE ( 0.5357875509 0.0000000000 ) 0.5357875509 0.2934217157 + BBE ( 0.5363399781 0.0000000000 ) 0.5363399781 0.2878054090 + BBE ( 0.5403105484 0.0000000000 ) 0.5403105484 0.2496195163 + BBE ( 0.5407593955 0.0000000000 ) 0.5407593955 0.2455543650 + BBE ( 0.5413118227 0.0000000000 ) 0.5413118227 0.2406240954 + BBE ( 0.5418642498 0.0000000000 ) 0.5418642498 0.2357753238 + BBE ( 0.5420196200 0.0000000000 ) 0.5420196200 0.2344264287 + BBE ( 0.5440739585 0.0005524272 ) 0.5440739585 0.2243656329 + BBE ( 0.5457312400 0.0000000000 ) 0.5457312400 0.2041983052 + BBE ( 0.5461455604 0.0000000000 ) 0.5461455604 0.2010684705 + BBE ( 0.5473885216 0.0000000000 ) 0.5473885216 0.1919834017 + BBE ( 0.5479409487 0.0000000000 ) 0.5479409487 0.1880940310 + BBE ( 0.5490458031 0.0000000000 ) 0.5490458031 0.1805936986 + BBE ( 0.5491493832 0.0000000000 ) 0.5491493832 0.1799097506 + BBE ( 0.5495982303 0.0000000000 ) 0.5495982303 0.1769843488 + BBE ( 0.5501506574 0.0000000000 ) 0.5501506574 0.1734699226 + BBE ( 0.5508584547 0.0000000000 ) 0.5508584547 0.1691070049 + BBE ( 0.5540176476 0.0000000000 ) 0.5540176476 0.1515886169 + BBE ( 0.5545700748 0.0000000000 ) 0.5545700748 0.1488595298 + BBE ( 0.5549843952 0.0000000000 ) 0.5549843952 0.1468790527 + BBE ( 0.5551225020 0.0000000000 ) 0.5551225020 0.1462315798 + BBE ( 0.5573322107 0.0000000000 ) 0.5573322107 0.1367428101 + BBE ( 0.5584370650 0.0000000000 ) 0.5584370650 0.1326198627 + BBE ( 0.5600943465 0.0000000000 ) 0.5600943465 0.1272233749 + BBE ( 0.5611992009 0.0000000000 ) 0.5611992009 0.1241561368 + BBE ( 0.5627183756 0.0000000000 ) 0.5627183756 0.1206381293 + BBE ( 0.5631326960 0.0000000000 ) 0.5631326960 0.1198200644 + BBE ( 0.5641167069 0.0000000000 ) 0.5641167069 0.1181212433 + BBE ( 0.5645137639 0.0000000000 ) 0.5645137639 0.1175332972 + BBE ( 0.5649453477 0.0000000000 ) 0.5649453477 0.1169580043 + BBE ( 0.5650661911 0.0000000000 ) 0.5650661911 0.1168088425 + BBE ( 0.5658948319 0.0000000000 ) 0.5658948319 0.1159267436 + BBE ( 0.5667234726 0.0000000000 ) 0.5667234726 0.1152907523 + BBE ( 0.5668615794 0.0000000000 ) 0.5668615794 0.1152087235 + BBE ( 0.5674140066 0.0000000000 ) 0.5674140066 0.1149491832 + BBE ( 0.5678283270 0.0000000000 ) 0.5678283270 0.1148265921 + BBE ( 0.5682426473 0.0000000000 ) 0.5682426473 0.1147658278 + BBE ( 0.5685361243 0.0000000000 ) 0.5685361243 0.1147602185 BBE ( 0.7661496820 0.0000000000 ) 0.7661496820 0.1105136967 - BBE ( 0.7669783228 0.0000000000 ) 0.7669783228 0.0943075051 BBE ( 0.7680831771 0.0000000000 ) 0.7680831771 0.0728635675 + BBE ( 0.7689118179 0.0000000000 ) 0.7689118179 0.0569125770 BBE ( 0.7691880314 0.0000000000 ) 0.7691880314 0.0516220389 - BBE ( 0.7694642450 0.0000000000 ) 0.7694642450 0.0463451418 - BBE ( 0.7704309926 0.0007941141 ) 0.7704309926 0.0406045540 + BBE ( 0.7699476188 0.0003841095 ) 0.7699476188 0.0432535935 BBE ( 0.7705690994 0.0000000000 ) 0.7705690994 0.0253788803 - BBE ( 0.7738836624 0.0000000000 ) 0.7738836624 -0.0360307769 - BBE ( 0.7741598760 0.0000000000 ) 0.7741598760 -0.0410385581 - BBE ( 0.7758171575 0.0000000000 ) 0.7758171575 -0.0706993622 - BBE ( 0.7760933711 0.0000000000 ) 0.7760933711 -0.0755763386 - BBE ( 0.7766457983 0.0000000000 ) 0.7766457983 -0.0852712175 - BBE ( 0.7771982255 0.0000000000 ) 0.7771982255 -0.0948858036 - BBE ( 0.7805127885 0.0000000000 ) 0.7805127885 -0.1507861609 - BBE ( 0.7816176428 0.0004488471 ) 0.7816176428 -0.1614780263 - BBE ( 0.7849322059 0.0000000000 ) 0.7849322059 -0.2200658533 - BBE ( 0.7854846330 0.0000000000 ) 0.7854846330 -0.2282658189 + BBE ( 0.7716739537 0.0000000000 ) 0.7716739537 0.0046504791 + BBE ( 0.7741598760 0.0002589502 ) 0.7741598760 -0.0369011145 + BBE ( 0.7783030798 0.0000000000 ) 0.7783030798 -0.1138668264 + BBE ( 0.7834820845 0.0000000000 ) 0.7834820845 -0.1980406893 + BBE ( 0.7841553552 0.0000000000 ) 0.7841553552 -0.2083556587 + BBE ( 0.7854673697 0.0005437955 ) 0.7854673697 -0.2192363858 + BBE ( 0.7858126367 0.0007250607 ) 0.7858126367 -0.2213881058 + BBE ( 0.7863650638 0.0007034815 ) 0.7863650638 -0.2297569563 + BBE ( 0.7864772756 0.0004822948 ) 0.7864772756 -0.2349368931 + BBE ( 0.7867103308 0.0000000000 ) 0.7867103308 -0.2460730547 + BBE ( 0.7870555978 0.0000000000 ) 0.7870555978 -0.2509912401 + BBE ( 0.7875864458 0.0002859242 ) 0.7875864458 -0.2538397470 BBE ( 0.7882467689 0.0000000000 ) 0.7882467689 -0.2676209257 - BBE ( 0.7937710406 0.0000000000 ) 0.7937710406 -0.3375181059 - BBE ( 0.7948758950 0.0000000000 ) 0.7948758950 -0.3499937714 - BBE ( 0.7970856037 0.0000000000 ) 0.7970856037 -0.3733607572 + BBE ( 0.7882985590 0.0000000000 ) 0.7882985590 -0.2683319140 + BBE ( 0.7895587834 0.0000000000 ) 0.7895587834 -0.2853173321 + BBE ( 0.7904564776 0.0000000000 ) 0.7904564776 -0.2970410590 + BBE ( 0.7926661863 0.0000000000 ) 0.7926661863 -0.3245272558 + BBE ( 0.7981904580 0.0000000000 ) 0.7981904580 -0.3842336561 BBE ( 0.8059244384 0.0000000000 ) 0.8059244384 -0.4444581650 - BBE ( 0.8103438558 0.0000000000 ) 0.8103438558 -0.4658115097 - BBE ( 0.8169729819 0.0000000000 ) 0.8169729819 -0.4792608690 + BBE ( 0.8147632732 0.0000000000 ) 0.8147632732 -0.4772846994 + BBE ( 0.8191826906 0.0000000000 ) 0.8191826906 -0.4787160837 } -number of Pareto points: 120 +number of Pareto points: 125 diff --git a/examples/basic/batch/single_obj/runExample.log b/examples/basic/batch/single_obj/runExample.log index 129534c62d6d14517472e10b8a68c1e37251e170..9311a4b97851af8276bca6ae400109436ebcecfa 100644 --- a/examples/basic/batch/single_obj/runExample.log +++ b/examples/basic/batch/single_obj/runExample.log @@ -1,17 +1,19 @@ -NOMAD - version 3.7.2 - www.gerad.ca/nomad - -Copyright (C) 2001-2015 { - Mark A. Abramson - The Boeing Company +NOMAD - version 3.7.3 has been created by { Charles Audet - Ecole Polytechnique de Montreal - Gilles Couture - Ecole Polytechnique de Montreal - John E. Dennis, Jr. - Rice University Sebastien Le Digabel - Ecole Polytechnique de Montreal Christophe Tribes - Ecole Polytechnique de Montreal } -Funded in part by AFOSR and Exxon Mobil. +The copyright of NOMAD - version 3.7.3 is owned by { + Sebastien Le Digabel - Ecole Polytechnique de Montreal + Christophe Tribes - Ecole Polytechnique de Montreal +} + +NOMAD version 3 is a new version of Nomad v1 and v2, it has been funded by AFOSR and Exxon Mobil. +Nomad v1 and v2 were created and developed by Mark A. Abramson from The Boeing Company, Charles Audet and Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from Rice University, and were funded by AFOSR and Exxon Mobil. +Download : www.gerad.ca/nomad License : '$NOMAD_HOME/src/lgpl.txt' User guide: '$NOMAD_HOME/doc/user_guide.pdf' Examples : '$NOMAD_HOME/examples' @@ -28,16 +30,12 @@ MADS run { 3 ( 0.0000000000 2.1466252584 2.3255106966 -1.0733126292 1.0733126292 ) 1.0733100000 10 ( 0.4919349550 2.8174456516 2.1801662781 -0.8720665112 1.0062305899 ) 1.0062300000 11 ( 1.9677398202 4.8299068314 1.7441330224 -0.2683281573 0.8049844719 ) 0.8049840000 - 13 ( 0.0000000000 1.6099689438 2.9068883707 -0.8049844719 0.5366563146 ) 0.5366560000 - 17 ( 3.5241951349 1.7067494832 0.5813776741 -0.5366563146 0.2683281573 ) 0.2683280000 - 28 ( 2.0483902697 -2.5865010336 3.4882660449 1.8782971011 0.0000000000 ) 0.0000000000 - 67 ( 2.0483902697 1.7067494832 2.3255106966 -0.5366563146 -2.4149534157 ) -2.4149500000 - 86 ( 3.0322601798 0.6334368540 0.0000000000 2.6832815730 -2.9516097303 ) -2.9516100000 - 96 ( 1.5564553147 1.7067494832 -0.5813776741 1.6099689438 -3.4882660449 ) -3.4882700000 - 100 ( 1.5564553147 1.7067494832 -0.5813776741 1.6099689438 -3.4882660449 ) -3.4882700000 + 19 ( 0.9838699101 1.0733126292 1.7441330224 1.0733126292 -3.4882660449 ) -3.4882700000 + 31 ( 1.9677398202 0.5366563146 1.7441330224 0.2683281573 -3.7565942022 ) -3.7565900000 + 100 ( 1.9677398202 0.5366563146 1.7441330224 0.2683281573 -3.7565942022 ) -3.7565900000 } end of run (max number of blackbox evaluations) blackbox evaluations : 100 -best infeasible solution (min. violation): ( -0.9032194606 -0.4398757752 4.069643719 -0.2683281573 -1.878297101 ) h=0.0114496 f=-1.8783 -best feasible solution : ( 1.556455315 1.706749483 -0.5813776741 1.609968944 -3.488266045 ) h=0 f=-3.48827 +best infeasible solution (min. violation): ( 0.9838699101 1.073312629 1.162755348 1.073312629 -4.024922359 ) h=0.287344 f=-4.02492 +best feasible solution : ( 1.96773982 0.5366563146 1.744133022 0.2683281573 -3.756594202 ) h=0 f=-3.75659 diff --git a/examples/basic/batch/single_obj_parallel/bb_parallel.cpp b/examples/basic/batch/single_obj_parallel/bb_parallel.cpp index c17a350dc66a5e27e49121fe8c6bea0de7a83f9d..71aba0e98e24d32ab2f4a6a80099287ebf3ce6fc 100644 --- a/examples/basic/batch/single_obj_parallel/bb_parallel.cpp +++ b/examples/basic/batch/single_obj_parallel/bb_parallel.cpp @@ -8,106 +8,117 @@ using namespace std; -// Number of threads to be used in parallel -#define NUM_THREADS 4 +// Number of threads to be used in parallel +#define NUM_THREADS 4 + +// A semaphore to manage the threads +sem_t mySemaphore; static void * eval_x ( void * dummy_eval_arg ) { - - double c1 = 0.0 , c2 = 0.0 ,f; - double * x = static_cast<double *>(dummy_eval_arg); - for ( int i = 0 ; i < 5 ; i++) - { - c1 += pow ( x[i]-1 , 2 ); - c2 += pow ( x[i]+1 , 2 ); + + double c1 = 0.0 , c2 = 0.0 ,f; + double * x = static_cast<double *>(dummy_eval_arg); + for ( int i = 0 ; i < 5 ; i++) + { + c1 += pow ( x[i]-1 , 2 ); + c2 += pow ( x[i]+1 , 2 ); } x[5]= x[4]; x[6] = c1 - 25; x[7] = 25 - c2; - - // cout << x[0] << " " << x[1] <<" " << x[2] <<" "<< x[3] <<" "<< x[4] << " " << x[5] << " " << x[6] << " " << x[7] << endl; - - pthread_exit(NULL); - + + // cout << x[0] << " " << x[1] <<" " << x[2] <<" "<< x[3] <<" "<< x[4] << " " << x[5] << " " << x[6] << " " << x[7] << endl; + + pthread_exit(NULL); + + // Increase the semaphore ---> a new thread can be launched + sem_post(&mySemaphore); + } int main ( int argc , char ** argv ) - { - - double f = 1e20, c1 = 1e20 , c2 = 1e20; - std::vector< double * > X; - - if ( argc >= 2 ) - { +{ - ifstream in ( argv[1] ); - - while( ! in.eof() ) + double f = 1e20, c1 = 1e20 , c2 = 1e20; + std::vector< double * > X; + + if ( argc >= 2 ) { - double *x = new double [8]; - for ( int i = 0 ; i < 5 ; i++ ) - in >> x[i]; + + ifstream in ( argv[1] ); + + while( ! in.eof() ) + { + double *x = new double [8]; + for ( int i = 0 ; i < 5 ; i++ ) + in >> x[i]; + + X.push_back(x); + + //char c; + // in >> c; + + // cout << x[0] << " " << x[1] <<endl; + + } + in.close(); + X.pop_back(); + + int nb_pts=X.size(); + + // All threads are created + pthread_t threads[nb_pts]; + + // Initialize the semaphore with the number of threads available + sem_init(&mySemaphore,0,NUM_THREADS); + + // Another way to use semaphore + // sem_t * mySemaphore; + // mySemaphore=sem_open("sem",0,NUM_THREADS); + + + // The list of points is evaluated under the control of a semaphore + int i=0; + for (std::vector< double * >::iterator it_x=X.begin(); it_x!=X.end(); ++it_x,++i) + { + // cout << (*it_x)[0] << " " << (*it_x)[1] << " " << (*it_x)[2] << endl; + int rc=pthread_create(&threads[i], NULL, eval_x,(*it_x)); + if (rc) + { + cout << "Error:unable to create thread," << rc << endl; + return false; + } + // wait until value of semaphore is greater than 0 + // and decrement the value of semaphore by 1 + sem_wait(&mySemaphore); + + } + + int ret; + + // cout << nb_pts << endl; + for (i=0; i<nb_pts; ++i) + { + // Wait for all the threads to finish + ret=pthread_join(threads[i],0); + if (ret!=0) + { + perror("pthread join has failed"); + return false; + } + cout << (X[i])[5] << " " << (X[i])[6] << " " << (X[i])[7] << endl; + delete [](X[i]); + } + // Unlink semaphore if the "other" way is used + // sem_unlink("sem"); + + sem_destroy(&mySemaphore); + + } + + return 0; - X.push_back(x); - - //char c; - // in >> c; - - // cout << x[0] << " " << x[1] <<endl; - - } - in.close(); - X.pop_back(); - - int nb_pts=X.size(); - - // All threads are created - pthread_t threads[nb_pts]; - - // The semaphore will allow to run NUM_THREADS in parallel - sem_t *mySemaphore; - mySemaphore=sem_open("sem",0,NUM_THREADS); - - // The list of points is evaluated under the control of a semaphore - int i=0; - for (std::vector< double * >::iterator it_x=X.begin(); it_x!=X.end(); ++it_x,++i) - { - // cout << (*it_x)[0] << " " << (*it_x)[1] << " " << (*it_x)[2] << endl; - int rc=pthread_create(&threads[i], NULL, eval_x,(*it_x)); - if (rc) - { - cout << "Error:unable to create thread," << rc << endl; - return false; - } - // wait until value of semaphore is greater than 0 - // decrement the value of semaphore by 1 - sem_wait(mySemaphore); - - } - - int ret; - - // cout << nb_pts << endl; - for (i=0; i<nb_pts; ++i) - { - // Wait for all the threads to finish - ret=pthread_join(threads[i],0); - if (ret!=0) - { - perror("pthread join has failed"); - return false; - } - cout << (X[i])[5] << " " << (X[i])[6] << " " << (X[i])[7] << endl; - delete [](X[i]); - } - - sem_unlink("sem"); - - - } - - return 0; - } diff --git a/examples/basic/batch/single_obj_parallel/param.txt b/examples/basic/batch/single_obj_parallel/param.txt index bd843429ced1236a62d6338e0de16a939fe649ac..237325e893c937ea040427cb0a0ee8130185f7ea 100644 --- a/examples/basic/batch/single_obj_parallel/param.txt +++ b/examples/basic/batch/single_obj_parallel/param.txt @@ -2,6 +2,7 @@ DIMENSION 5 # number of variables BB_EXE "$perl parallel_BBWrapper.pl" # BB_EXE bb_parallel.exe + BB_MAX_BLOCK_SIZE 2 BB_OUTPUT_TYPE OBJ PB EB diff --git a/examples/basic/batch/single_obj_parallel/runExample.log b/examples/basic/batch/single_obj_parallel/runExample.log index 2cad6904c99be5720e8b8392513889fdf8e20e89..fb033a1e7be0a7303acc1c15782b6f249a673229 100644 --- a/examples/basic/batch/single_obj_parallel/runExample.log +++ b/examples/basic/batch/single_obj_parallel/runExample.log @@ -2,19 +2,21 @@ Warning: { The maximum number of evaluations may be exceeded when BB_MAX_BLOCK_SIZE>1. } -NOMAD - version 3.7.2 - www.gerad.ca/nomad - -Copyright (C) 2001-2015 { - Mark A. Abramson - The Boeing Company +NOMAD - version 3.7.3 has been created by { Charles Audet - Ecole Polytechnique de Montreal - Gilles Couture - Ecole Polytechnique de Montreal - John E. Dennis, Jr. - Rice University Sebastien Le Digabel - Ecole Polytechnique de Montreal Christophe Tribes - Ecole Polytechnique de Montreal } -Funded in part by AFOSR and Exxon Mobil. +The copyright of NOMAD - version 3.7.3 is owned by { + Sebastien Le Digabel - Ecole Polytechnique de Montreal + Christophe Tribes - Ecole Polytechnique de Montreal +} + +NOMAD version 3 is a new version of Nomad v1 and v2, it has been funded by AFOSR and Exxon Mobil. +Nomad v1 and v2 were created and developed by Mark A. Abramson from The Boeing Company, Charles Audet and Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from Rice University, and were funded by AFOSR and Exxon Mobil. +Download : www.gerad.ca/nomad License : '$NOMAD_HOME/src/lgpl.txt' User guide: '$NOMAD_HOME/doc/user_guide.pdf' Examples : '$NOMAD_HOME/examples' @@ -31,13 +33,13 @@ MADS run { 4 0.0000000000 (PhaseOne) 4 -1.0733100000 10 -1.6099700000 - 23 -2.4149500000 - 26 -3.4882700000 - 48 -3.7565900000 - 101 -3.7565900000 + 15 -3.4882700000 + 45 -3.7565900000 + 79 -3.9578400000 + 100 -3.9578400000 } end of run (max number of blackbox evaluations) -blackbox evaluations : 101 -best infeasible solution (min. violation): ( 1.106853649 0.9391485505 1.01741093 1.00623059 -4.024922359 ) h=0.265307 f=-4.02492 -best feasible solution : ( 0.9838699101 0.5366563146 1.744133022 1.341640786 -3.756594202 ) h=0 f=-3.75659 +blackbox evaluations : 100 +best infeasible solution (min. violation): ( 0.9838699101 1.609968944 1.01741093 0.5366563146 -3.95784032 ) h=0.167493 f=-3.95784 +best feasible solution : ( 0.9531239754 1.475804865 0.9447387205 0.6037383539 -3.95784032 ) h=0 f=-3.95784 diff --git a/examples/basic/library/bi_obj/makefile b/examples/basic/library/bi_obj/makefile index 582714a76b2b8f9f7c9a8274fd94defad7cd34bc..8a2cbcb18287149a640371395be865a0b0f0360e 100644 --- a/examples/basic/library/bi_obj/makefile +++ b/examples/basic/library/bi_obj/makefile @@ -1,25 +1,37 @@ -EXE = basic_lib.exe -EXE_MPI = basic_lib_MPI.exe - -COMPILATOR = g++ -COMPILATOR_MPI = mpic++ -SUNAME = $(shell uname) -OSS=$(findstring MINGW32,$(SUNAME)) -ifneq "$(strip $(OSS))" "" -COMPILATOR_MPI = g++ -endif +UNAME := $(shell uname) + +EXE = basic_lib.exe +EXE_MPI = basic_lib_MPI.exe -COMPILATOR_OPTIONS = -O2 -ansi +COMPILATOR = g++ +COMPILATOR_MPI = mpic++ + +COMPILATOR_OPTIONS = -O2 -ansi COMPILATOR_OPTIONS_MPI = $(COMPILATOR_OPTIONS) -DUSE_MPI -L1 = $(NOMAD_HOME)/lib/nomad.a -L1_MPI = $(NOMAD_HOME)/lib/nomad.MPI.a -LIBS = $(L1) -lm -LIBS_MPI = $(L1_MPI) -lm -lmpi -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -COMPILE_MPI = $(COMPILATOR_MPI) $(COMPILATOR_OPTIONS_MPI) $(INCLUDE) -c -OBJS = basic_lib.o -OBJS_MPI = basic_lib_MPI.o + + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so +LIB_NOMAD_MPI = libnomad.MPI.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif +CXXFLAGS_MPI = $(CXXFLAGS) -DUSE_MPI + + +LDLIBS = -lm -lnomad +LDLIBS_MPI = -lm -lmpi -lnomad.MPI + +INCLUDE = -I$(NOMAD_HOME)/src -I. + +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +COMPILE_MPI = $(COMPILATOR_MPI) $(COMPILATOR_OPTIONS_MPI) $(INCLUDE) -c + +OBJS = basic_lib.o +OBJS_MPI = basic_lib_MPI.o ifndef NOMAD_HOME @@ -30,19 +42,23 @@ endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) @echo " building the scalar version ..." @echo " exe file : "$(EXE) - @$(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) - @strip $(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif -$(EXE_MPI): $(L1_MPI) $(OBJS_MPI) +$(EXE_MPI): $(OBJS_MPI) $(ECHO_NOMAD) @echo " building the MPI version ..." @echo " exe file : "$(EXE_MPI) - @$(COMPILATOR_MPI) -o $(EXE_MPI) $(OBJS_MPI) $(LIBS_MPI) $(COMPILATOR_OPTIONS_MPI) - @strip $(EXE_MPI) + @$(COMPILATOR_MPI) -o $(EXE_MPI) $(OBJS_MPI) $(LDLIBS_MPI) $(CXXFLAGS_MPI) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD_MPI) $(NOMAD_HOME)/lib/$(LIB_NOMAD_MPI) $(EXE_MPI) +endif basic_lib.o: basic_lib.cpp $(ECHO_NOMAD) @@ -52,8 +68,6 @@ basic_lib_MPI.o: basic_lib.cpp $(ECHO_NOMAD) @$(COMPILE_MPI) basic_lib.cpp -o basic_lib_MPI.o -$(L1) $(L1_MPI): ; - $(ECHO_NOMAD) mpi: $(EXE_MPI) diff --git a/examples/basic/library/bi_obj/runExample.log b/examples/basic/library/bi_obj/runExample.log index 368fa2ef0e8506c3e93de99319debf1d17551f7b..a35b120072c645caea25843416d24fe0b0bd37bb 100644 --- a/examples/basic/library/bi_obj/runExample.log +++ b/examples/basic/library/bi_obj/runExample.log @@ -2,9 +2,9 @@ multi-MADS run { MADS run 1 ...... OK [bb eval= 46] [overall bb eval= 46] [# dominant pts= 3] [# new pts= 3] [f1=-6 f2=152.5555363] - MADS run 2 ...... OK [bb eval= 23] [overall bb eval= 69] [# dominant pts= 6] [# new pts= 3] [f1=-1.170093169 f2=-7.948136425] - MADS run 3 ...... OK [bb eval= 23] [overall bb eval= 92] [# dominant pts= 8] [# new pts= 2] [f1=-6 f2=27.18734544] - MADS run 4 ...... OK [bb eval= 8] [overall bb eval= 100] [# dominant pts= 9] [# new pts= 1] [f1=-4.390031056 f2=12.07995483] + MADS run 2 ...... OK [bb eval= 23] [overall bb eval= 69] [# dominant pts= 5] [# new pts= 2] [f1=-0.5603796086 f2=-9.723737785] + MADS run 3 ...... OK [bb eval= 23] [overall bb eval= 92] [# dominant pts= 8] [# new pts= 3] [f1=-5.121958283 f2=23.04985828] + MADS run 4 ...... OK [bb eval= 8] [overall bb eval= 100] [# dominant pts= 10] [# new pts= 2] [f1=-3.780317496 f2=7.348181107] } end of run (max number of bb evaluations) @@ -14,15 +14,16 @@ number of MADS runs : 4 Pareto front { - -6.0000000000 27.1873454385 - -5.4633436854 20.4877802253 - -4.9266873708 17.7107260310 - -4.3900310562 12.0799548321 - -4.1217028989 4.6477802253 - -3.8533747416 1.3742832861 - -3.5850465843 -0.2031008969 - -3.3167184270 -3.6003194012 - -1.1700931686 -7.9481364246 + -6.0000000000 43.0227873016 + -5.9269427546 35.4890842852 + -5.3902864400 34.8873088235 + -5.1219582827 23.0498582755 + -4.5853019681 22.3745620084 + -3.7803174962 7.3481811074 + -2.7070048670 -2.5579608209 + -2.4386767097 -3.2681325630 + -0.8287077659 -4.2758679628 + -0.5603796086 -9.7237377852 } -number of Pareto points: 9 +number of Pareto points: 10 diff --git a/examples/basic/library/single_obj/basic_lib.cpp b/examples/basic/library/single_obj/basic_lib.cpp index ea99384fe47fab1920a84b6962168606c71f40f9..94b28b38ba083edfe646b1cf9fcbd15e867c703f 100644 --- a/examples/basic/library/single_obj/basic_lib.cpp +++ b/examples/basic/library/single_obj/basic_lib.cpp @@ -32,8 +32,11 @@ public: count_eval = true; // count a black-box evaluation + //if ( c1-25 < 0 && 25-c2 < 0 && x[4] < -3.2 ) + // NOMAD::Evaluator::force_quit(); + return true; // the evaluation succeeded - } +} }; @@ -75,7 +78,8 @@ int main ( int argc , char ** argv ) { ub[2] = 7.0; // x_3 <= 7 p.set_UPPER_BOUND ( ub ); - p.set_MAX_BB_EVAL (100); // the algorithm terminates after + p.set_LIMIT_MESH_INDEX( -1 ); + //p.set_MAX_BB_EVAL (10000); // the algorithm terminates after // 100 black-box evaluations p.set_DISPLAY_DEGREE(2); p.set_SOLUTION_FILE("sol.txt"); diff --git a/examples/basic/library/single_obj/makefile b/examples/basic/library/single_obj/makefile index 582714a76b2b8f9f7c9a8274fd94defad7cd34bc..8a2cbcb18287149a640371395be865a0b0f0360e 100644 --- a/examples/basic/library/single_obj/makefile +++ b/examples/basic/library/single_obj/makefile @@ -1,25 +1,37 @@ -EXE = basic_lib.exe -EXE_MPI = basic_lib_MPI.exe - -COMPILATOR = g++ -COMPILATOR_MPI = mpic++ -SUNAME = $(shell uname) -OSS=$(findstring MINGW32,$(SUNAME)) -ifneq "$(strip $(OSS))" "" -COMPILATOR_MPI = g++ -endif +UNAME := $(shell uname) + +EXE = basic_lib.exe +EXE_MPI = basic_lib_MPI.exe -COMPILATOR_OPTIONS = -O2 -ansi +COMPILATOR = g++ +COMPILATOR_MPI = mpic++ + +COMPILATOR_OPTIONS = -O2 -ansi COMPILATOR_OPTIONS_MPI = $(COMPILATOR_OPTIONS) -DUSE_MPI -L1 = $(NOMAD_HOME)/lib/nomad.a -L1_MPI = $(NOMAD_HOME)/lib/nomad.MPI.a -LIBS = $(L1) -lm -LIBS_MPI = $(L1_MPI) -lm -lmpi -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -COMPILE_MPI = $(COMPILATOR_MPI) $(COMPILATOR_OPTIONS_MPI) $(INCLUDE) -c -OBJS = basic_lib.o -OBJS_MPI = basic_lib_MPI.o + + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so +LIB_NOMAD_MPI = libnomad.MPI.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif +CXXFLAGS_MPI = $(CXXFLAGS) -DUSE_MPI + + +LDLIBS = -lm -lnomad +LDLIBS_MPI = -lm -lmpi -lnomad.MPI + +INCLUDE = -I$(NOMAD_HOME)/src -I. + +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +COMPILE_MPI = $(COMPILATOR_MPI) $(COMPILATOR_OPTIONS_MPI) $(INCLUDE) -c + +OBJS = basic_lib.o +OBJS_MPI = basic_lib_MPI.o ifndef NOMAD_HOME @@ -30,19 +42,23 @@ endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) @echo " building the scalar version ..." @echo " exe file : "$(EXE) - @$(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) - @strip $(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif -$(EXE_MPI): $(L1_MPI) $(OBJS_MPI) +$(EXE_MPI): $(OBJS_MPI) $(ECHO_NOMAD) @echo " building the MPI version ..." @echo " exe file : "$(EXE_MPI) - @$(COMPILATOR_MPI) -o $(EXE_MPI) $(OBJS_MPI) $(LIBS_MPI) $(COMPILATOR_OPTIONS_MPI) - @strip $(EXE_MPI) + @$(COMPILATOR_MPI) -o $(EXE_MPI) $(OBJS_MPI) $(LDLIBS_MPI) $(CXXFLAGS_MPI) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD_MPI) $(NOMAD_HOME)/lib/$(LIB_NOMAD_MPI) $(EXE_MPI) +endif basic_lib.o: basic_lib.cpp $(ECHO_NOMAD) @@ -52,8 +68,6 @@ basic_lib_MPI.o: basic_lib.cpp $(ECHO_NOMAD) @$(COMPILE_MPI) basic_lib.cpp -o basic_lib_MPI.o -$(L1) $(L1_MPI): ; - $(ECHO_NOMAD) mpi: $(EXE_MPI) diff --git a/examples/basic/library/single_obj/runExample.log b/examples/basic/library/single_obj/runExample.log index 062f2c3da6c7831a471eee9e8a055910f3031e8d..e10eb493b8917c9a46e5a28ac815427a8a823116 100644 --- a/examples/basic/library/single_obj/runExample.log +++ b/examples/basic/library/single_obj/runExample.log @@ -6,17 +6,15 @@ MADS run { 2 ( 0.0000000000 0.5366563146 0.5813776741 -0.2683281573 0.2683281573 ) 288.7937255854 (PhaseOne) 3 ( 0.0000000000 2.1466252584 2.3255106966 -1.0733126292 1.0733126292 ) 0.0000000000 (PhaseOne) 3 ( 0.0000000000 2.1466252584 2.3255106966 -1.0733126292 1.0733126292 ) 1.0733126292 - 11 ( 0.1229837388 2.5491174943 2.6161995337 -1.0733126292 0.8720665112 ) 0.8720665112 - 12 ( 0.4919349550 3.7565942022 3.4882660449 -1.0733126292 0.2683281573 ) 0.2683281573 - 21 ( 0.4919349550 4.2932505168 4.0696437190 -0.2683281573 -0.2683281573 ) -0.2683281573 - 23 ( 1.9677398202 1.6099689438 3.4882660449 -0.8049844719 -1.3416407865 ) -1.3416407865 - 38 ( 1.4758048651 3.2199378876 -0.5813776741 -0.2683281573 -2.9516097303 ) -2.9516097303 - 56 ( 1.9677398202 1.0733126292 1.7441330224 0.5366563146 -3.7565942022 ) -3.7565942022 - 85 ( 1.4758048651 0.9391485505 1.1627553483 0.8049844719 -3.8907582808 ) -3.8907582808 - 100 ( 1.4758048651 0.9391485505 1.1627553483 0.8049844719 -3.8907582808 ) -3.8907582808 + 10 ( -0.1229837388 2.0124611797 2.9068883707 -1.1403946685 1.0062305899 ) 1.0062305899 + 11 ( -0.4919349550 1.6099689438 4.6510213932 -1.3416407865 0.8049844719 ) 0.8049844719 + 13 ( 0.0000000000 0.5366563146 5.2323990673 -0.5366563146 0.5366563146 ) 0.5366563146 + 28 ( 2.9516097303 2.6832815730 4.6510213932 0.5366563146 -1.0733126292 ) -1.0733126292 + 32 ( 0.4919349550 2.1466252584 1.1627553483 0.2683281573 -3.7565942022 ) -3.7565942022 + 100 ( 0.4919349550 2.1466252584 1.1627553483 0.2683281573 -3.7565942022 ) -3.7565942022 } end of run (max number of blackbox evaluations) blackbox evaluations : 100 -best infeasible solution (min. violation): ( 3.443544685 2.683281573 1.744133022 0.8049844719 -2.95160973 ) h=0.0113319552 f=-2.95160973 -best feasible solution : ( 1.475804865 0.9391485505 1.162755348 0.8049844719 -3.890758281 ) h=0 f=-3.890758281 +best infeasible solution (min. violation): ( 2.459674775 0.5366563146 1.162755348 1.073312629 -3.756594202 ) h=0.0023902697 f=-3.756594202 +best feasible solution : ( 0.491934955 2.146625258 1.162755348 0.2683281573 -3.756594202 ) h=0 f=-3.756594202 diff --git a/examples/basic/library/single_obj_parallel/basic_lib.cpp b/examples/basic/library/single_obj_parallel/basic_lib.cpp index 408e841dc3442a35c94fcdaf8268a3d2f71d7e6f..e67457ea60d426a62f24cfcf8525da195f892fa5 100644 --- a/examples/basic/library/single_obj_parallel/basic_lib.cpp +++ b/examples/basic/library/single_obj_parallel/basic_lib.cpp @@ -8,196 +8,202 @@ using namespace std; // using namespace NOMAD; avoids putting NOMAD:: everywhere -// Number of threads to be used in parallel -#define NUM_THREADS 4 +// Number of threads to be used in parallel +#define NUM_THREADS 4 -// A semaphore to manage parallel evaluations with NUM_THREADS -sem_t *mySemaphore; +// A semaphore to manage the number of threads to be run concurrently +sem_t mySemaphore; // A structure to pass arguments to the evaluation wrapper function class My_Evaluator; typedef struct Arg_Eval_tag { - NOMAD::Eval_Point * x ; - NOMAD::Double h_max; - bool * count_eval; - const My_Evaluator * ev; + NOMAD::Eval_Point * x ; + NOMAD::Double h_max; + bool * count_eval; } Arg_Eval_t; +/*----------------------------------------*/ +/* The problem evaluatiom */ +/*----------------------------------------*/ +// Provide the objective and constraints here +bool eval_x ( NOMAD::Eval_Point & x , + const NOMAD::Double & h_max , + bool & count_eval ) +{ + + NOMAD::Double c1 = 0.0 , c2 = 0.0; + for ( int i = 0 ; i < 5 ; i++ ) + { + c1 += (x[i]-1).pow2(); + c2 += (x[i]+1).pow2(); + } + x.set_bb_output ( 0 , x[4] ); // objective value + x.set_bb_output ( 1 , c1-25 ); // constraint 1 + x.set_bb_output ( 2 , 25-c2 ); // constraint 2 + + count_eval = true; // count a black-box evaluation + + return true; // the evaluation succeeded +} -class My_Evaluator : public NOMAD::Evaluator { -public: - My_Evaluator ( const NOMAD::Parameters & p ) : - NOMAD::Evaluator ( p ) {} - - ~My_Evaluator ( void ) {} - - /*----------------------------------------*/ - /* The problem evaluatiom */ - /*----------------------------------------*/ - // Provide the objective and constraints here - bool eval_x ( NOMAD::Eval_Point & x , - const NOMAD::Double & h_max , - bool & count_eval ) const - { - - NOMAD::Double c1 = 0.0 , c2 = 0.0; - for ( int i = 0 ; i < 5 ; i++ ) - { - c1 += (x[i]-1).pow2(); - c2 += (x[i]+1).pow2(); - } - x.set_bb_output ( 0 , x[4] ); // objective value - x.set_bb_output ( 1 , c1-25 ); // constraint 1 - x.set_bb_output ( 2 , 25-c2 ); // constraint 2 - - count_eval = true; // count a black-box evaluation - - return true; // the evaluation succeeded - } - - // Wrapper of eval_x used for parallel evaluation (pthreads). - static void * wrapper_eval_x ( void * dummy_eval_arg ) - { - - Arg_Eval_t * eval_arg = static_cast<Arg_Eval_t *>(dummy_eval_arg); - - NOMAD::Eval_Point & x=*(eval_arg->x); - bool & count_eval = *(eval_arg->count_eval); - const NOMAD::Double & h_max = (eval_arg->h_max); - const My_Evaluator *ev=(eval_arg->ev); - - ev->eval_x(x,h_max,count_eval); - - pthread_exit(NULL); - - } - - // Implementation - bool eval_x ( std::list<NOMAD::Eval_Point *> &list_x , - const NOMAD::Double & h_max, - std::list<bool> & list_count_eval ) const - { - int rc; - +// Wrapper of eval_x used for parallel evaluation (pthreads). +static void * wrapper_eval_x ( void * dummy_eval_arg ) +{ + + Arg_Eval_t * eval_arg = static_cast<Arg_Eval_t *>(dummy_eval_arg); + + NOMAD::Eval_Point & x=*(eval_arg->x); + bool & count_eval = *(eval_arg->count_eval); + const NOMAD::Double & h_max = (eval_arg->h_max); + + eval_x(x,h_max,count_eval); + + pthread_exit(NULL); + + // The semaphore is incremented. Another thread can be started + sem_post(&mySemaphore); + +} - - list_count_eval.assign(list_count_eval.size(),false); // Evaluations are not counted until eval_x is called and set count_eval - - // All threads are created - pthread_t threads[list_x.size()]; - - // The semaphore will allow to run NUM_THREADS in parallel - mySemaphore=sem_open("sem",0,NUM_THREADS); - - // Arguments passed to the evaluation wrapper - Arg_Eval_t * eval_arg=new Arg_Eval_t[list_x.size()]; - std::list<NOMAD::Eval_Point *>::iterator it_x=list_x.begin(),end_x=list_x.end(); - std::list<bool>::iterator it_count=list_count_eval.begin(); - int i=0; - // The list of points is evaluated under the control of a semaphore - for (it_x=list_x.begin(); it_x!=end_x; ++it_x,++it_count,++i) - { - eval_arg[i].x=(*it_x); - eval_arg[i].h_max=h_max.value(); - eval_arg[i].count_eval=&(*it_count); - eval_arg[i].ev=this; - rc=pthread_create(&threads[i], NULL, wrapper_eval_x,&eval_arg[i]); - if (rc) - { - cout << "Error:unable to create thread," << rc << endl; - return false; - } - // wait until value of semaphore is greater than 0 - // decrement the value of semaphore by 1 - sem_wait(mySemaphore); - - } - - delete []eval_arg; - int ret; - for (i=0; i<list_x.size(); ++i) - { - // Wait for all the threads to finish - ret=pthread_join(threads[i],0); - if (ret!=0) - { - perror("pthread join has failed"); - return false; - } - } - - sem_unlink("sem"); - - return true; // the evaluation succeeded - } - - - +class My_Evaluator : public NOMAD::Evaluator +{ +public: + My_Evaluator ( const NOMAD::Parameters & p ) : + NOMAD::Evaluator ( p ) {} + + ~My_Evaluator ( void ) {} + + + // Implementation + bool eval_x ( std::list<NOMAD::Eval_Point *> &list_x , + const NOMAD::Double & h_max, + std::list<bool> & list_count_eval ) const + { + int rc; + + + + list_count_eval.assign(list_count_eval.size(),false); // Evaluations are not counted until eval_x is called and set count_eval + + // All threads are created + pthread_t threads[list_x.size()]; + + // The semaphore will allow to run NUM_THREADS in parallel + sem_init(&mySemaphore,0,NUM_THREADS); + + // Arguments passed to the evaluation wrapper + Arg_Eval_t * eval_arg=new Arg_Eval_t[list_x.size()]; + + std::list<NOMAD::Eval_Point *>::iterator it_x=list_x.begin(),end_x=list_x.end(); + std::list<bool>::iterator it_count=list_count_eval.begin(); + int i=0; + // The list of points is evaluated under the control of a semaphore + for (it_x=list_x.begin(); it_x!=end_x; ++it_x,++it_count,++i) + { + eval_arg[i].x=(*it_x); + eval_arg[i].h_max=h_max.value(); + eval_arg[i].count_eval=&(*it_count); + + rc=pthread_create(&threads[i], NULL, wrapper_eval_x,&eval_arg[i]); + if (rc) + { + cout << "Error:unable to create thread," << rc << endl; + return false; + } + // wait until value of semaphore is greater than 0 + // decrement the value of semaphore by 1 + sem_wait(&mySemaphore); + + } + + int ret; + for (i=0; i<list_x.size(); ++i) + { + // Wait for all the threads to finish + ret=pthread_join(threads[i],0); + if (ret!=0) + { + perror("pthread join has failed"); + return false; + } + } + delete []eval_arg; + sem_destroy(&mySemaphore); + + return true; // the evaluation succeeded + } + + + }; /*------------------------------------------*/ /* NOMAD main function */ /*------------------------------------------*/ -int main ( int argc , char ** argv ) { - - // display: - NOMAD::Display out ( std::cout ); - out.precision ( NOMAD::DISPLAY_PRECISION_STD ); - - try { - - // NOMAD initializations: - NOMAD::begin ( argc , argv ); - - // parameters creation: - NOMAD::Parameters p ( out ); - - p.set_DIMENSION (5); // number of variables - - vector<NOMAD::bb_output_type> bbot (3); // definition of - bbot[0] = NOMAD::OBJ; // output types - bbot[1] = NOMAD::PB; - bbot[2] = NOMAD::EB; - p.set_BB_OUTPUT_TYPE ( bbot ); - -// p.set_DISPLAY_ALL_EVAL(true); // displays all evaluations. - p.set_DISPLAY_DEGREE(2); - p.set_DISPLAY_STATS ( "bbe ( sol ) obj" ); - - p.set_X0 ( NOMAD::Point(5,0.0) ); // starting point - - p.set_LOWER_BOUND ( NOMAD::Point ( 5 , -6.0 ) ); // all var. >= -6 - NOMAD::Point ub ( 5 ); // x_4 and x_5 have no bounds - ub[0] = 5.0; // x_1 <= 5 - ub[1] = 6.0; // x_2 <= 6 - ub[2] = 7.0; // x_3 <= 7 - p.set_UPPER_BOUND ( ub ); - - p.set_MAX_BB_EVAL (100); // the algorithm terminates after - // 100 black-box evaluations - - // Max number of points to be given as a block for evaluation - // This option is required to perform parallel evaluations - p.set_BB_MAX_BLOCK_SIZE(NUM_THREADS); - - // parameters validation: - p.check(); - - // custom evaluator creation: - My_Evaluator ev ( p ); - - // algorithm creation and execution: - NOMAD::Mads mads ( p , &ev ); - mads.run(); - } - catch ( exception & e ) { - cerr << "\nNOMAD has been interrupted (" << e.what() << ")\n\n"; - } - - NOMAD::Slave::stop_slaves ( out ); - NOMAD::end(); - - return EXIT_SUCCESS; +int main ( int argc , char ** argv ) +{ + + + // display: + NOMAD::Display out ( std::cout ); + out.precision ( NOMAD::DISPLAY_PRECISION_STD ); + + try { + + // NOMAD initializations: + NOMAD::begin ( argc , argv ); + + // parameters creation: + NOMAD::Parameters p ( out ); + + p.set_DIMENSION (5); // number of variables + + vector<NOMAD::bb_output_type> bbot (3); // definition of + bbot[0] = NOMAD::OBJ; // output types + bbot[1] = NOMAD::PB; + bbot[2] = NOMAD::EB; + p.set_BB_OUTPUT_TYPE ( bbot ); + + // p.set_DISPLAY_ALL_EVAL(true); // displays all evaluations. + p.set_DISPLAY_DEGREE(2); + p.set_DISPLAY_STATS ( "bbe ( sol ) obj" ); + + p.set_X0 ( NOMAD::Point(5,0.0) ); // starting point + + p.set_LOWER_BOUND ( NOMAD::Point ( 5 , -6.0 ) ); // all var. >= -6 + NOMAD::Point ub ( 5 ); // x_4 and x_5 have no bounds + ub[0] = 5.0; // x_1 <= 5 + ub[1] = 6.0; // x_2 <= 6 + ub[2] = 7.0; // x_3 <= 7 + p.set_UPPER_BOUND ( ub ); + + p.set_MAX_BB_EVAL (100); // the algorithm terminates after + // 100 black-box evaluations + + // Max number of points to be given as a block for evaluation + // This option is required to perform parallel evaluations + p.set_BB_MAX_BLOCK_SIZE(NUM_THREADS); + + // parameters validation: + p.check(); + + // custom evaluator creation: + My_Evaluator ev ( p ); + + // algorithm creation and execution: + NOMAD::Mads mads ( p , &ev ); + mads.run(); + } + catch ( exception & e ) + { + + cerr << "\nNOMAD has been interrupted (" << e.what() << ")\n\n"; + } + + NOMAD::Slave::stop_slaves ( out ); + NOMAD::end(); + + return EXIT_SUCCESS; } diff --git a/examples/basic/library/single_obj_parallel/makefile b/examples/basic/library/single_obj_parallel/makefile index d7af8590b39b753b2c1d7c9ff6a4a5a4412bf573..1675b5e0e1528b4f6bddad6b5485c101d6ce3292 100644 --- a/examples/basic/library/single_obj_parallel/makefile +++ b/examples/basic/library/single_obj_parallel/makefile @@ -1,13 +1,29 @@ -EXE = basic_lib.exe +UNAME := $(shell uname) -COMPILATOR = g++ +EXE = basic_lib.exe -COMPILATOR_OPTIONS = -O2 -ansi -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lm -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -OBJS = basic_lib.o +COMPILATOR = g++ + +COMPILATOR_OPTIONS = -O2 -ansi -Wno-deprecated + + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif + + +LDLIBS = -lm -lnomad -lpthread + +INCLUDE = -I$(NOMAD_HOME)/src -I. + +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c + +OBJS = basic_lib.o ifndef NOMAD_HOME @@ -18,26 +34,25 @@ endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) - @echo " building the parallel (ptrhreads) version ..." + @echo " building the scalar version ..." @echo " exe file : "$(EXE) - @$(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) - @strip $(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif basic_lib.o: basic_lib.cpp $(ECHO_NOMAD) @$(COMPILE) basic_lib.cpp -$(L1) : ; - $(ECHO_NOMAD) - -all: $(EXE) +all: $(EXE) clean: ; @echo " cleaning obj files" - @rm -f $(OBJS) + @rm -f $(OBJS) del: ; @echo " cleaning trash files" diff --git a/examples/basic/library/single_obj_parallel/runExample.log b/examples/basic/library/single_obj_parallel/runExample.log index c69008cbeebc23cc2077f1733abf03ee7482cff2..69e53dea871dd9c99743dd0cf542596918dc5f55 100644 --- a/examples/basic/library/single_obj_parallel/runExample.log +++ b/examples/basic/library/single_obj_parallel/runExample.log @@ -13,15 +13,14 @@ MADS run { 6 ( 1.9677398202 0.0000000000 4.6510213932 1.0733126292 -1.0733126292 ) -1.0733126292 12 ( 1.4758048651 -0.5366563146 4.0696437190 0.8049844719 -1.6099689438 ) -1.6099689438 14 ( 0.4919349550 0.5366563146 4.0696437190 0.2683281573 -2.4149534157 ) -2.4149534157 - 30 ( 1.9677398202 0.5366563146 1.1627553483 1.3416407865 -3.2199378876 ) -3.2199378876 - 52 ( 0.9838699101 0.5366563146 1.7441330224 1.3416407865 -3.7565942022 ) -3.7565942022 - 74 ( 0.9838699101 1.0733126292 1.7441330224 0.5366563146 -3.7565942022 ) -3.7565942022 - 92 ( 1.2298373876 1.2074767078 1.3080997668 1.0062305899 -3.8236762415 ) -3.8236762415 - 95 ( 0.8608861713 1.2074767078 1.1627553483 1.3416407865 -3.8907582808 ) -3.8907582808 - 101 ( 0.8608861713 1.2074767078 1.1627553483 1.3416407865 -3.8907582808 ) -3.8907582808 + 30 ( 1.9677398202 0.0000000000 2.9068883707 0.2683281573 -2.9516097303 ) -2.9516097303 + 44 ( 2.4596747752 2.1466252584 1.1627553483 0.2683281573 -3.4882660449 ) -3.4882660449 + 76 ( 1.9677398202 1.6099689438 1.7441330224 0.4024922359 -3.7565942022 ) -3.7565942022 + 88 ( 1.4758048651 0.9391485505 1.8894774410 0.6708203932 -3.8236762415 ) -3.8236762415 + 100 ( 1.4758048651 0.9391485505 1.8894774410 0.6708203932 -3.8236762415 ) -3.8236762415 } end of run (max number of blackbox evaluations) -blackbox evaluations : 101 -best infeasible solution (min. violation): ( 0.9838699101 1.073312629 1.162755348 1.073312629 -4.024922359 ) h=0.2873436854 f=-4.024922359 -best feasible solution : ( 0.8608861713 1.207476708 1.162755348 1.341640786 -3.890758281 ) h=0 f=-3.890758281 +blackbox evaluations : 100 +best infeasible solution (min. violation): ( 1.96773982 1.744133022 1.598788604 0.2683281573 -3.756594202 ) h=0.009334196675 f=-3.756594202 +best feasible solution : ( 1.475804865 0.9391485505 1.889477441 0.6708203932 -3.823676242 ) h=0 f=-3.823676242 diff --git a/examples/interfaces/DLL/bi_obj/makefile b/examples/interfaces/DLL/bi_obj/makefile index 241139bf918324aeca9225689e45abe4fecc2a9d..e6109024b5861b721f2b4e802ca4f65e3878ac9a 100755 --- a/examples/interfaces/DLL/bi_obj/makefile +++ b/examples/interfaces/DLL/bi_obj/makefile @@ -1,11 +1,25 @@ -EXE = nomad_for_dll.exe -COMPILATOR = g++ -COMPILATOR_OPTIONS = -O3 -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lm -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -OBJS = nomad_for_dll.o +UNAME := $(shell uname) + +EXE = nomad_for_dll.exe +COMPILATOR = g++ +COMPILATOR_OPTIONS = -O3 -ansi + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif + +LDLIBS = -lm -lnomad + +INCLUDE = -I$(NOMAD_HOME)/src -I. + +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c + +OBJS = nomad_for_dll.o ifndef NOMAD_HOME define ECHO_NOMAD @@ -14,13 +28,19 @@ define ECHO_NOMAD endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) - $(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) + @echo " building the scalar version ..." + @echo " exe file : "$(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif + -nomad_for_dll.o: nomad_for_dll.cpp $(L1) +nomad_for_dll.o: nomad_for_dll.cpp $(ECHO_NOMAD) - $(COMPILE) nomad_for_dll.cpp + @$(COMPILE) nomad_for_dll.cpp $(L1): ; $(ECHO_NOMAD) diff --git a/examples/interfaces/DLL/single_obj/makefile b/examples/interfaces/DLL/single_obj/makefile index da0aa1b34380bc8974f9b7d8481d1c8ac44d42fa..e6109024b5861b721f2b4e802ca4f65e3878ac9a 100755 --- a/examples/interfaces/DLL/single_obj/makefile +++ b/examples/interfaces/DLL/single_obj/makefile @@ -1,11 +1,25 @@ -EXE = nomad_for_dll.exe -COMPILATOR = g++ -COMPILATOR_OPTIONS = -O3 -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lm -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -OBJS = nomad_for_dll.o +UNAME := $(shell uname) + +EXE = nomad_for_dll.exe +COMPILATOR = g++ +COMPILATOR_OPTIONS = -O3 -ansi + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif + +LDLIBS = -lm -lnomad + +INCLUDE = -I$(NOMAD_HOME)/src -I. + +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c + +OBJS = nomad_for_dll.o ifndef NOMAD_HOME define ECHO_NOMAD @@ -14,14 +28,19 @@ define ECHO_NOMAD endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) - $(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) + @echo " building the scalar version ..." + @echo " exe file : "$(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif nomad_for_dll.o: nomad_for_dll.cpp $(ECHO_NOMAD) - $(COMPILE) nomad_for_dll.cpp + @$(COMPILE) nomad_for_dll.cpp $(L1): ; $(ECHO_NOMAD) diff --git a/examples/interfaces/FORTRAN/example1/makefile b/examples/interfaces/FORTRAN/example1/makefile index 6f7ea743f1449e7e3dd3e894866204dbbd86581e..0b315b473e4266607c5ec9e68ad93e29b625a413 100644 --- a/examples/interfaces/FORTRAN/example1/makefile +++ b/examples/interfaces/FORTRAN/example1/makefile @@ -1,13 +1,26 @@ -EXE = test.exe -COMPILATOR = g++ -FCOMPILATOR = gfortran -COMPILATOR_OPTIONS = -ansi -Wall -O3 -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lm -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -FCOMPILE = $(FCOMPILATOR) -O3 -c -OBJS = test.o bb.o +UNAME := $(shell uname) + +EXE = test.exe +COMPILATOR = g++ +FCOMPILATOR = gfortran +COMPILATOR_OPTIONS = -ansi -Wall -O3 + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif + + +LDLIBS = -lm -lnomad + +INCLUDE = -I$(NOMAD_HOME)/src -I. +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +FCOMPILE = $(FCOMPILATOR) -O3 -c +OBJS = test.o bb.o ifndef NOMAD_HOME define ECHO_NOMAD @@ -17,18 +30,22 @@ endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) - $(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) -lgfortran + @echo " building the scalar version ..." + @echo " exe file : "$(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif test.o: test.cpp bb.o - $(COMPILE) test.cpp + $(ECHO_NOMAD) + @$(COMPILE) test.cpp bb.o: bb.f - $(FCOMPILE) bb.f - -$(L1): ; - $(ECHO_NOMAD) + $(ECHO_NOMAD) + @$(FCOMPILE) bb.f clean: @echo " cleaning obj files" diff --git a/examples/interfaces/FORTRAN/example1/runExample.log b/examples/interfaces/FORTRAN/example1/runExample.log index e13bad110a76da759609a650b7aab3c0a166dd8a..e14c513126688f5e41d1cf125231741e5ba659dd 100644 --- a/examples/interfaces/FORTRAN/example1/runExample.log +++ b/examples/interfaces/FORTRAN/example1/runExample.log @@ -3,15 +3,18 @@ MADS run { BBE OBJ - 2 275.2281000000 (PhaseOne) + 2 288.7937255854 (PhaseOne) 3 0.0000000000 (PhaseOne) - 3 0.0000000000 - 11 -1.5000000000 - 55 -3.0000000000 - 100 -3.0000000000 + 3 1.0733126292 + 10 1.0062305899 + 11 0.8049844719 + 13 0.5366563146 + 28 -1.0733126292 + 32 -3.7565942022 + 100 -3.7565942022 } end of run (max number of blackbox evaluations) -blackbox evaluations : 100 -best infeasible solution: ( 0.55 1.8 2.6 -1.5 -3 ) h=0.6525 f=-3 -best feasible solution : ( 1.65 1.8 1.95 -1.5 -3 ) h=0 f=-3 +blackbox evaluations : 100 +best infeasible solution (min. violation): ( 2.459674775 0.5366563146 1.162755348 1.073312629 -3.756594202 ) h=0.0023902697 f=-3.756594202 +best feasible solution : ( 0.491934955 2.146625258 1.162755348 0.2683281573 -3.756594202 ) h=0 f=-3.756594202 diff --git a/examples/interfaces/FORTRAN/example2/makefile b/examples/interfaces/FORTRAN/example2/makefile index 75f00d3c619b473ec9e4a7e7658a394a72d7e4ba..887570087356cbb52605f76291aca621c42d1a3d 100644 --- a/examples/interfaces/FORTRAN/example2/makefile +++ b/examples/interfaces/FORTRAN/example2/makefile @@ -1,13 +1,27 @@ -EXE = test.exe -COMPILATOR = g++ -FCOMPILATOR = gfortran -COMPILATOR_OPTIONS = -ansi -Wall -O3 -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lm -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -FCOMPILE = $(FCOMPILATOR) -O3 -c -OBJS = nomad.o test.o +UNAME := $(shell uname) + +EXE = test.exe +COMPILATOR = g++ +FCOMPILATOR = gfortran +COMPILATOR_OPTIONS = -ansi -Wall -O3 + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif + + +LDLIBS = -lm -lnomad -lstdc++ + +INCLUDE = -I$(NOMAD_HOME)/src -I. +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +FCOMPILE = $(FCOMPILATOR) -O3 -c + +OBJS = nomad.o test.o ifndef NOMAD_HOME define ECHO_NOMAD @@ -16,18 +30,17 @@ define ECHO_NOMAD endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) - $(FCOMPILATOR) -o $(EXE) $(OBJS) $(LIBS) -lstdc++ + $(FCOMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) -L$(LIB_DIR) $(CXXFLAGS) nomad.o: nomad.cpp + $(ECHO_NOMAD) $(COMPILE) nomad.cpp test.o: test.f - $(FCOMPILE) test.f - -$(L1): ; $(ECHO_NOMAD) + $(FCOMPILE) test.f clean: @echo " cleaning obj files" diff --git a/examples/interfaces/Matlab_MEX/nomad.m b/examples/interfaces/Matlab_MEX/Functions/nomad.m similarity index 83% rename from examples/interfaces/Matlab_MEX/nomad.m rename to examples/interfaces/Matlab_MEX/Functions/nomad.m index b273d1cc294536af053e4ebd2fc3ccb7c07402c7..e2365b3278ac4ea171433b52709d929e13131c04 100644 --- a/examples/interfaces/Matlab_MEX/nomad.m +++ b/examples/interfaces/Matlab_MEX/Functions/nomad.m @@ -2,11 +2,10 @@ % % min f(x) subject to: nlcon(x) <= 0 % x lb <= x <= ub -% xi in Z -% xj in {0,1} +% x in R % %%%%%%%%%%%%% GERAD VERSION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% [x,fval,exitflag,iter,nfval] = nomad(fun,x0,lb,ub,opts) +% [x,fval,exitflag,iter,nfval] = nomad(fun,x0,lb,ub,opts,param) % % Input arguments: % fun - nonlinear function handle (f and nlcon) @@ -14,10 +13,11 @@ % lb - decision variable lower bounds % ub - decision variable upper bounds % opts - solver options (see nomadset) +% param - extra parameter passed to the blackbox function % % Return arguments: % x - solution vector -% fval - objective value at the solution +% fval - objective value at the solution (paretor front if bi-obj) % exitflag - exit status (see below) % iter - number of iterations taken by the solver % nfval - number of function evaluations taken by the solver diff --git a/examples/interfaces/Matlab_MEX/nomadset.m b/examples/interfaces/Matlab_MEX/Functions/nomadset.m similarity index 100% rename from examples/interfaces/Matlab_MEX/nomadset.m rename to examples/interfaces/Matlab_MEX/Functions/nomadset.m diff --git a/examples/interfaces/Matlab_MEX/GERAD_NOMAD_build.m b/examples/interfaces/Matlab_MEX/GERAD_NOMAD_build.m index 36eee6c55f9768c7686e808a43f7d671d2ad41b3..f827e8e624b565c3822654631b60ac0eb4f67bf6 100644 --- a/examples/interfaces/Matlab_MEX/GERAD_NOMAD_build.m +++ b/examples/interfaces/Matlab_MEX/GERAD_NOMAD_build.m @@ -5,75 +5,163 @@ % To recompile you will need to get / do the following: % 1) Get NOMAD -% NOMAD is available from http://www.gerad.ca/NOMAD/PHP_Forms/Download.php. +% NOMAD is available from https://www.gerad.ca/nomad % Complete the download form then download the latest version. Define the % $NOMAD_HOME environment variable. -% 2) NOMAD MEX Interface +% 2) Start Matlab and go into $NOMAD_HOME/examples/interfaces/Matlab_Mex % The NOMAD MEX Interface is a simple MEX interface written to use NOMAD. -% 3) Compile the MEX File -% The code below will build the NOMAD MEX file. Once you have completed all the -% above steps, simply run this file to compile NOMAD! You MUST BE in the -% base directory of OPTI! +% 3) Compile the MEX File by executing this file in Matlab +% +% +% The code below will build the NOMAD MEX file and set the Matlab path. clear nomad -switch(computer) -case 'PCWIN' -libdir = ' -Lwin32\'; -case 'PCWIN64' -libdir = ' -Lwin64\'; -case 'GLNX86' -libdir = 'glnx86/'; -case 'GLNXA64' -libdir = 'glnxa64/'; -case 'MACI64' -libdir = 'maci64/'; -end +% Current directory +cdir = cd; +% Check and set nomad_home and create variables for path clear nomad_home nomad_src; +% Default values +nameLibNomad = ''; +updateLDFLAGS= ''; +install_name_tool=''; + +if ( strcmp(computer,'PCWIN64') == 1 || strcmp(computer,'PCWIN32') == 1 ) + + nomad_home = getenv('NOMAD_EXAMPLES'); + + if ( length(nomad_home) > 1) + nomad_home = [ nomad_home '\VisualStudio' ]; + warning('The nomad_home variable for Matlab is set to %s (that is NOMAD_EXAMPLES\\VisualStudio).The default can be replaced by using the command setenv(''NOMAD_EXAMPLES'',ARG1)! before running the GERAD_NOMAD_build command.',nomad_home); + if ( ~isempty( find(isspace(nomad_home),1) ) ) + error('The compilation of Nomad for Matlab must be performed in the NOMAD_EXAMPLES directory. The NOMAD_EXAMPLES directory should not contain empty space. Please consider moving the NOMAD_EXAMPLES directory and reset the NOMAD_EXAMPLES environment variable accordingly.'); + end + + else + cd .. + cd .. + cd .. + cd 'VisualStudio'; + nomad_home = cd; + + if ( ~ exist(nomad_home,'dir') ) + error('The default NOMAD_EXAMPLES\VisualStudio directory does not exist. Please make sure that a VisualStudio directory exists.'); + end + + cd(cdir); + end + + nomad_src=[nomad_home filesep 'src' filesep]; + nomad_bin=[nomad_home filesep 'bin' filesep]; + nomad_lib=''; + + %Compile & Move (Windows) ---> recompile Nomad + post = [' -I. -I' nomad_src ' -lut -output ' nomad_bin filesep 'nomad.' mexext]; + pre = ['mex -v -largeArrayDims nomadmex.cpp ' nomad_src 'Parameters.cpp ' nomad_src 'Barrier.cpp ' nomad_src 'Cache.cpp '... + nomad_src 'Cache_File_Point.cpp ' nomad_src 'Cache_Point.cpp ' nomad_src 'Cache_Search.cpp ' nomad_src 'Clock.cpp '... + nomad_src 'Direction.cpp ' nomad_src 'Directions.cpp ' nomad_src 'Display.cpp '... + nomad_src 'Double.cpp ' nomad_src 'Eval_Point.cpp ' nomad_src 'Evaluator.cpp ' nomad_src 'Evaluator_Control.cpp ' nomad_src 'Exception.cpp '... + nomad_src 'Extended_Poll.cpp ' nomad_src 'L_Curve.cpp ' nomad_src 'LH_Search.cpp ' nomad_src 'OrthogonalMesh.cpp ' nomad_src 'Mads.cpp ' nomad_src 'Model_Sorted_Point.cpp '... + nomad_src 'Model_Stats.cpp ' nomad_src 'Multi_Obj_Evaluator.cpp ' nomad_src 'Parameter_Entries.cpp '... + nomad_src 'Parameter_Entry.cpp ' nomad_src 'Pareto_Front.cpp ' nomad_src 'Pareto_Point.cpp ' nomad_src 'Phase_One_Evaluator.cpp '... + nomad_src 'Phase_One_Search.cpp ' nomad_src 'Point.cpp ' nomad_src 'Priority_Eval_Point.cpp ' nomad_src 'Quad_Model.cpp '... + nomad_src 'Quad_Model_Evaluator.cpp ' nomad_src 'Quad_Model_Search.cpp ' nomad_src 'Random_Pickup.cpp ' nomad_src 'RNG.cpp '... + nomad_src 'Signature.cpp ' nomad_src 'Slave.cpp ' nomad_src 'SMesh.cpp ' nomad_src 'Speculative_Search.cpp ' nomad_src 'Stats.cpp ' nomad_src 'utils.cpp '... + nomad_src 'Variable_Group.cpp ' nomad_src 'VNS_Search.cpp ' nomad_src 'XMesh.cpp']; + + +else + %%%%%%%%%%%%%%%%%%%%%%% + % LINUX AND OSX + %%%%%%%%%%%%%%%%%%%%%%% + + % Default library names + nameLibNomad = 'libnomad.so'; + + % Default update LDFLAGS (linux only) + updateLDFLAGS= ''; + % Post compilation tool for path to library (osx only) + install_name_tool=''; + + nomad_home = getenv('NOMAD_HOME'); + + if ( length(nomad_home) < 1 ) + % Get a default directory for NOMAD_HOME + cd .. + cd .. + cd .. + nomad_home = cd; + if ( ~ exist(nomad_home,'dir') ) + error('The default NOMAD_HOME directory does not exist. Please provide a correct value for the NOMAD_HOME variables with the command setenv(''NOMAD_HOME'',ARG1)'); + end + warning('The NOMAD_HOME variable for Matlab is set with its default value %s. The default can be replaced by using the command setenv(''NOMAD_HOME'',ARG1)! before running the GERAD_NOMAD_build command.',nomad_home); + cd(cdir); + else + if ( ~isempty( find(isspace(nomad_home),1) ) ) + error('The compilation of Nomad for Matlab uses the sources located in the NOMAD_HOME directory. The NOMAD_HOME directory should not contain empty space. Please consider moving the NOMAD_HOME directory and reset the NOMAD_HOME environment variable accordingly.'); + end + end + + nomad_src=[nomad_home filesep 'src' filesep]; + nomad_lib=[nomad_home filesep 'lib' filesep]; + nomad_bin=[nomad_home filesep 'bin' filesep]; + + switch(computer) + case 'GLNX86' + updateLDFLAGS = 'LDFLAGS=''$LDFLAGS -Wl,-rpath,''''$ORIGIN/../lib/'''' '' '; + case 'GLNXA64' + updateLDFLAGS = 'LDFLAGS=''$LDFLAGS -Wl,-rpath,''''$ORIGIN/../lib/'''' '' '; + case 'MACI64' + install_name_tool=['install_name_tool -change ' nameLibNomad ' @loader_path/../lib/' nameLibNomad ' ' nomad_bin filesep 'nomad.' mexext]; + end + + %Compile & Move (Default) --> use shared object library + post = [' -I. -I' nomad_src ' -lut -lnomad -L' nomad_lib ' -output ' nomad_bin filesep 'nomad.' mexext ]; + pre =[ 'mex -v -largeArrayDims nomadmex.cpp ' updateLDFLAGS ]; + + if ( ~ exist([nomad_lib filesep nameLibNomad],'file') ) + error('The Nomad library file %s is not available. Please perform Nomad project compilation before proceeding.',nameLibNomad); + end + +end + fprintf('\n------------------------------------------------\n'); fprintf('NOMAD MEX FILE BUILD --- GERAD VERSION \n\n'); -nomad_home = getenv('NOMAD_HOME'); -if (length(nomad_home)<1) - error('opti:nomad','Please set NOMAD_HOME variables properly with the command setenv(''NOMAD_HOME'',ARG1)!'); -end -nomad_src=[nomad_home filesep 'src' filesep]; - - -%Get NOMAD Libraries -post = [' -I. -I' nomad_src ' -lm -lut -output nomad']; - %CD to Source Directory -cdir = cd; cd 'Source'; -%Compile & Move -pre = ['mex -v -g -largeArrayDims nomadmex.cpp ' nomad_src 'Parameters.cpp ' nomad_src 'Barrier.cpp ' nomad_src 'Cache.cpp '... -nomad_src 'Cache_File_Point.cpp ' nomad_src 'Cache_Point.cpp ' nomad_src 'Cache_Search.cpp ' nomad_src 'Clock.cpp '... -nomad_src 'Direction.cpp ' nomad_src 'Directions.cpp ' nomad_src 'Display.cpp '... -nomad_src 'Double.cpp ' nomad_src 'Eval_Point.cpp ' nomad_src 'Evaluator.cpp ' nomad_src 'Evaluator_Control.cpp ' nomad_src 'Exception.cpp '... -nomad_src 'Extended_Poll.cpp ' nomad_src 'L_Curve.cpp ' nomad_src 'LH_Search.cpp ' nomad_src 'OrthogonalMesh.cpp ' nomad_src 'Mads.cpp ' nomad_src 'Model_Sorted_Point.cpp '... -nomad_src 'Model_Stats.cpp ' nomad_src 'Multi_Obj_Evaluator.cpp ' nomad_src 'Parameter_Entries.cpp '... -nomad_src 'Parameter_Entry.cpp ' nomad_src 'Pareto_Front.cpp ' nomad_src 'Pareto_Point.cpp ' nomad_src 'Phase_One_Evaluator.cpp '... -nomad_src 'Phase_One_Search.cpp ' nomad_src 'Point.cpp ' nomad_src 'Priority_Eval_Point.cpp ' nomad_src 'Quad_Model.cpp '... -nomad_src 'Quad_Model_Evaluator.cpp ' nomad_src 'Quad_Model_Search.cpp ' nomad_src 'Random_Pickup.cpp ' nomad_src 'RNG.cpp '... -nomad_src 'Signature.cpp ' nomad_src 'Slave.cpp ' nomad_src 'SMesh.cpp ' nomad_src 'Speculative_Search.cpp ' nomad_src 'Stats.cpp ' nomad_src 'utils.cpp '... -nomad_src 'Variable_Group.cpp ' nomad_src 'VNS_Search.cpp ' nomad_src 'XMesh.cpp']; - try + + if ( ~ exist([nomad_lib filesep nameLibNomad],'file') ) + error('The Nomad library file %s is not available. Please perform Nomad project compilation before proceeding.',nameLibNomad); + end + eval([pre post]) - movefile(['nomad.' mexext],['..' filesep],'f') + + if ( strcmp(computer,'MACI64') == 1 ) + system(install_name_tool); + end + cd(cdir); - clear nomad_home nomad_src cdir post pre libdir; - fprintf('Done!\n'); + fprintf('Compilation done!\n'); + fprintf('\n----------------------------------------------------------------------------------------------\n'); + fprintf(' To be able to use the nomad functions, you may need to modify the Matlab path \n'); + qstring = 'To be able to use the nomad functions, you may need to modify the Matlab path. Do you want to update the Matlab path?'; + choice = questdlg(qstring,'Set path','Yes','No','Yes'); + if ( strcmp(choice,'Yes') ) + addpath([ cdir filesep 'Functions']); + addpath(nomad_bin); + fprintf(' ---> The Matlab path has been modified but not saved.\n'); + end + clear nomad_home nomad_lib nomad_bin nomad_src cdir post pre updateLDFLAGS qstring choice install_name_tool nameLibNomad; catch ME cd(cdir); - clear nomad_home nomad_src cdir post pre libdir; - error('opti:nomad','Error Compiling NOMAD!\n%s',ME.message); + clear nomad_home nomad_lib noamd_bin nomad_src cdir post pre updateLDFLAGS qstring choice install_name_tool nameLibNomad; + error('Error Compiling NOMAD!\n%s',ME.message); end -fprintf('------------------------------------------------\n'); diff --git a/examples/interfaces/Matlab_MEX/Source/nomadmex.cpp b/examples/interfaces/Matlab_MEX/Source/nomadmex.cpp index cd8f3ec8fb80da882155a01dd4b42ded4f0c2623..e96f29e494f12c03130954a5a5227c2ca2d32b05 100755 --- a/examples/interfaces/Matlab_MEX/Source/nomadmex.cpp +++ b/examples/interfaces/Matlab_MEX/Source/nomadmex.cpp @@ -1,16 +1,24 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search MATLAB Interface */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ /* */ -/* MEX Interface Author: Jonathan Currie 2012 (I2C2) */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ +/* */ +/* */ +/* MEX Interface Author: Jonathan Currie 2012 (I2C2) + modifs C. Tribes */ /* */ /* MEX Interface Contact information: */ /* jocurrie@aut.ac.nz */ @@ -30,7 +38,7 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ -#define NOMADMEX_VERSION "1.24_ct [feb 12, 2015]" +#define NOMADMEX_VERSION "1.25_ct [Sept 3rd, 2015]" //NOTE from Version 1.15 on this MEX file contains a dual interface: // 1) The default (GERAD) interface is: @@ -54,7 +62,7 @@ using namespace std; //Function handle structure #define FLEN 128 /* max length of user function name */ -#define MAXRHS 3 /* max nrhs for user function */ +#define MAXRHS 4 /* max nrhs for user function */ typedef struct { char f[FLEN]; mxArray *plhs[1]; @@ -90,9 +98,9 @@ extern void utSetInterruptPending(bool); //Argument Enums (in expected order of arguments) #ifdef OPTI_VERSION -enum {eFUN, eX0, eLB, eUB, eNLCON, eNLRHS, eXTYPE, eOPTS}; +enum {eFUN, eX0, eLB, eUB, eNLCON, eNLRHS, eXTYPE, eOPTS, ePARAM}; #else //GERAD VERSION -enum {eFUN, eX0, eLB, eUB, eOPTS}; +enum {eFUN, eX0, eLB, eUB, eOPTS, ePARAM}; enum {eNLCON, eNLRHS, eXTYPE}; //placeholders #endif //PRHS Defines @@ -104,6 +112,7 @@ enum {eNLCON, eNLRHS, eXTYPE}; //placeholders #define pNLRHS prhs[eNLRHS] #define pXTYPE prhs[eXTYPE] #define pOPTS prhs[eOPTS] +#define pParam prhs[ePARAM] //Function Prototypes void printSolverInfo(); @@ -144,7 +153,7 @@ public: }; /*-----------------------------------------*/ -/* constructor: creates the signature */ +/* constructor: creates the 3 signatures */ /*-----------------------------------------*/ Matlab_Extended_Poll::Matlab_Extended_Poll ( NOMAD::Parameters & p , neighborsFcn * neighbors) : Extended_Poll ( p ) , @@ -163,8 +172,8 @@ void Matlab_Extended_Poll::construct_extended_points ( const NOMAD::Eval_Point & { double *xm; char errstr[1024]; - - if ( !x.is_complete() ) + + if ( !x.is_complete() ) { mexWarnMsgTxt("construct_extended_points: bad extended poll center\n%sExiting NOMAD...\n\n"); //Force exit @@ -172,7 +181,7 @@ void Matlab_Extended_Poll::construct_extended_points ( const NOMAD::Eval_Point & } - xm = mxGetPr(_neighbors->prhs[1]); + xm = mxGetPr( _neighbors->prhs[1] ); int n=_s1->get_n(); for(int i=0;i<n;i++) @@ -199,7 +208,7 @@ void Matlab_Extended_Poll::construct_extended_points ( const NOMAD::Eval_Point & } - size_t nbNPoints=mxGetNumberOfElements(_neighbors->plhs[0])/n; + int nbNPoints=static_cast<int>(mxGetNumberOfElements(_neighbors->plhs[0])/n); double *xr=mxGetPr(_neighbors->plhs[0]); for(int i=0;i<nbNPoints;i++) @@ -216,10 +225,12 @@ void Matlab_Extended_Poll::construct_extended_points ( const NOMAD::Eval_Point & //MATLAB Evaluator Class -class matlabEval : public NOMAD::Evaluator { +class matlabEval : public NOMAD::Evaluator +{ private: usrFcn *fun; bool hasSur; + // bool hasAdditionalParam; int nobj; usrFcn *con; int ncon; @@ -247,8 +258,7 @@ public: ~matlabEval(void) {} - // evaluating a list of points - bool eval_x(std::list<NOMAD::Eval_Point *> &x, const NOMAD::Double &h_max, std::list<bool> & list_count_eval ) + bool eval_x(std::list<NOMAD::Eval_Point *> &x, const NOMAD::Double &h_max, std::list<bool> & list_count_eval ) { #ifdef OPTI_VERSION @@ -261,17 +271,16 @@ public: char errstr[1024]; bool stop = false; - int i, j; - size_t m, n; + int i, j, m, n; double *fvals; mxLogical *sur; - m=x.size(); + m=static_cast<int>(x.size()); n=(*(x.begin()))->size(); if ( m !=list_count_eval.size()) { - mexPrintf("NomadMex Evaluator: inconsistent size of list" ); + mexPrintf("NomadMex Evaluator: inconsistent size of list" ); //Force exit raise(SIGINT); return false; @@ -279,7 +288,7 @@ public: //Check for Ctrl-C - if (utIsInterruptPending()) + if ( utIsInterruptPending() ) { utSetInterruptPending(false); /* clear Ctrl-C status */ mexPrintf("\nCtrl-C Detected. Exiting NOMAD...\n\n"); @@ -299,10 +308,10 @@ public: //Add Surrogate if present and requested - if(hasSur) - { + if( hasSur ) + { sur=mxGetLogicals(fun->prhs[fun->xrhs+1]); - (x.front()->get_eval_type()==NOMAD::SGTE)? *sur=true:*sur=false; // all evaluations in a list have the same eval_type + ( x.front()->get_eval_type()==NOMAD::SGTE )? *sur=true:*sur=false; // all evaluations in a list have the same eval_type } @@ -359,11 +368,11 @@ public: //Assign bb output - fvals = mxGetPr(fun->plhs[0]); - j=0; - for (it_x=x.begin();it_x!=x.end();++it_x,++j) - for(i=0;i<(nobj+ncon);i++) - (*it_x)->set_bb_output(i,fvals[m*i+j]); + fvals = mxGetPr(fun->plhs[0]); + j=0; + for (it_x=x.begin();it_x!=x.end();++it_x,++j) + for(i=0;i<(nobj+ncon);i++) + (*it_x)->set_bb_output(i,fvals[m*i+j]); //Iteration Callback if(iterF->enabled) @@ -414,13 +423,14 @@ public: { char errstr[1024]; bool stop = false; - int i, n = x.size(); + int i, n = static_cast<int>(x.size()); double *xm, *fvals; mxLogical *sur; count_eval = true; //mexErrMsgTxt will kill MEX //Check for Ctrl-C - if (utIsInterruptPending()) { + if ( utIsInterruptPending() ) + { utSetInterruptPending(false); /* clear Ctrl-C status */ mexPrintf("\nCtrl-C Detected. Exiting NOMAD...\n\n"); count_eval = false; @@ -432,24 +442,30 @@ public: xm = mxGetPr(fun->prhs[fun->xrhs]); for(i=0;i<n;i++) xm[i] = x[i].value(); + //Add Surrogate if present and requested - if(hasSur) { + if( hasSur ) + { sur=mxGetLogicals(fun->prhs[fun->xrhs+1]); - (x.get_eval_type()==NOMAD::SGTE)? *sur=true:*sur=false; + (x.get_eval_type()==NOMAD::SGTE)? *sur=true:*sur=false; } + //Call MATLAB Objective - try { + try + { mexCallMATLAB(1, fun->plhs, fun->nrhs, fun->prhs, fun->f); } //Note if these errors occur it is due to errors in MATLAB code, no way to recover? - catch(exception &e) { + catch(exception &e) + { sprintf(errstr,"Unrecoverable Error from Objective / Blackbox Callback:\n%sExiting NOMAD...\n\n",e.what()); mexWarnMsgTxt(errstr); //Force exit raise(SIGINT); return false; } - catch(...) { + catch(...) + { mexPrintf("Unrecoverable Error from Objective / Blackbox Callback, Exiting NOMAD...\n\n"); //Force exit raise(SIGINT); @@ -458,21 +474,24 @@ public: #ifdef OPTI_VERSION //Check we got the correct number back - if(mxGetM(fun->plhs[0]) != nobj) + if( mxGetM(fun->plhs[0]) != nobj ) mexErrMsgTxt("Incorrect number of elements returned from the objective function"); + //Set Objective (Or multi-objective) fvals = mxGetPr(fun->plhs[0]); - for(i=0;i<nobj;i++) - x.set_bb_output(i,fvals[i]); + for( i=0 ; i<nobj ; i++ ) + x.set_bb_output( i,fvals[i] ); //Constraint Evaluation - if(ncon) { + if( ncon ) + { con->plhs[0] = NULL; xm = mxGetPr(con->prhs[con->xrhs]); for(i=0;i<n;i++) xm[i] = x[i].value(); //Call MATLAB Constraint - try { + try + { mexCallMATLAB(1, con->plhs, con->nrhs, con->prhs, con->f); } catch(...) @@ -485,18 +504,20 @@ public: //Check we got the correct number back if(mxGetM(con->plhs[0]) != ncon) mexErrMsgTxt("Incorrect number of elements returned from nonlinear constraint function"); + //Set Constraints double *cons = mxGetPr(con->plhs[0]); for(i=0,j=nobj;i<ncon;i++,j++) x.set_bb_output(j,cons[i] - con->nlrhs[i]); //subtract nlrhs + // Clean up LHS Ptr mxDestroyArray(con->plhs[0]); } #else //GERAD VERSION //Check we got the correct number of elements back - if(mxGetNumberOfElements(fun->plhs[0]) > nobj+ncon) + if( mxGetNumberOfElements(fun->plhs[0]) > nobj+ncon ) mexWarnMsgTxt("Black box returns more elements than required. Please provide a BB_OUTPUT_TYPE consistent with your black box function"); - else if(mxGetNumberOfElements(fun->plhs[0]) < nobj+ncon) + else if( mxGetNumberOfElements(fun->plhs[0]) < nobj+ncon ) { mexPrintf("Insufficient outputs provided by the black box function. Exiting NOMAD...\n\n"); raise(SIGINT); @@ -572,13 +593,11 @@ public: { return mEval->eval_x(x,h_max,count_eval); } - - //Function + Constraint Information + //Function + Constraint Information bool eval_x(std::list<NOMAD::Eval_Point *> &x, const NOMAD::Double &h_max, std::list<bool> & list_count_eval ) { return mEval->eval_x(x,h_max,list_count_eval); } - }; //cout Redirection @@ -591,26 +610,28 @@ public: } private: enum { s_size = 1024 }; //not sure on this size - char m_buffer[s_size]; - int_type overflow(int_type c) - { - if (!traits_type::eq_int_type(c, traits_type::eof())) { - *pptr() = traits_type::to_char_type(c); - pbump(1); - } - return sync() != -1 ? traits_type::not_eof(c) : traits_type::eof(); - } - - int sync() { - *pptr() = 0; - mexPrintf(pbase()); + char m_buffer[s_size]; + int_type overflow(int_type c) + { + if (!traits_type::eq_int_type(c, traits_type::eof())) + { + *pptr() = traits_type::to_char_type(c); + pbump(1); + } + return sync() != -1 ? traits_type::not_eof(c) : traits_type::eof(); + } + + int sync() + { + *pptr() = 0; + mexPrintf(pbase()); mexEvalString("drawnow;"); - setp(m_buffer, m_buffer + s_size - 2); - return 0; - } + setp(m_buffer, m_buffer + s_size - 2); + return 0; + } }; -// make the buffer static to have a single buffer when nested nomad optimizations + static printfbuf buf; // Main Entry Function @@ -623,7 +644,7 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) char *xtype = NULL; //Outputs Args - double *exitflag, *iter, *nfval; + double *exitflag, *iter, *nfval; //Internal Vars size_t ndec; @@ -633,7 +654,7 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) neighborsFcn neighborsF; //Check user inputs - if(!checkInputs(prhs,nrhs,plhs,nlhs)) + if( !checkInputs(prhs,nrhs,plhs,nlhs) ) return; //Redirect cout @@ -646,9 +667,12 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) NOMAD::Point px0; NOMAD::Double *nx0; NOMAD::stop_type stopflag; + //Evaluator Vars matlabEval *mSEval = NULL; matlabMEval *mBEval = NULL; + + // Extended Poll Vars Matlab_Extended_Poll *mEP = NULL; @@ -663,37 +687,39 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) ndec = mxGetNumberOfElements(pX0); //Get Blackbox / Objective Function Handle - if (mxIsChar(pFUN)) + if ( mxIsChar(pFUN) ) { - if(mxGetString(pFUN, fun.f, FLEN) != 0) + if( mxGetString(pFUN, fun.f, FLEN) != 0 ) mexErrMsgTxt("error reading objective name string"); fun.nrhs = 1; fun.xrhs = 0; - } else + } + else { fun.prhs[0] = (mxArray*)pFUN; strcpy(fun.f, "feval"); fun.nrhs = 2; fun.xrhs = 1; } - fun.prhs[fun.xrhs] = mxCreateDoubleMatrix(ndec, 1, mxREAL); //x + fun.prhs[fun.xrhs] = mxCreateDoubleMatrix( ndec, 1, mxREAL ); //x //Get x0 x0 = mxGetPr(pX0); //Get xtype - if(nrhs > eXTYPE && !mxIsEmpty(pXTYPE)) + if( nrhs > eXTYPE && !mxIsEmpty(pXTYPE) ) xtype = mxArrayToString(pXTYPE); //Get MEX Options if specified - if(nrhs > eOPTS && !mxIsEmpty(pOPTS)) { - if(mxGetField(pOPTS,0,"display_degree") && !mxIsEmpty(mxGetField(pOPTS,0,"display_degree"))) + if( nrhs > eOPTS && !mxIsEmpty(pOPTS) ) + { + if( mxGetField(pOPTS,0,"display_degree") && !mxIsEmpty(mxGetField(pOPTS,0,"display_degree")) ) printLevel = (int)*mxGetPr(mxGetField(pOPTS,0,"display_degree")); - if(mxGetField(pOPTS,0,"param_file") && !mxIsEmpty(mxGetField(pOPTS,0,"param_file"))) + if( mxGetField(pOPTS,0,"param_file") && !mxIsEmpty(mxGetField(pOPTS,0,"param_file")) ) paramfile = mxArrayToString(mxGetField(pOPTS,0,"param_file")); - if(mxGetField(pOPTS,0,"bb_output_type") && !mxIsEmpty(mxGetField(pOPTS,0,"bb_output_type"))) + if( mxGetField(pOPTS,0,"bb_output_type") && !mxIsEmpty(mxGetField(pOPTS,0,"bb_output_type")) ) bb_out_type = mxGetField(pOPTS,0,"bb_output_type"); - if(mxGetField(pOPTS,0,"iterfun") && !mxIsEmpty(mxGetField(pOPTS,0,"iterfun"))) + if( mxGetField(pOPTS,0,"iterfun") && !mxIsEmpty(mxGetField(pOPTS,0,"iterfun")) ) { iterF.prhs[0] = (mxArray*)mxGetField(pOPTS,0,"iterfun"); strcpy(iterF.f, "feval"); @@ -702,7 +728,7 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) iterF.prhs[2] = mxCreateDoubleMatrix(1,1,mxREAL); iterF.prhs[3] = mxCreateDoubleMatrix(ndec,1,mxREAL); } - // This is for categorical variables + if(mxGetField(pOPTS,0,"neighbors_mat") && !mxIsEmpty(mxGetField(pOPTS,0,"neighbors_mat"))) { strcpy(neighborsF.f, "feval"); @@ -712,22 +738,27 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } } - + //Setup ndec p.set_DIMENSION((int)ndec); + //Warn if >1000 - if(ndec > 1000 && printLevel) { + if(ndec > 1000 && printLevel) + { sprintf(errstr,"Warning: NOMAD is designed for problems with less than 1000 variables. Your model has %d.\nWhile unlikely, it is possible that NOMAD may not perform as intended on this problem.",static_cast<int>(ndec)); mexWarnMsgTxt(errstr); } //Setup Lower Bounds - if(nrhs > eLB && !mxIsEmpty(pLB)) { + if( nrhs > eLB && !mxIsEmpty(pLB) ) + { NOMAD::Point ptLB; NOMAD::Double *dLB = new NOMAD::Double[ndec]; lb = mxGetPr(pLB); - for(i=0;i<ndec;i++) { + + for(i=0;i<ndec;i++) + { if(!mxIsInf(lb[i])) //if not initialized will not be used dLB[i] = lb[i]; } @@ -735,13 +766,15 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) p.set_LOWER_BOUND(ptLB); delete [] dLB; } + //Setup Upper Bounds - if(nrhs > eUB && !mxIsEmpty(pUB)) + if( nrhs > eUB && !mxIsEmpty(pUB) ) { NOMAD::Point ptUB; NOMAD::Double *dUB = new NOMAD::Double[ndec]; ub = mxGetPr(pUB); - for(i=0;i<ndec;i++) { + for(i=0;i<ndec;i++) + { if(!mxIsInf(ub[i])) //if not initialized will not be used dUB[i] = ub[i]; } @@ -752,10 +785,11 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) //Setup x0 nx0 = new NOMAD::Double[ndec]; + #ifdef OPTI_VERSION double xl, xu; //If integer variables declared, need to ensure x0[i] is an integer - if(xtype) + if( xtype ) { for(i=0;i<ndec;i++) { @@ -773,17 +807,22 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) case 'i': case 'b': xl = floor(x0[i]); //First round is a floor + //If lower bounds exist - if(lb) { + if( lb ) + { //if lower bound broken - if(xl < lb[i]) { + if( xl < lb[i] ) + { xu = ceil(x0[i]); //If upper bounds exist, check bound directions - if(ub && xu > ub[i]) { //if broken, no integer x0 exists + if( ub && xu > ub[i] ) + { //if broken, no integer x0 exists sprintf(errstr,"x0[%d] cannot be rounded to an integer value between lb: %g, ub %g",i,lb[i],ub[i]); mexErrMsgTxt(errstr); } - if(xu != x0[i]) { //If we changed something, warn user + if( xu != x0[i] ) + { //If we changed something, warn user sprintf(errstr,"x0[%d] was rounded up to %g to suit NOMAD interface",i,xu); mexWarnMsgTxt(errstr); } @@ -791,8 +830,10 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) nx0[i] = xu; } //Floor value did not break lower bounds, value OK - else { - if(xl != x0[i]) { //If we changed something, warn user + else + { + if( xl != x0[i] ) + { //If we changed something, warn user sprintf(errstr,"x0[%d] was rounded down to %g to suit NOMAD interface",i,xl); mexWarnMsgTxt(errstr); } @@ -802,7 +843,8 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } //No lower bounds, floor value assumed OK else { - if(xl != x0[i]) { //If we changed something, warn user + if( xl != x0[i] ) + { //If we changed something, warn user sprintf(errstr,"x0[%d] was rounded down to %g to suit NOMAD interface",i,xl); mexWarnMsgTxt(errstr); } @@ -820,9 +862,11 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) } } //Else user start position within bounds - else { - for(i=0;i<ndec;i++) { - if(lb && x0[i] < lb[i]) + else + { + for(i=0;i<ndec;i++) + { + if( lb && x0[i] < lb[i] ) nx0[i] = lb[i]; else if(ub && x0[i] > ub[i]) nx0[i] = ub[i]; @@ -841,24 +885,30 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) #ifdef OPTI_VERSION //Setup Nonlinear Constraints - if(nrhs > eNLCON && !mxIsEmpty(pNLCON)) { - if (mxIsChar(pNLCON)) { + if( nrhs > eNLCON && !mxIsEmpty(pNLCON) ) + { + if ( mxIsChar(pNLCON) ) + { if(mxGetString(pNLCON, con.f, FLEN) != 0) mexErrMsgTxt("error reading constraint name string"); con.nrhs = 1; con.xrhs = 0; - } else { + } + else + { con.prhs[0] = (mxArray*)pNLCON; strcpy(con.f, "feval"); con.nrhs = 2; con.xrhs = 1; } con.prhs[con.xrhs] = mxCreateDoubleMatrix(ndec, 1, mxREAL); //x - if(nrhs < eNLRHS+1 || mxIsEmpty(pNLRHS)) {//we will default to <= 0 + if(nrhs < eNLRHS+1 || mxIsEmpty(pNLRHS)) + {//we will default to <= 0 ncon = -1; con.nlrhs = NULL; } - else { + else + { ncon = (int)mxGetNumberOfElements(pNLRHS); con.nlrhs = mxGetPr(pNLRHS); } @@ -875,28 +925,29 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) #endif //GERAD Version does not have a separate constraint handler and handles input and output types using options - // evaluation tags and numbers are reset - NOMAD::Eval_Point::reset_tags_and_bbes(); + // Make sure that evaluation numbers are reset + NOMAD::Eval_Point::reset_tags_and_bbes(); - // Reset the random number generator for each mads run. // The seed will always be to its default value NOMAD::RNG::reset_seed_to_default(); //Set User Options - if(nrhs > eOPTS && !mxIsEmpty(pOPTS)) + if( nrhs > eOPTS && !mxIsEmpty(pOPTS) ) setNOMADopts(p,pOPTS); else setNOMADopts(p,NULL); //If the user has specified a parameter file to read, see if it exists, and if so, read and parse it. - if(paramfile) + if( paramfile ) { FILE *pFile = fopen(paramfile,"r"); - if(pFile==NULL) { + if(pFile==NULL) + { sprintf(errstr,"Cannot open parameter file: %s\n\nEnsure it exists!",paramfile); mexErrMsgTxt(errstr); } - else{ + else + { fclose(pFile); //close file pointer (we don't need it) try { @@ -915,7 +966,8 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { p.check(); } - catch(exception &e) { + catch(exception &e) + { sprintf(errstr,"NOMAD Parameter Error:\n\n%s",e.what()); mexErrMsgTxt(errstr); } @@ -924,21 +976,36 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) #ifndef OPTI_VERSION nobj=p.get_nb_obj(); ncon=(int)p.get_bb_output_type().size()-nobj; - if (p.has_sgte()) { + if ( p.has_sgte() ) + { fun.prhs[fun.xrhs+1] = mxCreateLogicalMatrix(1,1); //extra logical indicating surrogate or not fun.nrhs++; } #endif + + + // Get additional bb param if specified + if ( nrhs > ePARAM && ! mxIsEmpty(pParam) ) + { + fun.nrhs++; + + if ( p.has_sgte() ) + fun.prhs[fun.xrhs+2]=mxDuplicateArray(pParam); + else + fun.prhs[fun.xrhs+1]=mxDuplicateArray(pParam); + } + //Print Header - if(printLevel) { + if(printLevel) + { mexPrintf("\n------------------------------------------------------------------\n"); mexPrintf(" This is NOMAD v%s\n",NOMAD::VERSION.c_str()); - mexPrintf(" Authors: M. Abramson, C. Audet, G. Couture, J. Dennis, S. Le Digabel, C. Tribes\n"); + mexPrintf(" Authors: C. Audet, S. Le Digabel and C. Tribes\n"); #ifdef OPTI_VERSION mexPrintf(" MEX Interface (OPTI) J. Currie 2012\n\n"); #else - mexPrintf(" MEX Interface (GERAD) J. Currie 2012 and C.Tribes 2015 \n\n"); + mexPrintf(" MEX Interface (GERAD) J. Currie 2012 and C. Tribes 2016 \n\n"); #endif mexPrintf(" Problem Properties:\n"); mexPrintf(" # Decision Variables: %4d\n",ndec); @@ -952,7 +1019,7 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) //Create evaluator and run mads based on number of objectives try { - if(nobj > 1) + if( nobj > 1 ) { mBEval = new matlabMEval(p,&fun,nobj,&con,ncon,&iterF); //Bi-Objective Evaluator @@ -999,8 +1066,6 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) mxFree(xtype); xtype = NULL; - delete mads; - sprintf(errstr,"NOMAD Run Error:\n\n%s",e.what()); mexErrMsgTxt(errstr); } @@ -1008,99 +1073,120 @@ void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) if(printLevel) mexPrintf("------------------------------------------------------------------\n"); - //Obtain Solution - - - //Create Outputs + + //Create Outputs plhs[2] = mxCreateDoubleMatrix(1,1, mxREAL); plhs[3] = mxCreateDoubleMatrix(1,1, mxREAL); plhs[4] = mxCreateDoubleMatrix(1,1, mxREAL); + plhs[5] = mxCreateDoubleMatrix(ndec,1, mxREAL); + plhs[6] = mxCreateDoubleMatrix(ndec,1, mxREAL); + exitflag = mxGetPr(plhs[2]); iter = mxGetPr(plhs[3]); nfval = mxGetPr(plhs[4]); - if (nobj>1) - { - - NOMAD::Pareto_Front * pareto_front=mads->get_pareto_front(); + + double *mesh_size=mxGetPr(plhs[5]); + + //Save mesh size + NOMAD::Point ms( static_cast<int>(ndec) ); + p.get_signature()->get_mesh()->get_delta(ms); + for(i=0;i<ndec;i++) + mesh_size[i] = ms[i].value(); + + double *poll_size=mxGetPr(plhs[6]); + //Save poll size + NOMAD::Point ps( static_cast<int>(ndec) ); + p.get_signature()->get_mesh()->get_Delta(ps); + for(i=0;i<ndec;i++) + poll_size[i] = ps[i].value(); + + if (nobj>1) + { + + NOMAD::Pareto_Front * pareto_front=mads->get_pareto_front(); - if ( pareto_front ) - { - - int nb_pareto_pts = pareto_front->size(); - plhs[0] = mxCreateDoubleMatrix(ndec,nb_pareto_pts, mxREAL); - plhs[1] = mxCreateDoubleMatrix(nobj,nb_pareto_pts, mxREAL); - double *x = mxGetPr(plhs[0]); - double *fval = mxGetPr(plhs[1]); + if ( pareto_front ) + { - const NOMAD::Eval_Point * cur = pareto_front->begin(); - int i=0; - while ( cur ) - { - - if ( cur->is_eval_ok() && cur->is_feasible ( p.get_h_min() ) ) - { - const std::list<int> & index_obj = p.get_index_obj(); - std::list<int>::const_iterator it , end = index_obj.end(); - const NOMAD::Point & bbo = cur->get_bb_outputs(); - int j = 0; - NOMAD::Point multi_obj ( static_cast<int>(index_obj.size()) ); - - for ( it = index_obj.begin() ; it != end ; ++it,j++ ) - fval[nobj*i+j] = bbo[*it].value(); - - for(j=0;j<ndec;j++) - x[ndec*i+j] = (*cur)[j].value(); - } - cur = pareto_front->next(); - i++; - } - *exitflag = getStatus(stopflag); + int nb_pareto_pts = pareto_front->size(); + plhs[0] = mxCreateDoubleMatrix(ndec,nb_pareto_pts, mxREAL); + plhs[1] = mxCreateDoubleMatrix(nobj,nb_pareto_pts, mxREAL); + double *x = mxGetPr(plhs[0]); + double *fval = mxGetPr(plhs[1]); - } - else - { - stopflag = (NOMAD::stop_type)10; - *exitflag = -1; //No solution - } - //Save Status & Iterations + const NOMAD::Eval_Point * cur = pareto_front->begin(); + int i=0; + while ( cur ) + { + + if ( cur->is_eval_ok() && cur->is_feasible ( p.get_h_min() ) ) + { + const std::list<int> & index_obj = p.get_index_obj(); + std::list<int>::const_iterator it , end = index_obj.end(); + const NOMAD::Point & bbo = cur->get_bb_outputs(); + int j = 0; + NOMAD::Point multi_obj ( static_cast<int>(index_obj.size()) ); + + for ( it = index_obj.begin() ; it != end ; ++it,j++ ) + fval[nobj*i+j] = bbo[*it].value(); + + for(j=0;j<ndec;j++) + x[ndec*i+j] = (*cur)[j].value(); + } + cur = pareto_front->next(); + i++; + } + *exitflag = getStatus(stopflag); + + } + else + { + stopflag = (NOMAD::stop_type)10; + *exitflag = -1; //No solution + } + //Save Status & Iterations - *iter = mads->get_stats().get_iterations(); - *nfval = mads->get_stats().get_bb_eval(); - - } - else - { + *iter = mads->get_stats().get_iterations(); + *nfval = mads->get_stats().get_bb_eval(); - plhs[0] = mxCreateDoubleMatrix(ndec,1, mxREAL); - plhs[1] = mxCreateDoubleMatrix(1,1, mxREAL); //even bi-objectives return 1 fval - double *x = mxGetPr(plhs[0]); - double *fval = mxGetPr(plhs[1]); - - const NOMAD::Eval_Point *bestSol = mads->get_best_feasible(); - if(bestSol == NULL) - { - bestSol = mads->get_best_infeasible(); - //manually set as infeasible (no infeasible stop flag) - stopflag = (NOMAD::stop_type)10; - } - if(bestSol == NULL) - *exitflag = -1; //No solution + } + else + { + + plhs[0] = mxCreateDoubleMatrix(ndec,1, mxREAL); + plhs[1] = mxCreateDoubleMatrix(1,1, mxREAL); + double *x = mxGetPr(plhs[0]); + double *fval = mxGetPr(plhs[1]); + + + const NOMAD::Eval_Point *bestSol = mads->get_best_feasible(); + if(bestSol == NULL) + { + bestSol = mads->get_best_infeasible(); + //manually set as infeasible (no infeasible stop flag) + stopflag = (NOMAD::stop_type)10; + } + if(bestSol == NULL) + *exitflag = -1; //No solution - //If we have a solution, save it - if(*exitflag != -1) { - //Save x - NOMAD::Point pt(*bestSol); - for(i=0;i<ndec;i++) - x[i] = pt[i].value(); - //Save fval - *fval = bestSol->get_f().value(); + //If we have a solution, save it + if(*exitflag != -1) + { + //Save x + NOMAD::Point pt(*bestSol); + for(i=0;i<ndec;i++) + x[i] = pt[i].value(); + //Save fval + *fval = bestSol->get_f().value(); - //Save Status & Iterations - *exitflag = getStatus(stopflag); - *iter = mads->get_stats().get_iterations(); - *nfval = mads->get_stats().get_bb_eval(); - } - } + //Save Status & Iterations + *exitflag = getStatus(stopflag); + *iter = mads->get_stats().get_iterations(); + *nfval = mads->get_stats().get_bb_eval(); + + } + } + //Return error control to default mexSetTrapFlag(0); @@ -1132,43 +1218,48 @@ vector<NOMAD::bb_output_type> detRetTypes(usrFcn *fun, mxArray *out_types, int * //Test Blackbox / Objective Evaluation fun->plhs[0] = NULL; memcpy(mxGetPr(fun->prhs[fun->xrhs]), x0, n * sizeof(double)); + //Call MATLAB Objective stat = mexCallMATLAB(1, fun->plhs, fun->nrhs, fun->prhs, fun->f); if(stat) mexErrMsgTxt("Error calling Objective Function!"); //Ensure we have a real column - if(mxGetN(fun->plhs[0]) > mxGetM(fun->plhs[0])) + if( mxGetN(fun->plhs[0]) > mxGetM(fun->plhs[0]) ) mexErrMsgTxt("The objective function must return a scalar or column vector"); - if(mxIsSparse(fun->plhs[0]) || mxIsComplex(fun->plhs[0])) + if( mxIsSparse(fun->plhs[0]) || mxIsComplex(fun->plhs[0]) ) mexErrMsgTxt("The objective function must return a real, dense, vector"); //Ensure 1 or 2 rows (max of bi-objective) *nobj = (int)mxGetNumberOfElements(fun->plhs[0]); - if(*nobj < 1 || *nobj > 2) + if( *nobj < 1 || *nobj > 2 ) mexErrMsgTxt("The objective function must return a scalar or 2x1 vector (bi-objective)"); + // Clean up LHS Ptr mxDestroyArray(fun->plhs[0]); //Test Constraint Evaluation - if(*ncon) { + if( *ncon ) + { con->plhs[0] = NULL; memcpy(mxGetPr(con->prhs[con->xrhs]), x0, n * sizeof(double)); //Call MATLAB Objective stat = mexCallMATLAB(1, con->plhs, con->nrhs, con->prhs, con->f); - if(stat) + if( stat ) mexErrMsgTxt("Error calling Constraint Function!"); //Ensure we have a real column - if(mxGetN(con->plhs[0]) > mxGetM(con->plhs[0])) + if( mxGetN(con->plhs[0]) > mxGetM(con->plhs[0]) ) mexErrMsgTxt("The constraint function must return a scalar or column vector"); - if(mxIsSparse(con->plhs[0]) || mxIsComplex(con->plhs[0])) + if( mxIsSparse(con->plhs[0]) || mxIsComplex(con->plhs[0]) ) mexErrMsgTxt("The constraint function must return a real, dense, vector"); //If we have nlrhs, check against returned vector - if(*ncon > 0) { + if(*ncon > 0) + { if(mxGetM(con->plhs[0]) != *ncon) mexErrMsgTxt("The vector returned from nlcon is not the same length as nlrhs!"); } - else { + else + { *ncon = (int)mxGetM(con->plhs[0]); con->nlrhs = mxGetPr(mxCreateDoubleMatrix(*ncon,1, mxREAL)); //create dummy rhs } @@ -1182,13 +1273,15 @@ vector<NOMAD::bb_output_type> detRetTypes(usrFcn *fun, mxArray *out_types, int * for(i=0;i<*nobj;i++) varType[i] = NOMAD::OBJ; //If the user has set bb_output_type use it to set constraint types - if(out_types) { - if(!mxIsCell(out_types)) + if( out_types ) + { + if( !mxIsCell(out_types) ) mexErrMsgTxt("Parameter bb_output_type must be a cell array of strings."); - if(mxGetNumberOfElements(out_types) != *ncon) + if( mxGetNumberOfElements(out_types) != *ncon ) mexErrMsgTxt("You must specify a bb_output_type for each element returned by the constraint function (not objective)."); //Process each element in the array - for(i=0,j=*nobj;i<*ncon;i++,j++){ + for(i=0,j=*nobj;i<*ncon;i++,j++) + { mxArray *ctype = mxGetCell(out_types,i); if(!mxIsChar(ctype)) mexErrMsgTxt("An element in the bb_output_type paramter is not a string"); @@ -1243,7 +1336,8 @@ NOMAD::bb_output_type getOutEnum(char *str) void lower(char *str) { int i = 0; - while(str[i]) { + while(str[i]) + { str[i] = tolower(str[i]); i++; } @@ -1255,14 +1349,15 @@ vector<NOMAD::bb_input_type> detInTypes(char *xtype, size_t n) int i; char msgbuf[1024]; vector<NOMAD::bb_input_type> varType(n); - for(i=0;i<n;i++) { + for(i=0;i<n;i++) + { switch(tolower(xtype[i])) { case 'c': - varType[i] = NOMAD::CATEGORICAL; break; + varType[i] = NOMAD::CATEGORICAL; break; case 'r': varType[i] = NOMAD::CONTINUOUS; break; - mexErrMsgTxt("Please specify continuous (real) variables using 'c' when using the OPTI version"); + mexErrMsgTxt("Please specify continuous (real) variables using 'c' when using the OPTI version"); // C-> categorical (not implemented in Matlab version) R-> continuous/real ! case 'i': varType[i] = NOMAD::INTEGER; break; case 'b': @@ -1282,7 +1377,8 @@ int checkInputs(const mxArray *prhs[], int nrhs, mxArray *plhs[], int nlhs) char *str = NULL; //MEX Display Version (OPTI compatibility) - if (nrhs < 1) { + if (nrhs < 1) + { if(nlhs < 1) printSolverInfo(); else @@ -1292,58 +1388,65 @@ int checkInputs(const mxArray *prhs[], int nrhs, mxArray *plhs[], int nlhs) //Redirect cout std::streambuf *cout_sbuf = std::cout.rdbuf(); //keep existing buffer - std::cout.rdbuf(&buf); //redirect buffer + std::cout.rdbuf(&buf); //redirect buffer //NOMAD Display NOMAD::Display out (std::cout); //Check for display on options passed as structure - if(nrhs == 1 && mxIsStruct(prhs[0])) { + if(nrhs == 1 && mxIsStruct(prhs[0])) + { int i, no = mxGetNumberOfFields(prhs[0]); const char *field; std::list<std::string> ls; //For all fields, display nomad help - for(i=0;i<no;i++) { + for(i=0;i<no;i++) + { field = mxGetFieldNameByNumber(prhs[0],i); string st(field); ls.push_back ( st ); } - if(no>0) { + if(no>0) + { //NOMAD Display - NOMAD::Parameters p ( out ); + NOMAD::Parameters p ( out ); p.help(ls); } - std::cout.rdbuf(cout_sbuf); //Return cout to initial buffer + std::cout.rdbuf(cout_sbuf); //Return cout to initial buffer return 0; } //Check for Version / Information / Help Request - if(nrhs == 1 && mxIsChar(prhs[0])) { + if(nrhs == 1 && mxIsChar(prhs[0])) + { str = mxArrayToString(prhs[0]); //Check for Info Request - if(!strcmp(str,"-I") || !strcmp(str,"-INFO") || !strcmp(str,"-i") || !strcmp(str,"-info")) { + if(!strcmp(str,"-I") || !strcmp(str,"-INFO") || !strcmp(str,"-i") || !strcmp(str,"-info")) + { //Information to Print mexPrintf("\nNOMAD Blackbox Optimization Software, v%s\n\n",NOMAD::VERSION.c_str()); - mexPrintf("Copyright (C) 2001-2015\n"); - mexPrintf("Mark A. Abramson - The Boeing Company\n"); - mexPrintf("Charles Audet - Ecole Polytechnique de Montreal\n"); - mexPrintf("Gilles Couture - Ecole Polytechnique de Montreal\n"); - mexPrintf("John E. Dennis, Jr. - Rice University\n"); - mexPrintf("Sebastien Le Digabel - Ecole Polytechnique de Montreal\n"); - mexPrintf("Christophe Tribes - Ecole Polytechnique de Montreal\n\n"); - mexPrintf("Funded in part by AFOSR and Exxon Mobil.\n\n"); - mexPrintf("License : \'%s\'\n",NOMAD::LGPL_FILE.c_str()); - mexPrintf("User guide: \'%s\'\n",NOMAD::USER_GUIDE_FILE.c_str()); - mexPrintf("Examples : \'%s\'\n",NOMAD::EXAMPLES_DIR.c_str()); - mexPrintf("Tools : \'%s\'\n\n",NOMAD::TOOLS_DIR.c_str()); - mexPrintf("Please report NOMAD bugs to nomad@gerad.ca and MEX Interface bugs to jocurrie@aut.ac.nz\n\n"); + mexPrintf("NOMAD - version %s has been created by {\n",NOMAD::VERSION.c_str()); + mexPrintf(" Charles Audet - Ecole Polytechnique de Montreal\n"); + mexPrintf(" Sebastien Le Digabel - Ecole Polytechnique de Montreal\n"); + mexPrintf(" Christophe Tribes - Ecole Polytechnique de Montreal\n}\n\n"); + mexPrintf("The copyright of NOMAD - version %s is owned by {\n",NOMAD::VERSION.c_str()); + mexPrintf(" Sebastien Le Digabel - Ecole Polytechnique de Montreal\n"); + mexPrintf(" Christophe Tribes - Ecole Polytechnique de Montreal\n}\n\n"); + mexPrintf("NOMAD version 3 is a new version of Nomad v1 and v2, it has been funded by AFOSR and Exxon Mobil.\n"); + mexPrintf("Nomad v1 and v2 were created and developed by Mark A. Abramson from The Boeing Company, Charles Audet and Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from Rice University, and were funded by AFOSR and Exxon Mobil.\n\n"); + mexPrintf("Web : www.gerad.ca/nomad\n"); + mexPrintf("License : \'%s\'\n",NOMAD::LGPL_FILE.c_str()); + mexPrintf("User guide: \'%s\'\n",NOMAD::USER_GUIDE_FILE.c_str()); + mexPrintf("Examples : \'%s\'\n",NOMAD::EXAMPLES_DIR.c_str()); + mexPrintf("Tools : \'%s\'\n\n",NOMAD::TOOLS_DIR.c_str()); + mexPrintf("Please report bugs to nomad@gerad.ca\n\n"); std::cout.rdbuf(cout_sbuf); //Return cout to initial buffer return 0; } //Check for Ver Request if(!strcmp(str,"-V") || !strcmp(str,"-v") || !strcmp(str,"-version")) - { + { mexPrintf("NOMAD - version %s - www.gerad.ca/nomad\n\n",NOMAD::VERSION.c_str()); #ifdef OPTI_VERSION mexPrintf("MEX Interface (OPTI) v%s\n",NOMADMEX_VERSION); @@ -1353,23 +1456,23 @@ int checkInputs(const mxArray *prhs[], int nrhs, mxArray *plhs[], int nlhs) std::cout.rdbuf(cout_sbuf); //Return cout to initial buffer return 0; - } + } //Check for Help Request if (strcmp(str,"-H")<0 || strcmp(str,"-HELP")<0 || strcmp(str,"-h")<0 || strcmp(str,"-help")<0 ) - { + { NOMAD::Parameters p ( out ); - std::list<std::string> helpS; - const char * toks=" "; - char *w = strtok(str,toks) ; - for ( w = strtok(NULL,toks) ; w != NULL ; w = strtok(NULL,toks) ) - { - helpS.push_back(w); - } - p.help (helpS ); + std::list<std::string> helpS; + const char * toks=" "; + char *w = strtok(str,toks) ; + for ( w = strtok(NULL,toks) ; w != NULL ; w = strtok(NULL,toks) ) + { + helpS.push_back(w); + } + p.help (helpS ); std::cout.rdbuf(cout_sbuf); //Return cout to initial buffer return 0; - } + } } //Otherwise assume we have a normal problem @@ -1387,7 +1490,8 @@ int checkInputs(const mxArray *prhs[], int nrhs, mxArray *plhs[], int nlhs) ndec = mxGetNumberOfElements(prhs[1]); //Check Bounds - if(nrhs > 2) { + if(nrhs > 2) + { if(!mxIsDouble(pLB) || mxIsComplex(pLB)) mexErrMsgTxt("lb must be a real double column vector!"); if(nrhs > 3 && (!mxIsDouble(pUB) || mxIsComplex(pUB))) @@ -1405,14 +1509,16 @@ int checkInputs(const mxArray *prhs[], int nrhs, mxArray *plhs[], int nlhs) mexErrMsgTxt("It appears you may be calling NOMAD using the GERAD NOMAD Syntax - nomad(bb,x0,lb,ub,opts). This is the OPTI NOMAD version and requires nomad(fun,x0,lb,ub,nlcon,nlrhs,xtype,opts)."); //Check Nonlinear Constraint Handle - if(nrhs > eNLCON && !mxIsEmpty(pNLCON)) { + if(nrhs > eNLCON && !mxIsEmpty(pNLCON)) + { if(!mxIsFunctionHandle(pNLCON) && !mxIsChar(pNLCON)) mexErrMsgTxt("nlcon must be a function handle or function name!"); if(nrhs > eNLRHS && (!mxIsDouble(pNLRHS) || mxIsComplex(pNLRHS))) mexErrMsgTxt("nlrhs must be a real double column vector!"); } //Check for xtype - if(nrhs > eXTYPE && !mxIsEmpty(pXTYPE)) { + if(nrhs > eXTYPE && !mxIsEmpty(pXTYPE)) + { if(!mxIsChar(pXTYPE)) mexErrMsgTxt("The xtype vector must be a char array!"); if(ndec != mxGetNumberOfElements(pXTYPE)) @@ -1425,7 +1531,8 @@ int checkInputs(const mxArray *prhs[], int nrhs, mxArray *plhs[], int nlhs) #endif //Check Options - if(nrhs > eOPTS && !mxIsEmpty(pOPTS)) { + if(nrhs > eOPTS && !mxIsEmpty(pOPTS)) + { //Version check if(mxIsDouble(pOPTS)) mexErrMsgTxt("It appears you may be calling NOMAD using the OPTI NOMAD Syntax - nomad(fun,x0,lb,ub,nlcon,nlrhs,xtype,opts). This is the GERAD NOMAD version and requires nomad(bb,x0,lb,ub,opts)."); @@ -1456,28 +1563,34 @@ void setNOMADopts(NOMAD::Parameters &p, const mxArray *opts) no = mxGetNumberOfFields(opts); //For each field, check if it's empty, if not, set it within NOMAD - for(i=0;i<no;i++) { + for(i=0;i<no;i++) + { field = mxGetFieldNameByNumber(opts,i); value = mxGetFieldByNumber(opts,0,i); + //Check we don't have an empty or MEX option - if(!mxIsEmpty(value) && isNMDOption(field)) { + if( !mxIsEmpty(value) && isNMDOption(field) ) + { //Switch on data type - switch(mxGetClassID(value)) + switch( mxGetClassID(value) ) { case mxDOUBLE_CLASS: m = mxGetNumberOfElements(value); //This interface doesn't write vectors as options - if(m > 1) { + if(m > 1) + { sprintf(strbuf,"This interface does not support vector options for parameter %s. Please provide it as a string",field); mexErrMsgTxt(strbuf); } val = *mxGetPr(value); //Check if we have an integer parameter (I assume this check is ok!) - if(floor(val) == val) { + if(floor(val) == val) + { sprintf(strbuf,"%s %.0f",field,val); doAdd = true; //write with no decimal points and no exponent } - else {//write as double (exponent ok) + else + {//write as double (exponent ok) sprintf(strbuf,"%s %g",field,val); doAdd = true; } break; @@ -1500,23 +1613,28 @@ void setNOMADopts(NOMAD::Parameters &p, const mxArray *opts) #ifdef OPTI_VERSION //Add each string for the specified field m = mxGetNumberOfElements(value); - for(j=0;j<m;j++) { + for(j=0;j<m;j++) + { mxArray *cellopt = mxGetCell(value,j); - if(!mxIsChar(cellopt)) { + if( !mxIsChar(cellopt) ) + { sprintf(strbuf,"Element %d in the cell array of paramter %s is not a string",j+1,field); mexErrMsgTxt(strbuf); } //Get the string and create the required option string char *str = mxArrayToString(cellopt); sprintf(strbuf,"%s %s",field,str); + //Add to our set of parameter entries NOMAD::Parameter_Entry *pe = new NOMAD::Parameter_Entry(strbuf); // pe will be deleted by ~Parameter_Entries() - if(pe->is_ok()) + if( pe->is_ok() ) entries.insert(pe); - else { + else + { sprintf(strbuf,"Parameter %s has an error",field); mexErrMsgTxt(strbuf); } + //Free local memory at each iteration mxFree(str); } @@ -1532,24 +1650,25 @@ void setNOMADopts(NOMAD::Parameters &p, const mxArray *opts) } //If we have a valid parameter, add it to our set of entries - if(doAdd) { + if( doAdd ) { //mexPrintf("NOMAD Option set as: %s\n",strbuf); //enable for debug NOMAD::Parameter_Entry *pe = new NOMAD::Parameter_Entry(strbuf); - if(pe->is_ok()) + if( pe->is_ok() ) entries.insert(pe); // pe will be deleted by ~Parameter_Entries() else - { + { sprintf(strbuf,"Parameter %s has an error",field); mexErrMsgTxt(strbuf); } - + doAdd = false; } } } //GERAD default bb_output_type if not specified #ifndef OPTI_VERSION - if(!has_BB_OUTPUT_TYPE) { + if( ! has_BB_OUTPUT_TYPE ) + { NOMAD::Parameter_Entry *pe = new NOMAD::Parameter_Entry("BB_OUTPUT_TYPE OBJ"); entries.insert(pe); // pe will be deleted by ~Parameter_Entries() } @@ -1628,8 +1747,8 @@ void printSolverInfo() mexPrintf("\n-----------------------------------------------------------\n"); mexPrintf(" NOMAD: Nonlinear Optimization using the MADS Algorithm [v%s]\n",NOMAD::VERSION.c_str()); mexPrintf(" - Released under the GNU Lesser General Public License: http://www.gnu.org/copyleft/lesser.html\n"); - mexPrintf(" - Source available from: http://www.gerad.ca/NOMAD/Project/Home.html\n"); + mexPrintf(" - Source available from: https://www.gerad.ca/nomad/\n"); - mexPrintf("\n MEX Interface J.Currie 2013 (www.i2c2.aut.ac.nz) and C.Tribes 2015 \n"); + mexPrintf("\n MEX Interface J.Currie 2013 (www.i2c2.aut.ac.nz) and C. Tribes 2015 \n"); mexPrintf("-----------------------------------------------------------\n"); } diff --git a/examples/interfaces/Matlab_MEX/example_categorical/run_nomad.m b/examples/interfaces/Matlab_MEX/example_categorical/run_nomad.m index c4d169f61475134275e8c334c5afe8964d0e0060..3c93d8c889aac06d095fda081e555ca3de0451c9 100644 --- a/examples/interfaces/Matlab_MEX/example_categorical/run_nomad.m +++ b/examples/interfaces/Matlab_MEX/example_categorical/run_nomad.m @@ -1,7 +1,7 @@ x0 = [0 100 1 100 ]'; lb = [-100 0.0 0 0.0 ]'; ub = [100 10000.0 100 10000]'; -opts = nomadset('display_degree',2,'max_bb_eval',200,'bb_output_type','EB EB OBJ','bb_input_type','[C R C R]','neighbors_mat',@neighbors); +opts = nomadset('display_degree',2,'display_all_eval',1,'history_file','history.txt','max_bb_eval',500,'bb_output_type','EB EB OBJ','f_target',0,'bb_input_type','[C R C R]','neighbors_mat',@neighbors); % Start optimization [x,fval] = nomad(@fun,x0,lb,ub,opts); diff --git a/examples/interfaces/Matlab_MEX/example_extra_param/bb.m b/examples/interfaces/Matlab_MEX/example_extra_param/bb.m new file mode 100644 index 0000000000000000000000000000000000000000..b71bc0a7301b9c868af1f73c3c5acff966411c65 --- /dev/null +++ b/examples/interfaces/Matlab_MEX/example_extra_param/bb.m @@ -0,0 +1,8 @@ +function eval = bb(x,extra_param) + +param = [0 ;0]; +if (nargin==2) + param=extra_param; +end + +eval=[10*(x(2)-x(1)^2)+param(1); 1 - x(1)+param(2)]; diff --git a/examples/interfaces/Matlab_MEX/example_extra_param/run_nomad.m b/examples/interfaces/Matlab_MEX/example_extra_param/run_nomad.m new file mode 100644 index 0000000000000000000000000000000000000000..c7ec81ff4c42c0b90bc0ace4287b4924412e7fe5 --- /dev/null +++ b/examples/interfaces/Matlab_MEX/example_extra_param/run_nomad.m @@ -0,0 +1,7 @@ +%% TEST FOR EXTRA BB PARAMETER +clc +x0 = [1;1]; + +bb_extra_param = [ 0 ; 1 ]; +opts = nomadset('display_degree',2,'bb_output_type','OBJ EB'); +[x,fval] = nomad(@bb,x0,[-10;-10],[10;10],opts,bb_extra_param) diff --git a/examples/interfaces/Matlab_MEX/example_group_variables/param.txt b/examples/interfaces/Matlab_MEX/example_group_variables/param.txt new file mode 100644 index 0000000000000000000000000000000000000000..91163e0b60621ce7282b6670cedddad0c70fac91 --- /dev/null +++ b/examples/interfaces/Matlab_MEX/example_group_variables/param.txt @@ -0,0 +1,2 @@ +VARIABLE_GROUP 0 1 +VARIABLE_GROUP 2 3 \ No newline at end of file diff --git a/examples/interfaces/Matlab_MEX/example_group_variables/test.m b/examples/interfaces/Matlab_MEX/example_group_variables/test.m new file mode 100644 index 0000000000000000000000000000000000000000..585abc01523e3561ced64582d068561344cc2bfe --- /dev/null +++ b/examples/interfaces/Matlab_MEX/example_group_variables/test.m @@ -0,0 +1,19 @@ +%% PROBLEM 4 [fval = -2.5] + +clc +fun = @(x) [-x(1) - x(2) - x(3); + (x(2) - 1./2.)*(x(2) - 1./2.) + (x(3) - 1./2.)*(x(3) - 1./2.) - 1/4; + x(1) - x(2); + x(1) + x(3) + x(4) - 2]; +ub = [1;10;10;5]; +lb = [0;0;0;0]; +x0 = [0;0;0;0]; + +opts = []; %not no nomadset just to keep user options +opts.display_degree = 3; +opts.bb_output_type = 'OBJ PB PB PB'; +opts.model_search = 'false'; +opts.param_file='param.txt'; +opts.max_bb_eval = 20; + +[xr,fval,ef,iter] = nomad(fun,x0,lb,ub,opts) \ No newline at end of file diff --git a/examples/interfaces/Matlab_MEX/example_int_variables/param.txt b/examples/interfaces/Matlab_MEX/example_int_variables/param.txt new file mode 100644 index 0000000000000000000000000000000000000000..2e03401c8d1bd63d764d4a29bc8bfec7173505c4 --- /dev/null +++ b/examples/interfaces/Matlab_MEX/example_int_variables/param.txt @@ -0,0 +1,3 @@ +GRANULARITY 0-0 1 +GRANULARITY 3-3 1 +INITIAL_MESH_SIZE 5 \ No newline at end of file diff --git a/examples/interfaces/Matlab_MEX/example_int_variables/run.m b/examples/interfaces/Matlab_MEX/example_int_variables/run.m new file mode 100644 index 0000000000000000000000000000000000000000..872da6bbfafa202ba86c3ef49a7680e040156a03 --- /dev/null +++ b/examples/interfaces/Matlab_MEX/example_int_variables/run.m @@ -0,0 +1,10 @@ +%% MINLP 1 [fval = -5] +%clc +fun = @(x) [ (x(1) - 5)^2 + x(2)^2 - 25; + x(1)^2 - x(2) + 0.5 ]; +x0 = [10;10]; +opts = nomadset('display_degree',2,'initial_mesh_size','5','bb_input_type','[I I]','max_eval',100,'direction_type','ortho 2n','disable','models','bb_output_type','OBJ PB'); + +[xr,fval,ef,iter] = nomad(fun,x0,[],[],opts) + + diff --git a/examples/interfaces/Matlab_MEX/example_int_variables/run2.m b/examples/interfaces/Matlab_MEX/example_int_variables/run2.m new file mode 100644 index 0000000000000000000000000000000000000000..934c0ca00d7bbed0f94928c3c4f62a30b4f80f62 --- /dev/null +++ b/examples/interfaces/Matlab_MEX/example_int_variables/run2.m @@ -0,0 +1,23 @@ +%% PROBLEM 4 [fval = -2.5] +clc +fun = @(x) [-x(1) - x(2) - x(3); + (x(2) - 1./2.)*(x(2) - 1./2.) + (x(3) - 1./2.)*(x(3) - 1./2.) - 1/4; + x(1) - x(2); + x(1) + x(3) + x(4) - 2]; +ub = [1;10;10;5]; +lb = [0;0;0;0]; +x0 = [0;0;0;0]; + +opts = []; %just to keep user options +opts.display_degree = 2; +opts.bb_output_type = 'OBJ PB PB PB'; +opts.model_search = 'false'; +opts.model_eval_sort = 'false'; +opts.max_eval = 500; +opts.direction_type = 'ortho 2n'; +opts.param_file = 'param.txt'; +opts.anisotropic_mesh = 0; + +[xr,fval,ef,iter] = nomad(fun,x0,lb,ub,opts) + + diff --git a/examples/interfaces/Matlab_MEX/test_nomad_gerad.m b/examples/interfaces/Matlab_MEX/test_nomad_gerad.m index 810ca83da05d0b6e2dd3882ade116bc912ff7487..47d8c88ede6ed621c61d5900723a6b39a9f407b0 100755 --- a/examples/interfaces/Matlab_MEX/test_nomad_gerad.m +++ b/examples/interfaces/Matlab_MEX/test_nomad_gerad.m @@ -12,12 +12,12 @@ opts = nomadset('display_degree',2,'min_mesh_size','1e-004','initial_mesh_size', [x,fval] = nomad(fun,x0,lb,ub,opts); -%%Uncomment the following problems for further testing -% -% +%Uncomment the following problems for further testing + + % %% PROBLEM 2 -% %clc % % Blackbox Function +% %clc % bb = @(x) [29.4*x(1) + 18*x(2); % -(x(1) - 0.2458*x(1)^2/x(2)) + 6]; % % Bounds @@ -66,11 +66,9 @@ opts = nomadset('display_degree',2,'min_mesh_size','1e-004','initial_mesh_size', % [xr,fval,ef,iter] = nomad(fun,x0,lb,ub,opts) % % -% %% REMAINDER OF PROBLEMS OK -% % %% Rosenbrock [x = 1,1, fval = 0] -% %clc % % Blackbox Function +% %clc % bb = @(x) (1-x(1))^2 + 100 *(x(2)-x(1)^2)^2; % % Starting Guess % x0 = [0 0]'; @@ -78,8 +76,8 @@ opts = nomadset('display_degree',2,'min_mesh_size','1e-004','initial_mesh_size', % [x,fval,ef,iter] = nomad(bb,x0) % % %% St_e01 [x = 6,0.6667, fval = -6.6667] -% %clc % % Blackbox Function +% %clc % bb = @(x) [-x(1) - x(2); % x(1)*x(2) - 4]; % % Bounds @@ -127,7 +125,7 @@ opts = nomadset('display_degree',2,'min_mesh_size','1e-004','initial_mesh_size', % [x,fval,ef,iter] = nomad(bb,x0,lb,ub,opts) % % %% MINLP 1 [fval = -5] -% clc +% %clc % fun = @(x) [ (x(1) - 5)^2 + x(2)^2 - 25; % x(1)^2 - x(2) + 0.5 ]; % x0 = [0;0]; @@ -150,3 +148,4 @@ opts = nomadset('display_degree',2,'min_mesh_size','1e-004','initial_mesh_size', % opts = nomadset('display_degree',2,'multi_overall_bb_eval',100,'bb_output_type','obj obj eb'); % % [xr,fval,ef,iter] = nomad(bb,x0,lb,ub,opts) +% diff --git a/install/install.sh b/install/install.sh index a38c84720e6b88b2f67fdc093cd212786dbc99f4..27e136c5cc028c6ccb661afab8d426c4443ec298 100755 --- a/install/install.sh +++ b/install/install.sh @@ -1,44 +1,51 @@ #!/bin/bash -#-------------------------------------------------------------------------------------*/ -# NOMAD - Nonsmooth Optimization by Mesh Adaptive Direct search - version 3.7.2 */ -# */ -# Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -# Charles Audet - Ecole Polytechnique, Montreal */ -# Gilles Couture - Ecole Polytechnique, Montreal */ -# John Dennis - Rice University, Houston */ -# Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -# Christophe Tribes - Ecole Polytechnique, Montreal */ -# */ -# funded in part by AFOSR and Exxon Mobil */ -# */ -# Author: Christophe Tribes */ -# */ -# Contact information: */ -# Ecole Polytechnique de Montreal - GERAD */ -# C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */ -# e-mail: nomad@gerad.ca */ -# phone : 1-514-340-6053 #6928 */ -# fax : 1-514-340-5665 */ -# */ -# 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 <http://www.gnu.org/licenses/>. */ -# */ -# You can find information on the NOMAD software at www.gerad.ca/nomad */ -#-------------------------------------------------------------------------------------*/ +#-------------------------------------------------------------------------------------# +# NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 # +# # +# # +# NOMAD - version 3.7.3 has been created by # +# Charles Audet - Ecole Polytechnique de Montreal # +# Sebastien Le Digabel - Ecole Polytechnique de Montreal # +# Christophe Tribes - Ecole Polytechnique de Montreal # +# # +# The copyright of NOMAD - version 3.7.3 is owned by # +# Sebastien Le Digabel - Ecole Polytechnique de Montreal # +# Christophe Tribes - Ecole Polytechnique de Montreal # +# # +# NOMAD v3 has been funded by AFOSR and Exxon Mobil. # +# # +# NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and # +# developed by Mark A. Abramson from The Boeing Company, Charles Audet and # +# Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from # +# Rice University, and were funded by AFOSR and Exxon Mobil. # +# # +# # +# Contact information: # +# Ecole Polytechnique de Montreal - GERAD # +# C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada # +# e-mail: nomad@gerad.ca # +# phone : 1-514-340-6053 #6928 # +# fax : 1-514-340-5665 # +# # +# 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 <http://www.gnu.org/licenses/>. # +# # +# You can find information on the NOMAD software at www.gerad.ca/nomad # +#-------------------------------------------------------------------------------------# # echo "*****************************************************" -echo " NOMAD 3.7.2 Installation Script " +echo " NOMAD 3.7.3 Installation Script " echo " usage: ./install.sh [nparallel] " echo " - nparallel : number of parallel process to make " echo "*****************************************************" diff --git a/install/readme.MPI_for_MINGW.rtf b/install/readme.MPI_for_MINGW.rtf deleted file mode 100644 index e4381107ab6230f2ac39cf681ce9db2f2c418869..0000000000000000000000000000000000000000 --- a/install/readme.MPI_for_MINGW.rtf +++ /dev/null @@ -1,24 +0,0 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360 -{\fonttbl\f0\fswiss\fcharset0 Helvetica;} -{\colortbl;\red255\green255\blue255;} -\margl1440\margr1440\vieww9000\viewh8400\viewkind0 -\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural - -\f0\fs24 \cf0 For NOMAD, the suggested implementation of MPI to be used with MinGW under Windows operating system is MPICH2. The following steps briefly describe how to make nomad parallel version work on Windows :\ -\ -1- Download and install MPICH2 \ -2- Add or modify environment variables \ - * MPI_HOME=c:/mingw/mpich2 (or where MPICH2 has been installed),\ - * CPLUS_INCLUDE_PATH=%MPI_HOME%/include\ - * LIBRARY_PATH=%MPI_HOME%/lib\ - * PATH=%PATH%;%MPI_HOME%/bin\ -3- Start smpd with administrator privileges:\ - * c:/mingw/mpich2/bin/smpd.exe -install\ -4- Compile nomad mpi version in MSYS command shell:\ - * cd into the install directory \ - * type ./install.sh\ -5- For a single computer (local host only) with several nodes start nomad with the following command:\ - * mpiexec.exe -localonly n %NOMAD_HOME%/nomad.MPI.exe param.txt\ -\ -\ -} diff --git a/readme.txt b/readme.txt index 4966d0ca513aa3232b18f363a00667390907fe0d..62bf558f83c6831ad8abfd78086413d0c748fbcb 100644 --- a/readme.txt +++ b/readme.txt @@ -2,74 +2,57 @@ # # # README # # # -####################################################################################### +#-------------------------------------------------------------------------------------# +# NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 # # # -# NOMAD - Nonsmooth Optimization by Mesh Adaptive Direct search # -# V 3.7.2 # +# NOMAD - version 3.7.3 has been created by # +# Charles Audet - Ecole Polytechnique de Montreal # +# Sebastien Le Digabel - Ecole Polytechnique de Montreal # +# Christophe Tribes - Ecole Polytechnique de Montreal # # # -# Copyright (C) 2001-2015 # +# The copyright of NOMAD - version 3.7.3 is owned by # +# Sebastien Le Digabel - Ecole Polytechnique de Montreal # +# Christophe Tribes - Ecole Polytechnique de Montreal # # # -# Mark Abramson - the Boeing Company, Seattle # -# Charles Audet - Ecole Polytechnique, Montreal # -# Gilles Couture - Ecole Polytechnique, Montreal # -# John Dennis - Rice University, Houston # -# Sebastien Le Digabel - Ecole Polytechnique, Montreal # -# Christophe Tribes - Ecole Polytechnique, Montreal # +# NOMAD v3 has been funded by AFOSR and Exxon Mobil. # # # -#-------------------------------------------------------------------------------------# -# # -# Contact information: # +# NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and # +# developed by Mark A. Abramson from The Boeing Company, Charles Audet and # +# Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from # +# Rice University, and were funded by AFOSR and Exxon Mobil. # +# # +# Contact information: # # Ecole Polytechnique de Montreal - GERAD # # C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada # # e-mail: nomad@gerad.ca # # phone : 1-514-340-6053 #6928 # # fax : 1-514-340-5665 # # # -# 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 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. # +# 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 <http://www.gnu.org/licenses/>. # +# You should have received a copy of the GNU Lesser General Public License along # +# with this program. If not, see <http://www.gnu.org/licenses/>. # # # -# You can find information on the NOMAD software at www.gerad.ca/nomad # -####################################################################################### - - - AUTHORS : - -* Mark A. Abramson (Mark.A.Abramson@boeing.com), The Boeing Company. - -* Charles Audet (www.gerad.ca/Charles.Audet), GERAD and Departement de -mathematiques et de genie industriel, ecole Polytechnique de Montreal. - -* J.E. Dennis Jr. (www.caam.rice.edu/~dennis), Computational and Applied -Mathematics Department, Rice University. - -* Sebastien Le Digabel (www.gerad.ca/Sebastien.Le.Digabel), GERAD and Departement -de mathematiques et de genie industriel, ecole Polytechnique de Montreal. +# You can find information on the NOMAD software at www.gerad.ca/nomad # +#-------------------------------------------------------------------------------------# -* Christophe Tribes, GERAD, Departement -de mathematiques et de genie industriel, Department of mechanical engineering, ecole Polytechnique de Montreal. - DESCRIPTION : + DESCRIPTION : NOMAD is a C++ implementation of the Mesh Adaptive Direct Search (MADS) algorithm, designed for constrained optimization of black-box functions. -The project started in 2001, and was funded in part by AFOSR, CRIAQ, FQRNT, LANL, -NSERC, the Boeing Company, and ExxonMobil Upstream Research Company. - WEB PAGE : -http://www.gerad.ca/nomad/ +https://www.gerad.ca/nomad/ FURTHER INSTRUCTIONS : @@ -111,4 +94,4 @@ For informations about the execution of NOMAD, please read the user guide : or - http://www.gerad.ca/NOMAD/Downloads/user_guide.pdf + https://www.gerad.ca/NOMAD/Downloads/user_guide.pdf diff --git a/src/Barrier.cpp b/src/Barrier.cpp index ab768cdbd7fb1202821e41dac2c4c8276b42070e..b9289d785bea6cb9002bac970389c14007304592 100644 --- a/src/Barrier.cpp +++ b/src/Barrier.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -78,8 +85,9 @@ void NOMAD::Barrier::display ( const Display & out ) const if ( _p.get_barrier_type() == NOMAD::EB ) out << "extreme barrier (EB)" << std::endl; - - else { + else + { + out << "type : " << ( (_p.get_barrier_type()==NOMAD::FILTER) ? "filter" : "progressive" ) @@ -87,7 +95,8 @@ void NOMAD::Barrier::display ( const Display & out ) const << "h_norm : " << _p.get_h_norm() << std::endl << "h_min : " << _p.get_h_min() << std::endl << "h_max : " << _h_max << std::endl; - if ( _p.get_barrier_type()==NOMAD::PB || _p.get_barrier_type()==NOMAD::PEB_P ) { + if ( _p.get_barrier_type()==NOMAD::PB || _p.get_barrier_type()==NOMAD::PEB_P ) + { out << "poll center trigger rho : " << _p.get_rho() << std::endl << "number of trigger leaps : " << _rho_leaps << std::endl; if ( _p.get_barrier_type()==NOMAD::PEB_P ) @@ -125,9 +134,11 @@ void NOMAD::Barrier::display ( const Display & out ) const void NOMAD::Barrier::update_and_reset_success ( void ) { if ( ( _p.get_barrier_type() == NOMAD::PB || _p.get_barrier_type() == NOMAD::PEB_P ) && - _success != NOMAD::UNSUCCESSFUL ) { + _success != NOMAD::UNSUCCESSFUL ) + { - if ( _success == NOMAD::PARTIAL_SUCCESS ) { + if ( _success == NOMAD::PARTIAL_SUCCESS ) + { if ( _filter.empty() ) throw Barrier::Update_Error ( "Barrier.cpp" , __LINE__ , @@ -136,9 +147,11 @@ void NOMAD::Barrier::update_and_reset_success ( void ) std::set<NOMAD::Filter_Point>::const_iterator it = _filter.end(); --it; - while ( true ) { + while ( true ) + { - if ( it->get_point()->get_h().value() < _h_max.value() ) { + if ( it->get_point()->get_h().value() < _h_max.value() ) + { set_h_max ( it->get_point()->get_h() ); break; } @@ -171,7 +184,8 @@ void NOMAD::Barrier::insert ( const NOMAD::Eval_Point & x ) "insertion of an Eval_Point into the bad Barrier object" ); // basic check: - if ( !x.is_eval_ok() ) { + if ( !x.is_eval_ok() ) + { _one_eval_succ = NOMAD::UNSUCCESSFUL; return; } @@ -180,7 +194,8 @@ void NOMAD::Barrier::insert ( const NOMAD::Eval_Point & x ) // then return _UNSUCCESSFUL_: size_t size_before = _prefilter.size(); _prefilter.insert ( x.get_tag() ); - if ( _prefilter.size() == size_before ) { + if ( _prefilter.size() == size_before ) + { _one_eval_succ = NOMAD::UNSUCCESSFUL; return; } @@ -193,7 +208,8 @@ void NOMAD::Barrier::insert ( const NOMAD::Eval_Point & x ) if ( !x.is_EB_ok () || !x.get_f().is_defined () || !h.is_defined () || - h.value() > _h_max.value() ) { + h.value() > _h_max.value() ) + { _one_eval_succ = NOMAD::UNSUCCESSFUL; return; } @@ -217,7 +233,8 @@ void NOMAD::Barrier::insert ( const Barrier & b ) NOMAD::Eval_Point * modifiable_x; std::list<const NOMAD::Eval_Point *>::const_iterator it , end = b._all_inserted.end(); - for ( it = b._all_inserted.begin() ; it != end ; ++it ) { + for ( it = b._all_inserted.begin() ; it != end ; ++it ) + { modifiable_x = &NOMAD::Cache::get_modifiable_point ( **it ); @@ -238,7 +255,8 @@ void NOMAD::Barrier::insert ( const Barrier & b ) /*---------------------------------------------------------*/ NOMAD::success_type NOMAD::Barrier::insert_feasible ( const NOMAD::Eval_Point & x ) { - if ( !_best_feasible || ( x.get_f().value() < _best_feasible->get_f().value() ) ) { + if ( !_best_feasible || ( x.get_f().value() < _best_feasible->get_f().value() ) ) + { _best_feasible = &x; return NOMAD::FULL_SUCCESS; } @@ -250,16 +268,21 @@ NOMAD::success_type NOMAD::Barrier::insert_feasible ( const NOMAD::Eval_Point & /*---------------------------------------------------------*/ void NOMAD::Barrier::filter_insertion ( const NOMAD::Eval_Point & x , bool & insert ) { - if ( _filter.empty() ) { + if ( _filter.empty() ) + { _filter.insert (&x); insert = true; } - else { + else + { + insert = false; std::set<NOMAD::Filter_Point>::iterator it = _filter.begin(); - while ( it != _filter.end() ) { - if ( x < *(it->get_point()) ) { + while ( it != _filter.end() ) + { + if ( x < *(it->get_point()) ) + { _filter.erase(it++); insert = true; continue; @@ -268,11 +291,14 @@ void NOMAD::Barrier::filter_insertion ( const NOMAD::Eval_Point & x , bool & ins ++it; } - if ( !insert ) { + if ( !insert ) + { insert = true; std::set<NOMAD::Filter_Point>::iterator end = _filter.end(); - for ( it = _filter.begin() ; it != end ; ++it ) { - if ( *(it->get_point()) < x ) { + for ( it = _filter.begin() ; it != end ; ++it ) + { + if ( *(it->get_point()) < x ) + { insert = false; break; } @@ -298,11 +324,13 @@ NOMAD::success_type NOMAD::Barrier::insert_infeasible ( const NOMAD::Eval_Point // filter: // ------- - if ( _p.get_barrier_type() == NOMAD::FILTER ) { + if ( _p.get_barrier_type() == NOMAD::FILTER ) + { const NOMAD::Eval_Point * bi = get_best_infeasible(); if ( !bi ) return NOMAD::UNSUCCESSFUL; - if ( old_bi ) { + if ( old_bi ) + { if ( bi->get_h().value() < old_bi->get_h().value() ) return NOMAD::FULL_SUCCESS; if ( insert ) @@ -380,23 +408,28 @@ void NOMAD::Barrier::select_poll_center ( NOMAD::success_type last_it_success ) const NOMAD::Eval_Point * best_infeasible = get_best_infeasible(); _sec_poll_center = NULL; - if ( !_best_feasible && !best_infeasible ) { + if ( !_best_feasible && !best_infeasible ) + { _poll_center = NULL; return; } - if ( !best_infeasible ) { + if ( !best_infeasible ) + { _poll_center = _best_feasible; return; } - if ( !_best_feasible ) { + if ( !_best_feasible ) + { _poll_center = best_infeasible; return; } // filter: - if ( _p.get_barrier_type() == NOMAD::FILTER ) { + if ( _p.get_barrier_type() == NOMAD::FILTER ) + { - if ( !_poll_center ) { + if ( !_poll_center ) + { _poll_center = _best_feasible; return; } @@ -409,15 +442,19 @@ void NOMAD::Barrier::select_poll_center ( NOMAD::success_type last_it_success ) } // progressive barrier: - if ( _p.get_barrier_type() == NOMAD::PB || _p.get_barrier_type() == NOMAD::PEB_P ) { + if ( _p.get_barrier_type() == NOMAD::PB || _p.get_barrier_type() == NOMAD::PEB_P ) + { const NOMAD::Point * last_poll_center = _poll_center; - if ( best_infeasible->get_f() < (_best_feasible->get_f() - _p.get_rho()) ) { + if ( best_infeasible->get_f() < (_best_feasible->get_f() - _p.get_rho()) ) + { _poll_center = best_infeasible; _sec_poll_center = _best_feasible; } - else { + else + { + _poll_center = _best_feasible; _sec_poll_center = best_infeasible; } @@ -435,9 +472,11 @@ void NOMAD::Barrier::set_h_max ( const NOMAD::Double & h_max ) _h_max = h_max; // we remove all filter points x such that h(x) > h_max: - if ( !_filter.empty() ) { + if ( !_filter.empty() ) + { - if ( _filter.begin()->get_point()->get_h().value() > _h_max.value() ) { + if ( _filter.begin()->get_point()->get_h().value() > _h_max.value() ) + { _filter.clear(); return; } @@ -464,8 +503,10 @@ void NOMAD::Barrier::check_PEB_constraints ( const NOMAD::Eval_Point & x , bool int nb = static_cast<int>(bbot.size()); std::list<int> ks; - for ( int k = 0 ; k < nb ; ++k ) { - if ( bbot[k] == NOMAD::PEB_P && bbo[k] <= h_min ) { + for ( int k = 0 ; k < nb ; ++k ) + { + if ( bbot[k] == NOMAD::PEB_P && bbo[k] <= h_min ) + { if ( display ) _p.out() << std::endl << "change status of blackbox output " << k @@ -480,7 +521,8 @@ void NOMAD::Barrier::check_PEB_constraints ( const NOMAD::Eval_Point & x , bool // at least one constraint changed status, so we have to update the filter // and remove all points that have their h value changed to infinity // (it can add new dominant points from the list _peb_lop): - if ( !ks.empty() ) { + if ( !ks.empty() ) + { std::list<int>::const_iterator it_k , end_k = ks.end() , begin_k = ks.begin(); @@ -490,11 +532,13 @@ void NOMAD::Barrier::check_PEB_constraints ( const NOMAD::Eval_Point & x , bool bool reset_filter = false; std::set<NOMAD::Filter_Point>::const_iterator end = _filter.end() , it; - for ( it = _filter.begin() ; it != end ; ++it ) { + for ( it = _filter.begin() ; it != end ; ++it ) + { const NOMAD::Point & bbo_cur = it->get_point()->get_bb_outputs(); for ( it_k = begin_k ; it_k != end_k ; ++it_k ) - if ( bbo_cur[*it_k] > h_min ) { + if ( bbo_cur[*it_k] > h_min ) + { reset_filter = true; break; } @@ -502,7 +546,8 @@ void NOMAD::Barrier::check_PEB_constraints ( const NOMAD::Eval_Point & x , bool break; } - if ( reset_filter ) { + if ( reset_filter ) + { if ( display ) _p.out() << std::endl << "PEB change of status: filter reset" << std::endl; @@ -515,19 +560,22 @@ void NOMAD::Barrier::check_PEB_constraints ( const NOMAD::Eval_Point & x , bool std::list<const NOMAD::Eval_Point *>::const_iterator end2 = _peb_lop.end (); std::list<const NOMAD::Eval_Point *>::iterator it2 = _peb_lop.begin(); - while ( it2 != end2 ) { + while ( it2 != end2 ) + { insert = true; const NOMAD::Point & bbo_cur = (*it2)->get_bb_outputs(); for ( it_k = begin_k ; it_k != end_k ; ++it_k ) - if ( bbo_cur[*it_k] > h_min ) { + if ( bbo_cur[*it_k] > h_min ) + { insert = false; break; } // if insert==true: this point is potentially a new filter point: - if ( insert ) { + if ( insert ) + { filter_insertion ( **it2 , insert ); ++it2; } @@ -535,7 +583,9 @@ void NOMAD::Barrier::check_PEB_constraints ( const NOMAD::Eval_Point & x , bool // if insert==false: it means that the current filter point // has to be removed from filter and from _peb_lop, and // in addition, its h is put to INF: - else { + else + { + NOMAD::Cache::get_modifiable_point ( **it2 ).set_h ( NOMAD::Double() ); _peb_lop.erase(it2++); } diff --git a/src/Barrier.hpp b/src/Barrier.hpp index 2b303a47e2233545f94a1e407f7115c1cab54e4c..a41ad4cb940be700d7a7e436b6e232ce8686f773 100644 --- a/src/Barrier.hpp +++ b/src/Barrier.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -47,260 +54,260 @@ #include "Filter_Point.hpp" namespace NOMAD { - - /// Barrier class for constraints handling. - /** + + /// Barrier class for constraints handling. + /** The barrier is basically a structure that stores evaluation points. - */ - class Barrier : private NOMAD::Uncopyable { - - private: - - const NOMAD::Parameters & _p; ///< Parameters. - NOMAD::eval_type _eval_type; ///< Truth or surrogate. - NOMAD::Double _h_max; ///< Maximal value for \c h. - const NOMAD::Eval_Point * _best_feasible; ///< Best feasible solution. - - /// Progressive barrier reference point. - const NOMAD::Eval_Point * _ref; - - std::set<NOMAD::Filter_Point> _filter; ///< Filter. - std::set<int> _prefilter; ///< Pre-filter based on point tags. - - int _rho_leaps; ///< Number of trigger (rho) leaps. - - const NOMAD::Eval_Point * _poll_center; ///< Primary poll center. - const NOMAD::Eval_Point * _sec_poll_center; ///< Secondary poll center. - - /** - Number of constraints that have been changed to NOMAD::PEB_E - (Extreme status for the PEB strategy). - */ - int _peb_changes; - - /** - Number of times that the filter has been reseted following a PEB - change of status. - */ - int _peb_filter_reset; - - /** - List of all points that we tried to insert into the filter, - with PEB constraints. - */ - std::list<const NOMAD::Eval_Point *> _peb_lop; - - /// List of all points that we tried to insert into the filter. - std::list<const NOMAD::Eval_Point *> _all_inserted; - - NOMAD::success_type _one_eval_succ; ///< Success for one evaluation. - NOMAD::success_type _success; ///< Success for a list of evaluations. - - /*----------------------------------------------------*/ - - /// Insertion of a feasible point. - /** - \param x The feasible point to insert -- \b IN. - \return Success type of the insertion - (NOMAD::FULL_SUCCESS or NOMAD::UNSUCCESSFUL). - */ - NOMAD::success_type insert_feasible ( const NOMAD::Eval_Point & x ); - - /// Insertion of an infeasible point. - /** - \param x The infeasible point to insert -- \b IN. - \return Success type of the insertion - (NOMAD::FULL_SUCCESS, NOMAD::UNSUCCESSFUL, or NOMAD::PARTIAL_SUCCESS). - */ - NOMAD::success_type insert_infeasible ( const NOMAD::Eval_Point & x ); - - /// Change the value of \c h_max. - /** - \param h_max The new value of \c h_max -- \b IN. - */ - void set_h_max ( const NOMAD::Double & h_max ); - - /// Insertion into the filter. - /** - \param x The point to insert -- \b IN. - \param insert A boolean equal to \c true if the point has been - inserted into the barrier -- \b OUT. - */ - void filter_insertion ( const NOMAD::Eval_Point & x , bool & insert ); - - /*----------------------------------------------------*/ - - public: - - /// Exception class for barrier update error. - class Update_Error : public NOMAD::Exception - { - public: - /// Constructor. - Update_Error ( const std::string & file , - int line , - const std::string & msg ) - : NOMAD::Exception ( file , line , msg ) {} - }; - - /// Exception class for an insertion error. - class Insert_Error : public NOMAD::Exception - { - public: - /// Constructor. - Insert_Error ( const std::string & file , - int line , - const std::string & msg ) - : NOMAD::Exception ( file , line , msg ) {} - }; - - /*----------------------------------------------------*/ - - /// Constructor. - /** - \param p Parameters -- \b IN. - \param et Truth or surrogate -- \b IN. - */ - Barrier ( const NOMAD::Parameters & p , NOMAD::eval_type et ) - : _p ( p ) , - _eval_type ( et ) , - _h_max ( p.get_h_max_0() ) , - _best_feasible ( NULL ) , - _ref ( NULL ) , - _rho_leaps ( 0 ) , - _poll_center ( NULL ) , - _sec_poll_center ( NULL ) , - _peb_changes ( 0 ) , - _peb_filter_reset( 0 ) , - _one_eval_succ ( NOMAD::UNSUCCESSFUL ) , - _success ( NOMAD::UNSUCCESSFUL ) {} - - /// Destructor. - virtual ~Barrier ( void ) {} - - /// Reset the barrier. - void reset ( void ); - - /// Reset the success types. - void reset_success ( void ) { _one_eval_succ = _success = NOMAD::UNSUCCESSFUL; } - - /// Poll center selection. - /** - \param last_it_success Success of the last iteration -- \b IN. - */ - void select_poll_center ( NOMAD::success_type last_it_success ); - - /// Barrier updates. - void update_and_reset_success ( void ); - - /// Access to the best infeasible point. - /** - \return A pointer to the best infeasible point. - */ - const NOMAD::Eval_Point * get_best_infeasible ( void ) const; - - /// Access to the best feasible point. - /** - \return A pointer to the best feasible point. - */ - const NOMAD::Eval_Point * get_best_feasible ( void ) const { return _best_feasible; } - - /// Access to the best infeasible point with min. violation. - /** - \return A pointer to the best infeasible point with min. viol. - */ - const NOMAD::Eval_Point * get_best_infeasible_min_viol ( void ) const; - - /// Access to \c h_max. - /** - \return The value of \c h_max. - */ - const NOMAD::Double & get_h_max ( void ) const { return _h_max; } - - /// Access to the poll center. - /** - \return A pointer to the poll center. - */ - const NOMAD::Eval_Point * get_poll_center ( void ) const { return _poll_center; } - - /// Access to the success type of one evaluation. - /** - \return The success type of one evaluation. - */ - NOMAD::success_type get_one_eval_succ ( void ) const { return _one_eval_succ;} - - /// Access to the success type of a list of evaluations. - /** - \return The success type of a list of evaluations. - */ - NOMAD::success_type get_success ( void ) const { return _success; } - - /// Access to the secondary poll center. - /** - \return A pointer to the secondary poll center. - */ - const NOMAD::Eval_Point * get_sec_poll_center ( void ) const - { - return _sec_poll_center; - } - - /// Access the list of all inserted points. - /** - \return A list with pointers to the inserted points. - */ - const std::list<const NOMAD::Eval_Point *> & get_all_inserted ( void ) const - { - return _all_inserted; - } - - /// Insertion of a point into the barrier. - /** - \param x The point -- \b IN. - */ - void insert ( const NOMAD::Eval_Point & x ); - - /// Update the barrier from another barrier. - /** - Used by the VNS search. - \param b The other barrier -- \b IN. - */ - void insert ( const Barrier & b ); - - /// Check the PEB constraints. - /** - This will change eventually the status of PEB constraints - from NOMAD::PEB_P to NOMAD::PEB_E. - \param x Point at which the constraints are checked -- \b IN. - \param display A boolean equal to \c true if displays are authorized -- \b IN. - */ - void check_PEB_constraints ( const NOMAD::Eval_Point & x , bool display ); - - /// Display. - /** - \param out The NOMAD::Display object -- \b IN. - */ - void display ( const NOMAD::Display & out ) const; - - /// Display. - /** - Uses the NOMAD::Display object of the NOMAD::Parameters class. - */ - void display ( void ) const { display ( _p.out() ); } - - }; - - /// Display a NOMAD::Barrier object. - /** + */ + class Barrier : private NOMAD::Uncopyable { + + private: + + const NOMAD::Parameters & _p; ///< Parameters. + NOMAD::eval_type _eval_type; ///< Truth or surrogate. + NOMAD::Double _h_max; ///< Maximal value for \c h. + const NOMAD::Eval_Point * _best_feasible; ///< Best feasible solution. + + /// Progressive barrier reference point. + const NOMAD::Eval_Point * _ref; + + std::set<NOMAD::Filter_Point> _filter; ///< Filter. + std::set<int> _prefilter; ///< Pre-filter based on point tags. + + int _rho_leaps; ///< Number of trigger (rho) leaps. + + const NOMAD::Eval_Point * _poll_center; ///< Primary poll center. + const NOMAD::Eval_Point * _sec_poll_center; ///< Secondary poll center. + + /** + Number of constraints that have been changed to NOMAD::PEB_E + (Extreme status for the PEB strategy). + */ + int _peb_changes; + + /** + Number of times that the filter has been reseted following a PEB + change of status. + */ + int _peb_filter_reset; + + /** + List of all points that we tried to insert into the filter, + with PEB constraints. + */ + std::list<const NOMAD::Eval_Point *> _peb_lop; + + /// List of all points that we tried to insert into the filter. + std::list<const NOMAD::Eval_Point *> _all_inserted; + + NOMAD::success_type _one_eval_succ; ///< Success for one evaluation. + NOMAD::success_type _success; ///< Success for a list of evaluations. + + /*----------------------------------------------------*/ + + /// Insertion of a feasible point. + /** + \param x The feasible point to insert -- \b IN. + \return Success type of the insertion + (NOMAD::FULL_SUCCESS or NOMAD::UNSUCCESSFUL). + */ + NOMAD::success_type insert_feasible ( const NOMAD::Eval_Point & x ); + + /// Insertion of an infeasible point. + /** + \param x The infeasible point to insert -- \b IN. + \return Success type of the insertion + (NOMAD::FULL_SUCCESS, NOMAD::UNSUCCESSFUL, or NOMAD::PARTIAL_SUCCESS). + */ + NOMAD::success_type insert_infeasible ( const NOMAD::Eval_Point & x ); + + /// Change the value of \c h_max. + /** + \param h_max The new value of \c h_max -- \b IN. + */ + void set_h_max ( const NOMAD::Double & h_max ); + + /// Insertion into the filter. + /** + \param x The point to insert -- \b IN. + \param insert A boolean equal to \c true if the point has been + inserted into the barrier -- \b OUT. + */ + void filter_insertion ( const NOMAD::Eval_Point & x , bool & insert ); + + /*----------------------------------------------------*/ + + public: + + /// Exception class for barrier update error. + class Update_Error : public NOMAD::Exception + { + public: + /// Constructor. + Update_Error ( const std::string & file , + int line , + const std::string & msg ) + : NOMAD::Exception ( file , line , msg ) {} + }; + + /// Exception class for an insertion error. + class Insert_Error : public NOMAD::Exception + { + public: + /// Constructor. + Insert_Error ( const std::string & file , + int line , + const std::string & msg ) + : NOMAD::Exception ( file , line , msg ) {} + }; + + /*----------------------------------------------------*/ + + /// Constructor. + /** + \param p Parameters -- \b IN. + \param et Truth or surrogate -- \b IN. + */ + Barrier ( const NOMAD::Parameters & p , NOMAD::eval_type et ) + : _p ( p ) , + _eval_type ( et ) , + _h_max ( p.get_h_max_0() ) , + _best_feasible ( NULL ) , + _ref ( NULL ) , + _rho_leaps ( 0 ) , + _poll_center ( NULL ) , + _sec_poll_center ( NULL ) , + _peb_changes ( 0 ) , + _peb_filter_reset( 0 ) , + _one_eval_succ ( NOMAD::UNSUCCESSFUL ) , + _success ( NOMAD::UNSUCCESSFUL ) {} + + /// Destructor. + virtual ~Barrier ( void ) {} + + /// Reset the barrier. + void reset ( void ); + + /// Reset the success types. + void reset_success ( void ) { _one_eval_succ = _success = NOMAD::UNSUCCESSFUL; } + + /// Poll center selection. + /** + \param last_it_success Success of the last iteration -- \b IN. + */ + void select_poll_center ( NOMAD::success_type last_it_success ); + + /// Barrier updates. + void update_and_reset_success ( void ); + + /// Access to the best infeasible point. + /** + \return A pointer to the best infeasible point. + */ + const NOMAD::Eval_Point * get_best_infeasible ( void ) const; + + /// Access to the best feasible point. + /** + \return A pointer to the best feasible point. + */ + const NOMAD::Eval_Point * get_best_feasible ( void ) const { return _best_feasible; } + + /// Access to the best infeasible point with min. violation. + /** + \return A pointer to the best infeasible point with min. viol. + */ + const NOMAD::Eval_Point * get_best_infeasible_min_viol ( void ) const; + + /// Access to \c h_max. + /** + \return The value of \c h_max. + */ + const NOMAD::Double & get_h_max ( void ) const { return _h_max; } + + /// Access to the poll center. + /** + \return A pointer to the poll center. + */ + const NOMAD::Eval_Point * get_poll_center ( void ) const { return _poll_center; } + + /// Access to the success type of one evaluation. + /** + \return The success type of one evaluation. + */ + NOMAD::success_type get_one_eval_succ ( void ) const { return _one_eval_succ;} + + /// Access to the success type of a list of evaluations. + /** + \return The success type of a list of evaluations. + */ + NOMAD::success_type get_success ( void ) const { return _success; } + + /// Access to the secondary poll center. + /** + \return A pointer to the secondary poll center. + */ + const NOMAD::Eval_Point * get_sec_poll_center ( void ) const + { + return _sec_poll_center; + } + + /// Access the list of all inserted points. + /** + \return A list with pointers to the inserted points. + */ + const std::list<const NOMAD::Eval_Point *> & get_all_inserted ( void ) const + { + return _all_inserted; + } + + /// Insertion of a point into the barrier. + /** + \param x The point -- \b IN. + */ + void insert ( const NOMAD::Eval_Point & x ); + + /// Update the barrier from another barrier. + /** + Used by the VNS search. + \param b The other barrier -- \b IN. + */ + void insert ( const Barrier & b ); + + /// Check the PEB constraints. + /** + This will change eventually the status of PEB constraints + from NOMAD::PEB_P to NOMAD::PEB_E. + \param x Point at which the constraints are checked -- \b IN. + \param display A boolean equal to \c true if displays are authorized -- \b IN. + */ + void check_PEB_constraints ( const NOMAD::Eval_Point & x , bool display ); + + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display ( const NOMAD::Display & out ) const; + + /// Display. + /** + Uses the NOMAD::Display object of the NOMAD::Parameters class. + */ + void display ( void ) const { display ( _p.out() ); } + + }; + + /// Display a NOMAD::Barrier object. + /** \param out The NOMAD::Display object -- \b IN. \param b The NOMAD::Barrier object to be displayed -- \b IN. \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Barrier & b ) - { - b.display ( out ); - return out; - } + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::Barrier & b ) + { + b.display ( out ); + return out; + } } #endif diff --git a/src/Cache.cpp b/src/Cache.cpp index dea9a346d00e993655d5bc28698d2eb939c7a39f..d65dfcfb82fc4542e92685da79a80b3f54394c49 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -119,21 +126,24 @@ const NOMAD::Eval_Point * NOMAD::Cache::find // search in _cache2 (points to write in a cache file): NOMAD::Cache_Point cp ( &x ); it = _cache2.find ( cp ); - if ( it != _cache2.end() ) { + if ( it != _cache2.end() ) + { cache_index = NOMAD::CACHE_2; return it->get_point(); } // search in _cache3 (points saved in a file): it = _cache3.find ( cp ); - if ( it != _cache3.end() ) { + if ( it != _cache3.end() ) + { cache_index = NOMAD::CACHE_3; return it->get_point(); } // search in _cache1 (points read in an initial cache file): it = _cache1.find ( cp ); - if ( it != _cache1.end() ) { + if ( it != _cache1.end() ) + { cache_index = NOMAD::CACHE_1; return it->get_point(); } @@ -165,14 +175,18 @@ bool NOMAD::Cache::erase ( const NOMAD::Eval_Point & x ) const NOMAD::Eval_Point * cache_x = find ( x , it , cache_index ); // the point has been found: - if ( cache_x ) { + if ( cache_x ) + { // remove the point from the list of extern points: - if ( cache_x->get_current_run() || x.get_current_run() ) { + if ( cache_x->get_current_run() || x.get_current_run() ) + { std::list<const NOMAD::Eval_Point*>::const_iterator end2 = _extern_pts.end(); std::list<const NOMAD::Eval_Point*>::iterator it2 = _extern_pts.begin(); - while ( it2 != end2 ) { - if ( *it2 == cache_x || *it2 == &x ) { + while ( it2 != end2 ) + { + if ( *it2 == cache_x || *it2 == &x ) + { _extern_pts.erase ( it2 ); break; } @@ -187,7 +201,8 @@ bool NOMAD::Cache::erase ( const NOMAD::Eval_Point & x ) // remove the point from the cache: _sizeof -= x.size_of(); - switch ( cache_index ) { + switch ( cache_index ) + { case NOMAD::CACHE_1: _cache1.erase ( it ); break; @@ -211,7 +226,8 @@ bool NOMAD::Cache::erase ( const NOMAD::Eval_Point & x ) void NOMAD::Cache::clear ( void ) { const NOMAD::Eval_Point * x = begin(); - while ( x ) { + while ( x ) + { delete x; x = next(); } @@ -266,12 +282,14 @@ void NOMAD::Cache::insert ( Cache & c ) const NOMAD::Eval_Point * cache_x; const NOMAD::Eval_Point * cur = c.begin(); - while ( cur ) { + while ( cur ) + { cache_x = find ( *cur ); // the current point is already in cache: - if ( cache_x ) { + if ( cache_x ) + { update ( get_modifiable_point ( *cache_x ) , *cur ); delete cur; } @@ -297,7 +315,8 @@ void NOMAD::Cache::insert ( Cache & c ) /* . example of use: */ /* */ /* const NOMAD::Eval_Point * cur = cache.begin(); */ -/* while ( cur ) { */ +/* while ( cur ) + { */ /* ... */ /* cur = cache.next(); */ /* } */ @@ -309,15 +328,18 @@ void NOMAD::Cache::insert ( Cache & c ) // -------- const NOMAD::Eval_Point * NOMAD::Cache::begin ( void ) const { - if ( !_cache2.empty() ) { + if ( !_cache2.empty() ) + { _it = _cache2.begin(); return _it->get_point(); } - if ( !_cache3.empty() ) { + if ( !_cache3.empty() ) + { _it = _cache3.begin(); return _it->get_point(); } - if ( !_cache1.empty() ) { + if ( !_cache1.empty() ) + { _it = _cache1.begin(); return _it->get_point(); } @@ -330,12 +352,15 @@ const NOMAD::Eval_Point * NOMAD::Cache::next ( void ) const { ++_it; - if ( !_cache2.empty() && _it == _cache2.end() ) { - if ( !_cache3.empty() ) { + if ( !_cache2.empty() && _it == _cache2.end() ) + { + if ( !_cache3.empty() ) + { _it = _cache3.begin(); return _it->get_point(); } - if ( !_cache1.empty() ) { + if ( !_cache1.empty() ) + { _it = _cache1.begin(); return _it->get_point(); } @@ -343,8 +368,10 @@ const NOMAD::Eval_Point * NOMAD::Cache::next ( void ) const } - if ( !_cache3.empty() && _it == _cache3.end() ) { - if ( !_cache1.empty() ) { + if ( !_cache3.empty() && _it == _cache3.end() ) + { + if ( !_cache1.empty() ) + { _it = _cache1.begin(); return _it->get_point(); } @@ -417,10 +444,12 @@ bool NOMAD::Cache::read_points_from_cache_file ( std::ifstream & fin const NOMAD::Eval_Point * cache_x; // main loop: - while ( !fin.eof() ) { + while ( !fin.eof() ) + { // reading of the Cache_File_Point: - if ( !cfp.read ( fin ) ) { + if ( !cfp.read ( fin ) ) + { if ( fin.eof() ) break; return false; @@ -438,13 +467,16 @@ bool NOMAD::Cache::read_points_from_cache_file ( std::ifstream & fin cache_x = find ( *cur ); // the current point is already in cache: - if ( cache_x ) { + if ( cache_x ) + { update ( get_modifiable_point ( *cache_x ) , *cur ); delete cur; } // point not in cache: insertion: - else { + else + { + // insertion in _extern_pts: insert_extern_point ( *cur ); @@ -459,7 +491,8 @@ bool NOMAD::Cache::read_points_from_cache_file ( std::ifstream & fin } // end of main loop // display stats on the cache load: - if ( display ) { + if ( display ) + { _out << "number of points: " << static_cast<int>(_cache1.size()) << std::endl << "size : "; _out.display_size_of ( _sizeof ); @@ -467,7 +500,8 @@ bool NOMAD::Cache::read_points_from_cache_file ( std::ifstream & fin << "load time : " << c.get_real_time() << 's' << std::endl; } } - catch ( ... ) { + catch ( ... ) + { return false; } return true; @@ -500,7 +534,8 @@ bool NOMAD::Cache::load ( const std::string & file_name , return false; // the file exists: - if ( NOMAD::check_read_file ( file_name ) ) { + if ( NOMAD::check_read_file ( file_name ) ) + { int id; std::ifstream fin ( file_name.c_str() , std::ios::binary ); @@ -508,7 +543,8 @@ bool NOMAD::Cache::load ( const std::string & file_name , fin.read ( (char *) &id , sizeof(int) ); // it is a valid cache file: - if ( !fin.fail() && id == NOMAD::CACHE_FILE_ID ) { + if ( !fin.fail() && id == NOMAD::CACHE_FILE_ID ) + { // display: if ( display ) @@ -516,7 +552,8 @@ bool NOMAD::Cache::load ( const std::string & file_name , << NOMAD::open_block ( "loading of \'" + file_name + "\'" ); // read the points: - if ( !read_points_from_cache_file ( fin , p_nb_bb_outputs , display ) ) { + if ( !read_points_from_cache_file ( fin , p_nb_bb_outputs , display ) ) + { fin.close(); return false; // it is not a valid cache file } @@ -533,14 +570,18 @@ bool NOMAD::Cache::load ( const std::string & file_name , } // it is not a valid cache file: - else { + else + { + fin.close(); return false; } } // the file does not exist: - else { + else + { + // display: if ( display ) @@ -549,7 +590,8 @@ bool NOMAD::Cache::load ( const std::string & file_name , // create the file as a valid cache file: std::ofstream fout ( file_name.c_str() , std::ios::binary ); - if ( fout.fail() ) { + if ( fout.fail() ) + { fout.close(); return false; } @@ -583,11 +625,13 @@ bool NOMAD::Cache::save ( bool overwrite , bool display ) std::ofstream fout; - if ( overwrite ) { + if ( overwrite ) + { // open: fout.open ( _locked_file.c_str() , std::ios::binary ); - if ( fout.fail() ) { + if ( fout.fail() ) + { fout.close(); return false; } @@ -597,9 +641,11 @@ bool NOMAD::Cache::save ( bool overwrite , bool display ) // save all cache points: const NOMAD::Eval_Point * cur = begin(); - while ( cur ) { + while ( cur ) + { NOMAD::Cache_File_Point cfp ( *cur ); - if ( !cfp.write ( fout ) ) { + if ( !cfp.write ( fout ) ) + { fout.close(); return false; } @@ -607,21 +653,26 @@ bool NOMAD::Cache::save ( bool overwrite , bool display ) } } - else { + else + { + // open and go at the end of the file: fout.open ( _locked_file.c_str() , std::ios::binary | std::ios::app ); - if ( fout.fail() ) { + if ( fout.fail() ) + { fout.close(); return false; } std::set<NOMAD::Cache_Point>::iterator it = _cache2.begin(); - while ( it != _cache2.end() ) { + while ( it != _cache2.end() ) + { // write it->get_point() in 'fout': NOMAD::Cache_File_Point cfp ( *it->get_point() ); - if ( !cfp.write ( fout ) ) { + if ( !cfp.write ( fout ) ) + { fout.close(); return false; } @@ -676,8 +727,6 @@ void NOMAD::Cache::update ( NOMAD::Eval_Point & cache_x , cache_x.set_eval_status ( NOMAD::EVAL_OK ); cache_x.set_bb_output ( bbo_x ); cache_x.set_signature ( x.get_signature () ); - cache_x.set_direction ( x.get_direction () ); - _sizeof += cache_x.size_of(); return; } @@ -686,7 +735,8 @@ void NOMAD::Cache::update ( NOMAD::Eval_Point & cache_x , int c1 = 0; int c2 = 0; - for ( int i = 0 ; i < m ; ++i ) { + for ( int i = 0 ; i < m ; ++i ) + { if ( bbo_cache_x[i].is_defined() ) ++c1; @@ -700,10 +750,10 @@ void NOMAD::Cache::update ( NOMAD::Eval_Point & cache_x , // the two points are 'eval_ok' and have comparable outputs: // we select the best as the one with the more defined bb_outputs: - if ( c2 > c1 ) { + if ( c2 > c1 ) + { cache_x.set_signature ( x.get_signature () ); cache_x.set_direction ( x.get_direction () ); - } _sizeof += cache_x.size_of(); @@ -717,7 +767,8 @@ void NOMAD::Cache::display_extern_pts ( const NOMAD::Display & out ) const int nb = static_cast<int>(_extern_pts.size()); int cnt = 0; std::list<const NOMAD::Eval_Point *>::const_iterator it , end = _extern_pts.end(); - for ( it = _extern_pts.begin() ; it != end ; ++it ) { + for ( it = _extern_pts.begin() ; it != end ; ++it ) + { out << "point "; out.display_int_w ( ++cnt , nb ); out << "/" << nb << ": "; @@ -745,7 +796,8 @@ void NOMAD::Cache::display ( const NOMAD::Display & out ) const int cnt = 0; out << NOMAD::open_block ( "cache points" ) << std::endl; const NOMAD::Eval_Point * cur = begin(); - while ( cur ) { + while ( cur ) + { out << "point "; out.display_int_w ( ++cnt , nb ); out << "/" << nb << ": "; diff --git a/src/Cache.hpp b/src/Cache.hpp index 99cfbfbda65132d07e6cefd506eb05914dc06d92..260ec72f4031a4a53123e7e0f5c765f6750503e2 100644 --- a/src/Cache.hpp +++ b/src/Cache.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Cache.hpp - \brief Cache memorizing all evaluations (headers) - \author Sebastien Le Digabel - \date 2010-04-12 - \see Cache.cpp -*/ + \file Cache.hpp + \brief Cache memorizing all evaluations (headers) + \author Sebastien Le Digabel + \date 2010-04-12 + \see Cache.cpp + */ // To browse the cache: // --------------------- @@ -56,355 +63,357 @@ #include "Clock.hpp" namespace NOMAD { - - /// Cache memorizing all evaluations. - /** - - The evaluation are stored as NOMAD::Eval_Point objects in - three \c std::set containers - ( \c _cache1 , \c _cache2 and \c _cache3 ). - - Browse the points inside the cache with the following instructions: - \code - const NOMAD::Eval_Point * cur = cache.begin(); - while ( cur ) { - ... - cur = cache.next(); - } - \endcode - */ - class Cache : private NOMAD::Uncopyable { - - protected: - - /// Display: - const NOMAD::Display & _out; - - private: - - /// Static list of locked files. - static std::set<std::string> _locked_files; - - /// Cache file that is currently in use for load/save (this file is locked). - std::string _locked_file; - /// Type of cache (truth or surrogate). - NOMAD::eval_type _eval_type; - - /// Points read in the (optional) initial cache file. - std::set<NOMAD::Cache_Point> _cache1; - - /// Points of the cache to write in the cache file. - std::set<NOMAD::Cache_Point> _cache2; - - /// Points of the cache already saved in the file. - std::set<NOMAD::Cache_Point> _cache3; - - /// Points not from the current run (from a cache file or from a user). - mutable std::list<const NOMAD::Eval_Point*> _extern_pts; - - /// Size in memory. - mutable float _sizeof; - - /// Iterator to browse the cache with \c begin() and \c next(). - mutable std::set<NOMAD::Cache_Point>::const_iterator _it; - - /*---------------------------------------------------------------------------*/ - - /// Read points in a cache file. - /** - - Reads points from a cache file. - - Fills the set \c _cache1. - \param fin The already opened input file -- \b IN. - \param p_nb_bb_outputs A pointer on an integer with the number - of blackbox outputs; can be \c NULL -- \b IN. - \param display A boolean equal to \c true if displays - are authorized -- \b IN. - \return A boolean equal to \c true if the file could be read. - */ - bool read_points_from_cache_file ( std::ifstream & fin , - const int * p_nb_bb_outputs , - bool display ); - - /// Check if a file is locked. - /** - \param file_name Name of the file -- \b IN. - \return A boolean equal to \c true if the file is locked. - */ - bool is_locked ( const std::string & file_name ); - - /// Lock a file. - /** - \param file_name Name of the file -- \b IN. - \return A boolean equal to \c false if the file was already locked. - */ - bool lock ( const std::string & file_name ); - - /// Unlock the locked file. - void unlock ( void ); - - /// Update a point already in cache. + /// Cache memorizing all evaluations. /** - - The point already in cache is updated from another + - The evaluation are stored as NOMAD::Eval_Point objects in + three \c std::set containers + ( \c _cache1 , \c _cache2 and \c _cache3 ). + - Browse the points inside the cache with the following instructions: + \code + const NOMAD::Eval_Point * cur = cache.begin(); + while ( cur ) { + ... + cur = cache.next(); + } + \endcode + */ + class Cache : private NOMAD::Uncopyable { + + protected: + + /// Display: + const NOMAD::Display & _out; + + private: + + /// Static list of locked files. + static std::set<std::string> _locked_files; + + /// Cache file that is currently in use for load/save (this file is locked). + std::string _locked_file; + + /// Type of cache (truth or surrogate). + NOMAD::eval_type _eval_type; + + /// Points read in the (optional) initial cache file. + std::set<NOMAD::Cache_Point> _cache1; + + /// Points of the cache to write in the cache file. + std::set<NOMAD::Cache_Point> _cache2; + + /// Points of the cache already saved in the file. + std::set<NOMAD::Cache_Point> _cache3; + + /// Points not from the current run (from a cache file or from a user). + mutable std::list<const NOMAD::Eval_Point*> _extern_pts; + + /// Size in memory. + mutable float _sizeof; + + /// Iterator to browse the cache with \c begin() and \c next(). + mutable std::set<NOMAD::Cache_Point>::const_iterator _it; + + /*---------------------------------------------------------------------------*/ + + /// Read points in a cache file. + /** + - Reads points from a cache file. + - Fills the set \c _cache1. + \param fin The already opened input file -- \b IN. + \param p_nb_bb_outputs A pointer on an integer with the number + of blackbox outputs; can be \c NULL -- \b IN. + \param display A boolean equal to \c true if displays + are authorized -- \b IN. + \return A boolean equal to \c true if the file could be read. + */ + bool read_points_from_cache_file ( std::ifstream & fin , + const int * p_nb_bb_outputs , + bool display ); + + /// Check if a file is locked. + /** + \param file_name Name of the file -- \b IN. + \return A boolean equal to \c true if the file is locked. + */ + bool is_locked ( const std::string & file_name ); + + /// Lock a file. + /** + \param file_name Name of the file -- \b IN. + \return A boolean equal to \c false if the file was already locked. + */ + bool lock ( const std::string & file_name ); + + /// Unlock the locked file. + void unlock ( void ); + + /// Update a point already in cache. + /** + - The point already in cache is updated from another point with the same coordinates. - - If both points have a different number of blackbox outputs, + - If both points have a different number of blackbox outputs, they are not comparable and we set \c cache_x \c = \c x . - \param cache_x The point already in cache -- \b IN/OUT. - \param x The other point -- \b IN. - */ - void update ( NOMAD::Eval_Point & cache_x , const NOMAD::Eval_Point & x ) const; - - /// Find a point in the cache. - /** - \param x The point -- \b IN. - \param it An iterator indicating the position of the point - -- \b OUT. - \param cache_index Index of the std::set in which the point has been found - -- \b OUT. - \return A pointer to the point in cache. - \return \c NULL if \c x is not in the cache. - */ - const NOMAD::Eval_Point * find - ( const NOMAD::Eval_Point & x , - std::set<NOMAD::Cache_Point>::const_iterator & it , - NOMAD::cache_index_type & cache_index ) const; - - /// Initialization of \c _sizeof. - /** - \return The size of an empty cache. - */ - int sizeof_init ( void ) const; - - /*---------------------------------------------------------------------------*/ - - public: - - /// Exception class for a cache error. - /** - Occurs when points have not the same \c eval_type as \c this->_eval_type. - */ - class Cache_Error : public NOMAD::Exception - { + \param cache_x The point already in cache -- \b IN/OUT. + \param x The other point -- \b IN. + */ + void update ( NOMAD::Eval_Point & cache_x , const NOMAD::Eval_Point & x ) const; + + /// Find a point in the cache. + /** + \param x The point -- \b IN. + \param it An iterator indicating the position of the point + -- \b OUT. + \param cache_index Index of the std::set in which the point has been found + -- \b OUT. + \return A pointer to the point in cache. + \return \c NULL if \c x is not in the cache. + */ + const NOMAD::Eval_Point * find ( const NOMAD::Eval_Point & x , + std::set<NOMAD::Cache_Point>::const_iterator & it , + NOMAD::cache_index_type & cache_index) const; + + /// Initialization of \c _sizeof. + /** + \return The size of an empty cache. + */ + int sizeof_init ( void ) const; + + /*---------------------------------------------------------------------------*/ + public: - /// Constructor. - Cache_Error ( const std::string & file , - int line , - const std::string & msg ) - : NOMAD::Exception ( file , line , msg ) {} + + /// Exception class for a cache error. + /** + Occurs when points have not the same \c eval_type as \c this->_eval_type. + */ + class Cache_Error : public NOMAD::Exception + { + public: + /// Constructor. + Cache_Error ( const std::string & file , + int line , + const std::string & msg ) + : NOMAD::Exception ( file , line , msg ) {} + }; + + /*---------------------------------------------------------------------------*/ + + /// Constructor. + /** + \param out The NOMAD::Display object -- \b IN. + \param type Type of the cache + -- \b IN -- \b optional (default = NOMAD::TRUTH). + */ + explicit Cache ( const NOMAD::Display & out , + NOMAD::eval_type type = NOMAD::TRUTH ) + : _out ( out ) , + _eval_type ( type ) , + _sizeof ( static_cast<float>(sizeof_init()) ) {} + + /// Destructor. + virtual ~Cache ( void ) { clear(); } + + /// Access to the size of cache in memory. + /** + \return The size of cache in memory, in bytes. + */ + float size_of ( void ) const { return _sizeof; } + + /// Access to the number of points. + /** + \return The number of points in the cache. + */ + int size ( void ) const + { + return static_cast<int> ( _cache1.size() + _cache2.size() + _cache3.size() ); + } + + /// check if the cache is empty. + /** + \return A boolean equal to \c true if the cache is empty. + */ + bool empty ( void ) const + { + return _cache1.empty() && _cache2.empty() && _cache3.empty(); + } + + /// Access to the evaluation type (truth or surrogate). + /** + \return The evaluation type. + */ + NOMAD::eval_type get_eval_type ( void ) const { return _eval_type; } + + /// Const cast for an evaluation point. + /** + Transforms a \c const NOMAD::Eval_Point \c & into a NOMAD::Eval_Point \c &. + \param x The const point -- \b IN. + \return The non-const point. + */ + static NOMAD::Eval_Point & get_modifiable_point ( const NOMAD::Eval_Point & x ) + { + return const_cast<NOMAD::Eval_Point&> ( x ); + } + + /// Insertion of a point into the list of extern points. + /** + \param x The extern point -- \b IN. + */ + void insert_extern_point ( const NOMAD::Eval_Point & x ) const; + + /// Access to the number of extern points. + /** + \return The number of extern points. + */ + virtual int get_nb_extern_points ( void ) const + { + return static_cast<int>(_extern_pts.size()); + } + + /// Access to an extern point. + /** + Get the first extern point and remove it from the list. + \return A pointer to the extern point; + \c NULL if there is no extern point. + */ + virtual const NOMAD::Eval_Point * get_and_remove_extern_point ( void ) const; + + /// Find a point in the cache. + /** + \param x The point -- \b IN. + \return A pointer to the point in cache. + \return \c NULL if the point is not in cache. + */ + virtual const NOMAD::Eval_Point * find ( const NOMAD::Eval_Point & x ) const; + + /// Access to the first point in cache. + /** + We browse in this order: \c _cache2, \c _cache3, and \c _cache_1 . + \return A pointer to the first point in cache; + \c NULL if the cache is empty. + */ + const NOMAD::Eval_Point * begin ( void ) const; + + /// Access to the next point when browsing the cache. + /** + Supposes that \c begin() has already been called. + \return A pointer to the next point; \c NULL if there + is no more point. + */ + const NOMAD::Eval_Point * next ( void ) const; + + /// Erase a point. + /** + The point is not deleted from memory if its + address does not match the address of the point + in cache. + \param x The point -- \b IN. + \return A boolean equal to \c true + if the point has been found and removed from the cache. + */ + bool erase ( const NOMAD::Eval_Point & x ); + + /// Insertion of a point in the cache ( \c _cache2 ). + /** + Supposes that \c x is not already in cache. + \param x The point -- \b IN. + */ + virtual void insert ( const NOMAD::Eval_Point & x ); + + /// Insert all points of another cache into the current cache. + /** + This empties the points in \c c in order to avoid NOMAD::Eval_Point copies. + \c c._locked_file and \c this->_locked_file are different by construction. + \param c The other cache -- \b IN/OUT. + */ + void insert ( Cache & c ); + + /// Load a cache file. + /** + - fills the set \c _cache1. + - locks the file \c file_name. + + \param file_name The file -- \b IN. + + \param p_nb_bb_outputs A pointer to the number of blackbox outputs. + It is ignored if equal to \c NULL. + Points from the file with a different number + of outputs are ignored + -- \b IN -- \b optional (default = \c NULL). + + \param display A boolean equal to \c true if displays + are authorized + -- \b IN -- \b optional (default = \c true). + + \return \c false if the file exists and is not a valid cache file. + \return \c false if the file is already locked. + \return \c false if the object already locked another file. + \return \c true if the object is already locked with this file (and do nothing). + \return \c true and create a valid cache file if the file does not exist. + \return \c false if the previous anything else did not work. + */ + bool load ( const std::string & file_name , + const int * p_nb_bb_outputs = NULL , + bool display = true ); + + /// Save a cache file. + /** + \param overwrite A boolean. + If \c false, points are written + at the end of the locked file and only points + from \c _cache2 are considered. + These points are then transfered to \c _cache3. + If \c true, all the points are considered. + -- \b IN -- \b optional (default = \c false). + \param display A boolean equal to \c true if displays + are authorized + -- \b IN -- \b optional (default = \c true). + \return A boolean equal to \c true if the save could complete. + */ + bool save ( bool overwrite = false , + bool display = true ); + + /// Erase all points in cache and unlock the file. + void clear ( void ); + + /// Display the list of extern points. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display_extern_pts ( const NOMAD::Display & out ) const; + + /// Display the list of extern points. + /** + Uses the \c this->_out member as NOMAD::Display object. + */ + void display_extern_pts ( void ) const { display_extern_pts ( _out ); } + + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display ( const NOMAD::Display & out ) const; + + /// Display. + /** + Uses the \c this->_out member as NOMAD::Display object. + */ + void display ( void ) const { display ( _out ); } + }; - /*---------------------------------------------------------------------------*/ - - /// Constructor. - /** - \param out The NOMAD::Display object -- \b IN. - \param type Type of the cache - -- \b IN -- \b optional (default = NOMAD::TRUTH). - */ - explicit Cache ( const NOMAD::Display & out , - NOMAD::eval_type type = NOMAD::TRUTH ) - : _out ( out ) , - _eval_type ( type ) , - _sizeof ( static_cast<float>(sizeof_init()) ) {} - - /// Destructor. - virtual ~Cache ( void ) { clear(); } - - /// Access to the size of cache in memory. - /** - \return The size of cache in memory, in bytes. - */ - float size_of ( void ) const { return _sizeof; } - - /// Access to the number of points. - /** - \return The number of points in the cache. - */ - int size ( void ) const - { - return static_cast<int> ( _cache1.size() + _cache2.size() + _cache3.size() ); - } - - /// check if the cache is empty. + /// Display a NOMAD::Cache object. /** - \return A boolean equal to \c true if the cache is empty. - */ - bool empty ( void ) const - { - return _cache1.empty() && _cache2.empty() && _cache3.empty(); - } - - /// Access to the evaluation type (truth or surrogate). - /** - \return The evaluation type. - */ - NOMAD::eval_type get_eval_type ( void ) const { return _eval_type; } - - /// Const cast for an evaluation point. - /** - Transforms a \c const NOMAD::Eval_Point \c & into a NOMAD::Eval_Point \c &. - \param x The const point -- \b IN. - \return The non-const point. - */ - static NOMAD::Eval_Point & get_modifiable_point ( const NOMAD::Eval_Point & x ) - { - return const_cast<NOMAD::Eval_Point&> ( x ); - } - - /// Insertion of a point into the list of extern points. - /** - \param x The extern point -- \b IN. - */ - void insert_extern_point ( const NOMAD::Eval_Point & x ) const; - - /// Access to the number of extern points. - /** - \return The number of extern points. - */ - virtual int get_nb_extern_points ( void ) const { return static_cast<int>(_extern_pts.size()); } - - /// Access to an extern point. - /** - Get the first extern point and remove it from the list. - \return A pointer to the extern point; - \c NULL if there is no extern point. - */ - virtual const NOMAD::Eval_Point * get_and_remove_extern_point ( void ) const; - - /// Find a point in the cache. - /** - \param x The point -- \b IN. - \return A pointer to the point in cache. - \return \c NULL if the point is not in cache. - */ - virtual const NOMAD::Eval_Point * find ( const NOMAD::Eval_Point & x ) const; - - /// Access to the first point in cache. - /** - We browse in this order: \c _cache2, \c _cache3, and \c _cache_1 . - \return A pointer to the first point in cache; - \c NULL if the cache is empty. - */ - const NOMAD::Eval_Point * begin ( void ) const; - - /// Access to the next point when browsing the cache. - /** - Supposes that \c begin() has already been called. - \return A pointer to the next point; \c NULL if there - is no more point. - */ - const NOMAD::Eval_Point * next ( void ) const; - - /// Erase a point. - /** - The point is not deleted from memory if its - address does not match the address of the point - in cache. - \param x The point -- \b IN. - \return A boolean equal to \c true - if the point has been found and removed from the cache. - */ - bool erase ( const NOMAD::Eval_Point & x ); - - /// Insertion of a point in the cache ( \c _cache2 ). - /** - Supposes that \c x is not already in cache. - \param x The point -- \b IN. - */ - virtual void insert ( const NOMAD::Eval_Point & x ); - - /// Insert all points of another cache into the current cache. - /** - This empties the points in \c c in order to avoid NOMAD::Eval_Point copies. - \c c._locked_file and \c this->_locked_file are different by construction. - \param c The other cache -- \b IN/OUT. - */ - void insert ( Cache & c ); - - /// Load a cache file. - /** - - fills the set \c _cache1. - - locks the file \c file_name. - - \param file_name The file -- \b IN. - - \param p_nb_bb_outputs A pointer to the number of blackbox outputs. - It is ignored if equal to \c NULL. - Points from the file with a different number - of outputs are ignored - -- \b IN -- \b optional (default = \c NULL). - - \param display A boolean equal to \c true if displays - are authorized - -- \b IN -- \b optional (default = \c true). - - \return \c false if the file exists and is not a valid cache file. - \return \c false if the file is already locked. - \return \c false if the object already locked another file. - \return \c true if the object is already locked with this file (and do nothing). - \return \c true and create a valid cache file if the file does not exist. - \return \c false if the previous anything else did not work. - */ - bool load ( const std::string & file_name , - const int * p_nb_bb_outputs = NULL , - bool display = true ); - - /// Save a cache file. - /** - \param overwrite A boolean. - If \c false, points are written - at the end of the locked file and only points - from \c _cache2 are considered. - These points are then transfered to \c _cache3. - If \c true, all the points are considered. - -- \b IN -- \b optional (default = \c false). - \param display A boolean equal to \c true if displays - are authorized - -- \b IN -- \b optional (default = \c true). - \return A boolean equal to \c true if the save could complete. - */ - bool save ( bool overwrite = false , - bool display = true ); - - /// Erase all points in cache and unlock the file. - void clear ( void ); - - /// Display the list of extern points. - /** - \param out The NOMAD::Display object -- \b IN. - */ - void display_extern_pts ( const NOMAD::Display & out ) const; - - /// Display the list of extern points. - /** - Uses the \c this->_out member as NOMAD::Display object. - */ - void display_extern_pts ( void ) const { display_extern_pts ( _out ); } - - /// Display. - /** - \param out The NOMAD::Display object -- \b IN. - */ - void display ( const NOMAD::Display & out ) const; - - /// Display. - /** - Uses the \c this->_out member as NOMAD::Display object. - */ - void display ( void ) const { display ( _out ); } - - }; - - /// Display a NOMAD::Cache object. - /** \param out The NOMAD::Display object -- \b IN. \param c The NOMAD::Cache object to be displayed -- \b IN. \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Cache & c ) - { - c.display ( out ); - return out; - } + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::Cache & c ) + { + c.display ( out ); + return out; + } } #endif diff --git a/src/Cache_File_Point.cpp b/src/Cache_File_Point.cpp index 97aca5da5959c5a4c7ef6d962e85347d0daf101b..d5255df29cee55e09e14e70a7c6539c56e3c19c9 100644 --- a/src/Cache_File_Point.cpp +++ b/src/Cache_File_Point.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Cache_File_Point.cpp - \brief Class for points in binary files (implementation) - \author Sebastien Le Digabel - \date 2010-04-06 - \see Cache_File_Point.hpp -*/ + \file Cache_File_Point.cpp + \brief Class for points in binary files (implementation) + \author Sebastien Le Digabel + \date 2010-04-06 + \see Cache_File_Point.hpp + */ #include "Cache_File_Point.hpp" #include "Eval_Point.hpp" @@ -55,19 +62,19 @@ int NOMAD::Cache_File_Point::_max_cardinality = 0; /* constructor 1 */ /*---------------------------------------------------------------------*/ NOMAD::Cache_File_Point::Cache_File_Point ( void ) - : _n ( 0 ) , - _m ( 0 ) , - _m_def ( 0 ) , - _eval_status ( 3 ) , - _coords ( NULL ) , - _bbo_def ( NULL ) , - _bbo_index ( NULL ) +: _n ( 0 ) , +_m ( 0 ) , +_m_def ( 0 ) , +_eval_status ( 3 ) , +_coords ( NULL ) , +_bbo_def ( NULL ) , +_bbo_index ( NULL ) { #ifdef MEMORY_DEBUG - ++NOMAD::Cache_File_Point::_cardinality; - if ( NOMAD::Cache_File_Point::_cardinality > - NOMAD::Cache_File_Point::_max_cardinality ) - ++NOMAD::Cache_File_Point::_max_cardinality; + ++NOMAD::Cache_File_Point::_cardinality; + if ( NOMAD::Cache_File_Point::_cardinality > + NOMAD::Cache_File_Point::_max_cardinality ) + ++NOMAD::Cache_File_Point::_max_cardinality; #endif } @@ -75,88 +82,94 @@ NOMAD::Cache_File_Point::Cache_File_Point ( void ) /* constructor 2 */ /*---------------------------------------------------------------------*/ NOMAD::Cache_File_Point::Cache_File_Point ( const NOMAD::Eval_Point & x ) - : _n ( x.size() ) , - _m ( 0 ) , - _m_def ( 0 ) , - _coords ( NULL ) , - _bbo_def ( NULL ) , - _bbo_index ( NULL ) +: _n ( x.size() ) , +_m ( 0 ) , +_m_def ( 0 ) , +_coords ( NULL ) , +_bbo_def ( NULL ) , +_bbo_index ( NULL ) { - int i; - - // eval_status: - switch ( x.get_eval_status() ) { - case NOMAD::EVAL_FAIL: - _eval_status = 0; - break; - case NOMAD::EVAL_OK: - _eval_status = 1; - break; - case NOMAD::EVAL_IN_PROGRESS: - _eval_status = 2; - break; - case NOMAD::UNDEFINED_STATUS: - _eval_status = 3; - break; - case NOMAD::EVAL_USER_REJECT: - _eval_status = 3; - break; - } - - // inputs: - if ( _n > 0 ) { - _coords = new double [_n]; - for ( i = 0 ; i < _n ; ++i ) - _coords[i] = x[i].value(); - } - else - _n = 0; - - // outputs: - const NOMAD::Point & bbo = x.get_bb_outputs(); - _m = bbo.size(); - if ( _m > 0 ) { - - std::vector<double> vd; - std::vector<int> vi; - - for ( i = 0 ; i < _m ; ++i ) - if ( bbo[i].is_defined() ) { - vd.push_back ( bbo[i].value() ); - vi.push_back ( i ); - } - - _m_def = static_cast<int> ( vd.size() ); - if ( _m_def > 0 ) { - _bbo_def = new double [_m_def]; - _bbo_index = new int [_m_def]; - for ( i = 0 ; i < _m_def ; ++i ) { - _bbo_def [i] = vd[i]; - _bbo_index[i] = vi[i]; - } - } - } - else - _m = 0; - + int i; + + // eval_status: + switch ( x.get_eval_status() ) + { + case NOMAD::EVAL_FAIL: + _eval_status = 0; + break; + case NOMAD::EVAL_OK: + _eval_status = 1; + break; + case NOMAD::EVAL_IN_PROGRESS: + _eval_status = 2; + break; + case NOMAD::UNDEFINED_STATUS: + _eval_status = 3; + break; + case NOMAD::EVAL_USER_REJECT: + _eval_status = 3; + break; + } + + // inputs: + if ( _n > 0 ) + { + _coords = new double [_n]; + for ( i = 0 ; i < _n ; ++i ) + _coords[i] = x[i].value(); + } + else + _n = 0; + + // outputs: + const NOMAD::Point & bbo = x.get_bb_outputs(); + _m = bbo.size(); + if ( _m > 0 ) + { + + std::vector<double> vd; + std::vector<int> vi; + + for ( i = 0 ; i < _m ; ++i ) + if ( bbo[i].is_defined() ) + { + vd.push_back ( bbo[i].value() ); + vi.push_back ( i ); + } + + _m_def = static_cast<int> ( vd.size() ); + if ( _m_def > 0 ) + { + _bbo_def = new double [_m_def]; + _bbo_index = new int [_m_def]; + for ( i = 0 ; i < _m_def ; ++i ) + { + _bbo_def [i] = vd[i]; + _bbo_index[i] = vi[i]; + } + } + } + else + _m = 0; + #ifdef MEMORY_DEBUG - ++NOMAD::Cache_File_Point::_cardinality; - if ( NOMAD::Cache_File_Point::_cardinality > - NOMAD::Cache_File_Point::_max_cardinality ) - ++NOMAD::Cache_File_Point::_max_cardinality; + ++NOMAD::Cache_File_Point::_cardinality; + if ( NOMAD::Cache_File_Point::_cardinality > + NOMAD::Cache_File_Point::_max_cardinality ) + ++NOMAD::Cache_File_Point::_max_cardinality; #endif } /*---------------------------------------------------------------------*/ /* destructor */ /*---------------------------------------------------------------------*/ -NOMAD::Cache_File_Point::~Cache_File_Point ( void ) +NOMAD::Cache_File_Point::~Cache_File_Point ( void ) { - delete [] _coords; - delete [] _bbo_def; - delete [] _bbo_index; + delete [] _coords; + delete [] _bbo_def; + delete [] _bbo_index; #ifdef MEMORY_DEBUG - --NOMAD::Cache_File_Point::_cardinality; + --NOMAD::Cache_File_Point::_cardinality; #endif } @@ -165,10 +178,10 @@ NOMAD::Cache_File_Point::~Cache_File_Point ( void ) /*---------------------------------------------------------------------*/ double NOMAD::Cache_File_Point::get_coord ( int i ) const { - if ( !_coords || i < 0 || i >= _n ) - throw NOMAD::Exception ( "Cache_File_Point.cpp" , __LINE__ , - "bad access in Cache_File_Point::get_coord()" ); - return _coords[i]; + if ( !_coords || i < 0 || i >= _n ) + throw NOMAD::Exception ( "Cache_File_Point.cpp" , __LINE__ , + "bad access in Cache_File_Point::get_coord()" ); + return _coords[i]; } /*---------------------------------------------------------------------*/ @@ -176,10 +189,10 @@ double NOMAD::Cache_File_Point::get_coord ( int i ) const /*---------------------------------------------------------------------*/ const NOMAD::Point NOMAD::Cache_File_Point::get_bb_outputs ( void ) const { - NOMAD::Point bbo ( _m ); - for ( int i = 0 ; i < _m_def ; ++i ) - bbo [ _bbo_index[i] ] = _bbo_def[i]; - return bbo; + NOMAD::Point bbo ( _m ); + for ( int i = 0 ; i < _m_def ; ++i ) + bbo [ _bbo_index[i] ] = _bbo_def[i]; + return bbo; } /*---------------------------------------------------------*/ @@ -187,16 +200,16 @@ const NOMAD::Point NOMAD::Cache_File_Point::get_bb_outputs ( void ) const /*---------------------------------------------------------*/ void NOMAD::Cache_File_Point::reset ( void ) { - _n = _m = _m_def = 0; - _eval_status = 3; - - delete [] _coords; - delete [] _bbo_def; - delete [] _bbo_index; - - _coords = NULL; - _bbo_def = NULL; - _bbo_index = NULL; + _n = _m = _m_def = 0; + _eval_status = 3; + + delete [] _coords; + delete [] _bbo_def; + delete [] _bbo_index; + + _coords = NULL; + _bbo_def = NULL; + _bbo_index = NULL; } /*---------------------------------------------------------*/ @@ -204,35 +217,36 @@ void NOMAD::Cache_File_Point::reset ( void ) /*---------------------------------------------------------*/ bool NOMAD::Cache_File_Point::write ( std::ofstream & fout ) const { - // do nothing if no point: - if ( _n <= 0 ) - return true; - - // 1. _eval_status: - fout.write ( (char *) &_eval_status , sizeof(_eval_status) ); - - // 2. _n: - fout.write ( (char *) &_n , sizeof(_n) ); - - // 3. _m: - fout.write ( (char *) &_m , sizeof(_m) ); - - // 4. _m_def: - fout.write ( (char *) &_m_def , sizeof(_m_def) ); - - // 5. _coords: - fout.write ( (char *) _coords , _n*sizeof(double) ); - - if ( _m_def > 0 ) { - - // 6. _bbo_def: - fout.write ( (char *) _bbo_def , _m_def*sizeof(double) ); - - // 7. _bbo_index: - fout.write ( (char *) _bbo_index , _m_def*sizeof(int) ); - } - - return !fout.fail(); + // do nothing if no point: + if ( _n <= 0 ) + return true; + + // 1. _eval_status: + fout.write ( (char *) &_eval_status , sizeof(_eval_status) ); + + // 2. _n: + fout.write ( (char *) &_n , sizeof(_n) ); + + // 3. _m: + fout.write ( (char *) &_m , sizeof(_m) ); + + // 4. _m_def: + fout.write ( (char *) &_m_def , sizeof(_m_def) ); + + // 5. _coords: + fout.write ( (char *) _coords , _n*sizeof(double) ); + + if ( _m_def > 0 ) + { + + // 6. _bbo_def: + fout.write ( (char *) _bbo_def , _m_def*sizeof(double) ); + + // 7. _bbo_index: + fout.write ( (char *) _bbo_index , _m_def*sizeof(int) ); + } + + return !fout.fail(); } /*---------------------------------------------------------*/ @@ -240,62 +254,69 @@ bool NOMAD::Cache_File_Point::write ( std::ofstream & fout ) const /*---------------------------------------------------------*/ bool NOMAD::Cache_File_Point::read ( std::ifstream & fin ) { - reset(); - - // 1. _eval_status: - fin.read ( (char *) &_eval_status , sizeof(_eval_status) ); - if ( fin.fail() || _eval_status > 3 ) - return false; - - // 2. _n: - fin.read ( (char *) &_n , sizeof(_n) ); - if ( fin.fail() || _n <= 0 ) { - _n = 0; - return false; - } - - // 3. _m: - fin.read ( (char *) &_m , sizeof(_m) ); - if ( fin.fail() || _m < 0 ) { - _n = _m = 0; - return false; - } - - // 4. _m_def: - fin.read ( (char *) &_m_def , sizeof(_m_def) ); - if ( fin.fail() || _m_def < 0 ) { - _m_def = _n = _m = 0; - return false; - } - - // 5. _coords: - _coords = new double [_n]; - fin.read ( (char *) _coords , _n*sizeof(double) ); - if ( fin.fail() ) { reset(); - return false; - } - - if ( _m_def > 0 ) { - - // 6. _bb_def: - _bbo_def = new double [_m_def]; - fin.read ( (char *) _bbo_def , _m_def*sizeof(double) ); - if ( fin.fail() ) { - reset(); - return false; + + // 1. _eval_status: + fin.read ( (char *) &_eval_status , sizeof(_eval_status) ); + if ( fin.fail() || _eval_status > 3 ) + return false; + + // 2. _n: + fin.read ( (char *) &_n , sizeof(_n) ); + if ( fin.fail() || _n <= 0 ) + { + _n = 0; + return false; } - - // 7. _bbo_index: - _bbo_index = new int [_m_def]; - fin.read ( (char *) _bbo_index , _m_def*sizeof(int) ); - if ( fin.fail() ) { - reset(); - return false; + + // 3. _m: + fin.read ( (char *) &_m , sizeof(_m) ); + if ( fin.fail() || _m < 0 ) + { + _n = _m = 0; + return false; } - } - - return true; + + // 4. _m_def: + fin.read ( (char *) &_m_def , sizeof(_m_def) ); + if ( fin.fail() || _m_def < 0 ) + { + _m_def = _n = _m = 0; + return false; + } + + // 5. _coords: + _coords = new double [_n]; + fin.read ( (char *) _coords , _n*sizeof(double) ); + if ( fin.fail() ) + { + reset(); + return false; + } + + if ( _m_def > 0 ) + { + + // 6. _bb_def: + _bbo_def = new double [_m_def]; + fin.read ( (char *) _bbo_def , _m_def*sizeof(double) ); + if ( fin.fail() ) + { + reset(); + return false; + } + + // 7. _bbo_index: + _bbo_index = new int [_m_def]; + fin.read ( (char *) _bbo_index , _m_def*sizeof(int) ); + if ( fin.fail() ) + { + reset(); + return false; + } + } + + return true; } /*---------------------------------------------------------*/ @@ -303,25 +324,27 @@ bool NOMAD::Cache_File_Point::read ( std::ifstream & fin ) /*---------------------------------------------------------*/ void NOMAD::Cache_File_Point::display ( const NOMAD::Display & out ) const { - out << "n : " << _n << std::endl - << "m : " << _m << std::endl - << "m_def : " << _m_def << std::endl; - - int i; - if ( _n > 0 ) { - out << "coords : ( "; - for ( i = 0 ; i < _n ; ++i ) - out << _coords[i] << " "; - out << ")" << std::endl; - } - if ( _m_def > 0 ) { - out << "bbo_def : [ "; - for ( i = 0 ; i < _m_def ; ++i ) - out << _bbo_def[i] << " "; - out << "]" << std::endl - << "bbo_index : [ "; - for ( i = 0 ; i < _m_def ; ++i ) - out << _bbo_index[i] << " "; - out << "]" << std::endl; - } + out << "n : " << _n << std::endl + << "m : " << _m << std::endl + << "m_def : " << _m_def << std::endl; + + int i; + if ( _n > 0 ) + { + out << "coords : ( "; + for ( i = 0 ; i < _n ; ++i ) + out << _coords[i] << " "; + out << ")" << std::endl; + } + if ( _m_def > 0 ) + { + out << "bbo_def : [ "; + for ( i = 0 ; i < _m_def ; ++i ) + out << _bbo_def[i] << " "; + out << "]" << std::endl + << "bbo_index : [ "; + for ( i = 0 ; i < _m_def ; ++i ) + out << _bbo_index[i] << " "; + out << "]" << std::endl; + } } diff --git a/src/Cache_File_Point.hpp b/src/Cache_File_Point.hpp index 3fcf4f04a8e1f67446c766edd1f50e1599e41de0..7688a9e74624dcbb96d088daa9904bb9df84e460 100644 --- a/src/Cache_File_Point.hpp +++ b/src/Cache_File_Point.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Cache_File_Point.hpp - \brief Class for points in binary files (headers) - \author Sebastien Le Digabel - \date 2010-04-06 - \see Cache_File_Point.cpp -*/ + \file Cache_File_Point.hpp + \brief Class for points in binary files (headers) + \author Sebastien Le Digabel + \date 2010-04-06 + \see Cache_File_Point.cpp + */ #ifndef __CACHE_FILE_POINT__ #define __CACHE_FILE_POINT__ @@ -48,155 +55,155 @@ #include "Uncopyable.hpp" namespace NOMAD { - - // forward declarations: - class Point; - class Eval_Point; - - /// Class to represent NOMAD::Eval_Point objects in binary files. - /** - - All point coordinates are saved. - - Only defined blackbox outputs are saved. - - To get all bb_outputs: - \code - NOMAD::Point bbo ( _m ); - for ( int i = 0 ; i < _m_def ; ++i ) - bbo [ _bbo_index[i] ] = _bbo_def[i]; - \endcode - */ - class Cache_File_Point : private NOMAD::Uncopyable { - - private: + // forward declarations: + class Point; + class Eval_Point; + + /// Class to represent NOMAD::Eval_Point objects in binary files. + /** + - All point coordinates are saved. + - Only defined blackbox outputs are saved. + - To get all bb_outputs: + \code + NOMAD::Point bbo ( _m ); + for ( int i = 0 ; i < _m_def ; ++i ) + bbo [ _bbo_index[i] ] = _bbo_def[i]; + \endcode + */ + class Cache_File_Point : private NOMAD::Uncopyable { + + private: + #ifdef MEMORY_DEBUG - /// Number of NOMAD::Cache_File_Point objects in memory. - static int _cardinality; - - /// Max number of NOMAD::Cache_File_Point objects in memory. - static int _max_cardinality; + /// Number of NOMAD::Cache_File_Point objects in memory. + static int _cardinality; + + /// Max number of NOMAD::Cache_File_Point objects in memory. + static int _max_cardinality; #endif - - int _n; ///< Dimension of the point. - int _m; ///< Number of blackbox outputs (both defined and undefined). - int _m_def; ///< Number of defined blackbox outputs. - - /// Evaluation status. - /** - - 0: fail. - - 1: ok. - - 2: in progress. - - 3: undefined. - */ - unsigned char _eval_status; - - double * _coords; ///< The \c _n coordinates. - double * _bbo_def; ///< The \c _m_def defined blackbox output values. - int * _bbo_index; ///< The index for the blackbox output values. - - /// Reset. - void reset ( void ); - - public: - + + int _n; ///< Dimension of the point. + int _m; ///< Number of blackbox outputs (both defined and undefined). + int _m_def; ///< Number of defined blackbox outputs. + + /// Evaluation status. + /** + - 0: fail. + - 1: ok. + - 2: in progress. + - 3: undefined. + */ + unsigned char _eval_status; + + double * _coords; ///< The \c _n coordinates. + double * _bbo_def; ///< The \c _m_def defined blackbox output values. + int * _bbo_index; ///< The index for the blackbox output values. + + /// Reset. + void reset ( void ); + + public: + #ifdef MEMORY_DEBUG - /// Access to the number of NOMAD::Cache_File_Point objects in memory. - /** - \return The number of NOMAD::Cache_File_Point objects in memory. - */ - static int get_cardinality ( void ) { return Cache_File_Point::_cardinality; } - - /// Access to the max number of NOMAD::Cache_File_Point objects in memory. - /** - \return The max number of NOMAD::Cache_File_Point objects in memory. - */ - static int get_max_cardinality ( void ) - { - return Cache_File_Point::_max_cardinality; - } + /// Access to the number of NOMAD::Cache_File_Point objects in memory. + /** + \return The number of NOMAD::Cache_File_Point objects in memory. + */ + static int get_cardinality ( void ) { return Cache_File_Point::_cardinality; } + + /// Access to the max number of NOMAD::Cache_File_Point objects in memory. + /** + \return The max number of NOMAD::Cache_File_Point objects in memory. + */ + static int get_max_cardinality ( void ) + { + return Cache_File_Point::_max_cardinality; + } #endif - - /// Constructor #1. - explicit Cache_File_Point ( void ); - - /// Constructor #2. - /** - From a NOMAD::Eval_Point object. - \param x The evaluation point. - */ - explicit Cache_File_Point ( const NOMAD::Eval_Point & x ); + + /// Constructor #1. + explicit Cache_File_Point ( void ); + + /// Constructor #2. + /** + From a NOMAD::Eval_Point object. + \param x The evaluation point. + */ + explicit Cache_File_Point ( const NOMAD::Eval_Point & x ); + + /// Destructor. + virtual ~Cache_File_Point ( void ); + + /// Access to the dimension of the point. + /** + \return The dimension of the point. + */ + int get_n ( void ) const { return _n; } + + /// Access to the number of blackbox outputs. + /** + \return The number of blackbox outputs. + */ + int get_m ( void ) const { return _m; } + + /// Access to the evaluation status. + /** + Evaluation status as a character: + - 0: fail. + - 1: ok. + - 2: in progress. + - 3: undefined. + \return A character as the evaluation status. + */ + unsigned char get_eval_status ( void ) const { return _eval_status; } + + /// Access to the coordinates. + /** + \param i The index (0 for the first element) -- \b IN. + \return The \c (i+1)th coordinate. + */ + double get_coord ( int i ) const; + + /// Access to the blackbox outputs. + /** + \return A NOMAD::Point as the \c _m outputs. + */ + const NOMAD::Point get_bb_outputs ( void ) const; + + /// Write in a binary file. + /** + \param fout The output file -- \b IN/OUT. + \return A boolean equal to \c true if the file could be written. + */ + bool write ( std::ofstream & fout ) const; + + /// Read in a binary file. + /** + \param fin The input file -- \b IN/OUT. + \return A boolean equal to \c true if the file could be read. + */ + bool read ( std::ifstream & fin ); + + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display ( const NOMAD::Display & out ) const; + }; - /// Destructor. - virtual ~Cache_File_Point ( void ); - - /// Access to the dimension of the point. - /** - \return The dimension of the point. - */ - int get_n ( void ) const { return _n; } - - /// Access to the number of blackbox outputs. + /// Display a NOMAD::Cache_File_Point object. /** - \return The number of blackbox outputs. - */ - int get_m ( void ) const { return _m; } - - /// Access to the evaluation status. - /** - Evaluation status as a character: - - 0: fail. - - 1: ok. - - 2: in progress. - - 3: undefined. - \return A character as the evaluation status. - */ - unsigned char get_eval_status ( void ) const { return _eval_status; } - - /// Access to the coordinates. - /** - \param i The index (0 for the first element) -- \b IN. - \return The \c (i+1)th coordinate. - */ - double get_coord ( int i ) const; - - /// Access to the blackbox outputs. - /** - \return A NOMAD::Point as the \c _m outputs. - */ - const NOMAD::Point get_bb_outputs ( void ) const; - - /// Write in a binary file. - /** - \param fout The output file -- \b IN/OUT. - \return A boolean equal to \c true if the file could be written. - */ - bool write ( std::ofstream & fout ) const; - - /// Read in a binary file. - /** - \param fin The input file -- \b IN/OUT. - \return A boolean equal to \c true if the file could be read. - */ - bool read ( std::ifstream & fin ); - - /// Display. - /** - \param out The NOMAD::Display object -- \b IN. - */ - void display ( const NOMAD::Display & out ) const; - }; - - /// Display a NOMAD::Cache_File_Point object. - /** \param out The NOMAD::Display object -- \b IN. \param x The NOMAD::Cache_File_Point object to be displayed -- \b IN. \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Cache_File_Point & x ) - { - x.display ( out ); - return out; - } + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::Cache_File_Point & x ) + { + x.display ( out ); + return out; + } } #endif diff --git a/src/Cache_Point.cpp b/src/Cache_Point.cpp index 9b177256b279454a81828f5badf3672941e72529..ef4334526a1e4c6ee24852f3bd8ad13479cc2755 100644 --- a/src/Cache_Point.cpp +++ b/src/Cache_Point.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Cache_Point.cpp - \brief Point stored in the cache (implementation) - \author Sebastien Le Digabel - \date 2010-04-08 - \see Cache_Point.hpp -*/ + \file Cache_Point.cpp + \brief Point stored in the cache (implementation) + \author Sebastien Le Digabel + \date 2010-04-08 + \see Cache_Point.hpp + */ #include "Cache_Point.hpp" /*-----------------------------------------------------------*/ @@ -47,7 +54,7 @@ /*-----------------------------------------------------------*/ bool NOMAD::Cache_Point::operator < ( const Set_Element<NOMAD::Eval_Point> & cp ) const { - if ( get_element()->get_tag() == cp.get_element()->get_tag() ) - return false; - return get_element()->Point::operator < ( *(cp.get_element()) ); + if ( get_element()->get_tag() == cp.get_element()->get_tag() ) + return false; + return get_element()->Point::operator < ( *(cp.get_element()) ); } diff --git a/src/Cache_Point.hpp b/src/Cache_Point.hpp index eb76b6a6dd49a3744e0786c1775fb5979161dc76..4a7bd2c4700d04239937bdb1798aaccc10bbfd80 100644 --- a/src/Cache_Point.hpp +++ b/src/Cache_Point.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,64 +41,64 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Cache_Point.hpp - \brief Point stored in the cache (headers) - \author Sebastien Le Digabel - \date 2010-04-08 - \see Cache_Point.cpp -*/ + \file Cache_Point.hpp + \brief Point stored in the cache (headers) + \author Sebastien Le Digabel + \date 2010-04-08 + \see Cache_Point.cpp + */ #ifndef __CACHE_POINT__ #define __CACHE_POINT__ #include "Eval_Point.hpp" namespace NOMAD { - - /// Class for the representation of NOMAD::Eval_Point objects stored in the cache. - class Cache_Point : public NOMAD::Set_Element<NOMAD::Eval_Point> { - - private: - - /// Affectation operator. - /** - \param cp The right-hand side object -- \b IN. - \return \c *this as the result of the affectation. - */ - Cache_Point & operator = ( const Cache_Point & cp ); - - public: - - /// Constructor. - /** - \param x A pointer to the NOMAD::Eval_Point object - that is stored in the cache -- \b IN. - */ - explicit Cache_Point ( const NOMAD::Eval_Point * x ) - : NOMAD::Set_Element<NOMAD::Eval_Point> ( x ) {} - - /// Copy constructor. - /** - \param cp The copied object -- \b IN. - */ - Cache_Point ( const Cache_Point & cp ) - : NOMAD::Set_Element<NOMAD::Eval_Point> ( cp.get_element() ) {} - - /// Destructor. - virtual ~Cache_Point ( void ) {} - - /// Comparison operator. - /** - \param cp The right-hand side object. - \return A boolean equal to \c true if \c *this \c < \c cp. - */ - virtual bool operator < ( const NOMAD::Set_Element<NOMAD::Eval_Point> & cp ) const; - - /// Access to the point. - /** - \return A pointer to the NOMAD::Eval_Point stored in the cache. - */ - const NOMAD::Eval_Point * get_point ( void ) const { return get_element(); } - }; + + /// Class for the representation of NOMAD::Eval_Point objects stored in the cache. + class Cache_Point : public NOMAD::Set_Element<NOMAD::Eval_Point> { + + private: + + /// Affectation operator. + /** + \param cp The right-hand side object -- \b IN. + \return \c *this as the result of the affectation. + */ + Cache_Point & operator = ( const Cache_Point & cp ); + + public: + + /// Constructor. + /** + \param x A pointer to the NOMAD::Eval_Point object + that is stored in the cache -- \b IN. + */ + explicit Cache_Point ( const NOMAD::Eval_Point * x ) + : NOMAD::Set_Element<NOMAD::Eval_Point> ( x ) {} + + /// Copy constructor. + /** + \param cp The copied object -- \b IN. + */ + Cache_Point ( const Cache_Point & cp ) + : NOMAD::Set_Element<NOMAD::Eval_Point> ( cp.get_element() ) {} + + /// Destructor. + virtual ~Cache_Point ( void ) {} + + /// Comparison operator. + /** + \param cp The right-hand side object. + \return A boolean equal to \c true if \c *this \c < \c cp. + */ + virtual bool operator < ( const NOMAD::Set_Element<NOMAD::Eval_Point> & cp ) const; + + /// Access to the point. + /** + \return A pointer to the NOMAD::Eval_Point stored in the cache. + */ + const NOMAD::Eval_Point * get_point ( void ) const { return get_element(); } + }; } #endif diff --git a/src/Cache_Search.cpp b/src/Cache_Search.cpp index 58cbd700c3c93003da1216779317267a1f763251..2d22fc9ee7b5e1f32b52508be80bea183e100a93 100644 --- a/src/Cache_Search.cpp +++ b/src/Cache_Search.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,122 +41,127 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Cache_Search.cpp - \brief NOMAD::Search subclass for the cache search (implementation) - \author Sebastien Le Digabel - \date 2010-04-08 - \see Cache_Search.hpp -*/ + \file Cache_Search.cpp + \brief NOMAD::Search subclass for the cache search (implementation) + \author Sebastien Le Digabel + \date 2010-04-08 + \see Cache_Search.hpp + */ #include "Cache_Search.hpp" /*---------------------------------------------------------*/ /* the search */ /*---------------------------------------------------------*/ void NOMAD::Cache_Search::search ( NOMAD::Mads & mads , - int & nb_search_pts , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - bool & count_search , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ) -{ - new_feas_inc = new_infeas_inc = NULL; - nb_search_pts = 0; - success = NOMAD::UNSUCCESSFUL; - count_search = false; - - NOMAD::Evaluator_Control & ev_control = mads.get_evaluator_control(); - const Cache & cache = mads.get_cache(); - int nb_extern_pts = cache.get_nb_extern_points(); - - // do not perform the search if the number of extern points did not change: - if ( stop || nb_extern_pts == 0 || nb_extern_pts == _last_search_nb_extern_pts ) - return; - - count_search = true; - - // initial display: - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_search_dd(); - if ( display_degree == NOMAD::FULL_DISPLAY ) { - std::ostringstream oss; - oss << NOMAD::CACHE_SEARCH; - out << std::endl << NOMAD::open_block ( oss.str() ) << std::endl; - } - - std::list<const NOMAD::Eval_Point*> list_of_extern_pts; - const NOMAD::Eval_Point * extern_pt = cache.get_and_remove_extern_point(); - NOMAD::Eval_Point * pt = NULL; - int n = _p.get_dimension(); - - // add the extern points to the list of points to be evaluated: - while ( extern_pt ) { - - list_of_extern_pts.push_front ( extern_pt ); - - pt = &NOMAD::Cache::get_modifiable_point ( *extern_pt ); + int & nb_search_pts , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + bool & count_search , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ) +{ + new_feas_inc = new_infeas_inc = NULL; + nb_search_pts = 0; + success = NOMAD::UNSUCCESSFUL; + count_search = false; + + NOMAD::Evaluator_Control & ev_control = mads.get_evaluator_control(); + const Cache & cache = mads.get_cache(); + int nb_extern_pts = cache.get_nb_extern_points(); - if ( extern_pt->get_signature() ) - pt->set_signature ( extern_pt->get_signature() ); - else if ( extern_pt->size() == n ) - pt->set_signature ( _p.get_signature() ); + // do not perform the search if the number of extern points did not change: + if ( stop || nb_extern_pts == 0 || nb_extern_pts == _last_search_nb_extern_pts ) + return; - if ( pt->get_signature() ) - ev_control.add_eval_point ( pt , - display_degree , - false , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() ); - else { - if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY ) - out << std::endl << "Warning (Cache_Search.cpp, " << __LINE__ - << "): could not use the point " << *pt - << "(no signature)" << std::endl; + count_search = true; + + // initial display: + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_search_dd(); + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + std::ostringstream oss; + oss << NOMAD::CACHE_SEARCH; + out << std::endl << NOMAD::open_block ( oss.str() ) << std::endl; + } + + std::list<const NOMAD::Eval_Point*> list_of_extern_pts; + const NOMAD::Eval_Point * extern_pt = cache.get_and_remove_extern_point(); + NOMAD::Eval_Point * pt = NULL; + int n = _p.get_dimension(); + + // add the extern points to the list of points to be evaluated: + while ( extern_pt ) + { + + list_of_extern_pts.push_front ( extern_pt ); + + pt = &NOMAD::Cache::get_modifiable_point ( *extern_pt ); + + if ( extern_pt->get_signature() ) + pt->set_signature ( extern_pt->get_signature() ); + else if ( extern_pt->size() == n ) + pt->set_signature ( _p.get_signature() ); + + if ( pt->get_signature() ) + ev_control.add_eval_point ( pt , + display_degree , + false , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() ); + else + { + + if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY ) + out << std::endl << "Warning (Cache_Search.cpp, " << __LINE__ + << "): could not use the point " << *pt + << "(no signature)" << std::endl; + } + + extern_pt = cache.get_and_remove_extern_point(); + } + + nb_search_pts = ev_control.get_nb_eval_points(); + + // display all the search points: + if ( display_degree == NOMAD::FULL_DISPLAY ) + ev_control.display_eval_lop ( NOMAD::CACHE_SEARCH ); + + // eval_list_of_points: + new_feas_inc = new_infeas_inc = NULL; + ev_control.eval_list_of_points ( NOMAD::CACHE_SEARCH , + mads.get_true_barrier() , + mads.get_sgte_barrier() , + mads.get_pareto_front() , + stop , + stop_reason , + new_feas_inc , + new_infeas_inc , + success ); + + // the method cache.get_and_remove_extern_point() removes the first extern + // point from the cache. If the search is opportunistic and if there are + // extern points that have not been treated, then they must be put back + // in the cache list of extern points: + { + std::list<const NOMAD::Eval_Point*>::const_iterator + it , end = list_of_extern_pts.end(); + for ( it = list_of_extern_pts.begin() ; it != end ; ++it ) + if ( !(*it)->get_current_run() ) + cache.insert_extern_point ( **it ); + } + + // update _last_search_nb_extern_pts: + _last_search_nb_extern_pts = cache.get_nb_extern_points(); + + // final display: + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + std::ostringstream oss; + oss << "end of cache search (" << success << ")"; + out << std::endl << NOMAD::close_block ( oss.str() ) << std::endl; } - - extern_pt = cache.get_and_remove_extern_point(); - } - - nb_search_pts = ev_control.get_nb_eval_points(); - - // display all the search points: - if ( display_degree == NOMAD::FULL_DISPLAY ) - ev_control.display_eval_lop ( NOMAD::CACHE_SEARCH ); - - // eval_list_of_points: - new_feas_inc = new_infeas_inc = NULL; - ev_control.eval_list_of_points ( NOMAD::CACHE_SEARCH , - mads.get_true_barrier() , - mads.get_sgte_barrier() , - mads.get_pareto_front() , - stop , - stop_reason , - new_feas_inc , - new_infeas_inc , - success ); - - // the method cache.get_and_remove_extern_point() removes the first extern - // point from the cache. If the search is opportunistic and if there are - // extern points that have not been treated, then they must be put back - // in the cache list of extern points: - { - std::list<const NOMAD::Eval_Point*>::const_iterator - it , end = list_of_extern_pts.end(); - for ( it = list_of_extern_pts.begin() ; it != end ; ++it ) - if ( !(*it)->get_current_run() ) - cache.insert_extern_point ( **it ); - } - - // update _last_search_nb_extern_pts: - _last_search_nb_extern_pts = cache.get_nb_extern_points(); - - // final display: - if ( display_degree == NOMAD::FULL_DISPLAY ) { - std::ostringstream oss; - oss << "end of cache search (" << success << ")"; - out << std::endl << NOMAD::close_block ( oss.str() ) << std::endl; - } } diff --git a/src/Cache_Search.hpp b/src/Cache_Search.hpp index 25e2e51a6e57dea8b65c553e407d89e313e425d6..94029651f5daf45c80614cdbec0dcfe2cabacd31 100644 --- a/src/Cache_Search.hpp +++ b/src/Cache_Search.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Cache_Search.hpp - \brief NOMAD::Search subclass for the cache search (headers) - \author Sebastien Le Digabel - \date 2010-04-08 - \see Cache_Search.cpp -*/ + \file Cache_Search.hpp + \brief NOMAD::Search subclass for the cache search (headers) + \author Sebastien Le Digabel + \date 2010-04-08 + \see Cache_Search.cpp + */ #ifndef __CACHE_SEARCH__ #define __CACHE_SEARCH__ @@ -47,50 +54,50 @@ #include "Search.hpp" namespace NOMAD { - - /// Cache search. - class Cache_Search : public NOMAD::Search , private NOMAD::Uncopyable { - - private: - - /// Number of extern points at the end of the last cache search. - int _last_search_nb_extern_pts; - - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - */ - Cache_Search ( NOMAD::Parameters & p ) - : NOMAD::Search ( p , NOMAD::CACHE_SEARCH ) , - _last_search_nb_extern_pts ( 0 ) {} - /// Destructor. - virtual ~Cache_Search ( void ) {} - - /// Reset. - virtual void reset ( void ) { _last_search_nb_extern_pts = 0; } - - /// The cache search. - /** - \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. - \param nb_search_pts Number of generated search points -- \b OUT. - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - \param success Type of success -- \b OUT. - \param count_search Count or not the search -- \b OUT. - \param new_feas_inc New feasible incumbent -- \b IN/OUT. - \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. - */ - virtual void search ( NOMAD::Mads & mads , - int & nb_search_pts , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - bool & count_search , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ); - }; + /// Cache search. + class Cache_Search : public NOMAD::Search , private NOMAD::Uncopyable { + + private: + + /// Number of extern points at the end of the last cache search. + int _last_search_nb_extern_pts; + + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + */ + Cache_Search ( NOMAD::Parameters & p ) + : NOMAD::Search ( p , NOMAD::CACHE_SEARCH ) , + _last_search_nb_extern_pts ( 0 ) {} + + /// Destructor. + virtual ~Cache_Search ( void ) {} + + /// Reset. + virtual void reset ( void ) { _last_search_nb_extern_pts = 0; } + + /// The cache search. + /** + \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. + \param nb_search_pts Number of generated search points -- \b OUT. + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + \param success Type of success -- \b OUT. + \param count_search Count or not the search -- \b OUT. + \param new_feas_inc New feasible incumbent -- \b IN/OUT. + \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. + */ + virtual void search ( NOMAD::Mads & mads , + int & nb_search_pts , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + bool & count_search , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ); + }; } #endif diff --git a/src/Clock.cpp b/src/Clock.cpp index 6f95c226f1776d73ec592f4d054d1363924b5089..5e69bf090727e827aee1d3ae2a9b07fb7e8007e2 100644 --- a/src/Clock.cpp +++ b/src/Clock.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Clock.cpp - \brief Clock class (implementation) - \author Sebastien Le Digabel - \date 2010-04-02 - \see Clock.hpp -*/ + \file Clock.cpp + \brief Clock class (implementation) + \author Sebastien Le Digabel + \date 2010-04-02 + \see Clock.hpp + */ #include "Clock.hpp" /*-----------------------------------*/ diff --git a/src/Clock.hpp b/src/Clock.hpp index adc303db112353a7da7df6eda32b60f9f95580bc..2b9466c908ec57cf1970b2aa6632d1567d3ac5cd 100644 --- a/src/Clock.hpp +++ b/src/Clock.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,88 +41,88 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Clock.hpp - \brief Clock class (headers) - \author Sebastien Le Digabel - \date 2010-04-02 - \see Clock.cpp -*/ + \file Clock.hpp + \brief Clock class (headers) + \author Sebastien Le Digabel + \date 2010-04-02 + \see Clock.cpp + */ #ifndef __CLOCK__ #define __CLOCK__ #include <ctime> namespace NOMAD { - - /// Clock class. - /** + + /// Clock class. + /** Time measurement.\n\n \b Example: \code Clock c; - + // some instructions here - + std::cout << "elapsed real time = " << c.get_real_time() << std::endl; std::cout << "elapsed CPU time = " << c.get_CPU_time() << std::endl; \endcode - */ - class Clock { - - private: - - time_t _real_t0; ///< Wall clock time measurement. - clock_t _CPU_t0; ///< CPU time measurement. - static const double _D_CLOCKS_PER_SEC; ///< System constant for CPU time measurement. - - public: - - /// Constructor. - Clock ( void ) : _CPU_t0 ( clock() ) { time (&_real_t0); } - - /// Copy constructor. - /** - \param c The copied object -- \b IN. - */ - Clock ( const Clock & c ) : _real_t0 ( c._real_t0 ) , _CPU_t0 ( c._CPU_t0 ) {} - - /// Affectation operator. - /** - \param c The right-hand side object -- \b IN. - \return \c *this as the result of the affectation. - */ - Clock & operator = ( const Clock & c ) - { - _real_t0 = c._real_t0; - _CPU_t0 = c._CPU_t0; - return *this; - } - - /// Destructor. - virtual ~Clock ( void ) {} - - /// Reset the clock. - void reset ( void ) - { - time ( &_real_t0 ); - _CPU_t0 = clock(); - } - - /// Get wall clock time. - /** - \return The wall clock time. - */ - int get_real_time ( void ) const; - - /// Get the CPU time. - /** - \return The CPU time. - */ - double get_CPU_time ( void ) const - { - return ( clock() - _CPU_t0 ) / _D_CLOCKS_PER_SEC; - } - }; + */ + class Clock { + + private: + + time_t _real_t0; ///< Wall clock time measurement. + clock_t _CPU_t0; ///< CPU time measurement. + static const double _D_CLOCKS_PER_SEC; ///< System constant for CPU time measurement. + + public: + + /// Constructor. + Clock ( void ) : _CPU_t0 ( clock() ) { time (&_real_t0); } + + /// Copy constructor. + /** + \param c The copied object -- \b IN. + */ + Clock ( const Clock & c ) : _real_t0 ( c._real_t0 ) , _CPU_t0 ( c._CPU_t0 ) {} + + /// Affectation operator. + /** + \param c The right-hand side object -- \b IN. + \return \c *this as the result of the affectation. + */ + Clock & operator = ( const Clock & c ) + { + _real_t0 = c._real_t0; + _CPU_t0 = c._CPU_t0; + return *this; + } + + /// Destructor. + virtual ~Clock ( void ) {} + + /// Reset the clock. + void reset ( void ) + { + time ( &_real_t0 ); + _CPU_t0 = clock(); + } + + /// Get wall clock time. + /** + \return The wall clock time. + */ + int get_real_time ( void ) const; + + /// Get the CPU time. + /** + \return The CPU time. + */ + double get_CPU_time ( void ) const + { + return ( clock() - _CPU_t0 ) / _D_CLOCKS_PER_SEC; + } + }; } #endif diff --git a/src/Direction.cpp b/src/Direction.cpp index 7eda2279e50aeed7ce09e1b4b603be292d0f18e9..1f6c9415617e098099fc96ff40dd323279daea25 100644 --- a/src/Direction.cpp +++ b/src/Direction.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Direction.cpp - \brief Polling direction (implementation) - \author Sebastien Le Digabel - \date 2010-04-05 - \see Direction.hpp -*/ + \file Direction.cpp + \brief Polling direction (implementation) + \author Sebastien Le Digabel + \date 2010-04-05 + \see Direction.hpp + */ #include "Direction.hpp" /*-----------------------------------*/ @@ -54,15 +61,15 @@ int NOMAD::Direction::_max_cardinality = 0; /* constructor 1 */ /*---------------------------------------------------------*/ NOMAD::Direction::Direction ( void ) - : NOMAD::Point ( ) , - _type ( NOMAD::UNDEFINED_DIRECTION ) , +: NOMAD::Point ( ) , +_type ( NOMAD::UNDEFINED_DIRECTION ) , _index ( -1 ), _dir_group_index (-1) { #ifdef MEMORY_DEBUG - ++NOMAD::Direction::_cardinality; - if ( NOMAD::Direction::_cardinality > NOMAD::Direction::_max_cardinality ) - ++NOMAD::Direction::_max_cardinality; + ++NOMAD::Direction::_cardinality; + if ( NOMAD::Direction::_cardinality > NOMAD::Direction::_max_cardinality ) + ++NOMAD::Direction::_max_cardinality; #endif } @@ -70,18 +77,18 @@ _dir_group_index (-1) /* constructor 2 */ /*---------------------------------------------------------*/ NOMAD::Direction::Direction ( int n , - const NOMAD::Double & v , - NOMAD::direction_type type , - int dir_group_index ) - : NOMAD::Point ( n , v ) , - _type ( type ) , - _index ( -1 ) , - _dir_group_index (dir_group_index) + const NOMAD::Double & v , + NOMAD::direction_type type , + int dir_group_index ) +: NOMAD::Point ( n , v ) , +_type ( type ) , +_index ( -1 ) , +_dir_group_index (dir_group_index) { #ifdef MEMORY_DEBUG - ++NOMAD::Direction::_cardinality; - if ( NOMAD::Direction::_cardinality > NOMAD::Direction::_max_cardinality ) - ++NOMAD::Direction::_max_cardinality; + ++NOMAD::Direction::_cardinality; + if ( NOMAD::Direction::_cardinality > NOMAD::Direction::_max_cardinality ) + ++NOMAD::Direction::_max_cardinality; #endif } @@ -89,34 +96,34 @@ NOMAD::Direction::Direction ( int n , /* constructor 2b */ /*---------------------------------------------------------*/ NOMAD::Direction::Direction ( int n , - const NOMAD::Double & v , - NOMAD::direction_type type ) + const NOMAD::Double & v , + NOMAD::direction_type type ) : NOMAD::Point ( n , v ) , _type ( type ) , _index ( -1 ), _dir_group_index (-1) { #ifdef MEMORY_DEBUG - ++NOMAD::Direction::_cardinality; - if ( NOMAD::Direction::_cardinality > NOMAD::Direction::_max_cardinality ) - ++NOMAD::Direction::_max_cardinality; + ++NOMAD::Direction::_cardinality; + if ( NOMAD::Direction::_cardinality > NOMAD::Direction::_max_cardinality ) + ++NOMAD::Direction::_max_cardinality; #endif } /*---------------------------------------------------------*/ /* constructor 3 */ /*---------------------------------------------------------*/ -NOMAD::Direction::Direction ( const NOMAD::Point & x , - NOMAD::direction_type type ) - : NOMAD::Point ( x ) , - _type ( type ) , +NOMAD::Direction::Direction ( const NOMAD::Point & x , + NOMAD::direction_type type ) +: NOMAD::Point ( x ) , +_type ( type ) , _index ( -1 ), _dir_group_index (-1) { #ifdef MEMORY_DEBUG - ++NOMAD::Direction::_cardinality; - if ( NOMAD::Direction::_cardinality > NOMAD::Direction::_max_cardinality ) - ++NOMAD::Direction::_max_cardinality; + ++NOMAD::Direction::_cardinality; + if ( NOMAD::Direction::_cardinality > NOMAD::Direction::_max_cardinality ) + ++NOMAD::Direction::_max_cardinality; #endif } @@ -124,15 +131,15 @@ _dir_group_index (-1) /* copy constructor */ /*---------------------------------------------------------*/ NOMAD::Direction::Direction ( const Direction & d ) - : NOMAD::Point ( d ) , - _type ( d._type ) , - _index ( d._index ), +: NOMAD::Point ( d ) , +_type ( d._type ) , +_index ( d._index ), _dir_group_index (d._dir_group_index) { #ifdef MEMORY_DEBUG - ++NOMAD::Direction::_cardinality; - if ( NOMAD::Direction::_cardinality > NOMAD::Direction::_max_cardinality ) - ++NOMAD::Direction::_max_cardinality; + ++NOMAD::Direction::_cardinality; + if ( NOMAD::Direction::_cardinality > NOMAD::Direction::_max_cardinality ) + ++NOMAD::Direction::_max_cardinality; #endif } @@ -142,7 +149,7 @@ _dir_group_index (d._dir_group_index) NOMAD::Direction::~Direction ( void ) { #ifdef MEMORY_DEBUG - --NOMAD::Direction::_cardinality; + --NOMAD::Direction::_cardinality; #endif } @@ -151,15 +158,15 @@ NOMAD::Direction::~Direction ( void ) /*---------------------------------------------------------*/ NOMAD::Direction & NOMAD::Direction::operator = ( const NOMAD::Direction & d ) { - if ( this == &d ) + if ( this == &d ) + return *this; + + NOMAD::Point::operator = ( d ); + + _type = d._type; + _index = d._index; + return *this; - - NOMAD::Point::operator = ( d ); - - _type = d._type; - _index = d._index; - - return *this; } /*---------------------------------------------------------*/ @@ -167,9 +174,9 @@ NOMAD::Direction & NOMAD::Direction::operator = ( const NOMAD::Direction & d ) /*---------------------------------------------------------*/ void NOMAD::Direction::clear ( void ) { - NOMAD::Point::clear(); - _type = NOMAD::UNDEFINED_DIRECTION; - _index = -1; + NOMAD::Point::clear(); + _type = NOMAD::UNDEFINED_DIRECTION; + _index = -1; } /*-----------------------------------------------------------*/ @@ -177,22 +184,24 @@ void NOMAD::Direction::clear ( void ) /*-----------------------------------------------------------*/ const NOMAD::Direction NOMAD::Direction::operator - ( void ) const { - return NOMAD::Direction ( this->NOMAD::Point::operator-() , _type ); + return NOMAD::Direction ( this->NOMAD::Point::operator-() , _type ); } + /*---------------------------------------------------------*/ /* display */ /*---------------------------------------------------------*/ void NOMAD::Direction::display ( const NOMAD::Display & out , - const std::string & sep , - int w , - int lim ) const + const std::string & sep , + int w , + int lim ) const { - if ( is_defined() ) { - out << "( "; - NOMAD::Point::display ( out , sep , w , lim ); - out << " ) " << _type; - } - else - out << "undefined"; + if ( is_defined() ) + { + out << "( "; + NOMAD::Point::display ( out , sep , w , lim ); + out << " ) " << _type; + } + else + out << "undefined"; } diff --git a/src/Direction.hpp b/src/Direction.hpp index b6c192e28282dfb9c4e7a411758235c2514d1b08..2a2813e6118b1502d178ca3b4d774dad1c52ca24 100644 --- a/src/Direction.hpp +++ b/src/Direction.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,198 +41,204 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Direction.hpp - \brief Polling direction (headers) - \author Sebastien Le Digabel - \date 2010-04-05 - \see Direction.cpp -*/ + \file Direction.hpp + \brief Polling direction (headers) + \author Sebastien Le Digabel + \date 2010-04-05 + \see Direction.cpp + */ #ifndef __DIRECTION__ #define __DIRECTION__ #include "Point.hpp" namespace NOMAD { - - - - /// Class describing a polling direction. - class Direction : public NOMAD::Point { - - private: - + + + + /// Class describing a polling direction. + class Direction : public NOMAD::Point { + + private: + #ifdef MEMORY_DEBUG - static int _cardinality; ///< Number of NOMAD::Direction objects in memory. - static int _max_cardinality; ///< Max number of NOMAD::Direction objects in memory. + static int _cardinality; ///< Number of NOMAD::Direction objects in memory. + static int _max_cardinality; ///< Max number of NOMAD::Direction objects in memory. #endif - - NOMAD::direction_type _type; ///< Type of direction. - mutable int _index; ///< Direction index (used only for display). - int _dir_group_index ; ///< Index a the group of direction - - public: - + + NOMAD::direction_type _type; ///< Type of direction. + mutable int _index; ///< Direction index (used only for display). + int _dir_group_index ; ///< Index a the group of direction + + public: + #ifdef MEMORY_DEBUG - /// Access to the number of NOMAD::Direction objects in memory. - /** - \return The number of NOMAD::Direction objects in memory. - */ - static int get_cardinality ( void ) { return Direction::_cardinality; } - - /// Access to the max number of NOMAD::Direction objects in memory. - /** - \return The max number of NOMAD::Direction objects in memory. - */ - static int get_max_cardinality ( void ) { return Direction::_max_cardinality; } + /// Access to the number of NOMAD::Direction objects in memory. + /** + \return The number of NOMAD::Direction objects in memory. + */ + static int get_cardinality ( void ) { return Direction::_cardinality; } + + /// Access to the max number of NOMAD::Direction objects in memory. + /** + \return The max number of NOMAD::Direction objects in memory. + */ + static int get_max_cardinality ( void ) { return Direction::_max_cardinality; } #endif - - /// Constructor #1. - Direction ( void ); - - /// Constructor #2. - /** - \param n Dimension -- \b IN. - \param v Initial value for all coordinates -- \b IN. - \param type Type of direction -- \b IN. - \param dir_group_index Index of the variable group the direction belongs --\b IN. - */ - Direction ( int n , const NOMAD::Double & v , NOMAD::direction_type type, int dir_group_index ); - - /// Constructor #2b. - /** - \param n Dimension -- \b IN. - \param v Initial value for all coordinates -- \b IN. - \param type Type of direction -- \b IN. - */ - Direction ( int n , const NOMAD::Double & v , NOMAD::direction_type type); - - - /// Constructor #3. - /** - \param x Coordinates -- \b IN. - \param type Type of direction -- \b IN. - */ - Direction ( const NOMAD::Point & x , NOMAD::direction_type type ); - - /// Copy constructor. - /** - \param d The copied object. - */ - Direction ( const Direction & d ); - - /// Destructor. - virtual ~Direction ( void ); - - /// Affectation operator. - /** - \param d The right-hand side object -- \b IN. - \return \c *this as the result of the affectation. - */ - Direction & operator = ( const Direction & d ); - - /// Check if the direction is defined. - /** - \return A boolean equal to \c true if the direction has no defined type. - */ - virtual bool is_defined ( void ) const - { return _type != NOMAD::UNDEFINED_DIRECTION; } - - /// Clear the direction. - virtual void clear ( void ); - - /// Size of the direction in memory. - /** - \return An integer for the size of the direction in bytes. - */ virtual int size_of ( void ) const - { - return NOMAD::Point::size_of() + sizeof(_type) + sizeof(_index); - } - - /// Negation. - /** - The current object \c *this is not modified. - \return A new direction equal to \c -*this. - */ - const Direction operator - ( void ) const; - - /*---------------*/ - /* GET methods */ - /*---------------*/ - - /// Access to the type of direction. - /** - \return The type of the direction. - */ - NOMAD::direction_type get_type ( void ) const { return _type; } + + /// Constructor #1. + Direction ( void ); + + /// Constructor #2. + /** + \param n Dimension -- \b IN. + \param v Initial value for all coordinates -- \b IN. + \param type Type of direction -- \b IN. + \param dir_group_index Index of the variable group the direction belongs --\b IN. + */ + Direction ( int n , + const NOMAD::Double & v , + NOMAD::direction_type type, + int dir_group_index ); + + /// Constructor #2b. + /** + \param n Dimension -- \b IN. + \param v Initial value for all coordinates -- \b IN. + \param type Type of direction -- \b IN. + */ + Direction ( int n , + const NOMAD::Double & v , + NOMAD::direction_type type); + + + /// Constructor #3. + /** + \param x Coordinates -- \b IN. + \param type Type of direction -- \b IN. + */ + Direction ( const NOMAD::Point & x , NOMAD::direction_type type ); + + /// Copy constructor. + /** + \param d The copied object. + */ + Direction ( const Direction & d ); + + /// Destructor. + virtual ~Direction ( void ); + + /// Affectation operator. + /** + \param d The right-hand side object -- \b IN. + \return \c *this as the result of the affectation. + */ + Direction & operator = ( const Direction & d ); + + + /// Check if the direction is defined. + /** + \return A boolean equal to \c true if the direction has no defined type. + */ + virtual bool is_defined ( void ) const + { return _type != NOMAD::UNDEFINED_DIRECTION; } + + /// Clear the direction. + virtual void clear ( void ); + + /// Size of the direction in memory. + /** + \return An integer for the size of the direction in bytes. + */ virtual int size_of ( void ) const + { + return NOMAD::Point::size_of() + sizeof(_type) + sizeof(_index); + } + + /// Negation. + /** + The current object \c *this is not modified. + \return A new direction equal to \c -*this. + */ + const Direction operator - ( void ) const; + + /*---------------*/ + /* GET methods */ + /*---------------*/ + + /// Access to the type of direction. + /** + \return The type of the direction. + */ + NOMAD::direction_type get_type ( void ) const { return _type; } + + /// Access to the direction index. + /** + \return The direction index. + */ + int get_index ( void ) const { return _index; } + + /// Access to the direction group index. + /** + \return The direction group index. + */ + int get_dir_group_index ( void ) const { return _dir_group_index; } + + + /// Check if the direction is a MADS direction. + /** + \return A boolean equal to \c true if the direction is a MADS direction. + */ + bool is_mads ( void ) const { return NOMAD::dir_is_mads ( _type ); } + + /// Check if the direction is a GPS direction. + /** + \return A boolean equal to \c true if the direction is a GPS direction. + */ + bool is_gps ( void ) const { return NOMAD::dir_is_gps ( _type ); } + + /*---------------*/ + /* SET methods */ + /*---------------*/ + + /// Set the direction index. + /** + \param i The direction index -- \b IN. + */ + void set_index ( int i ) const { _index = i; } + + /// Set the direction type. + /** + \param t The direction type -- \b IN. + */ + void set_type ( NOMAD::direction_type t ) { _type = t; } + + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + \param sep A string that is used as a separator between the coordinates + -- \b IN. + \param w An integer indicating a width for the display of + each coordinate -- \b IN. + \param lim Max number of coordinates to display -- \b IN. + */ + virtual void display ( const NOMAD::Display & out , + const std::string & sep , + int w , + int lim ) const; + }; - /// Access to the direction index. + /// Display a NOMAD::Direction object. /** - \return The direction index. - */ - int get_index ( void ) const { return _index; } - - /// Access to the direction group index. - /** - \return The direction group index. - */ - int get_dir_group_index ( void ) const { return _dir_group_index; } - - - /// Check if the direction is a MADS direction. - /** - \return A boolean equal to \c true if the direction is a MADS direction. - */ - bool is_mads ( void ) const { return NOMAD::dir_is_mads ( _type ); } - - /// Check if the direction is a GPS direction. - /** - \return A boolean equal to \c true if the direction is a GPS direction. - */ - bool is_gps ( void ) const { return NOMAD::dir_is_gps ( _type ); } - - /*---------------*/ - /* SET methods */ - /*---------------*/ - - /// Set the direction index. - /** - \param i The direction index -- \b IN. - */ - void set_index ( int i ) const { _index = i; } - - /// Set the direction type. - /** - \param t The direction type -- \b IN. - */ - void set_type ( NOMAD::direction_type t ) { _type = t; } - - /// Display. - /** - \param out The NOMAD::Display object -- \b IN. - \param sep A string that is used as a separator between the coordinates - -- \b IN. - \param w An integer indicating a width for the display of - each coordinate -- \b IN. - \param lim Max number of coordinates to display -- \b IN. - */ - virtual void display ( const NOMAD::Display & out , - const std::string & sep , - int w , - int lim ) const; - }; - - /// Display a NOMAD::Direction object. - /** \param out The NOMAD::Display object -- \b IN. \param d The NOMAD::Direction object to be displayed -- \b IN. \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Direction & d ) - { - d.display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); - return out; - } + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::Direction & d ) + { + d.display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); + return out; + } } #endif diff --git a/src/Directions.cpp b/src/Directions.cpp index e52f61fcdd071faba862c4391efcf51886a2f923..8c34295411eb29b231e40b126e640ced0be68bd9 100644 --- a/src/Directions.cpp +++ b/src/Directions.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -46,14 +53,14 @@ #include "SMesh.hpp" + /*---------------------------------------------------------*/ /* constructor */ /*---------------------------------------------------------*/ -NOMAD::Directions::Directions -( int nc , - const std::set<NOMAD::direction_type> & direction_types , - const std::set<NOMAD::direction_type> & sec_poll_dir_types , - const NOMAD::Display & out ) +NOMAD::Directions::Directions ( int nc , + const std::set<NOMAD::direction_type> & direction_types , + const std::set<NOMAD::direction_type> & sec_poll_dir_types , + const NOMAD::Display & out ) : _nc ( nc ) , _direction_types ( direction_types ) , _sec_poll_dir_types ( sec_poll_dir_types ) , @@ -88,7 +95,6 @@ NOMAD::Directions::~Directions ( void ) for ( int i = 0 ; i <= n ; ++i ) delete _bl[i]; } - } /*---------------------------------------------------------*/ @@ -105,6 +111,7 @@ void NOMAD::Directions::lt_mads_init ( void ) _lt_initialized = true; } + /*---------------------------------------------------------*/ /* set_binary */ /*---------------------------------------------------------*/ @@ -115,7 +122,8 @@ void NOMAD::Directions::set_binary ( void ) _is_orthomads = false; _direction_types.clear(); _direction_types.insert ( NOMAD::GPS_BINARY ); - if ( !_sec_poll_dir_types.empty() ) { + if ( !_sec_poll_dir_types.empty() ) + { _sec_poll_dir_types.clear(); _sec_poll_dir_types.insert ( NOMAD::GPS_BINARY ); } @@ -137,12 +145,12 @@ void NOMAD::Directions::set_categorical ( void ) /* compute binary directions when all groups of variables are binary */ /* (private) */ /*----------------------------------------------------------------------*/ -void NOMAD::Directions::compute_binary_directions -( std::list<NOMAD::Direction> & d ) const +void NOMAD::Directions::compute_binary_directions ( std::list<NOMAD::Direction> & d ) const { // _GPS_BINARY_ n directions: NOMAD::Direction * pd; - for ( int i = 0 ; i < _nc ; ++i ) { + for ( int i = 0 ; i < _nc ; ++i ) + { d.push_back ( NOMAD::Direction ( _nc , 0.0 , NOMAD::GPS_BINARY ) ); pd = &(*(--d.end())); (*pd)[i] = 1.0; @@ -153,9 +161,9 @@ void NOMAD::Directions::compute_binary_directions /*----------------------------------------------------------------------------*/ /* get the directions on a unit n-sphere for a given mesh */ /*----------------------------------------------------------------------------*/ -void NOMAD::Directions::compute ( std::list<NOMAD::Direction> & dirs , - NOMAD::poll_type poll , - const NOMAD::OrthogonalMesh & mesh ) +void NOMAD::Directions::compute ( std::list<NOMAD::Direction> & dirs , + NOMAD::poll_type poll , + const NOMAD::OrthogonalMesh & mesh ) { dirs.clear(); @@ -208,6 +216,7 @@ void NOMAD::Directions::compute ( std::list<NOMAD::Direction> & dirs , NOMAD::Direction dir ( _nc , 0.0 , *it ); NOMAD::Double alpha_t_l; + success_dir=compute_dir_on_unit_sphere ( dir ); if ( success_dir ) @@ -243,7 +252,7 @@ void NOMAD::Directions::compute ( std::list<NOMAD::Direction> & dirs , #endif // Ortho-MADS 2n and n+1: // ---------------------- - if ( *it == NOMAD::ORTHO_2N || *it == NOMAD::ORTHO_NP1_QUAD || *it == NOMAD::ORTHO_NP1_NEG ) + if ( *it == NOMAD::ORTHO_2N || *it == NOMAD::ORTHO_NP1_QUAD || *it == NOMAD::ORTHO_NP1_NEG || *it==NOMAD::ORTHO_NP1_UNI ) { // creation of the 2n directions: @@ -262,6 +271,38 @@ void NOMAD::Directions::compute ( std::list<NOMAD::Direction> & dirs , // Householder transformations on the 2n directions on a unit n-sphere: householder ( dir , true , H ); + if ( *it == NOMAD::ORTHO_NP1_UNI ) + { + std::list<NOMAD::Direction> refac_dirs; + + // dir 0 + NOMAD::Point dir0=-(*H[0]); + for ( i = 1 ; i < _nc ; ++i ) + { + dir0=dir0-(*H[i]); + } + dir0*=1.0/sqrt(double(_nc)); + refac_dirs.push_back ( NOMAD::Direction ( dir0, NOMAD::ORTHO_NP1_UNI ) ); + + NOMAD::Double beta=(sqrt(_nc+1.0)-1.0)/sqrt(double(_nc)); + dir0*=beta; + for ( i = 0 ; i < _nc ; i++ ) + { + NOMAD::Point diri(*H[i]); + diri*=sqrt(double(_nc+1)); + diri=diri+dir0; + diri*=1.0/sqrt(double(_nc)); + refac_dirs.push_back ( NOMAD::Direction ( diri, NOMAD::ORTHO_NP1_UNI ) ); + + } + + dirs.clear(); + dirs.assign( refac_dirs.begin(), refac_dirs.end() ); + + + } + + delete [] H; @@ -302,7 +343,9 @@ void NOMAD::Directions::compute ( std::list<NOMAD::Direction> & dirs , // LT-MADS 2n or LT-MADS n+1: // -------------------------- - else { + else + { + // row permutation vector: int * row_permutation_vector = new int [_nc]; @@ -623,10 +666,10 @@ void NOMAD::Directions::compute ( std::list<NOMAD::Direction> & dirs , /*-----------------------------------------------------------------------------*/ -/* compute a random direction on a unit N-Sphere */ +/* compute a random direction on a unit N-Sphere */ /* see http://en.wikipedia.org/wiki/N-sphere */ /*-----------------------------------------------------------------------------*/ -bool NOMAD::Directions::compute_dir_on_unit_sphere ( NOMAD::Direction & random_dir ) const +bool NOMAD::Directions::compute_dir_on_unit_sphere ( NOMAD::Direction & random_dir ) const { int i; @@ -635,6 +678,8 @@ bool NOMAD::Directions::compute_dir_on_unit_sphere ( NOMAD::Direction & random_d for ( i = 0 ; i < _nc ; ++i ) random_dir[i]=NOMAD::RNG::normal_rand(0,1); + // } + norm=random_dir.norm(); if ( norm==0 ) @@ -660,7 +705,8 @@ NOMAD::Double NOMAD::Directions::eval_ortho_norm ( const NOMAD::Double & x { NOMAD::Double fx = 0.0; - for ( int i = 0 ; i < _nc ; ++i ) { + for ( int i = 0 ; i < _nc ; ++i ) + { new_b[i] = ( x * b[i] / norm ).round(); fx += new_b[i]*new_b[i]; } @@ -680,7 +726,8 @@ NOMAD::Double NOMAD::Directions::get_phi ( int t , int p ) int ll = t; NOMAD::Double d = 0.0; - for ( int i = 0 ; i < size ; ++i ) { + for ( int i = 0 ; i < size ; ++i ) + { div = NOMAD::Double ( pow ( p , size-i-1.0 ) ).round(); d += ( ll / div ) * pow ( static_cast<double>(p) , i-size ); ll = ll % div; @@ -702,11 +749,13 @@ void NOMAD::Directions::householder ( const NOMAD::Direction & dir , NOMAD::Double norm2 = dir.squared_norm() , v , h2i; - for ( i = 0 ; i < _nc ; ++i ) { + for ( i = 0 ; i < _nc ; ++i ) + { h2i = 2 * dir[i]; - for ( j = 0 ; j < _nc ; ++j ) { + for ( j = 0 ; j < _nc ; ++j ) + { // H[i]: (*H[i])[j] = v = (i==j) ? norm2 - h2i * dir[j] : - h2i * dir[j]; @@ -727,6 +776,7 @@ const NOMAD::Direction * NOMAD::Directions::get_bl ( const NOMAD::OrthogonalMesh { NOMAD::Point mesh_indices = mesh.get_mesh_indices(); + int mesh_index =static_cast<int>(mesh_indices[0].value()); NOMAD::Direction * bl = _bl [ mesh_index + NOMAD::L_LIMITS ]; hat_i = _hat_i [ mesh_index + NOMAD::L_LIMITS ]; @@ -858,7 +908,8 @@ bool NOMAD::Directions::operator < ( const NOMAD::Directions & d ) const it2 = d._direction_types.begin() , end = _direction_types.end(); - while ( it1 != end ) { + while ( it1 != end ) + { if ( *it1 < *it2 ) return true; if ( *it2 < *it1 ) @@ -871,7 +922,8 @@ bool NOMAD::Directions::operator < ( const NOMAD::Directions & d ) const it2 = d._sec_poll_dir_types.begin(); end = _sec_poll_dir_types.end(); - while ( it1 != end ) { + while ( it1 != end ) + { if ( *it1 < *it2 ) return true; if ( *it2 < *it1 ) diff --git a/src/Directions.hpp b/src/Directions.hpp index a9d87c85346afbdb609780e33a6e937b2d72e071..2651974063d9747bbf7d46d9f8b89b1766598777 100644 --- a/src/Directions.hpp +++ b/src/Directions.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -84,6 +91,7 @@ namespace NOMAD { */ Directions & operator = ( const Directions & d ); + /// LT-MADS initializations. void lt_mads_init ( void ); @@ -198,20 +206,20 @@ namespace NOMAD { /// Compute the directions for a given mesh. /** - \param mesh The given mesh -- \b IN. - \param dirs Set of directions -- \b OUT. - \param poll Type of poll (primary or secondary) -- \b IN. + \param mesh The given mesh -- \b IN. + \param dirs Set of directions -- \b OUT. + \param poll Type of poll (primary or secondary) -- \b IN. */ void compute ( std::list<NOMAD::Direction> & dirs , NOMAD::poll_type poll , - const NOMAD::OrthogonalMesh & mesh ); + const NOMAD::OrthogonalMesh & mesh ); /// Compute a random direction on a N-Sphere. /** - \param random_dir -- \b OUT. + \param random_dir -- \b OUT. \return A boolean equal to \c true if the computation went well. */ - bool compute_dir_on_unit_sphere ( NOMAD::Direction & random_dir ) const; + bool compute_dir_on_unit_sphere ( NOMAD::Direction & random_dir ) const; /// Check if Ortho-MADS directions are used. @@ -287,7 +295,7 @@ namespace NOMAD { /// Display a NOMAD::Directions object. /** - \param out The NOMAD::Display object -- \b IN. + \param out The NOMAD::Display object -- \b IN. \param d The NOMAD::Directions object to be displayed -- \b IN. \return The NOMAD::Display object. */ diff --git a/src/Display.cpp b/src/Display.cpp index e8b340f913c24afad048d433d91b82dce4a33687..4cb46314971bf064f6fa16c7b725d16634d0bb51 100644 --- a/src/Display.cpp +++ b/src/Display.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -406,7 +413,8 @@ std::ostream & NOMAD::operator << ( std::ostream & ou /*-----------------------------------------------------------------*/ std::ostream & NOMAD::operator << ( std::ostream & out , NOMAD::bb_input_type bi ) { - switch ( bi ) { + switch ( bi ) + { case NOMAD::CONTINUOUS: out << "cont(R)"; break; @@ -484,34 +492,12 @@ std::ostream & NOMAD::operator << ( std::ostream & out , NOMAD::model_type mt ) case NOMAD::QUADRATIC_MODEL: out << "quadratic"; break; - case NOMAD::TGP_MODEL: - out << "TGP"; - break; case NOMAD::NO_MODEL: out << "no models"; } return out; } -/*-----------------------------------------------------------------*/ -/* to display a TGP mode */ -/*-----------------------------------------------------------------*/ -std::ostream & NOMAD::operator << ( std::ostream & out , NOMAD::TGP_mode_type m ) -{ - switch ( m ) - { - case NOMAD::TGP_FAST: - out << "fast"; - break; - case NOMAD::TGP_PRECISE: - out << "precise"; - break; - case NOMAD::TGP_USER: - out << "user"; - break; - } - return out; -} /*-----------------------------------------------------------------*/ /* to display an evaluation type */ @@ -581,6 +567,9 @@ std::ostream & NOMAD::operator << ( std::ostream & out , NOMAD::stop_type st ) case NOMAD::XL_LIMITS_REACHED: out << "mesh index limits"; break; + case NOMAD::GL_LIMITS_REACHED: + out << "mesh index limits"; + break; case NOMAD::MAX_TIME_REACHED: out << "max time"; break; @@ -786,6 +775,9 @@ std::ostream & NOMAD::operator << ( std::ostream & out , case NOMAD::ORTHO_NP1_NEG: out << "Ortho-MADS n+1 NEG"; break; + case NOMAD::ORTHO_NP1_UNI: + out << "Ortho-MADS n+1 UNI"; + break; case NOMAD::DYN_ADDED: out << "Dynamic n+1th direction"; break; diff --git a/src/Display.hpp b/src/Display.hpp index e88323bcc02882f7d3885ee21d33225bbb0c550c..59ce2c2aeb86bac97e982ba7abc20b768ed1f72c 100644 --- a/src/Display.hpp +++ b/src/Display.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,48 +41,48 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Display.hpp - \brief Custom class for display (headers) - \author Sebastien Le Digabel - \date 2010-03-30 - \see Display.cpp -*/ + \file Display.hpp + \brief Custom class for display (headers) + \author Sebastien Le Digabel + \date 2010-03-30 + \see Display.cpp + */ #ifndef __DISPLAY__ #define __DISPLAY__ #include "utils.hpp" namespace NOMAD { - - /// Custom display class. - /** + + /// Custom display class. + /** - This class is used instead of \c std::ostream ojects. - Use \c std::endl as new line character; \c '\\n' will ignore indentation. - Do not use \c << \c flush; : it would create a new indentation. - Use method \c Display::flush() instead. + Use method \c Display::flush() instead. \b Two \b examples \b for \b creating \b indented \b blocks: - + \code using namespace NOMAD; Display out ( std::cout ); \endcode \b Example \b 1: - + \code out << "line #1" << std::endl - << open_block() - << "line #2" << std::endl << "line #3" << std::endl - << open_block ( "begin of block 2" ) - << "line #4" << std::endl << "line #5" << std::endl - << close_block ( "end of block 2" ) - << close_block() - << std::endl; + << open_block() + << "line #2" << std::endl << "line #3" << std::endl + << open_block ( "begin of block 2" ) + << "line #4" << std::endl << "line #5" << std::endl + << close_block ( "end of block 2" ) + << close_block() + << std::endl; \endcode - + \b Example \b 2: - + \code out << "line #1" << std::endl; out.open_block(); @@ -86,456 +93,456 @@ namespace NOMAD { out.close_block(); out << std::endl; \endcode - + \b This \b displays \b twice: - + \verbatim line #1 { - line #2 - line #3 - begin of block 2 { - line #4 - line #5 - } end of block 2 + line #2 + line #3 + begin of block 2 { + line #4 + line #5 + } end of block 2 } \endverbatim - */ - class Display { - - private: - - std::ostream & _out; ///< Display. - - mutable std::string _indent_str; ///< Indentation string (tabulations). - mutable bool _newline; ///< Indent or not. + */ + class Display { + + private: + + std::ostream & _out; ///< Display. + + mutable std::string _indent_str; ///< Indentation string (tabulations). + mutable bool _newline; ///< Indent or not. + + std::string _open_brace; ///< Braces of the indentation blocks. + std::string _closed_brace; ///< Defaults: "{" and "}". + + NOMAD::dd_type _gen_dd; ///< General display degree. + NOMAD::dd_type _search_dd; ///< Search display degree. + NOMAD::dd_type _poll_dd; ///< Poll display degree. + NOMAD::dd_type _iter_dd; ///< Iterative display degree. + + /// Private affectation operator. + /** + \param out The right-hand side object -- \b IN. + */ + const Display & operator = ( const Display & out ); + + public: + + /// Constructor. + /** + \param out A \c std::ostream that will be used for all displays + (can be a \c std::ofstream) + -- \b IN -- \b optional (default = \c std::cout). + */ + Display ( std::ostream & out = std::cout ) + : _out ( out ) , // can be a std::ofstream + _newline ( true ) , + _open_brace ( "{" ) , + _closed_brace ( "}" ) , + _gen_dd ( NOMAD::NORMAL_DISPLAY ) , + _search_dd ( NOMAD::NORMAL_DISPLAY ) , + _poll_dd ( NOMAD::NORMAL_DISPLAY ) , + _iter_dd ( NOMAD::NORMAL_DISPLAY ) {} + + /// Copy constructor. + /** + \param out The copied object -- \b IN. + */ + Display ( const Display & out ) + : _out ( out._out ) , + _indent_str ( out._indent_str ) , + _newline ( out._newline ) , + _open_brace ( out._open_brace ) , + _closed_brace ( out._closed_brace ) , + _gen_dd ( out._gen_dd ) , + _search_dd ( out._search_dd ) , + _poll_dd ( out._poll_dd ) , + _iter_dd ( out._iter_dd ) {} + + /// Destructor. + virtual ~Display ( void ) {} + + /// Flush. + /** + Must be used instead of \c out \c << \c std::flush. + */ + void flush ( void ) const { _out << std::flush; } + + /*---------------*/ + /* GET methods */ + /*---------------*/ + + /// Access to the indentation string. + /** + \return The indentation string. + */ + const std::string get_indent_str ( void ) const { return _indent_str; } + + /// Access to the general display degree. + /** + \return _gen_dd. + */ + NOMAD::dd_type get_gen_dd ( void ) const { return _gen_dd; } + + /// Access to the search display degree. + /** + \return _search_dd. + */ + NOMAD::dd_type get_search_dd ( void ) const { return _search_dd; } + + /// Access to the poll display degree. + /** + \return _poll_dd. + */ + NOMAD::dd_type get_poll_dd ( void ) const { return _poll_dd; } + + /// Access to the iterative display degree. + /** + \return _iter_dd. + */ + NOMAD::dd_type get_iter_dd ( void ) const { return _iter_dd; } + + /// Get the display degree for a specific search type. + /** + \param search The search type. + \return The display degree. + */ + NOMAD::dd_type get_display_degree ( NOMAD::search_type search ) const; + + /// Get the display degrees as a string of size 4. + /** + \param dd The string containing the display degrees -- \b OUT. + */ + void get_display_degree ( std::string & dd ) const; + + /*---------------*/ + /* SET methods */ + /*---------------*/ + + /// Set the indentation string. + /** + \param is The indentation string -- \b IN. + */ + void set_indent_str ( const std::string & is ) { _indent_str = is; } + + /// Set the _open_brace string. + /** + \param ob The string -- \b IN. + */ + void set_open_brace ( const std::string & ob ) { _open_brace = ob; } + + /// Set the _closed_brace string. + /** + \param cb The string -- \b IN. + */ + void set_closed_brace ( const std::string & cb ) { _closed_brace = cb; } + + /// Set the display degrees. + /** + \param gen_dd General display degree -- \b IN. + \param search_dd Search display degree -- \b IN. + \param poll_dd Poll display degree -- \b IN. + \param iter_dd Iterative display degree -- \b IN. + */ + void set_degrees ( NOMAD::dd_type gen_dd , + NOMAD::dd_type search_dd , + NOMAD::dd_type poll_dd , + NOMAD::dd_type iter_dd ); + + /// Set all the display degrees to one given display degree. + /** + \param dd The 4 display degrees -- \b IN. + */ + void set_degrees ( NOMAD::dd_type dd ) { set_degrees ( dd , dd , dd , dd ); } + + /// Open an indentation block. + /** + \param msg Message displayed as the block title + -- \b IN -- \b optional (default = empty string). + */ + void open_block ( const std::string & msg = "" ) const; + + /// Close an indentation block. + /** + \param msg Message displayed at the end of the block + -- \b IN -- \b optional (default = empty string). + */ + void close_block ( const std::string & msg = "" ) const; + + /// Operator <<. + template <class T> + const Display & operator << ( const T & ) const; + + /// Defines the \c cout type. + typedef std::basic_ostream<char, std::char_traits<char> > CoutType; + + /// Allows the use of \c out \c << \c endl (\c std::endl is used). + /** + \warning This considers also \c std::flush. + */ + typedef CoutType& (*StandardEndLine)(CoutType&); + + /// Operator << for \c std::endl. + const Display & operator << ( StandardEndLine ) const; + + /// Set the display precision. + /** + \param p The display precision -- \b IN. + */ + void precision ( int p ) const { _out.precision(p); } + + /// Get the current display precision. + /** + \return An integer for the current precision. + */ + int precision ( void ) const { return static_cast<int>(_out.precision()); } + + /// Set the format flags (1/2). + /** + \param f The flags -- \b IN. + */ + void flags ( std::ios_base::fmtflags f ) const { _out.flags(f); } + + /// Set the format flags (2/2). + /** + \param f The flags -- \b IN. + */ + void setf ( std::ios_base::fmtflags f ) const { _out.setf(f); } + + /// Unset the format flags. + /** + \param f The flags -- \b IN. + */ + void unsetf ( std::ios_base::fmtflags f ) const { _out.unsetf(f); } + + + /// Get the current format flags. + /** + \return The format flags. + */ + std::ios_base::fmtflags flags ( void ) const { return _out.flags(); } + + /*--------------------*/ + /* type conversions */ + /*--------------------*/ + + /// Convert a NOMAD::dd_type to a character. + /** + \param dd The NOMAD::dd_type -- \b IN. + \return The character. + */ + static char dd_to_char ( NOMAD::dd_type dd ); + + /// Convert a NOMAD::dd_type to an integer. + /** + \param dd The NOMAD::dd_type -- \b IN. + \return The integer. + */ + static int dd_to_int ( NOMAD::dd_type dd ); + + /// Convert an integer to a NOMAD::dd_type. + /** + \param dd The integer -- \b IN. + \return The NOMAD::dd_type. + */ + static NOMAD::dd_type int_to_dd ( int dd ); + + /// Display a duration with a smart format. + /** + \param t Duration as an integer in seconds -- \b IN. + */ + void display_time ( int t ) const; + + /// Display a boolean with format \c yes/no. + /** + \param b The boolean -- \b IN. + */ + void display_yes_or_no ( bool b ) const { (*this) << ( (b) ? "yes" : "no" ); } + + /// Display a memory size. + /** + \param size The memory size. + */ + void display_size_of ( float size ) const; + + /// Display an integer with a specific width. + /** + \param i The integer to display -- \b IN. + \param max_i Maximal value of \c i used to determine the display width + -- \b IN -- \b optional (default = \c -1). + */ + void display_int_w ( int i , int max_i = -1 ) const; + + /// Get the keyword associated with a NOMAD::display_stats_type. + /** + \param dst The NOMAD::display_stats_type -- \b IN. + \return A string containing the keyword. + */ + static std::string get_display_stats_keyword ( NOMAD::display_stats_type dst ); + + /// Extract display format from a string. + /** + \param s The string -- \b IN/OUT. + \param format The format -- \b OUT. + */ + static void extract_display_format ( std::string & s , std::string & format ); + + /// Get the NOMAD::display_stats_type from a string. + /** + \param s The string -- \b IN. + \return The NOMAD::display_stats_type. + */ + static NOMAD::display_stats_type get_display_stats_type ( const std::string & s ); + + }; - std::string _open_brace; ///< Braces of the indentation blocks. - std::string _closed_brace; ///< Defaults: "{" and "}". - - NOMAD::dd_type _gen_dd; ///< General display degree. - NOMAD::dd_type _search_dd; ///< Search display degree. - NOMAD::dd_type _poll_dd; ///< Poll display degree. - NOMAD::dd_type _iter_dd; ///< Iterative display degree. - - /// Private affectation operator. - /** - \param out The right-hand side object -- \b IN. - */ - const Display & operator = ( const Display & out ); - - public: + /*-------------------------------------------------------------------------*/ - /// Constructor. + /// Open an indented block. /** - \param out A \c std::ostream that will be used for all displays - (can be a \c std::ofstream) - -- \b IN -- \b optional (default = \c std::cout). + Allows the use of \c out \c << \c open_block(msg). */ - Display ( std::ostream & out = std::cout ) - : _out ( out ) , // can be a std::ofstream - _newline ( true ) , - _open_brace ( "{" ) , - _closed_brace ( "}" ) , - _gen_dd ( NOMAD::NORMAL_DISPLAY ) , - _search_dd ( NOMAD::NORMAL_DISPLAY ) , - _poll_dd ( NOMAD::NORMAL_DISPLAY ) , - _iter_dd ( NOMAD::NORMAL_DISPLAY ) {} - - /// Copy constructor. - /** - \param out The copied object -- \b IN. - */ - Display ( const Display & out ) - : _out ( out._out ) , - _indent_str ( out._indent_str ) , - _newline ( out._newline ) , - _open_brace ( out._open_brace ) , - _closed_brace ( out._closed_brace ) , - _gen_dd ( out._gen_dd ) , - _search_dd ( out._search_dd ) , - _poll_dd ( out._poll_dd ) , - _iter_dd ( out._iter_dd ) {} - - /// Destructor. - virtual ~Display ( void ) {} - - /// Flush. - /** - Must be used instead of \c out \c << \c std::flush. - */ - void flush ( void ) const { _out << std::flush; } - - /*---------------*/ - /* GET methods */ - /*---------------*/ - - /// Access to the indentation string. - /** - \return The indentation string. - */ - const std::string get_indent_str ( void ) const { return _indent_str; } - - /// Access to the general display degree. - /** - \return _gen_dd. - */ - NOMAD::dd_type get_gen_dd ( void ) const { return _gen_dd; } - - /// Access to the search display degree. - /** - \return _search_dd. - */ - NOMAD::dd_type get_search_dd ( void ) const { return _search_dd; } - - /// Access to the poll display degree. - /** - \return _poll_dd. - */ - NOMAD::dd_type get_poll_dd ( void ) const { return _poll_dd; } - - /// Access to the iterative display degree. - /** - \return _iter_dd. - */ - NOMAD::dd_type get_iter_dd ( void ) const { return _iter_dd; } - - /// Get the display degree for a specific search type. - /** - \param search The search type. - \return The display degree. - */ - NOMAD::dd_type get_display_degree ( NOMAD::search_type search ) const; - - /// Get the display degrees as a string of size 4. - /** - \param dd The string containing the display degrees -- \b OUT. - */ - void get_display_degree ( std::string & dd ) const; - - /*---------------*/ - /* SET methods */ - /*---------------*/ - - /// Set the indentation string. - /** - \param is The indentation string -- \b IN. - */ - void set_indent_str ( const std::string & is ) { _indent_str = is; } - - /// Set the _open_brace string. - /** - \param ob The string -- \b IN. - */ - void set_open_brace ( const std::string & ob ) { _open_brace = ob; } - - /// Set the _closed_brace string. - /** - \param cb The string -- \b IN. - */ - void set_closed_brace ( const std::string & cb ) { _closed_brace = cb; } - - /// Set the display degrees. - /** - \param gen_dd General display degree -- \b IN. - \param search_dd Search display degree -- \b IN. - \param poll_dd Poll display degree -- \b IN. - \param iter_dd Iterative display degree -- \b IN. - */ - void set_degrees ( NOMAD::dd_type gen_dd , - NOMAD::dd_type search_dd , - NOMAD::dd_type poll_dd , - NOMAD::dd_type iter_dd ); - - /// Set all the display degrees to one given display degree. - /** - \param dd The 4 display degrees -- \b IN. - */ - void set_degrees ( NOMAD::dd_type dd ) { set_degrees ( dd , dd , dd , dd ); } - - /// Open an indentation block. - /** - \param msg Message displayed as the block title - -- \b IN -- \b optional (default = empty string). - */ - void open_block ( const std::string & msg = "" ) const; + class open_block { + private: + std::string _msg; ///< Message displayed as a block title. + public: + + /// Constructor. + /** + Open an indented block. + \param msg The block title + -- \b IN -- \b optional (default = empty string). + */ + open_block ( const std::string & msg = "" ) : _msg ( msg ) {} + + /// Operator (). + const Display & operator() ( const Display & out ) const + { + out.open_block ( _msg ); + return out; + } + }; - /// Close an indentation block. + /*-------------------------------------------------------------------------*/ + + /// Close an indented block. /** - \param msg Message displayed at the end of the block - -- \b IN -- \b optional (default = empty string). - */ - void close_block ( const std::string & msg = "" ) const; - + Allows the use of \c out \c << \c close_block(msg). + */ + class close_block { + private: + std::string _msg; ///< Message displayed at the end of a block. + public: + + /// Constructor. + /** + Close an indented block. + \param msg Message displayed at the end of a block + -- \b IN -- \b optional (default = empty string). + */ + close_block ( const std::string & msg = "" ) : _msg ( msg ) {} + + /// Operator (). + const Display & operator() ( const Display & out ) const + { + out.close_block ( _msg ); + return out; + } + }; + + /*-------------------------------------------------------------*/ + /* display functions for enum types defined in 'defines.hpp' */ + /*-------------------------------------------------------------*/ + + /// Operator << for NOMAD::stop_type. + std::ostream & operator << ( std::ostream & , NOMAD::stop_type ); + + /// Operator << for NOMAD::dd_type. + std::ostream & operator << ( std::ostream & , NOMAD::dd_type ); + + /// Operator << for NOMAD::success_type. + std::ostream & operator << ( std::ostream & , NOMAD::success_type ); + + /// Operator << for NOMAD::bb_input_type. + std::ostream & operator << ( std::ostream & , NOMAD::bb_input_type ); + + /// Operator << for NOMAD::bb_output_type. + std::ostream & operator << ( std::ostream & , NOMAD::bb_output_type ); + + /// Operator << for NOMAD::interpolation_type. + std::ostream & operator << ( std::ostream & , NOMAD::interpolation_type ); + + /// Operator << for NOMAD::hnorm_type. + std::ostream & operator << ( std::ostream & , NOMAD::hnorm_type ); + + /// Operator << for NOMAD::search_type. + std::ostream & operator << ( std::ostream & , NOMAD::search_type ); + + /// Operator << for NOMAD::model_type. + std::ostream & operator << ( std::ostream & , NOMAD::model_type ); + + /// Operator << for NOMAD::direction_type. + std::ostream & operator << ( std::ostream & , NOMAD::direction_type ); + + /// Operator << for NOMAD::check_failed_type. + std::ostream & operator << ( std::ostream & , NOMAD::check_failed_type ); + + /// Operator << for NOMAD::display_stats_type. + std::ostream & operator << ( std::ostream & , NOMAD::display_stats_type ); + + /// Operator << for NOMAD::eval_type. + std::ostream & operator << ( std::ostream & , NOMAD::eval_type ); + + /// Operator << for NOMAD::eval_status_type. + std::ostream & operator << ( std::ostream & , NOMAD::eval_status_type ); + + /// Operator << for NOMAD::multi_formulation_type. + std::ostream & operator << ( std::ostream & , NOMAD::multi_formulation_type ); + + /// Operator << for a vector of NOMAD::bb_intput_type. + std::ostream & operator << ( std::ostream & , + const std::vector<NOMAD::bb_input_type> & ); + /// Operator <<. template <class T> - const Display & operator << ( const T & ) const; - - /// Defines the \c cout type. - typedef std::basic_ostream<char, std::char_traits<char> > CoutType; - - /// Allows the use of \c out \c << \c endl (\c std::endl is used). - /** - \warning This considers also \c std::flush. - */ - typedef CoutType& (*StandardEndLine)(CoutType&); - - /// Operator << for \c std::endl. - const Display & operator << ( StandardEndLine ) const; - - /// Set the display precision. - /** - \param p The display precision -- \b IN. - */ - void precision ( int p ) const { _out.precision(p); } - - /// Get the current display precision. - /** - \return An integer for the current precision. - */ - int precision ( void ) const { return static_cast<int>(_out.precision()); } - - /// Set the format flags (1/2). - /** - \param f The flags -- \b IN. - */ - void flags ( std::ios_base::fmtflags f ) const { _out.flags(f); } - - /// Set the format flags (2/2). - /** - \param f The flags -- \b IN. - */ - void setf ( std::ios_base::fmtflags f ) const { _out.setf(f); } - - /// Unset the format flags. - /** - \param f The flags -- \b IN. - */ - void unsetf ( std::ios_base::fmtflags f ) const { _out.unsetf(f); } - - - /// Get the current format flags. - /** - \return The format flags. - */ - std::ios_base::fmtflags flags ( void ) const { return _out.flags(); } + inline const NOMAD::Display & NOMAD::Display::operator << ( const T & t ) const + { + if ( _newline ) + { + _out << _indent_str; + _newline = false; + } + _out << t; + return *this; + } - /*--------------------*/ - /* type conversions */ - /*--------------------*/ - - /// Convert a NOMAD::dd_type to a character. - /** - \param dd The NOMAD::dd_type -- \b IN. - \return The character. - */ - static char dd_to_char ( NOMAD::dd_type dd ); - - /// Convert a NOMAD::dd_type to an integer. - /** - \param dd The NOMAD::dd_type -- \b IN. - \return The integer. - */ - static int dd_to_int ( NOMAD::dd_type dd ); - - /// Convert an integer to a NOMAD::dd_type. - /** - \param dd The integer -- \b IN. - \return The NOMAD::dd_type. - */ - static NOMAD::dd_type int_to_dd ( int dd ); - - /// Display a duration with a smart format. - /** - \param t Duration as an integer in seconds -- \b IN. - */ - void display_time ( int t ) const; - - /// Display a boolean with format \c yes/no. - /** - \param b The boolean -- \b IN. - */ - void display_yes_or_no ( bool b ) const { (*this) << ( (b) ? "yes" : "no" ); } - - /// Display a memory size. - /** - \param size The memory size. - */ - void display_size_of ( float size ) const; - - /// Display an integer with a specific width. - /** - \param i The integer to display -- \b IN. - \param max_i Maximal value of \c i used to determine the display width - -- \b IN -- \b optional (default = \c -1). - */ - void display_int_w ( int i , int max_i = -1 ) const; - - /// Get the keyword associated with a NOMAD::display_stats_type. - /** - \param dst The NOMAD::display_stats_type -- \b IN. - \return A string containing the keyword. - */ - static std::string get_display_stats_keyword ( NOMAD::display_stats_type dst ); - - /// Extract display format from a string. - /** - \param s The string -- \b IN/OUT. - \param format The format -- \b OUT. - */ - static void extract_display_format ( std::string & s , std::string & format ); - - /// Get the NOMAD::display_stats_type from a string. - /** - \param s The string -- \b IN. - \return The NOMAD::display_stats_type. - */ - static NOMAD::display_stats_type get_display_stats_type ( const std::string & s ); - - }; - - /*-------------------------------------------------------------------------*/ - - /// Open an indented block. - /** - Allows the use of \c out \c << \c open_block(msg). - */ - class open_block { - private: - std::string _msg; ///< Message displayed as a block title. - public: - - /// Constructor. - /** - Open an indented block. - \param msg The block title - -- \b IN -- \b optional (default = empty string). - */ - open_block ( const std::string & msg = "" ) : _msg ( msg ) {} - - /// Operator (). - const Display & operator() ( const Display & out ) const { - out.open_block ( _msg ); - return out; + /// Allows the use of \c out \c << \c endl. + inline const NOMAD::Display & NOMAD::Display::operator << ( StandardEndLine m ) const + { + m ( _out ); // this could be a std::flush, so don't use it: instead use method flush() + _newline = true; + return *this; } - }; - - /*-------------------------------------------------------------------------*/ - - /// Close an indented block. - /** - Allows the use of \c out \c << \c close_block(msg). - */ - class close_block { - private: - std::string _msg; ///< Message displayed at the end of a block. - public: - - /// Constructor. - /** - Close an indented block. - \param msg Message displayed at the end of a block - -- \b IN -- \b optional (default = empty string). - */ - close_block ( const std::string & msg = "" ) : _msg ( msg ) {} - - /// Operator (). - const Display & operator() ( const Display & out ) const { - out.close_block ( _msg ); - return out; + + /// Allows the use of \c out \c << \c open_block(msg). + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::open_block & ob ) + { + return ob ( out ); } - }; - - /*-------------------------------------------------------------*/ - /* display functions for enum types defined in 'defines.hpp' */ - /*-------------------------------------------------------------*/ - - /// Operator << for NOMAD::stop_type. - std::ostream & operator << ( std::ostream & , NOMAD::stop_type ); - - /// Operator << for NOMAD::dd_type. - std::ostream & operator << ( std::ostream & , NOMAD::dd_type ); - - /// Operator << for NOMAD::success_type. - std::ostream & operator << ( std::ostream & , NOMAD::success_type ); - - /// Operator << for NOMAD::bb_input_type. - std::ostream & operator << ( std::ostream & , NOMAD::bb_input_type ); - - /// Operator << for NOMAD::bb_output_type. - std::ostream & operator << ( std::ostream & , NOMAD::bb_output_type ); - - /// Operator << for NOMAD::interpolation_type. - std::ostream & operator << ( std::ostream & , NOMAD::interpolation_type ); - - /// Operator << for NOMAD::hnorm_type. - std::ostream & operator << ( std::ostream & , NOMAD::hnorm_type ); - - /// Operator << for NOMAD::search_type. - std::ostream & operator << ( std::ostream & , NOMAD::search_type ); - - /// Operator << for NOMAD::model_type. - std::ostream & operator << ( std::ostream & , NOMAD::model_type ); - - /// Operator << for NOMAD::TGP_mode_type. - std::ostream & operator << ( std::ostream & , NOMAD::TGP_mode_type ); - - /// Operator << for NOMAD::direction_type. - std::ostream & operator << ( std::ostream & , NOMAD::direction_type ); - - /// Operator << for NOMAD::check_failed_type. - std::ostream & operator << ( std::ostream & , NOMAD::check_failed_type ); - - /// Operator << for NOMAD::display_stats_type. - std::ostream & operator << ( std::ostream & , NOMAD::display_stats_type ); - - /// Operator << for NOMAD::eval_type. - std::ostream & operator << ( std::ostream & , NOMAD::eval_type ); - - /// Operator << for NOMAD::eval_status_type. - std::ostream & operator << ( std::ostream & , NOMAD::eval_status_type ); - - /// Operator << for NOMAD::multi_formulation_type. - std::ostream & operator << ( std::ostream & , NOMAD::multi_formulation_type ); - - /// Operator << for a vector of NOMAD::bb_intput_type. - std::ostream & operator << ( std::ostream & , - const std::vector<NOMAD::bb_input_type> & ); - - /// Operator <<. - template <class T> - inline const NOMAD::Display & NOMAD::Display::operator << ( const T & t ) const - { - if ( _newline ) { - _out << _indent_str; - _newline = false; + + /// Allows the use of \c out \c << \c close_block(msg). + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::close_block & cb ) + { + return cb ( out ); } - _out << t; - return *this; - } - - /// Allows the use of \c out \c << \c endl. - inline const NOMAD::Display & NOMAD::Display::operator << ( StandardEndLine m ) const - { - m ( _out ); // this could be a std::flush, so don't use it: instead use method flush() - _newline = true; - return *this; - } - - /// Allows the use of \c out \c << \c open_block(msg). - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::open_block & ob ) - { - return ob ( out ); - } - - /// Allows the use of \c out \c << \c close_block(msg). - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::close_block & cb ) - { - return cb ( out ); - } - + } #endif diff --git a/src/Double.cpp b/src/Double.cpp index 8a7c06714f85ece2d191ab9f51d06b400324ebd0..28b1f3c2ff7aacf686d64b1c39ff38207d26f250 100644 --- a/src/Double.cpp +++ b/src/Double.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -150,7 +157,8 @@ bool NOMAD::Double::atof ( const std::string & ss ) std::string s = ss; NOMAD::toupper(s); - if ( s == "-" || ss == NOMAD::Double::_undef_str ) { + if ( s == "-" || ss == NOMAD::Double::_undef_str ) + { _value = 0.0; _defined = false; return true; @@ -158,13 +166,15 @@ bool NOMAD::Double::atof ( const std::string & ss ) if ( s == "INF" || s == "+INF" || ss == NOMAD::Double::_inf_str || - ss == ("+" + NOMAD::Double::_inf_str) ) { + ss == ("+" + NOMAD::Double::_inf_str) ) + { _value = NOMAD::INF; _defined = true; return true; } - if ( s == "-INF" || ss == ("-" + NOMAD::Double::_inf_str) ) { + if ( s == "-INF" || ss == ("-" + NOMAD::Double::_inf_str) ) + { _value = -NOMAD::INF; _defined = true; return true; @@ -178,8 +188,10 @@ bool NOMAD::Double::atof ( const std::string & ss ) size_t n = s.size(); for ( size_t k = 1 ; k < n ; ++k ) - if ( !isdigit(s[k]) && s[k] != '.' ) { - if ( s[k] == 'E' ) { + if ( !isdigit(s[k]) && s[k] != '.' ) + { + if ( s[k] == 'E' ) + { if ( s.size() == k+1 ) return false; ++k; @@ -200,7 +212,8 @@ bool NOMAD::Double::atof ( const std::string & ss ) /*-------------------------------------------------*/ bool NOMAD::Double::relative_atof ( const std::string & s , bool & relative ) { - if ( std::toupper(s[0]) == 'R' ) { + if ( std::toupper(s[0]) == 'R' ) + { relative = true; std::string ss = s; ss.erase(ss.begin()); @@ -368,7 +381,8 @@ NOMAD::Double & NOMAD::Double::operator = ( double r ) /*------------------------------------------*/ void NOMAD::Double::display ( const NOMAD::Display & out ) const { - if ( _defined ) { + if ( _defined ) + { if ( _value == NOMAD::INF ) out << NOMAD::Double::_inf_str; else if ( _value == -NOMAD::INF ) @@ -484,18 +498,22 @@ void NOMAD::Double::display ( const NOMAD::Display & out , out.precision ( prec ); if ( c == 'f' ) + { out.setf ( std::ios::fixed ); - + out << _value; + } else if ( c == 'e' ) { out.unsetf ( std::ios::fixed ); out.setf ( std::ios::scientific ); + out << _value; } else if ( c == 'E' ) { out.unsetf ( std::ios::fixed ); out.setf ( std::ios::scientific | std::ios::uppercase ); + out << _value; } else if ( c == 'g' ) @@ -509,10 +527,11 @@ void NOMAD::Double::display ( const NOMAD::Display & out , streamS.setf( std::ios::scientific); streamS << _value; streamF << _value; - if (streamS.str().length() < streamF.str().length()) - out.setf(std::ios::scientific); + + if ( streamS.str().length() < streamF.str().length() ) + out << streamS.str(); else - out.setf(std::ios::fixed); + out << streamF.str(); } @@ -522,19 +541,17 @@ void NOMAD::Double::display ( const NOMAD::Display & out , streamS.precision ( prec ); streamF.precision ( prec ); streamF.unsetf(std::ios::scientific); - streamF.setf( std::ios::fixed ); + streamF.setf( std::ios::fixed | std::ios::uppercase ); streamS.unsetf(std::ios::fixed); - streamS.setf( std::ios::scientific); + streamS.setf( std::ios::scientific | std::ios::uppercase ); streamS << _value ; streamF << _value ; if (streamS.str().length() < streamF.str().length()) - out.setf(std::ios::scientific | std::ios::uppercase ); + out << streamS.str(); else - out.setf(std::ios::fixed | std::ios::uppercase ); + out << streamF.str(); } - out << _value; - out.precision ( old_prec ); out.flags ( old_flags ); } @@ -543,6 +560,7 @@ void NOMAD::Double::display ( const NOMAD::Display & out , out << NOMAD::Double::_undef_str; } + /*------------------------------------------*/ /* round */ /*------------------------------------------*/ @@ -551,10 +569,33 @@ int NOMAD::Double::round ( void ) const if ( !_defined ) throw Not_Defined ( "Double.cpp" , __LINE__ , "NOMAD::Double::round(): value not defined" ); - return static_cast<int>(_value < 0.0 ? -std::floor(.5-_value) : std::floor(.5+_value)); + + double d = (_value < 0.0 ? -std::floor(.5-_value) : std::floor(.5+_value)); + + if ( d > NOMAD::P_INF_INT || d < NOMAD::M_INF_INT ) + throw Invalid_Value ( "Double.cpp" , __LINE__ , + "NOMAD::Double::round(): value cannot be rounded to integer because it is outside of range" ); + + return static_cast<int> (d); +} + +/*------------------------------------------*/ +/* round to double */ +/*------------------------------------------*/ +const NOMAD::Double NOMAD::Double::roundd ( void ) const +{ + if ( !_defined ) + throw Not_Defined ( "Double.cpp" , __LINE__ , + "NOMAD::Double::round(): value not defined" ); + + NOMAD::Double d = (_value < 0.0 ? -std::floor(.5-_value) : std::floor(.5+_value)); + + return (_value < 0.0 ? -std::floor(.5-_value) : std::floor(.5+_value)); + } + /*------------------------------------------*/ /* Ceil */ /*------------------------------------------*/ @@ -563,7 +604,7 @@ const NOMAD::Double NOMAD::Double::ceil ( void ) const if ( !_defined ) throw Not_Defined ( "Double.cpp" , __LINE__ , "NOMAD::Double::ceil(): value not defined" ); - return NOMAD::Double(std::ceil(_value)); + return NOMAD::Double( std::ceil(_value) ); } /*------------------------------------------*/ @@ -574,7 +615,7 @@ const NOMAD::Double NOMAD::Double::floor ( void ) const if ( !_defined ) throw Not_Defined ( "Double.cpp" , __LINE__ , "NOMAD::Double::floor(): value not defined" ); - return NOMAD::Double(std::floor(_value)); + return NOMAD::Double( std::floor(_value) ); } /*------------------------------------------*/ @@ -640,7 +681,8 @@ const NOMAD::Double NOMAD::Double::rel_err ( const Double & x ) const double diff = fabs ( _value - x._value ); // 2. test if one of the values is zero: - if ( _value == 0.0 || x._value == 0.0 ) { + if ( _value == 0.0 || x._value == 0.0 ) + { // we return min{2,|x-y|} (instead of 1): if ( diff > 2.0 ) @@ -654,7 +696,8 @@ const NOMAD::Double NOMAD::Double::rel_err ( const Double & x ) const double err = diff / ( (a<b) ? b : a ); // 4. test if we have opposite signs: - if ( _value * x._value < 0.0 ) { + if ( _value * x._value < 0.0 ) + { // the original error gives err in ]1;2] : we check if |x-y| < 1 // and if so we return |x-y| : @@ -701,12 +744,13 @@ void NOMAD::Double::project_to_mesh ( const NOMAD::Double & ref , { if ( !_defined ) return; - + NOMAD::Double v0 = ( ref._defined ) ? ref : 0.0; - if ( delta._defined && delta != 0.0 ) { + if ( delta._defined && delta != 0.0 ) + { - *this = v0 + ( (*this-v0) / delta).round() * delta; + *this = v0 + ( (*this-v0) / delta).roundd() * delta; if ( ub._defined && *this > ub ) *this = ub; diff --git a/src/Double.hpp b/src/Double.hpp index 5a9cf7f6ee92a74dd836d3cae54332b8c02f20d8..405f78658f2f02efbf18403ac544332384e902a1 100644 --- a/src/Double.hpp +++ b/src/Double.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Double.hpp - \brief Custom class for double-precision reals (headers) - \author Sebastien Le Digabel - \date 2010-04-02 - \see Double.cpp -*/ + \file Double.hpp + \brief Custom class for double-precision reals (headers) + \author Sebastien Le Digabel + \date 2010-04-02 + \see Double.cpp + */ #ifndef __NOMAD_DOUBLE__ #define __NOMAD_DOUBLE__ @@ -47,357 +54,363 @@ #include "Display.hpp" namespace NOMAD { - - /// Custom class for double-precision reals. - /** + + /// Custom class for double-precision reals. + /** - Allows comparisons on reals with custom precision. - Deals with undefined values. - Use \c value() to access the true \c double value. - */ - class Double { - - private: - + */ + class Double { + + private: + #ifdef MEMORY_DEBUG - static int _cardinality; ///< Number of NOMAD::Double objects in memory. - static int _max_cardinality; ///< Max number of NOMAD::Double objects in memory. + static int _cardinality; ///< Number of NOMAD::Double objects in memory. + static int _max_cardinality; ///< Max number of NOMAD::Double objects in memory. #endif - - double _value; ///< The value of the number. - bool _defined; ///< \c true if the number has a defined value. - - static double _epsilon; ///< Desired precision on comparisons. - static std::string _inf_str; ///< Infinity string. - static std::string _undef_str; ///< Undefined value string. - - public: - - /*-------------------------------------------------------------------*/ - - /// Exception class for undefined NOMAD::Double objects. - class Not_Defined : public NOMAD::Exception { + + double _value; ///< The value of the number. + bool _defined; ///< \c true if the number has a defined value. + + static double _epsilon; ///< Desired precision on comparisons. + static std::string _inf_str; ///< Infinity string. + static std::string _undef_str; ///< Undefined value string. + public: - /// Constructor. - Not_Defined ( const std::string & file , - int line , - const std::string & msg ) - : NOMAD::Exception ( file , line , msg ) {} - }; - - /// Exception class for divisons by zero with NOMAD::Double objects. - class Invalid_Value : public NOMAD::Exception { - public: - /// Constructor. - Invalid_Value ( const std::string & file , - int line , - const std::string & msg ) - : NOMAD::Exception ( file , line , msg ) {} - }; - - /*-------------------------------------------------------------------*/ + + /*-------------------------------------------------------------------*/ + + /// Exception class for undefined NOMAD::Double objects. + class Not_Defined : public NOMAD::Exception { + public: + /// Constructor. + Not_Defined ( const std::string & file , + int line , + const std::string & msg ) + : NOMAD::Exception ( file , line , msg ) {} + }; + + /// Exception class for divisons by zero with NOMAD::Double objects. + class Invalid_Value : public NOMAD::Exception { + public: + /// Constructor. + Invalid_Value ( const std::string & file , + int line , + const std::string & msg ) + : NOMAD::Exception ( file , line , msg ) {} + }; + + /*-------------------------------------------------------------------*/ #ifdef MEMORY_DEBUG - /// Access to the number of NOMAD::Double objects in memory. - /** - \return The number of NOMAD::Double objects in memory. - */ - static int get_cardinality ( void ) { return NOMAD::Double::_cardinality; } - - /// Access to the max number of NOMAD::Double objects in memory. - /** - \return The max number of NOMAD::Double objects in memory. - */ - static int get_max_cardinality ( void ) { return NOMAD::Double::_max_cardinality; } + /// Access to the number of NOMAD::Double objects in memory. + /** + \return The number of NOMAD::Double objects in memory. + */ + static int get_cardinality ( void ) { return NOMAD::Double::_cardinality; } + + /// Access to the max number of NOMAD::Double objects in memory. + /** + \return The max number of NOMAD::Double objects in memory. + */ + static int get_max_cardinality ( void ) { return NOMAD::Double::_max_cardinality; } #endif - - /// Constructor #1. - explicit Double ( void ); - - /// Constructor #2. - /** - From a \c double. - \param v The \c double -- \b IN. - */ - Double ( double v ); - - /// Copy constructor. - /** - \param d The copied object -- \b IN. - */ - Double ( const Double & d ); - - /// Destructor. - virtual ~Double ( void ); - - /// Function \c atof (conversion from a string to a real). - /** - The value is determined by a string. - \param s The string -- \b IN. - \return A boolean equal to \c true if the string was valid. - */ - bool atof ( const std::string & s ); - - /// Function \c atof (conversion from a string to a real) with a relative value. - /** - The value is determined by a string that may begin with \c 'r' to - indicate a proportion (relative value). - \param s The string -- \b IN. - \param relative A boolean indicating if the conversion was relative -- \b OUT. - \return A boolean equal to \c true if the string was valid. - */ - bool relative_atof ( const std::string & s , bool & relative ); - - /// Reset the Double. - void clear ( void ) { _value = 0.0; _defined = false; } + + /// Constructor #1. + explicit Double ( void ); + + /// Constructor #2. + /** + From a \c double. + \param v The \c double -- \b IN. + */ + Double ( double v ); + + /// Copy constructor. + /** + \param d The copied object -- \b IN. + */ + Double ( const Double & d ); + + /// Destructor. + virtual ~Double ( void ); + + /// Function \c atof (conversion from a string to a real). + /** + The value is determined by a string. + \param s The string -- \b IN. + \return A boolean equal to \c true if the string was valid. + */ + bool atof ( const std::string & s ); + + /// Function \c atof (conversion from a string to a real) with a relative value. + /** + The value is determined by a string that may begin with \c 'r' to + indicate a proportion (relative value). + \param s The string -- \b IN. + \param relative A boolean indicating if the conversion was relative -- \b OUT. + \return A boolean equal to \c true if the string was valid. + */ + bool relative_atof ( const std::string & s , bool & relative ); + + /// Reset the Double. + void clear ( void ) { _value = 0.0; _defined = false; } + + /// Reset the Double. + void reset ( void ) { clear(); } + + /// Affectation operator #1. + /** + \param d The right-hand side object -- \b IN. + \return \c *this as the result of the affectation. + */ + Double & operator = ( const Double & d ); + + /// Affectation operator #2. + /** + \param r The right-hand side \c double -- \b IN. + \return \c *this as the result of the affectation. + */ + Double & operator = ( double r ); + + /// Access to the \c double value. + /** + \return The \c double value. + */ + double value ( void ) const; + + /// Is the value defined ? + /** + \return A boolean equal to \c true if the NOMAD::Double is defined. + */ + bool is_defined ( void ) const { return _defined; } + + /// Is the value an integer ? + /** + \return A boolean equal to \c true if the NOMAD::Double is an integer. + */ + bool is_integer ( void ) const; + + /// Is the value binary ? + /** + \return A boolean equal to \c true if the NOMAD::Double is in {0,1}. + */ + bool is_binary ( void ) const; + + /// Sizeof. + /** + The size of an object in memory. + \return An integer value for the size in bytes. + */ + int size_of ( void ) const { return sizeof(_defined) + sizeof(_value); } + + /// Access to the NOMAD::Double precision. + /** + \return A \c double for the precision. + */ + static double get_epsilon ( void ) { return Double::_epsilon; } + + /// Set the NOMAD::Double precision. + /** + \param eps The precision -- \b IN. + */ + static void set_epsilon ( double eps ); + + /// Access to the undefined value string. + /** + \return A \c std::string for the undefined value string. + */ + static std::string get_undef_str ( void ) { return Double::_undef_str; } + + /// Set the NOMAD::Double undefined value string. + /** + \param undef_str The undefined value string -- \b IN. + */ + static void set_undef_str ( const std::string & undef_str ) + { + NOMAD::Double::_undef_str = undef_str; + } + + /// Access to the infinity string. + /** + \return A \c std::string for the infinity string. + */ + static std::string get_inf_str ( void ) { return Double::_inf_str; } + + /// Set the NOMAD::Double infinity string. + /** + \param inf_str The infinity string -- \b IN. + */ + static void set_inf_str ( const std::string & inf_str ) + { + NOMAD::Double::_inf_str = inf_str; + } + + /// Rounding to int + /** + \return An integer with the rounding result. + */ + int round ( void ) const; + + /// Rounding to a Double + /** + \return A NOMAD::Double with the rounding result. + */ + const Double roundd ( void ) const; + + + /// Ceil. + /** + \return A NOMAD::double with the rounding result. + */ + const Double ceil ( void ) const; + + /// Floor. + /** + \return A NOMAD::double with the rounding result. + */ + const Double floor ( void ) const; + + + /// Absolute value. + /** + \return Another NOMAD::Double equal to max{\c -*this,\c *this}. + */ + const Double abs ( void ) const; + + /// Square. + /** + \return Another NOMAD::Double equal to \c *this \c * \c *this. + */ + const Double pow2 ( void ) const; + + /// Square root. + /** + \return Another NOMAD::Double equal to \c (*this)^0.5. + */ + const Double sqrt ( void ) const; + + /// Relative error with another NOMAD::Double. + /** + \param x The other real -- \b IN. + \return A new object with the relative error value in \c [0;1]. + */ + const Double rel_err ( const Double & x ) const; + + /// Operator \c ++ (prefix position). + /** + Allows \c ++d; + \return The NOMAD::Double plus 1. + */ + Double & operator++ ( void ); + + /// Operator \c ++ (suffix position). + /** + Allows \c d++; + \return A copy of the NOMAD::Double before incrementation. + */ + Double operator++ ( int n ); + + /// Operator \c -- (prefix position). + /** + Allows \c --d; + \return The NOMAD::Double minus 1. + */ Double & operator-- ( void ); + + /// Operator \c -- (suffix position). + /** + Allows \c d--; + \return A copy of the NOMAD::Double before decrementation. + */ Double operator-- ( int n ); + + /// Operator \c +=. + /** + Allows \c d \c += \c d1. + \param d1 The increment -- \b IN. + \return The NOMAD::Double plus \c d1. + */ + const Double & operator += ( const Double & d1 ); + + /// Operator \c -=. + /** + Allows \c d \c -= \c d1. + \param d1 The decrement -- \b IN. + \return The NOMAD::Double minus \c d1. + */ + const Double & operator -= ( const Double & d1 ); + + /// Operator \c *=. + /** + Allows \c d \c *= \c d1. + \param d1 The factor -- \b IN. + \return The NOMAD::Double times \c d1. + */ + const Double & operator *= ( const Double & d1 ); + + /// Operator \c /=. + /** + Allows \c d \c /= \c d1. Throws a NOMAD::Exception::Invalid_Value if \c d1==0. + \param d1 The denominator -- \b IN. + \return The NOMAD::Double divided by \c d1. + */ + const Double & operator /= ( const Double & d1 ); + + /// Comparison <. + /** + The same as operator \c < but with consideration of undefined values. + When comparing \c d1 and \c d2, \c (d1<d2) is equal to \c true for example + if \c d1 is defined and if \c d2 is not. + \param d The right-hand side of the comparison -- \b IN. + \return A boolean equal to \c true if \c *this \c < \c d. + */ + bool comp_with_undef ( const Double & d ) const; + + /// Projection to the mesh. + /** + Projection to the mesh of size delta + ( \c *this \c = \c ref \c + \c k \c * \c delta ). + \param ref Reference for projection -- \b IN. + \param delta Mesh size parameter -- \b IN. + \param lb Lower bound -- \b IN -- \b optional (default=undefined real.) + \param ub Upper bound -- \b IN -- \b optional (default=undefined real.) + */ + void project_to_mesh ( const Double & ref , + const Double & delta , + const Double & lb = Double() , + const Double & ub = Double() ); + + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display ( const NOMAD::Display & out ) const; + + /// Display with format. + /** + \param out The NOMAD::Display object -- \b IN. + \param format The format as in C -- \b IN. + */ + void display ( const NOMAD::Display & out , + const std::string & format ) const; + }; - /// Reset the Double. - void reset ( void ) { clear(); } - - /// Affectation operator #1. - /** - \param d The right-hand side object -- \b IN. - \return \c *this as the result of the affectation. - */ - Double & operator = ( const Double & d ); - - /// Affectation operator #2. - /** - \param r The right-hand side \c double -- \b IN. - \return \c *this as the result of the affectation. - */ - Double & operator = ( double r ); - - /// Access to the \c double value. - /** - \return The \c double value. - */ - double value ( void ) const; - - /// Is the value defined ? - /** - \return A boolean equal to \c true if the NOMAD::Double is defined. - */ - bool is_defined ( void ) const { return _defined; } - - /// Is the value an integer ? - /** - \return A boolean equal to \c true if the NOMAD::Double is an integer. - */ - bool is_integer ( void ) const; - - /// Is the value binary ? - /** - \return A boolean equal to \c true if the NOMAD::Double is in {0,1}. - */ - bool is_binary ( void ) const; + /*---------------------------------------------------------------------------*/ - /// Sizeof. - /** - The size of an object in memory. - \return An integer value for the size in bytes. - */ - int size_of ( void ) const { return sizeof(_defined) + sizeof(_value); } - - /// Access to the NOMAD::Double precision. - /** - \return A \c double for the precision. - */ - static double get_epsilon ( void ) { return Double::_epsilon; } - - /// Set the NOMAD::Double precision. + /// Display a NOMAD::Double object. /** - \param eps The precision -- \b IN. - */ - static void set_epsilon ( double eps ); - - /// Access to the undefined value string. - /** - \return A \c std::string for the undefined value string. - */ - static std::string get_undef_str ( void ) { return Double::_undef_str; } - - /// Set the NOMAD::Double undefined value string. - /** - \param undef_str The undefined value string -- \b IN. - */ - static void set_undef_str ( const std::string & undef_str ) - { - NOMAD::Double::_undef_str = undef_str; - } - - /// Access to the infinity string. - /** - \return A \c std::string for the infinity string. - */ - static std::string get_inf_str ( void ) { return Double::_inf_str; } - - /// Set the NOMAD::Double infinity string. - /** - \param inf_str The infinity string -- \b IN. - */ - static void set_inf_str ( const std::string & inf_str ) + \param out The NOMAD::Display object -- \b IN. + \param d The NOMAD::Double object to be displayed -- \b IN. + \return The NOMAD::Display object. + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const Double & d ) { - NOMAD::Double::_inf_str = inf_str; + d.display ( out ); + return out; } - - /// Rounding. - /** - \return An integer with the rounding result. - */ - int round ( void ) const; - - - /// Ceil. - /** - \return A NOMAD::double with the rounding result. - */ - const Double ceil ( void ) const; - - /// Floor. - /** - \return A NOMAD::double with the rounding result. - */ - const Double floor ( void ) const; - - - /// Absolute value. - /** - \return Another NOMAD::Double equal to max{\c -*this,\c *this}. - */ - const Double abs ( void ) const; - - /// Square. - /** - \return Another NOMAD::Double equal to \c *this \c * \c *this. - */ - const Double pow2 ( void ) const; - - /// Square root. - /** - \return Another NOMAD::Double equal to \c (*this)^0.5. - */ - const Double sqrt ( void ) const; - /// Relative error with another NOMAD::Double. - /** - \param x The other real -- \b IN. - \return A new object with the relative error value in \c [0;1]. - */ - const Double rel_err ( const Double & x ) const; - - /// Operator \c ++ (prefix position). - /** - Allows \c ++d; - \return The NOMAD::Double plus 1. - */ - Double & operator++ ( void ); - - /// Operator \c ++ (suffix position). - /** - Allows \c d++; - \return A copy of the NOMAD::Double before incrementation. - */ - Double operator++ ( int n ); - - /// Operator \c -- (prefix position). - /** - Allows \c --d; - \return The NOMAD::Double minus 1. - */ Double & operator-- ( void ); - - /// Operator \c -- (suffix position). - /** - Allows \c d--; - \return A copy of the NOMAD::Double before decrementation. - */ Double operator-- ( int n ); - - /// Operator \c +=. + /// Input. /** - Allows \c d \c += \c d1. - \param d1 The increment -- \b IN. - \return The NOMAD::Double plus \c d1. - */ - const Double & operator += ( const Double & d1 ); - - /// Operator \c -=. - /** - Allows \c d \c -= \c d1. - \param d1 The decrement -- \b IN. - \return The NOMAD::Double minus \c d1. - */ - const Double & operator -= ( const Double & d1 ); - - /// Operator \c *=. - /** - Allows \c d \c *= \c d1. - \param d1 The factor -- \b IN. - \return The NOMAD::Double times \c d1. - */ - const Double & operator *= ( const Double & d1 ); - - /// Operator \c /=. - /** - Allows \c d \c /= \c d1. Throws a NOMAD::Exception::Invalid_Value if \c d1==0. - \param d1 The denominator -- \b IN. - \return The NOMAD::Double divided by \c d1. - */ - const Double & operator /= ( const Double & d1 ); - - /// Comparison <. - /** - The same as operator \c < but with consideration of undefined values. - When comparing \c d1 and \c d2, \c (d1<d2) is equal to \c true for example - if \c d1 is defined and if \c d2 is not. - \param d The right-hand side of the comparison -- \b IN. - \return A boolean equal to \c true if \c *this \c < \c d. - */ - bool comp_with_undef ( const Double & d ) const; - - /// Projection to the mesh. - /** - Projection to the mesh of size delta - ( \c *this \c = \c ref \c + \c k \c * \c delta ). - \param ref Reference for projection -- \b IN. - \param delta Mesh size parameter -- \b IN. - \param lb Lower bound -- \b IN -- \b optional (default=undefined real.) - \param ub Upper bound -- \b IN -- \b optional (default=undefined real.) - */ - void project_to_mesh ( const Double & ref , - const Double & delta , - const Double & lb = Double() , - const Double & ub = Double() ); - - /// Display. - /** - \param out The NOMAD::Display object -- \b IN. - */ - void display ( const NOMAD::Display & out ) const; - - /// Display with format. - /** - \param out The NOMAD::Display object -- \b IN. - \param format The format as in C -- \b IN. - */ - void display ( const NOMAD::Display & out , - const std::string & format ) const; - }; - - /*---------------------------------------------------------------------------*/ - - /// Display a NOMAD::Double object. - /** - \param out The NOMAD::Display object -- \b IN. - \param d The NOMAD::Double object to be displayed -- \b IN. - \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const Double & d ) - { - d.display ( out ); - return out; - } - - /// Input. - /** - Allows the input of NOMAD::Double objects with operator \c >>. - Can read undefined values (parameter \c UNDEF_STR with default \c "-".) - Example: @@ -410,128 +423,155 @@ namespace NOMAD { \param in A \c std::istream object (can be a file) -- \b IN/OUT. \param d The NOMAD::Double object to be read -- \b OUT. \return The modified \c std::istream object. - */ - std::istream & operator >> ( std::istream & in , Double & d ); - - /// Inverse operator. - /** + */ + std::istream & operator >> ( std::istream & in , Double & d ); + + /// Inverse operator. + /** Allows operations such as \c d \c = \c -d. \param d The NOMAD::Double to be inversed -- \b IN. \return A new NOMAD::Double as the result of the operation. - */ - inline const Double operator - ( const Double & d ) - { - return NOMAD::Double (-d.value()); - } - - /// Operator \c + for two NOMAD::Double objects. - /** + */ + inline const Double operator - ( const Double & d ) + { + return NOMAD::Double (-d.value()); + } + + /// Operator \c + for two NOMAD::Double objects. + /** Allows operations such as \c d \c = \c d1 \c + \c d2. \param d1 The first NOMAD::Double -- \b IN. \param d2 The second NOMAD::Double -- \b IN. \return A third NOMAD::Double as the result of the operation. - */ - inline const Double operator + ( const Double & d1 , const Double & d2 ) - { - return NOMAD::Double ( d1.value() + d2.value() ); - } - - /// Operator \c - for two NOMAD::Double objects. - /** + */ + inline const Double operator + ( const Double & d1 , const Double & d2 ) + { + return NOMAD::Double ( d1.value() + d2.value() ); + } + + /// Operator \c - for two NOMAD::Double objects. + /** Allows operations such as \c d \c = \c d1 \c - \c d2. \param d1 The first NOMAD::Double -- \b IN. \param d2 The second NOMAD::Double -- \b IN. \return A third NOMAD::Double as the result of the operation. - */ - inline const Double operator - ( const Double & d1 , const Double & d2 ) - { - return NOMAD::Double (d1.value() - d2.value()); - } - - /// Operator \c * for two NOMAD::Double objects. - /** + */ + inline const Double operator - ( const Double & d1 , const Double & d2 ) + { + return NOMAD::Double (d1.value() - d2.value()); + } + + /// Operator \c * for two NOMAD::Double objects. + /** Allows operations such as \c d \c = \c d1 \c * \c d2. \param d1 The first NOMAD::Double -- \b IN. \param d2 The second NOMAD::Double -- \b IN. \return A third NOMAD::Double as the result of the operation. - */ - inline const Double operator * ( const Double & d1 , const Double & d2 ) - { - return NOMAD::Double ( d1.value() * d2.value() ); - } - - /// Operator \c / for two NOMAD::Double objects. - /** + */ + inline const Double operator * ( const Double & d1 , const Double & d2 ) + { + return NOMAD::Double ( d1.value() * d2.value() ); + } + + /// Operator \c / for two NOMAD::Double objects. + /** Allows operations such as \c d \c = \c d1 \c / \c d2. \param d1 The first NOMAD::Double -- \b IN. \param d2 The second NOMAD::Double -- \b IN. \return A third NOMAD::Double as the result of the operation. - */ - const Double operator / ( const Double & d1 , const Double & d2 ); - - /// Comparison operator \c ==. - /** + */ + const Double operator / ( const Double & d1 , const Double & d2 ); + + /// Comparison operator \c ==. + /** Allows the comparison \c d1 \c == \c d2. \param d1 The first NOMAD::Double -- \b IN. \param d2 The second NOMAD::Double -- \b IN. \return A boolean equal to true if \c d1 \c == \c d2. - */ - inline bool operator == ( const Double & d1 , const Double & d2 ) - { - return fabs ( d1.value() - d2.value() ) < NOMAD::Double::get_epsilon(); - } - - /// Comparison operator \c !=. - /** + */ + inline bool operator == ( const Double & d1 , const Double & d2 ) + { + return fabs ( d1.value() - d2.value() ) < NOMAD::Double::get_epsilon(); + } + + /// Comparison operator \c !=. + /** Allows the comparison \c d1 \c != \c d2. \param d1 The first NOMAD::Double -- \b IN. \param d2 The second NOMAD::Double -- \b IN. \return A boolean equal to true if \c d1 \c != \c d2. - */ - inline bool operator != ( const Double & d1 , const Double & d2 ) { return !(d1==d2); } - - /// Comparison operator \c <. - /** + */ + inline bool operator != ( const Double & d1 , const Double & d2 ) + { + return !(d1==d2); + } + + /// Comparison operator \c <. + /** Allows the comparison \c d1 \c < \c d2. \param d1 The first NOMAD::Double -- \b IN. \param d2 The second NOMAD::Double -- \b IN. \return A boolean equal to true if \c d1 \c < \c d2. - */ - inline bool operator < ( const Double & d1 , const Double & d2 ) - { - return d1.value() < d2.value() - NOMAD::Double::get_epsilon(); - } - - /// Comparison operator \c >. - /** + */ + inline bool operator < ( const Double & d1 , const Double & d2 ) + { + return d1.value() < d2.value() - NOMAD::Double::get_epsilon(); + } + + /// Comparison operator \c >. + /** Allows the comparison \c d1 \c > \c d2. \param d1 The first NOMAD::Double -- \b IN. \param d2 The second NOMAD::Double -- \b IN. \return A boolean equal to true if \c d1 \c > \c d2. - */ - inline bool operator > ( const Double & d1 , const Double & d2 ) - { - return d1.value() > d2.value() + NOMAD::Double::get_epsilon(); - } - - /// Comparison operator \c <=. - /** + */ + inline bool operator > ( const Double & d1 , const Double & d2 ) + { + return d1.value() > d2.value() + NOMAD::Double::get_epsilon(); + } + + /// Comparison operator \c <=. + /** Allows the comparison \c d1 \c <= \c d2. \param d1 The first NOMAD::Double -- \b IN. \param d2 The second NOMAD::Double -- \b IN. \return A boolean equal to true if \c d1 \c <= \c d2. - */ - inline bool operator <= ( const Double & d1 , const Double & d2 ) { return !(d1>d2); } - - /// Comparison operator \c >=. - /** + */ + inline bool operator <= ( const Double & d1 , const Double & d2 ) { return !(d1>d2); } + + /// Comparison operator \c >=. + /** Allows the comparison \c d1 \c >= \c d2. \param d1 The first NOMAD::Double -- \b IN. \param d2 The second NOMAD::Double -- \b IN. \return A boolean equal to true if \c d1 \c >= \c d2. - */ inline bool operator >= ( const Double & d1 , const Double & d2 ) - { - return !(d1<d2); - } + */ + inline bool operator >= ( const Double & d1 , const Double & d2 ) + { + return !(d1<d2); + } + + /// Largest of two values \c >=. + /** + Return the largest of two NOMAD::Double + \param d1 The first NOMAD::Double -- \b IN. + \param d2 The second NOMAD::Double -- \b IN. + \return A NOMAD::Double equal to the max(d1,d2) + */ + inline Double max (const Double d1 , const Double d2 ) { return (d1>d2)?d1:d2; } + + /// Smallest of two values \c >=. + /** + Return the largest of two NOMAD::Double + \param d1 The first NOMAD::Double -- \b IN. + \param d2 The second NOMAD::Double -- \b IN. + \return A NOMAD::Double equal to the min(d1,d2) + */ + inline Double min ( const Double d1 , const Double d2 ) { return (d1<d2)?d1:d2; } + + + + + } #endif diff --git a/src/Eval_Point.cpp b/src/Eval_Point.cpp index fa193fe0ad3afcbb0eb020fe8d25134918a0519d..f862e1300ef0eb3cd56732a4d1ee7d8e9357a814 100644 --- a/src/Eval_Point.cpp +++ b/src/Eval_Point.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -48,6 +55,7 @@ /* static members initialization */ /*-----------------------------------*/ int NOMAD::Eval_Point::_current_tag = 0; + int NOMAD::Eval_Point::_current_bbe = 0; int NOMAD::Eval_Point::_current_sgte_bbe = 0; /*---------------------------------------------------------------------*/ @@ -128,7 +136,8 @@ _bb_outputs ( x.get_bb_outputs() ) for ( int i = 0 ; i < n ; ++i ) (*this)[i] = x.get_coord(i); - switch ( x.get_eval_status() ) { + switch ( x.get_eval_status() ) + { case 0: _eval_status = NOMAD::EVAL_FAIL; break; @@ -249,7 +258,9 @@ void NOMAD::Eval_Point::set_direction ( const NOMAD::Direction * dir ) void NOMAD::Eval_Point::set_poll_center ( const NOMAD::Eval_Point * pc ) { + _poll_center=pc; + } /*-------------------------------------------------------*/ @@ -257,7 +268,8 @@ void NOMAD::Eval_Point::set_poll_center ( const NOMAD::Eval_Point * pc ) /*-------------------------------------------------------*/ void NOMAD::Eval_Point::set_signature ( NOMAD::Signature * s ) { - if ( !s ) { + if ( !s ) + { _signature = NULL; return; } @@ -356,7 +368,8 @@ bool NOMAD::Eval_Point::treat_periodic_variables ( NOMAD::Direction *& new_dir ) /*--------------------------------------------------*/ bool NOMAD::Eval_Point::check ( int m , NOMAD::check_failed_type & cf ) const { - if ( size() <= 0 || !_signature || m != _bb_outputs.size() ) { + if ( size() <= 0 || !_signature || m != _bb_outputs.size() ) + { std::string err = "Eval_Point::check() could not procede"; if ( !_signature ) err += " (no signature)"; @@ -404,19 +417,22 @@ bool NOMAD::Eval_Point::check ( int m , NOMAD::check_failed_type & cf ) const // check the integer/categorical/binary variables: iti = input_types[i]; - if ( iti == NOMAD::BINARY && !xi.is_binary() ) { + if ( iti == NOMAD::BINARY && !xi.is_binary() ) + { cf = NOMAD::BIN_FAIL; return false; } if ( ( iti == NOMAD::INTEGER || iti == NOMAD::CATEGORICAL ) - && !xi.is_integer() ) { + && !xi.is_integer() ) + { cf = ( iti == NOMAD::INTEGER ) ? NOMAD::INT_FAIL : NOMAD::CAT_FAIL; return false; } // check the fixed-variables: const NOMAD::Double & fvi = fv[i]; - if ( fvi.is_defined() && fvi != xi ) { + if ( fvi.is_defined() && fvi != xi ) + { cf = NOMAD::FIX_VAR_FAIL; return false; } @@ -438,7 +454,8 @@ void NOMAD::Eval_Point::display_tag ( const NOMAD::Display & out ) const /*--------------------------------------------------*/ void NOMAD::Eval_Point::display_eval( const NOMAD::Display & out , bool in_block ) const { - if ( in_block ) { + if ( in_block ) + { std::ostringstream oss; oss << "#" << _tag; @@ -455,7 +472,9 @@ void NOMAD::Eval_Point::display_eval( const NOMAD::Display & out , bool in_block out << "f = " << _f << std::endl; out.close_block(); } - else { + else + { + display_tag ( out ); out << " x=( "; NOMAD::Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); @@ -498,8 +517,10 @@ bool NOMAD::Eval_Point::operator < ( const NOMAD::Eval_Point & x ) const bool NOMAD::Eval_Point::check_nan ( void ) const { int m = _bb_outputs.size(); - for ( int i = 0 ; i < m ; ++i ) { - if ( _bb_outputs[i].is_defined() ) { + for ( int i = 0 ; i < m ; ++i ) + { + if ( _bb_outputs[i].is_defined() ) + { #ifdef WINDOWS if ( isnan ( _bb_outputs[i].value() ) ) return true; diff --git a/src/Eval_Point.hpp b/src/Eval_Point.hpp index 64184038d35c779ebae5d33517c53f99188023a6..050efcad403c6342f7356cffd09278e08bd3cc1a 100644 --- a/src/Eval_Point.hpp +++ b/src/Eval_Point.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -64,16 +71,16 @@ namespace NOMAD { private: - static int _current_tag; ///< Current tag for all NOMAD::Eval_Point objects. - int _tag; ///< Unique tag. + static int _current_tag; ///< Current tag for all NOMAD::Eval_Point objects. + int _tag; ///< Unique tag. - static int _current_bbe; ///< Current bbe for all NOMAD::Eval_Point objects - static int _current_sgte_bbe; ///< Current sgte_bbe for all NOMAD::Eval_Point objects . - int _bbe; /// Recorded bbe for current NOMAD::Eval_Point object - int _sgte_bbe; /// Recorded sgte_bbe for current NOMAD::Eval_Point object - int _real_time; /// Recorded time for current NOMAD::Eval_Point object + static int _current_bbe; ///< Current bbe for all NOMAD::Eval_Point objects + static int _current_sgte_bbe; ///< Current sgte_bbe for all NOMAD::Eval_Point objects . + int _bbe; /// Recorded bbe for current NOMAD::Eval_Point object + int _sgte_bbe; /// Recorded sgte_bbe for current NOMAD::Eval_Point object + int _real_time; /// Recorded time for current NOMAD::Eval_Point object - NOMAD::Signature * _signature; ///< Signature of the point. + NOMAD::Signature * _signature; ///< Signature of the point. /** \c f is explicitely computed by a NOMAD::Evaluator object @@ -301,7 +308,6 @@ namespace NOMAD { */ const NOMAD::Eval_Point * get_poll_center ( void ) const { return _poll_center ; } - /// Check if the point has been generated during the current run. /** \return A boolean equal to \c true if the point has been @@ -552,7 +558,7 @@ namespace NOMAD { /// Reset the tags and bbes /** - */ + */ static void reset_tags_and_bbes ( void ) {_current_tag = 0;_current_bbe = 0;_current_sgte_bbe = 0;} #ifdef MODEL_STATS diff --git a/src/Evaluator.cpp b/src/Evaluator.cpp index f0f8ca91374a2a05ea9ec05f51302e8593c85cd1..278b662efa4410b9be8560827e13efc26e2d803d 100644 --- a/src/Evaluator.cpp +++ b/src/Evaluator.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -56,774 +63,785 @@ bool NOMAD::Evaluator::_force_quit = false; /* . _bb_exe includes the blackbox path */ /*-----------------------------------------------------------------*/ NOMAD::Evaluator::Evaluator ( const NOMAD::Parameters & p ) -: _p ( p ) , -_is_multi_obj ( false ) , -_is_model_evaluator ( false ) +: _p ( p ) , +_is_multi_obj ( false ) , +_is_model_evaluator ( false ) { - NOMAD::Evaluator::_force_quit = false; - - if ( _p.get_bb_exe().empty() ) - return; - - // _bbe_exe and _bb_nbo construction: - std::list<std::string>::const_iterator it = _p.get_bb_exe().begin(); - _bb_exe.push_back(*it); - _bb_nbo.push_back(1); - ++it; - - std::list<std::string>::const_iterator end = _p.get_bb_exe().end(); - while ( it != end ) + NOMAD::Evaluator::_force_quit = false; + + if ( _p.get_bb_exe().empty() ) + return; + + // _bbe_exe and _bb_nbo construction: + std::list<std::string>::const_iterator it = _p.get_bb_exe().begin(); + _bb_exe.push_back(*it); + _bb_nbo.push_back(1); + ++it; + + std::list<std::string>::const_iterator end = _p.get_bb_exe().end(); + while ( it != end ) { - if ( *it != _bb_exe[_bb_exe.size()-1] ) + if ( *it != _bb_exe[_bb_exe.size()-1] ) { - _bb_exe.push_back(*it); - _bb_nbo.push_back(1); - } - else - ++_bb_nbo[_bb_exe.size()-1]; - ++it; - } - - // we check that _bb_exe contains unique names and we add the problem path: - size_t k , l , n = _bb_exe.size() , nm1 = n-1; - for ( k = 0 ; k < nm1 ; ++k ) + _bb_exe.push_back(*it); + _bb_nbo.push_back(1); + } + else + ++_bb_nbo[_bb_exe.size()-1]; + ++it; + } + + // we check that _bb_exe contains unique names and we add the problem path: + size_t k , l , n = _bb_exe.size() , nm1 = n-1; + for ( k = 0 ; k < nm1 ; ++k ) { - for ( l = k+1 ; l < n ; ++l ) - if ( _bb_exe[k] == _bb_exe[l] ) - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , - "problem with executable names" ); - } - - // construction of _sgte_exe: - bool has_sgte_exe = _p.has_sgte_exe(); - std::string err; - if ( has_sgte_exe ) + for ( l = k+1 ; l < n ; ++l ) + if ( _bb_exe[k] == _bb_exe[l] ) + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , + "problem with executable names" ); + } + + // construction of _sgte_exe: + bool has_sgte_exe = _p.has_sgte_exe(); + std::string err; + if ( has_sgte_exe ) { - for ( k = 0 ; k < n ; ++k ) + for ( k = 0 ; k < n ; ++k ) { - - _sgte_exe.push_back ( _p.get_sgte_exe(_bb_exe[k]) ); - - if ( _sgte_exe[_sgte_exe.size()-1].empty() ) + + _sgte_exe.push_back ( _p.get_sgte_exe(_bb_exe[k]) ); + + if ( _sgte_exe[_sgte_exe.size()-1].empty() ) { - err = "blackbox executable \'" + _bb_exe[k] + "\' has no surrogate"; - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err ); - } - } - } - - // process blakc-box executables (check and add problem path): - for ( k = 0 ; k < n ; ++k ) + err = "blackbox executable \'" + _bb_exe[k] + "\' has no surrogate"; + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err ); + } + } + } + + // process blakc-box executables (check and add problem path): + for ( k = 0 ; k < n ; ++k ) { - process_bb_exe_name ( _bb_exe[k] ); - if ( has_sgte_exe ) - process_bb_exe_name ( _sgte_exe[k] ); - } - - // blackbox names and indexes display: + process_bb_exe_name ( _bb_exe[k] ); + if ( has_sgte_exe ) + process_bb_exe_name ( _sgte_exe[k] ); + } + + // blackbox names and indexes display: #ifdef DEBUG #ifdef USE_MPI - int rank; - MPI_Comm_rank ( MPI_COMM_WORLD, &rank); - if ( rank == 0 ) - { + int rank; + MPI_Comm_rank ( MPI_COMM_WORLD, &rank); + if ( rank == 0 ) #else - { + { #endif - const NOMAD::Display & out = _p.out(); - if ( !_bb_exe.empty() ) - { - out << std::endl - << NOMAD::open_block ( "blackbox executables" ); - for ( k = 0 ; k < n ; ++k ) - { - out << NOMAD::open_block ( "bb #" + NOMAD::itos(k) ) - << _bb_exe[k] << std::endl - << "number of outputs=" << _bb_nbo[k] << std::endl - << NOMAD::close_block(); - } - out.close_block(); - } - if ( !_sgte_exe.empty() ) + const NOMAD::Display & out = _p.out(); + if ( !_bb_exe.empty() ) + { + out << std::endl + << NOMAD::open_block ( "blackbox executables" ); + for ( k = 0 ; k < n ; ++k ) { - out << std::endl - << NOMAD::open_block ( "surrogate executables" ); - for ( k = 0 ; k < n ; ++k ) - out << "sgte #" << static_cast<int>(k) << ": " - << _sgte_exe[k] << std::endl; - out.close_block(); - } - } + out << NOMAD::open_block ( "bb #" + NOMAD::itos(k) ) + << _bb_exe[k] << std::endl + << "number of outputs=" << _bb_nbo[k] << std::endl + << NOMAD::close_block(); + } + out.close_block(); + } + if ( !_sgte_exe.empty() ) + { + out << std::endl + << NOMAD::open_block ( "surrogate executables" ); + for ( k = 0 ; k < n ; ++k ) + out << "sgte #" << static_cast<int>(k) << ": " + << _sgte_exe[k] << std::endl; + out.close_block(); + } + } #endif +} + +/*----------------------------------------------------------------*/ +/* process a blackbox executable name (private) */ +/*----------------------------------------------------------------*/ +void NOMAD::Evaluator::process_bb_exe_name ( std::string & bb_exe ) const +{ + std::string err; + std::list<std::string> bb_exe_words; + + NOMAD::get_words ( bb_exe , bb_exe_words ); + + if ( bb_exe_words.empty() ) + { + err = "problem with executable \'" + bb_exe + "\'"; + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err ); } - - /*----------------------------------------------------------------*/ - /* process a blackbox executable name (private) */ - /*----------------------------------------------------------------*/ - void NOMAD::Evaluator::process_bb_exe_name ( std::string & bb_exe ) const - { - std::string err; - std::list<std::string> bb_exe_words; - - NOMAD::get_words ( bb_exe , bb_exe_words ); - - if ( bb_exe_words.empty() ) + + std::string problem_dir = _p.get_problem_dir(); + + // bb_exe is composed of several words (it is a command): + if ( bb_exe_words.size() > 1 ) + { + + bb_exe.clear(); + + std::list<std::string>::const_iterator it = bb_exe_words.begin() , + end = bb_exe_words.end(); + while (true) { - err = "problem with executable \'" + bb_exe + "\'"; - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err ); - } - - std::string problem_dir = _p.get_problem_dir(); - - // bb_exe is composed of several words (it is a command): - if ( bb_exe_words.size() > 1 ) + + if ( (*it)[0] != '$' ) + { + bb_exe += "\"" + problem_dir; + bb_exe += *it + "\""; + } + else + bb_exe += it->substr ( 1 , it->size()-1 ); + + ++it; + + if ( it == end ) + break; + + bb_exe += " "; + } + } + + // bb_exe is just composed of one name (it is an executable): + else + { + + if ( bb_exe[0] != '$' ) + bb_exe = problem_dir + bb_exe; + else + bb_exe = bb_exe.substr ( 1 , bb_exe.size()-1 ); + if ( !NOMAD::check_exe_file ( bb_exe ) ) { - - bb_exe.clear(); - - std::list<std::string>::const_iterator it = bb_exe_words.begin() , - end = bb_exe_words.end(); - while (true) + err = "\'" + bb_exe + "\' is not a valid executable file"; + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err ); + } + if ( bb_exe[0] != '$' ) + bb_exe = "\"" + bb_exe + "\""; + } +} + +/*-----------------------------------------------------------------------*/ +/* check the constraints to decide if an evaluation have to be stopped */ +/*-----------------------------------------------------------------------*/ +/* . checked when h > h_max or if a 'EB' constraint is violated */ +/* . private method */ +/*-----------------------------------------------------------------------*/ +bool NOMAD::Evaluator::interrupt_evaluations ( const NOMAD::Eval_Point & x , + const NOMAD::Double & h_max ) const +{ + int nbo = _p.get_bb_nb_outputs(); + const NOMAD::Point & bbo = x.get_bb_outputs(); + const std::vector<NOMAD::bb_output_type> & bbot = _p.get_bb_output_type(); + NOMAD::Double h = 0.0; + bool check_h = h_max.is_defined(); + + for ( int i = 0 ; i < nbo ; ++i ) + { + + if ( bbo[i].is_defined() && + ( bbot[i] == NOMAD::EB || bbot[i] == NOMAD::PEB_E ) && + bbo[i] > _p.get_h_min() ) + return true; + + if ( check_h && bbo[i].is_defined() && + (bbot[i] == NOMAD::FILTER || + bbot[i] == NOMAD::PB || + bbot[i] == NOMAD::PEB_P ) ) + { + + if ( bbo[i] > _p.get_h_min() ) { - - if ( (*it)[0] != '$' ) + switch ( _p.get_h_norm() ) { - bb_exe += "\"" + problem_dir; - bb_exe += *it + "\""; - } - else - bb_exe += it->substr ( 1 , it->size()-1 ); - - ++it; - - if ( it == end ) - break; - - bb_exe += " "; - } - } - - // bb_exe is just composed of one name (it is an executable): - else { - if ( bb_exe[0] != '$' ) - bb_exe = problem_dir + bb_exe; - else - bb_exe = bb_exe.substr ( 1 , bb_exe.size()-1 ); - if ( !NOMAD::check_exe_file ( bb_exe ) ) - { - err = "\'" + bb_exe + "\' is not a valid executable file"; - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err ); - } - if ( bb_exe[0] != '$' ) - bb_exe = "\"" + bb_exe + "\""; - } - } - - /*-----------------------------------------------------------------------*/ - /* check the constraints to decide if an evaluation have to be stopped */ - /*-----------------------------------------------------------------------*/ - /* . checked when h > h_max or if a 'EB' constraint is violated */ - /* . private method */ - /*-----------------------------------------------------------------------*/ - bool NOMAD::Evaluator::interrupt_evaluations ( const NOMAD::Eval_Point & x , - const NOMAD::Double & h_max ) const - { - int nbo = _p.get_bb_nb_outputs(); - const NOMAD::Point & bbo = x.get_bb_outputs(); - const std::vector<NOMAD::bb_output_type> & bbot = _p.get_bb_output_type(); - NOMAD::Double h = 0.0; - bool check_h = h_max.is_defined(); - - for ( int i = 0 ; i < nbo ; ++i ) { - - if ( bbo[i].is_defined() && - ( bbot[i] == NOMAD::EB || bbot[i] == NOMAD::PEB_E ) && - bbo[i] > _p.get_h_min() ) - return true; - - if ( check_h && bbo[i].is_defined() && - (bbot[i] == NOMAD::FILTER || - bbot[i] == NOMAD::PB || - bbot[i] == NOMAD::PEB_P ) ) { - - if ( bbo[i] > _p.get_h_min() ) { - switch ( _p.get_h_norm() ) { - case NOMAD::L1: - h += bbo[i]; - break; - case NOMAD::L2: - h += bbo[i].pow2(); - break; - case NOMAD::LINF: - if ( bbo[i] > h ) - h = bbo[i]; - break; - } - - if ( _p.get_h_norm() == NOMAD::L2 ) { - if ( h > h_max.pow2() ) - return true; - } - else if ( h > h_max ) - return true; - } - } - } - return false; - } - - /*--------------------------------------------------------*/ - /* compute f(x) from the blackbox outputs of a point */ - /* (define a Multi_Obj_Evaluator to treat more than */ - /* one objective) */ - /*--------------------------------------------------------*/ - void NOMAD::Evaluator::compute_f ( NOMAD::Eval_Point & x ) const - { - if ( x.get_bb_outputs().size() != _p.get_bb_nb_outputs() ) { - std::ostringstream err; - err << "Evaluator::compute_f(x): x has a wrong number of blackbox outputs (" - << x.get_bb_outputs().size() << " != " - << _p.get_bb_nb_outputs() << ")"; - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err.str() ); - } - - x.set_f ( x.get_bb_outputs()[*(_p.get_index_obj().begin())] ); - } - - /*--------------------------------------------------------*/ - /* compute h(x) from the blackbox outputs of a point */ - /* set also the flag 'EB_ok' of the point */ - /*--------------------------------------------------------*/ - void NOMAD::Evaluator::compute_h ( NOMAD::Eval_Point & x ) const - { - if ( x.get_bb_outputs().size() != _p.get_bb_nb_outputs() ) + case NOMAD::L1: + h += bbo[i]; + break; + case NOMAD::L2: + h += bbo[i].pow2(); + break; + case NOMAD::LINF: + if ( bbo[i] > h ) + h = bbo[i]; + break; + } + + if ( _p.get_h_norm() == NOMAD::L2 ) + { + if ( h > h_max.pow2() ) + return true; + } + else if ( h > h_max ) + return true; + } + } + } + return false; +} + +/*--------------------------------------------------------*/ +/* compute f(x) from the blackbox outputs of a point */ +/* (define a Multi_Obj_Evaluator to treat more than */ +/* one objective) */ +/*--------------------------------------------------------*/ +void NOMAD::Evaluator::compute_f ( NOMAD::Eval_Point & x ) const +{ + if ( x.get_bb_outputs().size() != _p.get_bb_nb_outputs() ) + { + std::ostringstream err; + err << "Evaluator::compute_f(x): x has a wrong number of blackbox outputs (" + << x.get_bb_outputs().size() << " != " + << _p.get_bb_nb_outputs() << ")"; + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err.str() ); + } + + x.set_f ( x.get_bb_outputs()[*(_p.get_index_obj().begin())] ); +} + +/*--------------------------------------------------------*/ +/* compute h(x) from the blackbox outputs of a point */ +/* set also the flag 'EB_ok' of the point */ +/*--------------------------------------------------------*/ +void NOMAD::Evaluator::compute_h ( NOMAD::Eval_Point & x ) const +{ + if ( x.get_bb_outputs().size() != _p.get_bb_nb_outputs() ) + { + std::ostringstream err; + err << "Evaluator::compute_h(x): x has a wrong number of blackbox outputs (" + << x.get_bb_outputs().size() << " != " + << _p.get_bb_nb_outputs() << ")"; + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err.str() ); + } + + int nbo = _p.get_bb_nb_outputs(); + const std::vector<NOMAD::bb_output_type> & bbot = _p.get_bb_output_type(); + const NOMAD::Point & bbo = x.get_bb_outputs(); + NOMAD::Double h = 0.0 , bboi; + + x.set_EB_ok ( true ); + + for ( int i = 0 ; i < nbo ; ++i ) + { + + bboi = bbo[i]; + + if ( bboi.is_defined() && + (bbot[i] == NOMAD::EB || bbot[i] == NOMAD::PEB_E ) && + bboi > _p.get_h_min() ) { - std::ostringstream err; - err << "Evaluator::compute_h(x): x has a wrong number of blackbox outputs (" - << x.get_bb_outputs().size() << " != " - << _p.get_bb_nb_outputs() << ")"; - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err.str() ); - } - - int nbo = _p.get_bb_nb_outputs(); - const std::vector<NOMAD::bb_output_type> & bbot = _p.get_bb_output_type(); - const NOMAD::Point & bbo = x.get_bb_outputs(); - NOMAD::Double h = 0.0 , bboi; - - x.set_EB_ok ( true ); - - for ( int i = 0 ; i < nbo ; ++i ) + h.clear(); + x.set_h ( h ); + x.set_EB_ok ( false ); + return; + } + + if ( bboi.is_defined() && + ( bbot[i] == NOMAD::FILTER || + bbot[i] == NOMAD::PB || + bbot[i] == NOMAD::PEB_P ) ) { - - bboi = bbo[i]; - - if ( bboi.is_defined() && - (bbot[i] == NOMAD::EB || bbot[i] == NOMAD::PEB_E ) && - bboi > _p.get_h_min() ) - { - h.clear(); - x.set_h ( h ); - x.set_EB_ok ( false ); - return; - } - - if ( bboi.is_defined() && - ( bbot[i] == NOMAD::FILTER || - bbot[i] == NOMAD::PB || - bbot[i] == NOMAD::PEB_P ) ) + if ( bboi > _p.get_h_min() ) { - if ( bboi > _p.get_h_min() ) - { - switch ( _p.get_h_norm() ) - { - case NOMAD::L1: - h += bboi; - break; - case NOMAD::L2: - h += bboi * bboi; - break; - case NOMAD::LINF: - if ( bboi > h ) - h = bboi; - break; - } - } - } - } - - if ( _p.get_h_norm() == NOMAD::L2 ) - h = h.sqrt(); - - x.set_h ( h ); - } - - /*-------------------------------------------------------------------*/ - /* . evaluate the black boxes at a given Eval_Point */ - /* . the function returns true if the evaluation did not fail */ - /* . set count_eval=true to count the evaluation */ - /* (unless the output value CNT_EVAL is defined and set to 1 */ - /* by the blackbox) */ - /*-------------------------------------------------------------------*/ - bool NOMAD::Evaluator::eval_x ( NOMAD::Eval_Point & x , - const NOMAD::Double & h_max , - bool & count_eval ) const - { - count_eval = false; - - if ( _bb_exe.empty() || !x.is_complete() ) - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , - "Evaluator: no BB_EXE is defined (blackbox executable names)" ); - - bool sgte = x.get_eval_type() == NOMAD::SGTE; - if ( sgte && _sgte_exe.empty() ) - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , - "Evaluator: no SGTE_EXE is defined (surrogate executable names)" ); - - int pid = NOMAD::get_pid(); - int seed = _p.get_seed(); - std::string tmp_dir = _p.get_tmp_dir(); - - std::ostringstream oss; - oss << "." << seed; - if ( pid != seed ) - oss << "." << pid; - oss << "." << x.get_tag() << "."; - const std::string & sint = oss.str(); - - // for the parallel version: no need to include the process rank in the names - // as the point tags are unique for all the processes: each process creates - // its own points and uses Eval_Point::set_tag() - - // blackbox input file writing: - // ---------------------------- - std::string bb_input_file_name = - tmp_dir + NOMAD::BLACKBOX_INPUT_FILE_PREFIX - + sint + NOMAD::BLACKBOX_INPUT_FILE_EXT; - - std::string bb_output_file_name = - tmp_dir + NOMAD::BLACKBOX_OUTPUT_FILE_PREFIX - + sint + NOMAD::BLACKBOX_OUTPUT_FILE_EXT; - - std::ofstream fout ( bb_input_file_name.c_str() ); - if ( fout.fail() ) - { - std::string err = "could not create file blackbox input file " + bb_input_file_name + ". \n \n #### Please check that write permission are granted for the working directory. #### "; - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err ); - } - - // include seed: - if ( _p.get_bb_input_include_seed() ) - fout << seed << " "; - - // include tag: - if ( _p.get_bb_input_include_tag() ) - fout << x.get_tag() << " "; - - fout.setf ( std::ios::fixed ); - fout.precision ( NOMAD::DISPLAY_PRECISION_BB ); - x.Point::display ( fout , " " , -1 , -1 ); - fout << std::endl; - - fout.close(); - - if ( fout.fail() ) - return false; - - x.set_eval_status ( NOMAD::EVAL_IN_PROGRESS ); - - std::string cmd , bb_exe; - std::ifstream fin; - bool failed; - NOMAD::Double d; - int j , nbbok; - int ibbo = 0; - - // system call to evaluate the blackbox: - // ------------------------------------- - size_t bn = _bb_exe.size(); - for ( size_t k = 0 ; k < bn ; ++k ) - { - - // executable name: - bb_exe = ( sgte ) ? _sgte_exe[k] : _bb_exe[k]; - - // system command: - cmd = bb_exe + " " + bb_input_file_name; - - // redirection ? if no, the blackbox has to create - // the output file 'bb_output_file_name': - if ( _p.get_bb_redirection() ) - cmd += " > " + bb_output_file_name; - + switch ( _p.get_h_norm() ) + { + case NOMAD::L1: + h += bboi; + break; + case NOMAD::L2: + h += bboi * bboi; + break; + case NOMAD::LINF: + if ( bboi > h ) + h = bboi; + break; + } + } + } + } + + if ( _p.get_h_norm() == NOMAD::L2 ) + h = h.sqrt(); + + x.set_h ( h ); +} + +/*-------------------------------------------------------------------*/ +/* . evaluate the black boxes at a given Eval_Point */ +/* . the function returns true if the evaluation did not fail */ +/* . set count_eval=true to count the evaluation */ +/* (unless the output value CNT_EVAL is defined and set to 1 */ +/* by the blackbox) */ +/*-------------------------------------------------------------------*/ +bool NOMAD::Evaluator::eval_x ( NOMAD::Eval_Point & x , + const NOMAD::Double & h_max , + bool & count_eval ) const +{ + count_eval = false; + + if ( _bb_exe.empty() || !x.is_complete() ) + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , + "Evaluator: no BB_EXE is defined (blackbox executable names)" ); + + bool sgte = x.get_eval_type() == NOMAD::SGTE; + if ( sgte && _sgte_exe.empty() ) + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , + "Evaluator: no SGTE_EXE is defined (surrogate executable names)" ); + + int pid = NOMAD::get_pid(); + int seed = _p.get_seed(); + std::string tmp_dir = _p.get_tmp_dir(); + + std::ostringstream oss; + oss << "." << seed; + if ( pid != seed ) + oss << "." << pid; + oss << "." << x.get_tag() << "."; + const std::string & sint = oss.str(); + + // for the parallel version: no need to include the process rank in the names + // as the point tags are unique for all the processes: each process creates + // its own points and uses Eval_Point::set_tag() + + // blackbox input file writing: + // ---------------------------- + std::string bb_input_file_name = + tmp_dir + NOMAD::BLACKBOX_INPUT_FILE_PREFIX + + sint + NOMAD::BLACKBOX_INPUT_FILE_EXT; + + std::string bb_output_file_name = + tmp_dir + NOMAD::BLACKBOX_OUTPUT_FILE_PREFIX + + sint + NOMAD::BLACKBOX_OUTPUT_FILE_EXT; + + std::ofstream fout ( bb_input_file_name.c_str() ); + if ( fout.fail() ) + { + std::string err = "could not create file blackbox input file " + bb_input_file_name + ". \n \n #### Please check that write permission are granted for the working directory. #### "; + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err ); + } + + // include seed: + if ( _p.get_bb_input_include_seed() ) + fout << seed << " "; + + // include tag: + if ( _p.get_bb_input_include_tag() ) + fout << x.get_tag() << " "; + + fout.setf ( std::ios::fixed ); + fout.precision ( NOMAD::DISPLAY_PRECISION_BB ); + x.Point::display ( fout , " " , -1 , -1 ); + fout << std::endl; + + fout.close(); + + if ( fout.fail() ) + return false; + + x.set_eval_status ( NOMAD::EVAL_IN_PROGRESS ); + + std::string cmd , bb_exe; + std::ifstream fin; + bool failed; + NOMAD::Double d; + int j , nbbok; + int ibbo = 0; + + // system call to evaluate the blackbox: + // ------------------------------------- + size_t bn = _bb_exe.size(); + for ( size_t k = 0 ; k < bn ; ++k ) + { + + // executable name: + bb_exe = ( sgte ) ? _sgte_exe[k] : _bb_exe[k]; + + // system command: + cmd = bb_exe + " " + bb_input_file_name; + + // redirection ? if no, the blackbox has to create + // the output file 'bb_output_file_name': + if ( _p.get_bb_redirection() ) + cmd += " > " + bb_output_file_name; + #ifdef DEBUG #ifdef USE_MPI - int rank; - MPI_Comm_rank ( MPI_COMM_WORLD, &rank); - _p.out() << "command(rank=" << rank - << ") = \'" << cmd << "\'" << std::endl; + int rank; + MPI_Comm_rank ( MPI_COMM_WORLD, &rank); + _p.out() << "command(rank=" << rank + << ") = \'" << cmd << "\'" << std::endl; #else - _p.out() << "command=\'" << cmd << "\'" << std::endl; + _p.out() << "command=\'" << cmd << "\'" << std::endl; #endif #endif - - // the evaluation: - { - int signal = system ( cmd.c_str() ); - - // catch the ctrl-c signal: - if ( signal == SIGINT ) - raise ( SIGINT ); - - // other evaluation error: - failed = ( signal != 0 ); - count_eval = true; - } - - // the evaluation failed (we stop the evaluations): - if ( failed ) - { - x.set_eval_status ( NOMAD::EVAL_FAIL ); - break; - } - - // reading of the blackbox output file: - // ------------------------------------ - else + + // the evaluation: + { + int signal = system ( cmd.c_str() ); + + // catch the ctrl-c signal: + if ( signal == SIGINT ) + raise ( SIGINT ); + + // other evaluation error: + failed = ( signal != 0 ); + count_eval = true; + } + + // the evaluation failed (we stop the evaluations): + if ( failed ) + { + x.set_eval_status ( NOMAD::EVAL_FAIL ); + break; + } + + // reading of the blackbox output file: + // ------------------------------------ + else + { + + // bb-output file reading: + fin.open ( bb_output_file_name.c_str() ); + + failed = false; + bool is_defined = true; + bool is_inf = false; + + // loop on the number of outputs for this blackbox: + nbbok = _bb_nbo[k]; + for ( j = 0 ; j < nbbok ; ++j ) + { + + fin >> d; + + if ( !d.is_defined() ) + { + is_defined = false; + break; + } + + if ( fin.fail() ) + { + failed = true; + break; + } + + if ( d.value() >= NOMAD::INF ) + { + is_inf = true; + break; + } + + x.set_bb_output ( ibbo++ , d ); + } + + fin.close(); + + // the evaluation failed: + if ( failed || !is_defined || is_inf ) + { + x.set_eval_status ( NOMAD::EVAL_FAIL ); + break; + } + + // stop the evaluations if h > h_max or if a 'EB' constraint is violated: + if ( k < _bb_exe.size() - 1 && interrupt_evaluations ( x , h_max ) ) + break; + } + } + + if ( x.get_eval_status() == NOMAD::EVAL_IN_PROGRESS ) + x.set_eval_status ( NOMAD::EVAL_OK ); + + // delete the blackbox input and output files: + // ------------------------------------------- + remove ( bb_input_file_name.c_str () ); + remove ( bb_output_file_name.c_str() ); + + // check the CNT_EVAL output: + // -------------------------- + int index_cnt_eval = _p.get_index_cnt_eval(); + if ( index_cnt_eval >= 0 && x.get_bb_outputs()[index_cnt_eval] == 0.0 ) + count_eval = false; + + return x.is_eval_ok(); + + +} + +/*-------------------------------------------------------------------*/ +/* . evaluate the black boxes at a list of given Eval_Points */ +/*-------------------------------------------------------------------*/ +bool NOMAD::Evaluator::eval_x ( std::list<NOMAD::Eval_Point *> & list_eval, + const NOMAD::Double & h_max , + std::list<bool> & list_count_eval) const +{ + + std::list<NOMAD::Eval_Point *>::iterator it; + std::list<NOMAD::Eval_Point *>::iterator it_begin=list_eval.begin(); + std::list<NOMAD::Eval_Point *>::iterator it_end=list_eval.end(); + std::list<bool>::iterator it_count=list_count_eval.begin(); + + if ( list_eval.size() !=list_count_eval.size()) + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , + "Evaluator: inconsistent size of list" ); + + if ( _bb_exe.empty()) + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , + "Evaluator: no BB_EXE is defined (blackbox executable names)" ); + + bool sgte = ((*it_begin)->get_eval_type() == NOMAD::SGTE); + if ( sgte && _sgte_exe.empty() ) + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , + "Evaluator: no SGTE_EXE is defined (surrogate executable names)" ); + + + + int pid = NOMAD::get_pid(); + int seed = _p.get_seed(); + std::string tmp_dir = _p.get_tmp_dir(); + + std::ostringstream oss; + oss << "." << seed; + if ( pid != seed ) + oss << "." << pid; + + for (it=it_begin;it!=it_end;++it) + { + if (!(*it)->is_complete() ) + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , + "Evaluator: points provided for evaluations are incomplete " ); + + } + // add the tag of the first point + oss << "." << (*it_begin)->get_tag(); + + oss << "." ; + const std::string & sint = oss.str(); + + // for the parallel version: no need to include the process rank in the names + // as the point tags are unique for all the processes: each process creates + // its own points and uses Eval_Point::set_tag() + + // blackbox input file writing: + // ---------------------------- + std::string bb_input_file_name = + tmp_dir + NOMAD::BLACKBOX_INPUT_FILE_PREFIX + + sint + NOMAD::BLACKBOX_INPUT_FILE_EXT; + + std::string bb_output_file_name = + tmp_dir + NOMAD::BLACKBOX_OUTPUT_FILE_PREFIX + + sint + NOMAD::BLACKBOX_OUTPUT_FILE_EXT; + + std::ofstream fout ( bb_input_file_name.c_str() ); + if ( fout.fail() ) + { + std::string err = "could not create file blackbox input file " + bb_input_file_name + ". \n \n #### Please check that write permission are granted for the working directory. #### "; + throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err ); + } + + + for (it=it_begin;it!=it_end;++it) + { + // include seed: + if ( _p.get_bb_input_include_seed() ) + fout << seed << " "; + + // include tag: + if ( _p.get_bb_input_include_tag() ) + fout << (*it)->get_tag() << " "; + + fout.setf ( std::ios::fixed ); + fout.precision ( NOMAD::DISPLAY_PRECISION_BB ); + (*it)->Point::display ( fout , " " , -1 , -1 ); + fout << std::endl; + } + + fout.close(); + + if ( fout.fail() ) + return false; + + for (it=it_begin;it!=it_end;++it) + (*it)->set_eval_status ( NOMAD::EVAL_IN_PROGRESS ); + + + std::string cmd , bb_exe; + std::ifstream fin; + bool failed; + NOMAD::Double d; + int j , nbbok; + int ibbo = 0; + + // system call to evaluate the blackboxes: + // ------------------------------------- + size_t bn = _bb_exe.size(); + for ( size_t k = 0 ; k < bn ; ++k ) + { + + // executable name: + bb_exe = ( sgte ) ? _sgte_exe[k] : _bb_exe[k]; + + // system command: + cmd = bb_exe + " " + bb_input_file_name; + + // redirection ? if no, the blackbox has to create + // the output file 'bb_output_file_name': + if ( _p.get_bb_redirection() ) + cmd += " > " + bb_output_file_name; + + + // the evaluation: + { + int signal = system ( cmd.c_str() ); + + // catch the ctrl-c signal: + if ( signal == SIGINT ) + raise ( SIGINT ); + + // other evaluation error: + failed = ( signal != 0 ); + } + + // the evaluation failed (we stop the evaluations): + if ( failed ) + { + it_count=list_count_eval.begin(); + for (it=it_begin;it!=it_end;++it,++it_count) { - - // bb-output file reading: - fin.open ( bb_output_file_name.c_str() ); - - failed = false; - bool is_defined = true; - bool is_inf = false; - - // loop on the number of outputs for this blackbox: - nbbok = _bb_nbo[k]; - for ( j = 0 ; j < nbbok ; ++j ) + (*it)->set_eval_status ( NOMAD::EVAL_FAIL ); + (*it_count)=true; // + } + break; + } + + // reading of the blackbox output file: + // ------------------------------------ + else + { + + // bb-output file reading: + fin.open ( bb_output_file_name.c_str() ); + + string s; + bool is_defined,is_inf; + + bool list_all_failed_eval=true; + bool list_all_interrupt=true; + + // loop on the points + it_count=list_count_eval.begin(); + for (it=it_begin;it!=it_end;++it,++it_count) + { + failed = false; + is_defined = true; + is_inf = false; + + // loop on the number of outputs for this blackbox: + nbbok = _bb_nbo[k]; + ibbo=0; + for ( j = 0 ; j < nbbok ; ++j ) { - - fin >> d; - - if ( !d.is_defined() ) + + fin >> s; + + if ( fin.fail() ) { - is_defined = false; - break; - } - - if ( fin.fail() ) + failed = true; + break; + } + + toupper(s); + if (s.compare("REJECT")==0) { - failed = true; - break; - } - - if ( d.value() >= NOMAD::INF ) + *it_count=false; // Rejected points are not counted + (*it)->set_eval_status(NOMAD::EVAL_USER_REJECT); + break; + } + else { - is_inf = true; - break; - } - - x.set_bb_output ( ibbo++ , d ); - } - - fin.close(); - - // the evaluation failed: - if ( failed || !is_defined || is_inf ) + d.atof(s); + (*it_count)=true; + } + // + + if (s.compare("FAIL")==0) + { + failed = true; + break; + } + + + if ( !d.is_defined() ) + { + is_defined = false; + break; + } + + + if ( d.value() >= NOMAD::INF ) + { + is_inf = true; + break; + } + + (*it)->set_bb_output ( ibbo++ , d ); + } + + + // the evaluation failed: + if ( failed || !is_defined || is_inf ) { - x.set_eval_status ( NOMAD::EVAL_FAIL ); - break; - } - - // stop the evaluations if h > h_max or if a 'EB' constraint is violated: - if ( k < _bb_exe.size() - 1 && interrupt_evaluations ( x , h_max ) ) - break; - } - } - - if ( x.get_eval_status() == NOMAD::EVAL_IN_PROGRESS ) - x.set_eval_status ( NOMAD::EVAL_OK ); - - // delete the blackbox input and output files: - // ------------------------------------------- - remove ( bb_input_file_name.c_str () ); - remove ( bb_output_file_name.c_str() ); - - // check the CNT_EVAL output: - // -------------------------- - int index_cnt_eval = _p.get_index_cnt_eval(); - if ( index_cnt_eval >= 0 && x.get_bb_outputs()[index_cnt_eval] == 0.0 ) - count_eval = false; - - return x.is_eval_ok(); - + (*it)->set_eval_status ( NOMAD::EVAL_FAIL ); + + } + else + list_all_failed_eval=false; - } - - - /*-------------------------------------------------------------------*/ - /* . evaluate the black boxes at a list of given Eval_Points */ - /*-------------------------------------------------------------------*/ - bool NOMAD::Evaluator::eval_x ( std::list<NOMAD::Eval_Point *> & list_eval, - const NOMAD::Double & h_max , - std::list<bool> & list_count_eval) const - { - - std::list<NOMAD::Eval_Point *>::iterator it; - std::list<NOMAD::Eval_Point *>::iterator it_begin=list_eval.begin(); - std::list<NOMAD::Eval_Point *>::iterator it_end=list_eval.end(); - std::list<bool>::iterator it_count=list_count_eval.begin(); - - if ( list_eval.size() !=list_count_eval.size()) - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , - "Evaluator: inconsistent size of list" ); - - if ( _bb_exe.empty()) - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , - "Evaluator: no BB_EXE is defined (blackbox executable names)" ); - - bool sgte = ((*it_begin)->get_eval_type() == NOMAD::SGTE); - if ( sgte && _sgte_exe.empty() ) - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , - "Evaluator: no SGTE_EXE is defined (surrogate executable names)" ); - - - - int pid = NOMAD::get_pid(); - int seed = _p.get_seed(); - std::string tmp_dir = _p.get_tmp_dir(); - - std::ostringstream oss; - oss << "." << seed; - if ( pid != seed ) - oss << "." << pid; - - for (it=it_begin;it!=it_end;++it) - { - if (!(*it)->is_complete() ) - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , - "Evaluator: points provided for evaluations are incomplete " ); + + // stop the evaluations if h > h_max or if a 'EB' constraint is violated: + if ( !( k < _bb_exe.size() - 1 && interrupt_evaluations ( *(*it) , h_max ) && list_all_interrupt )) + list_all_interrupt=false; + } - } - // add the tag of the first point - oss << "." << (*it_begin)->get_tag(); - - oss << "." ; - const std::string & sint = oss.str(); - - // for the parallel version: no need to include the process rank in the names - // as the point tags are unique for all the processes: each process creates - // its own points and uses Eval_Point::set_tag() - - // blackbox input file writing: - // ---------------------------- - std::string bb_input_file_name = - tmp_dir + NOMAD::BLACKBOX_INPUT_FILE_PREFIX - + sint + NOMAD::BLACKBOX_INPUT_FILE_EXT; - - std::string bb_output_file_name = - tmp_dir + NOMAD::BLACKBOX_OUTPUT_FILE_PREFIX - + sint + NOMAD::BLACKBOX_OUTPUT_FILE_EXT; - - std::ofstream fout ( bb_input_file_name.c_str() ); - if ( fout.fail() ) { - std::string err = "could not create file blackbox input file " + bb_input_file_name + ". \n \n #### Please check that write permission are granted for the working directory. #### "; - throw NOMAD::Exception ( "Evaluator.cpp" , __LINE__ , err ); - } - - - for (it=it_begin;it!=it_end;++it) - { - // include seed: - if ( _p.get_bb_input_include_seed() ) - fout << seed << " "; + fin.close(); - // include tag: - if ( _p.get_bb_input_include_tag() ) - fout << (*it)->get_tag() << " "; - - fout.setf ( std::ios::fixed ); - fout.precision ( NOMAD::DISPLAY_PRECISION_BB ); - (*it)->Point::display ( fout , " " , -1 , -1 ); - fout << std::endl; - } - - fout.close(); - - if ( fout.fail() ) - return false; - - for (it=it_begin;it!=it_end;++it) - (*it)->set_eval_status ( NOMAD::EVAL_IN_PROGRESS ); - - - std::string cmd , bb_exe; - std::ifstream fin; - bool failed; - NOMAD::Double d; - int j , nbbok; - int ibbo = 0; - - // system call to evaluate the blackboxes: - // ------------------------------------- - size_t bn = _bb_exe.size(); - for ( size_t k = 0 ; k < bn ; ++k ) - { - - // executable name: - bb_exe = ( sgte ) ? _sgte_exe[k] : _bb_exe[k]; - - // system command: - cmd = bb_exe + " " + bb_input_file_name; - - // redirection ? if no, the blackbox has to create - // the output file 'bb_output_file_name': - if ( _p.get_bb_redirection() ) - cmd += " > " + bb_output_file_name; - - - // the evaluation: - { - int signal = system ( cmd.c_str() ); - - // catch the ctrl-c signal: - if ( signal == SIGINT ) - raise ( SIGINT ); - - // other evaluation error: - failed = ( signal != 0 ); - } - - // the evaluation failed (we stop the evaluations): - if ( failed ) - { - it_count=list_count_eval.begin(); - for (it=it_begin;it!=it_end;++it,++it_count) - { - (*it)->set_eval_status ( NOMAD::EVAL_FAIL ); - (*it_count)=true; // - } - break; - } - - // reading of the blackbox output file: - // ------------------------------------ - else - { - - // bb-output file reading: - fin.open ( bb_output_file_name.c_str() ); - - string s; - bool is_defined,is_inf; - - bool list_all_failed_eval=true; - bool list_all_interrupt=true; - - // loop on the points - it_count=list_count_eval.begin(); - for (it=it_begin;it!=it_end;++it,++it_count) - { - failed = false; - is_defined = true; - is_inf = false; - - // loop on the number of outputs for this blackbox: - nbbok = _bb_nbo[k]; - ibbo=0; - for ( j = 0 ; j < nbbok ; ++j ) - { - fin >> s; - - if ( fin.fail() ) - { - failed = true; - break; - } - - toupper(s); - if (s.compare("REJECT")==0) - { - *it_count=false; // Rejected points are not counted - (*it)->set_eval_status(NOMAD::EVAL_USER_REJECT); - break; - } - else - { - d.atof(s); - (*it_count)=true; - } - // - - if (s.compare("FAIL")==0) - { - failed = true; - break; - } - - - if ( !d.is_defined() ) - { - is_defined = false; - break; - } - - - if ( d.value() >= NOMAD::INF ) { - is_inf = true; - break; - } - - (*it)->set_bb_output ( ibbo++ , d ); - } - - - // the evaluation failed: - if ( failed || !is_defined || is_inf ) - { - (*it)->set_eval_status ( NOMAD::EVAL_FAIL ); - - } else - list_all_failed_eval=false; - - - // stop the evaluations if h > h_max or if a 'EB' constraint is violated: - if ( !( k < _bb_exe.size() - 1 && interrupt_evaluations ( *(*it) , h_max ) && list_all_interrupt )) - list_all_interrupt=false; - } - - fin.close(); - if (list_all_failed_eval || list_all_interrupt) - break; - - } - } - - - // delete the blackbox input and output files: - // ------------------------------------------- - remove ( bb_input_file_name.c_str () ); - remove ( bb_output_file_name.c_str() ); - - bool at_least_one_eval_ok=false; - int index_cnt_eval = _p.get_index_cnt_eval(); - - - // update eval status and check that at least one was ok - it_count=list_count_eval.begin(); - for (it=it_begin;it!=it_end;++it,++it_count) - { - if ( (*it)->get_eval_status() == NOMAD::EVAL_IN_PROGRESS ) - (*it)->set_eval_status ( NOMAD::EVAL_OK ); - - if (!at_least_one_eval_ok && (*it)->is_eval_ok()) - at_least_one_eval_ok=true; - - // count_eval from bb_outputs: - // -------------------------- - if ( index_cnt_eval >= 0 && (*it)->get_bb_outputs()[index_cnt_eval]==0) - *it_count=false; - } - - return at_least_one_eval_ok; - } + if (list_all_failed_eval || list_all_interrupt) + break; + + } + } + + + // delete the blackbox input and output files: + // ------------------------------------------- + remove ( bb_input_file_name.c_str () ); + remove ( bb_output_file_name.c_str() ); + + bool at_least_one_eval_ok=false; + int index_cnt_eval = _p.get_index_cnt_eval(); + + + // update eval status and check that at least one was ok + it_count=list_count_eval.begin(); + for (it=it_begin;it!=it_end;++it,++it_count) + { + if ( (*it)->get_eval_status() == NOMAD::EVAL_IN_PROGRESS ) + (*it)->set_eval_status ( NOMAD::EVAL_OK ); + + if (!at_least_one_eval_ok && (*it)->is_eval_ok()) + at_least_one_eval_ok=true; + + // count_eval from bb_outputs: + // -------------------------- + if ( index_cnt_eval >= 0 && (*it)->get_bb_outputs()[index_cnt_eval]==0) + *it_count=false; + } + + return at_least_one_eval_ok; +} diff --git a/src/Evaluator.hpp b/src/Evaluator.hpp index 80119dffdf096da907174eb945ec622878999a3e..03d52a83628baa4bc04fa45baa9a732b2d98490e 100644 --- a/src/Evaluator.hpp +++ b/src/Evaluator.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -49,235 +56,237 @@ #include <list> namespace NOMAD { - - // forward declarations: - class Barrier; - class Pareto_Front; - class Evaluator_Control; - - /// Evaluation of blackbox functions. - /** + + // forward declarations: + class Barrier; + class Pareto_Front; + class Evaluator_Control; + + /// Evaluation of blackbox functions. + /** This class allows the evaluation of one trial point. - */ - class Evaluator : private NOMAD::Uncopyable { - - protected: - - /// Parameters. - const NOMAD::Parameters & _p; - - /// Multi-objective flag. - /** - Identifies if a NOMAD::Evaluator object refers to - a NOMAD::Multi_Obj_Evaluator for more than one - objective function. - */ - bool _is_multi_obj; - - /// Model flag. - /** - Identifies if a NOMAD::Evaluator object refers to - a NOMAD::***_Model_Evaluator - */ - bool _is_model_evaluator; - - private: - - /// Blackbox executable names. - /** - - Not the same as Parameters::_bb_exe. - - NOMAD::Evaluator::_bb_exe is constructed from + */ + class Evaluator : private NOMAD::Uncopyable { + + protected: + + /// Parameters. + const NOMAD::Parameters & _p; + + /// Multi-objective flag. + /** + Identifies if a NOMAD::Evaluator object refers to + a NOMAD::Multi_Obj_Evaluator for more than one + objective function. + */ + bool _is_multi_obj; + + /// Model flag. + /** + Identifies if a NOMAD::Evaluator object refers to + a NOMAD::***_Model_Evaluator + */ + bool _is_model_evaluator; + + private: + + /// Blackbox executable names. + /** + - Not the same as Parameters::_bb_exe. + - NOMAD::Evaluator::_bb_exe is constructed from NOMAD::Parameters::_bb_exe. - */ - std::vector<std::string> _bb_exe; - - std::vector<std::string> _sgte_exe; ///< Surrogate executable names. - - /// Number of outputs for each blackbox executable. - std::vector<int> _bb_nbo; - - static bool _force_quit; ///< Flag equal to \c true if ctrl-c is pressed. - - /// Check the constraints to decide if the evaluations have to be stopped. - /** - \param x Point at which the constraints are checked -- \b IN. - \param h_max Maximal feasibility value \c h_max -- \b IN. - \return A boolean equal to \c true if - the evaluations have to be stopped. - */ - bool interrupt_evaluations ( const NOMAD::Eval_Point & x , - const NOMAD::Double & h_max ) const; - - /// Process a blackbox executable name. - /** - \param bb_exe Executable name -- \b IN/OUT. - */ - void process_bb_exe_name ( std::string & bb_exe ) const; - - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - */ - Evaluator ( const NOMAD::Parameters & p ); - - /// Destructor. - virtual ~Evaluator ( void ) {} - - /// Force quit (called by pressing ctrl-c). - static void force_quit ( void ) + */ + std::vector<std::string> _bb_exe; + + std::vector<std::string> _sgte_exe; ///< Surrogate executable names. + + /// Number of outputs for each blackbox executable. + std::vector<int> _bb_nbo; + + static bool _force_quit; ///< Flag equal to \c true if ctrl-c is pressed. + + /// Check the constraints to decide if the evaluations have to be stopped. + /** + \param x Point at which the constraints are checked -- \b IN. + \param h_max Maximal feasibility value \c h_max -- \b IN. + \return A boolean equal to \c true if + the evaluations have to be stopped. + */ + bool interrupt_evaluations ( const NOMAD::Eval_Point & x , + const NOMAD::Double & h_max ) const; + + /// Process a blackbox executable name. + /** + \param bb_exe Executable name -- \b IN/OUT. + */ + void process_bb_exe_name ( std::string & bb_exe ) const; + + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + */ + Evaluator ( const NOMAD::Parameters & p ); + + /// Destructor. + virtual ~Evaluator ( void ) {} + + /// Force quit (called by pressing ctrl-c). + static void force_quit ( void ) { NOMAD::Evaluator::_force_quit = true; } - - /// Access to the \c force_quit flag. - /** - \return The \c force_quit flag. - */ - static bool get_force_quit ( void ) + + /// Access to the \c force_quit flag. + /** + \return The \c force_quit flag. + */ + static bool get_force_quit ( void ) { return NOMAD::Evaluator::_force_quit; } - - /// Access to the multi-objective flag. - /** - \return The multi-objective flag. - */ - bool is_multi_obj ( void ) const + + /// Access to the multi-objective flag. + /** + \return The multi-objective flag. + */ + bool is_multi_obj ( void ) const { return _is_multi_obj; } - - /// Access to the model evaluator flag. - /** - \return The model evaluator flag. - */ - virtual bool is_model_evaluator ( void ) const + + /// Access to the model evaluator flag. + /** + \return The model evaluator flag. + */ + virtual bool is_model_evaluator ( void ) const { return _is_model_evaluator; } - - /// User pre-processing of a list of points. - /** - - This virtual method is called before the evaluation of a list + + /// User pre-processing of a list of points. + /** + - This virtual method is called before the evaluation of a list of points. - - It allows the user to pre-process the points to be evaluated. - \param pts The list of points -- \b IN/OUT. - */ - virtual void list_of_points_preprocessing - ( std::set<Priority_Eval_Point> & pts ) const {} - - /// User updates after a success. - /** - This virtual method is called every time a new (full) success is made. - \param stats Stats -- \b IN. - \param x Last successful point -- \b IN. - */ - virtual void update_success ( const NOMAD::Stats & stats , - const NOMAD::Eval_Point & x ) {} - - /// User updates after an iteration. - /** - This virtual method is called every time a MADS iteration is terminated. - \param success Success of the iteration -- \b IN. - \param stats Stats -- \b IN. - \param ev_control The NOMAD::Evaluator_Control object -- \b IN. - \param true_barrier Barrier for true evaluations -- \b IN. - \param sgte_barrier Barrier for surrogate evaluations -- \b IN. - \param pareto_front Pareto front -- \b IN. - \param stop Allows the user to stop the algorithm -- \b OUT. - */ - virtual void update_iteration ( NOMAD::success_type success , - const NOMAD::Stats & stats , - const NOMAD::Evaluator_Control & ev_control , - const NOMAD::Barrier & true_barrier , - const NOMAD::Barrier & sgte_barrier , - const NOMAD::Pareto_Front & pareto_front , - bool & stop ) {} - - /// Evaluate the blackbox functions at a given trial point (#1). - /** - - Const version. - - May be user-defined. - - Surrogate or true evaluation depending on the value of \c x.is_surrogate(). - \param x The trial point -- \b IN/OUT. - \param h_max Maximal feasibility value \c h_max -- \b IN. - \param count_eval Flag indicating if the evaluation has to be counted - or not -- \b OUT. - \return A boolean equal to \c false if the evaluation failed. - */ - virtual bool eval_x ( NOMAD::Eval_Point & x , - const NOMAD::Double & h_max , - bool & count_eval ) const; - - /// Evaluate the blackbox functions at a given trial point (#2). - /** - - Non-const version. - - Calls the const version by default. - - May be user-defined. - - Surrogate or true evaluation depending on the value of \c x.is_surrogate(). - \param x The trial point -- \b IN/OUT. - \param h_max Maximal feasibility value \c h_max -- \b IN. - \param count_eval Flag indicating if the evaluation has to be counted - or not -- \b OUT. - \return A boolean equal to \c false if the evaluation failed. - */ - virtual bool eval_x ( NOMAD::Eval_Point & x , - const NOMAD::Double & h_max , - bool & count_eval ) - { - return static_cast<const Evaluator *>(this)->eval_x ( x , h_max , count_eval ); - } - - - - /// Evaluate the blackbox functions at a given list of trial points (#1). - /** - - Const version. - - May be user-defined. - - Surrogate or true evaluation depending on the value of \c x.is_surrogate(). - \param x The list of trial points -- \b IN/OUT. - \param h_max Maximal feasibility value \c h_max -- \b IN. - \param count_eval Number of evaluations that are counted -- \b OUT. - \return A boolean equal to \c false if the evaluation failed. - */ - virtual bool eval_x ( std::list<NOMAD::Eval_Point *> &x , - const NOMAD::Double & h_max, - std::list<bool> & count_eval ) const; - - - /// Evaluate the blackbox functions at a given list of trial points (#2). - /** - - Non-Const version. - - May be user-defined. - - Surrogate or true evaluation depending on the value of \c x.is_surrogate(). - \param x The list of trial points -- \b IN/OUT. - \param h_max Maximal feasibility value \c h_max -- \b IN. - \param count_eval Number of evaluations that are counted -- \b OUT. - \return A boolean equal to \c false if the evaluation failed. - */ - virtual bool eval_x ( std::list<NOMAD::Eval_Point *> &x , - const NOMAD::Double & h_max, - std::list<bool> & count_eval ) - { - return static_cast<const Evaluator *>(this)->eval_x ( x , h_max , count_eval ); - } - - - - /// Compute the objective value \c f(x) from the blackbox outputs of a point. - /** - \param x The point -- \b IN/OUT. - */ - virtual void compute_f ( NOMAD::Eval_Point & x ) const; - - /// Compute the feasibility value \c h(x) from the blackbox outputs of a point. - /** - \param x The point -- \b IN/OUT. - */ - void compute_h ( NOMAD::Eval_Point & x ) const; - }; + - It allows the user to pre-process the points to be evaluated. + \param pts The list of points -- \b IN/OUT. + */ + virtual void list_of_points_preprocessing + ( std::set<Priority_Eval_Point> & pts ) const {} + + /// User updates after a success. + /** + This virtual method is called every time a new (full) success is made. + \param stats Stats -- \b IN. + \param x Last successful point -- \b IN. + */ + virtual void update_success ( const NOMAD::Stats & stats , + const NOMAD::Eval_Point & x ) {} + + /// User updates after an iteration. + /** + This virtual method is called every time a MADS iteration is terminated. + \param success Success of the iteration -- \b IN. + \param stats Stats -- \b IN. + \param ev_control The NOMAD::Evaluator_Control object -- \b IN. + \param true_barrier Barrier for true evaluations -- \b IN. + \param sgte_barrier Barrier for surrogate evaluations -- \b IN. + \param pareto_front Pareto front -- \b IN. + \param stop Allows the user to stop the algorithm -- \b OUT. + */ + virtual void update_iteration ( NOMAD::success_type success , + const NOMAD::Stats & stats , + const NOMAD::Evaluator_Control & ev_control , + const NOMAD::Barrier & true_barrier , + const NOMAD::Barrier & sgte_barrier , + const NOMAD::Pareto_Front & pareto_front , + bool & stop ) {} + + /// Evaluate the blackbox functions at a given trial point (#1). + /** + - Const version. + - May be user-defined. + - Surrogate or true evaluation depending on the value of \c x.is_surrogate(). + \param x The trial point -- \b IN/OUT. + \param h_max Maximal feasibility value \c h_max -- \b IN. + \param count_eval Flag indicating if the evaluation has to be counted + or not -- \b OUT. + \return A boolean equal to \c false if the evaluation failed. + */ + virtual bool eval_x ( NOMAD::Eval_Point & x , + const NOMAD::Double & h_max , + bool & count_eval ) const; + + /// Evaluate the blackbox functions at a given trial point (#2). + /** + - Non-const version. + - Calls the const version by default. + - May be user-defined. + - Surrogate or true evaluation depending on the value of \c x.is_surrogate(). + \param x The trial point -- \b IN/OUT. + \param h_max Maximal feasibility value \c h_max -- \b IN. + \param count_eval Flag indicating if the evaluation has to be counted + or not -- \b OUT. + \return A boolean equal to \c false if the evaluation failed. + */ + virtual bool eval_x ( NOMAD::Eval_Point & x , + const NOMAD::Double & h_max , + bool & count_eval ) + { + + return static_cast<const Evaluator *>(this)->eval_x ( x , h_max , count_eval ); + + } + + + + /// Evaluate the blackbox functions at a given list of trial points (#1). + /** + - Const version. + - May be user-defined. + - Surrogate or true evaluation depending on the value of \c x.is_surrogate(). + \param x The list of trial points -- \b IN/OUT. + \param h_max Maximal feasibility value \c h_max -- \b IN. + \param count_eval Number of evaluations that are counted -- \b OUT. + \return A boolean equal to \c false if the evaluation failed. + */ + virtual bool eval_x ( std::list<NOMAD::Eval_Point *> &x , + const NOMAD::Double & h_max, + std::list<bool> & count_eval ) const; + + + /// Evaluate the blackbox functions at a given list of trial points (#2). + /** + - Non-Const version. + - May be user-defined. + - Surrogate or true evaluation depending on the value of \c x.is_surrogate(). + \param x The list of trial points -- \b IN/OUT. + \param h_max Maximal feasibility value \c h_max -- \b IN. + \param count_eval Number of evaluations that are counted -- \b OUT. + \return A boolean equal to \c false if the evaluation failed. + */ + virtual bool eval_x ( std::list<NOMAD::Eval_Point *> &x , + const NOMAD::Double & h_max, + std::list<bool> & count_eval ) + { + return static_cast<const Evaluator *>(this)->eval_x ( x , h_max , count_eval ); + } + + + + /// Compute the objective value \c f(x) from the blackbox outputs of a point. + /** + \param x The point -- \b IN/OUT. + */ + virtual void compute_f ( NOMAD::Eval_Point & x ) const; + + /// Compute the feasibility value \c h(x) from the blackbox outputs of a point. + /** + \param x The point -- \b IN/OUT. + */ + void compute_h ( NOMAD::Eval_Point & x ) const; + }; } #endif diff --git a/src/Evaluator_Control.cpp b/src/Evaluator_Control.cpp index 77b5c10cdb0a56e7c04500d473ca288a0813e75a..d0873d06ef2d7a735ed7f05dc8e0318f8a49ca5d 100644 --- a/src/Evaluator_Control.cpp +++ b/src/Evaluator_Control.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Evaluator_Control.cpp - \brief Control of the blackbox evaluations (implementation) - \author Sebastien Le Digabel - \date 2010-04-15 - \see Evaluator_Control.hpp -*/ + \file Evaluator_Control.cpp + \brief Control of the blackbox evaluations (implementation) + \author Sebastien Le Digabel + \date 2010-04-15 + \see Evaluator_Control.hpp + */ #include "Evaluator_Control.hpp" #include "Multi_Obj_Quad_Model_Evaluator.hpp" #include "Single_Obj_Quad_Model_Evaluator.hpp" @@ -54,125 +61,129 @@ bool NOMAD::Evaluator_Control::_force_evaluation_failure = false; /*---------------------------------------------------------*/ /* constructor */ /*---------------------------------------------------------*/ -NOMAD::Evaluator_Control::Evaluator_Control -( const NOMAD::Parameters & p , - NOMAD::Stats & stats , - NOMAD::Evaluator * ev , // can be NULL - NOMAD::Cache * cache , // can be NULL - NOMAD::Cache * sgte_cache ) // can be NULL - : _p ( p ) , - _ev ( ev ) , - _cache ( cache ) , - _sgte_cache ( sgte_cache ) , - _model_eval_sort ( true ) , - _del_ev ( false ) , - _del_cache ( false ) , - _del_sgte_cache ( false ) , +NOMAD::Evaluator_Control::Evaluator_Control ( const NOMAD::Parameters & p , + NOMAD::Stats & stats , + NOMAD::Evaluator * ev , // can be NULL + NOMAD::Cache * cache , // can be NULL + NOMAD::Cache * sgte_cache ) // can be NULL +: _p ( p ) , +_ev ( ev ) , +_cache ( cache ) , +_sgte_cache ( sgte_cache ) , +_model_eval_sort ( true ) , +_del_ev ( false ) , +_del_cache ( false ) , +_del_sgte_cache ( false ) , #ifdef USE_MPI - _eval_in_progress ( NULL ) , - _nb_in_progress ( 0 ) , - _elop_tag ( 0 ) , - _slaves_elop_tags ( NULL ) , - _slave ( NULL ) , -#endif -#ifdef USE_TGP - _last_TGP_model ( NULL ) , +_eval_in_progress ( NULL ) , +_nb_in_progress ( 0 ) , +_elop_tag ( 0 ) , +_slaves_elop_tags ( NULL ) , +_slave ( NULL ) , #endif - _stats ( stats ) , - _last_stats_tag ( -1 ) , - _last_stats_bbe ( -1 ) , - _last_history_bbe ( -1 ) +_stats ( stats ) , +_last_stats_tag ( -1 ) , +_last_stats_bbe ( -1 ) , +_last_history_bbe ( -1 ) { - NOMAD::Evaluator_Control::_force_quit = false; - - // Evaluator init: - if ( !_ev ) { - _ev = ( _p.get_index_obj().size() > 1 ) ? new NOMAD::Multi_Obj_Evaluator ( p ): - new NOMAD::Evaluator ( p ); - _del_ev = true; - } - - if ( NOMAD::Slave::is_master() ) { - -#ifdef USE_MPI - - int np = NOMAD::Slave::get_nb_processes(); - - _eval_in_progress = new NOMAD::Eval_Point * [np]; - _slaves_elop_tags = new int [np]; - for ( int i = 0 ; i < np ; ++i ) { - _eval_in_progress[i] = NULL; - _slaves_elop_tags[i] = -1; - } - - _slave = new NOMAD::Slave ( _p , _ev ); - -#endif - - const NOMAD::Display & out = _p.out(); - - // caches creation: - if ( !_cache ) { - _cache = new NOMAD::Cache ( out , NOMAD::TRUTH ); - _del_cache = true; - } - if ( !_sgte_cache ) { - _sgte_cache = new NOMAD::Cache ( out , NOMAD::SGTE ); - _del_sgte_cache = true; - } - - // caches init (we only load cache file points with m blackbox outputs): - std::string file_name; - int m = p.get_bb_nb_outputs(); - NOMAD::dd_type display_degree = out.get_gen_dd(); + NOMAD::Evaluator_Control::_force_quit = false; - if ( !_p.get_cache_file().empty() ) { - file_name = _p.get_problem_dir() + _p.get_cache_file(); - if ( !_cache->load ( file_name , &m , display_degree == NOMAD::FULL_DISPLAY ) - && display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - out << std::endl - << "Warning (" << "Evaluator_Control.cpp" << ", " << __LINE__ - << "): could not load (or create) the cache file " << file_name - << std::endl << std::endl; + // Evaluator init: + if ( !_ev ) + { + _ev = ( _p.get_index_obj().size() > 1 ) ? new NOMAD::Multi_Obj_Evaluator ( p ): + new NOMAD::Evaluator ( p ); + _del_ev = true; } - if ( !_p.get_sgte_cache_file().empty() ) { - file_name = _p.get_problem_dir() + _p.get_sgte_cache_file(); - if ( !_sgte_cache->load ( file_name , &m , display_degree==NOMAD::FULL_DISPLAY ) && - display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY ) - out << std::endl << "Warning (" << "Evaluator_Control.cpp" << ", " << __LINE__ - << "): could not load (or create) the surrogate cache file " - << file_name << std::endl << std::endl; - } - + if ( NOMAD::Slave::is_master() ) + { + +#ifdef USE_MPI + + int np = NOMAD::Slave::get_nb_processes(); + + _eval_in_progress = new NOMAD::Eval_Point * [np]; + _slaves_elop_tags = new int [np]; + for ( int i = 0 ; i < np ; ++i ) + { + _eval_in_progress[i] = NULL; + _slaves_elop_tags[i] = -1; + } + + _slave = new NOMAD::Slave ( _p , _ev ); + +#endif + + const NOMAD::Display & out = _p.out(); + + // caches creation: + if ( !_cache ) + { + _cache = new NOMAD::Cache ( out , NOMAD::TRUTH ); + _del_cache = true; + } + if ( !_sgte_cache ) + { + _sgte_cache = new NOMAD::Cache ( out , NOMAD::SGTE ); + _del_sgte_cache = true; + } + + // caches init (we only load cache file points with m blackbox outputs): + std::string file_name; + int m = p.get_bb_nb_outputs(); + NOMAD::dd_type display_degree = out.get_gen_dd(); + + if ( !_p.get_cache_file().empty() ) + { + file_name = _p.get_problem_dir() + _p.get_cache_file(); + if ( !_cache->load ( file_name , &m , display_degree == NOMAD::FULL_DISPLAY ) + && display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + out << std::endl + << "Warning (" << "Evaluator_Control.cpp" << ", " << __LINE__ + << "): could not load (or create) the cache file " << file_name + << std::endl << std::endl; + } + + if ( !_p.get_sgte_cache_file().empty() ) + { + file_name = _p.get_problem_dir() + _p.get_sgte_cache_file(); + if ( !_sgte_cache->load ( file_name , &m , display_degree==NOMAD::FULL_DISPLAY ) && + display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY ) + out << std::endl << "Warning (" << "Evaluator_Control.cpp" << ", " << __LINE__ + << "): could not load (or create) the surrogate cache file " + << file_name << std::endl << std::endl; + } + #ifdef MODEL_STATS - if ( _p.has_model_search() || - ( _model_eval_sort && - _p.get_model_eval_sort() != NOMAD::NO_MODEL ) ) { - out << std::endl - << "MODEL_STATS is active. Displayed model stats are:" - << std::endl - << "mode ell nY wY cond"; - if ( _p.has_constraints() ) - out << " h mh eh"; - out << " f mf ef" << std::endl - << NOMAD::open_block() - << "mode: model search (1) or model ordering (2)" << std::endl - << "ell : mesh_index" << std::endl - << "nY : cardinality of the interpolation set Y" << std::endl - << "wY : width of Y" << std::endl - << "cond: Y condition number" << std::endl; - if ( _p.has_constraints() ) - out << "h : h value" << std::endl - << "mh : model value for h" << std::endl - << "eh : relative error(%)" << std::endl; - out << "f : f value" << std::endl - << "mf : model value for f" << std::endl - << "ef : relative error(%)" << std::endl - << NOMAD::close_block() << std::endl; - } + if ( _p.has_model_search() || + ( _model_eval_sort && + _p.get_model_eval_sort() != NOMAD::NO_MODEL ) ) + { + out << std::endl + << "MODEL_STATS is active. Displayed model stats are:" + << std::endl + << "mode ell nY wY cond"; + if ( _p.has_constraints() ) + out << " h mh eh"; + out << " f mf ef" << std::endl + << NOMAD::open_block() + << "mode: model search (1) or model ordering (2)" << std::endl + << "ell : mesh_index" << std::endl + << "nY : cardinality of the interpolation set Y" << std::endl + << "wY : width of Y" << std::endl + << "cond: Y condition number" << std::endl; + if ( _p.has_constraints() ) + out << "h : h value" << std::endl + << "mh : model value for h" << std::endl + << "eh : relative error(%)" << std::endl; + out << "f : f value" << std::endl + << "mf : model value for f" << std::endl + << "ef : relative error(%)" << std::endl + << NOMAD::close_block() << std::endl; + } #endif - } + } } /*---------------------------------------------------------*/ @@ -180,31 +191,32 @@ NOMAD::Evaluator_Control::Evaluator_Control /*---------------------------------------------------------*/ NOMAD::Evaluator_Control::~Evaluator_Control ( void ) { - if ( _del_ev ) - delete _ev; - - if ( _del_cache ) - delete _cache; - - if ( _del_sgte_cache ) - delete _sgte_cache; - - clear_eval_lop(); - + if ( _del_ev ) + delete _ev; + + if ( _del_cache ) + delete _cache; + + if ( _del_sgte_cache ) + delete _sgte_cache; + + clear_eval_lop(); + #ifdef USE_MPI - - if ( _eval_in_progress ) { - int np = NOMAD::Slave::get_nb_processes(); - for ( int i = 0 ; i < np ; ++i ) - if ( _eval_in_progress[i] && !_eval_in_progress[i]->is_in_cache() ) - delete _eval_in_progress[i]; - delete [] _eval_in_progress; - } - if ( _slaves_elop_tags ) - delete [] _slaves_elop_tags; - - delete _slave; - + + if ( _eval_in_progress ) + { + int np = NOMAD::Slave::get_nb_processes(); + for ( int i = 0 ; i < np ; ++i ) + if ( _eval_in_progress[i] && !_eval_in_progress[i]->is_in_cache() ) + delete _eval_in_progress[i]; + delete [] _eval_in_progress; + } + if ( _slaves_elop_tags ) + delete [] _slaves_elop_tags; + + delete _slave; + #endif } @@ -213,10 +225,7 @@ NOMAD::Evaluator_Control::~Evaluator_Control ( void ) /*---------------------------------------------------------*/ void NOMAD::Evaluator_Control::reset ( void ) { - _last_stats_tag = _last_stats_bbe = -1; -#ifdef USE_TGP - _last_TGP_model = NULL; -#endif + _last_stats_tag = _last_stats_bbe = -1; } /*---------------------------------------------------------*/ @@ -224,112 +233,110 @@ void NOMAD::Evaluator_Control::reset ( void ) /*---------------------------------------------------------*/ bool NOMAD::Evaluator_Control::save_caches ( bool overwrite ) { - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_gen_dd(); - - bool b1 = _cache->save ( overwrite , display_degree == NOMAD::FULL_DISPLAY ); - bool b2 = _sgte_cache->save ( overwrite , display_degree == NOMAD::FULL_DISPLAY ); - - if ( !b1 && display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - out << std::endl << "Warning (" << "Evaluator_Control.cpp" << ", " << __LINE__ - << "): could not save the cache file " - << _p.get_problem_dir() << _p.get_cache_file() - << std::endl << std::endl; - - if ( !b2 && display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - out << std::endl - << "Warning (" << "Evaluator_Control.cpp" << ", " << __LINE__ - << "): could not save the surrogate cache file " - << _p.get_problem_dir() << _p.get_sgte_cache_file() - << std::endl << std::endl; - return b1 && b2; + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_gen_dd(); + + bool b1 = _cache->save ( overwrite , display_degree == NOMAD::FULL_DISPLAY ); + bool b2 = _sgte_cache->save ( overwrite , display_degree == NOMAD::FULL_DISPLAY ); + + if ( !b1 && display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + out << std::endl << "Warning (" << "Evaluator_Control.cpp" << ", " << __LINE__ + << "): could not save the cache file " + << _p.get_problem_dir() << _p.get_cache_file() + << std::endl << std::endl; + + if ( !b2 && display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + out << std::endl + << "Warning (" << "Evaluator_Control.cpp" << ", " << __LINE__ + << "): could not save the surrogate cache file " + << _p.get_problem_dir() << _p.get_sgte_cache_file() + << std::endl << std::endl; + return b1 && b2; } /*---------------------------------------------------------*/ /* process an already evaluated Eval_Point (private) */ /*---------------------------------------------------------*/ -void NOMAD::Evaluator_Control::process_eval_point -( const NOMAD::Eval_Point & x , - NOMAD::Barrier & barrier , - NOMAD::Pareto_Front * pareto_front ) const +void NOMAD::Evaluator_Control::process_eval_point ( const NOMAD::Eval_Point & x , + NOMAD::Barrier & barrier , + NOMAD::Pareto_Front * pareto_front ) const { - // insertion of the Eval_Point in the barriers: - barrier.insert(x); - - if ( x.get_eval_type() == NOMAD::TRUTH || _p.get_opt_only_sgte() ) - { - - // multi-objective: - if ( pareto_front ) - { - - // insertion of the Eval_Point in the Pareto front: - if ( x.is_feasible ( _p.get_h_min() ) && - pareto_front->insert ( x ) && - _p.get_user_calls_enabled() ) - _ev->update_success ( _stats , x ); - + // insertion of the Eval_Point in the barriers: + barrier.insert(x); + + if ( x.get_eval_type() == NOMAD::TRUTH || _p.get_opt_only_sgte() ) + { + + // multi-objective: + if ( pareto_front ) + { + + // insertion of the Eval_Point in the Pareto front: + if ( x.is_feasible ( _p.get_h_min() ) && + pareto_front->insert ( x ) && + _p.get_user_calls_enabled() ) + _ev->update_success ( _stats , x ); + + } + + // single-objective: call virtual method Evaluator::update_success(): + else if ( _p.get_user_calls_enabled() && + barrier.get_one_eval_succ() == NOMAD::FULL_SUCCESS ) + _ev->update_success ( _stats , x ); } - - // single-objective: call virtual method Evaluator::update_success(): - else if ( _p.get_user_calls_enabled() && - barrier.get_one_eval_succ() == NOMAD::FULL_SUCCESS ) - _ev->update_success ( _stats , x ); - } } /*---------------------------------------------------------*/ /* update barrier b1 from points in barrier b2 and treat */ /* these points as evaluations (used in VNS search) */ /*---------------------------------------------------------*/ -NOMAD::success_type NOMAD::Evaluator_Control::process_barrier_points -( NOMAD::Barrier & b1 , - const NOMAD::Barrier & b2 , - NOMAD::Pareto_Front * pareto_front , - NOMAD::dd_type display_degree , - NOMAD::search_type search ) const +NOMAD::success_type NOMAD::Evaluator_Control::process_barrier_points ( NOMAD::Barrier & b1 , + const NOMAD::Barrier & b2 , + NOMAD::Pareto_Front * pareto_front , + NOMAD::dd_type display_degree , + NOMAD::search_type search ) const { - b1.reset_success(); - - NOMAD::Eval_Point * modifiable_x; - NOMAD::success_type one_eval_succ; - const NOMAD::Eval_Point * last_success = NULL; - const std::list<const NOMAD::Eval_Point *> & all_inserted = b2.get_all_inserted(); - std::list<const NOMAD::Eval_Point *>::const_iterator it , end = all_inserted.end(); - for ( it = all_inserted.begin() ; it != end ; ++it ) - { - - // insertion in barrier: - modifiable_x = &NOMAD::Cache::get_modifiable_point ( **it ); - - modifiable_x->set_direction ( NULL ); - modifiable_x->set_poll_center_type ( NOMAD::UNDEFINED_POLL_CENTER_TYPE ); - modifiable_x->set_user_eval_priority ( NOMAD::Double() ); - modifiable_x->set_rand_eval_priority ( NOMAD::Double() ); - - // process evaluation point: - process_eval_point ( **it , b1 , pareto_front ); - - one_eval_succ = b1.get_one_eval_succ(); - if ( one_eval_succ != NOMAD::UNSUCCESSFUL && one_eval_succ >= b1.get_success() ) - last_success = *it; - - } - - NOMAD::success_type success = b1.get_success(); - - // display and save only the last success: - if ( last_success && display_degree == NOMAD::FULL_DISPLAY) - display_eval_result ( *last_success , - display_degree , - search , - success , - success ); - - // barrier update: - b1.update_and_reset_success(); - - return success; + b1.reset_success(); + + NOMAD::Eval_Point * modifiable_x; + NOMAD::success_type one_eval_succ; + const NOMAD::Eval_Point * last_success = NULL; + const std::list<const NOMAD::Eval_Point *> & all_inserted = b2.get_all_inserted(); + std::list<const NOMAD::Eval_Point *>::const_iterator it , end = all_inserted.end(); + for ( it = all_inserted.begin() ; it != end ; ++it ) + { + + // insertion in barrier: + modifiable_x = &NOMAD::Cache::get_modifiable_point ( **it ); + + modifiable_x->set_direction ( NULL ); + modifiable_x->set_poll_center_type ( NOMAD::UNDEFINED_POLL_CENTER_TYPE ); + modifiable_x->set_user_eval_priority ( NOMAD::Double() ); + modifiable_x->set_rand_eval_priority ( NOMAD::Double() ); + + // process evaluation point: + process_eval_point ( **it , b1 , pareto_front ); + + one_eval_succ = b1.get_one_eval_succ(); + if ( one_eval_succ != NOMAD::UNSUCCESSFUL && one_eval_succ >= b1.get_success() ) + last_success = *it; + + } + + NOMAD::success_type success = b1.get_success(); + + // display and save only the last success: + if ( last_success && display_degree == NOMAD::FULL_DISPLAY) + display_eval_result ( *last_success , + display_degree , + search , + success , + success ); + + // barrier update: + b1.update_and_reset_success(); + + return success; } /*---------------------------------------------------------*/ @@ -338,425 +345,423 @@ NOMAD::success_type NOMAD::Evaluator_Control::process_barrier_points /*---------------------------------------------------------*/ void NOMAD::Evaluator_Control::count_output_stats ( const NOMAD::Eval_Point & x ) { - const NOMAD::Point & bbo = x.get_bb_outputs(); - int i_sum = _p.get_index_stat_sum(); - int i_avg = _p.get_index_stat_avg(); - - // STAT_SUM: - if ( i_sum >= 0 ) - _stats.update_stat_sum ( bbo[i_sum] ); - - // STAT_AVG: - if ( i_avg >= 0 ) - _stats.update_stat_avg ( bbo[i_avg] ); + const NOMAD::Point & bbo = x.get_bb_outputs(); + int i_sum = _p.get_index_stat_sum(); + int i_avg = _p.get_index_stat_avg(); + + // STAT_SUM: + if ( i_sum >= 0 ) + _stats.update_stat_sum ( bbo[i_sum] ); + + // STAT_AVG: + if ( i_avg >= 0 ) + _stats.update_stat_avg ( bbo[i_avg] ); } /*-------------------------------------------------------------------*/ /* file displays for parameter STATS_FILE */ /*-------------------------------------------------------------------*/ void NOMAD::Evaluator_Control::stats_file ( const std::string & file_name , - const NOMAD::Eval_Point * x , - bool feasible , - const NOMAD::Point * multi_obj ) const + const NOMAD::Eval_Point * x , + bool feasible , + const NOMAD::Point * multi_obj ) const { - std::string fn = _p.get_problem_dir() + file_name; - std::ofstream fout ( fn.c_str() , std::ios::app ); - - if ( !fout.fail() ) - { - fout.setf ( std::ios::fixed ); - fout.precision ( NOMAD::DISPLAY_PRECISION_BB ); - display_stats ( false , fout , _p.get_stats_file() , x , feasible , multi_obj ); - } - else - { - const NOMAD::Display & out = _p.out(); - if ( out.get_gen_dd() != NOMAD::NO_DISPLAY && out.get_gen_dd() != NOMAD::MINIMAL_DISPLAY) - out << std::endl - << "Warning (" << "Evaluator_Control.cpp" << ", " << __LINE__ - << "): could not save information in stats file \'" - << file_name << "\'" << std::endl << std::endl; - } - fout.close(); + std::string fn = _p.get_problem_dir() + file_name; + std::ofstream fout ( fn.c_str() , std::ios::app ); + + if ( !fout.fail() ) + { + fout.setf ( std::ios::fixed ); + fout.precision ( NOMAD::DISPLAY_PRECISION_BB ); + display_stats ( false , fout , _p.get_stats_file() , x , feasible , multi_obj ); + } + else + { + const NOMAD::Display & out = _p.out(); + if ( out.get_gen_dd() != NOMAD::NO_DISPLAY && out.get_gen_dd() != NOMAD::MINIMAL_DISPLAY) + out << std::endl + << "Warning (" << "Evaluator_Control.cpp" << ", " << __LINE__ + << "): could not save information in stats file \'" + << file_name << "\'" << std::endl << std::endl; + } + fout.close(); } /*-------------------------------------------------------------------*/ /* display stats during Mads::run() for minimal and normal display */ /*-------------------------------------------------------------------*/ -void NOMAD::Evaluator_Control::display_stats -( bool header , - const NOMAD::Display & out , - const std::list<std::string> & stats , - const NOMAD::Eval_Point * x , - bool feasible , - const NOMAD::Point * multi_obj ) const +void NOMAD::Evaluator_Control::display_stats ( bool header , + const NOMAD::Display & out , + const std::list<std::string> & stats , + const NOMAD::Eval_Point * x , + bool feasible , + const NOMAD::Point * multi_obj ) const { - if ( stats.empty() ) - { + if ( stats.empty() ) + { #ifndef R_VERSION - out << std::endl; + out << std::endl; #endif - return; - } - - if ( header ) - { + return; + } + + if ( header ) + { #ifndef R_VERSION - out << std::endl; + out << std::endl; #endif - } - - NOMAD::Double f; - const NOMAD::Point * sol = NULL; - const NOMAD::Point * bbo = NULL; - const NOMAD::Signature * signature = NULL; - int bbe = _stats.get_bb_eval(); - int real_time = _stats.get_real_time(); - int blk_bbe = _stats.get_block_eval(); - int i; - - // this integer is used for the default width display - // of the various stats on the number of evaluations: - int max_bbe = _p.get_max_bb_eval(); - if ( _p.get_max_sgte_eval() > max_bbe ) - max_bbe = _p.get_max_sgte_eval(); - if ( _p.get_max_sim_bb_eval() > max_bbe ) - max_bbe = _p.get_max_sim_bb_eval(); - if ( _p.get_max_eval() > max_bbe ) - max_bbe = _p.get_max_eval(); - - if ( x ) - { - signature = x->get_signature(); - f = (feasible) ? x->get_f() : NOMAD::INF; - sol = x; - bbo = &(x->get_bb_outputs()); - - if (bbe < _last_stats_bbe && ! multi_obj) - return; - - _last_stats_tag = x->get_tag(); - _last_stats_bbe = bbe; - } - - - - std::string s1 , format; - std::list<std::string>::const_iterator it , end = stats.end(); - for ( it = stats.begin() ; it != end ; ++it ) - { - - if ( it->empty() ) - { + } + + NOMAD::Double f; + const NOMAD::Point * sol = NULL; + const NOMAD::Point * bbo = NULL; + const NOMAD::Signature * signature = NULL; + int bbe = _stats.get_bb_eval(); + int real_time = _stats.get_real_time(); + int blk_bbe = _stats.get_block_eval(); + int i; + + // this integer is used for the default width display + // of the various stats on the number of evaluations: + int max_bbe = _p.get_max_bb_eval(); + if ( _p.get_max_sgte_eval() > max_bbe ) + max_bbe = _p.get_max_sgte_eval(); + if ( _p.get_max_sim_bb_eval() > max_bbe ) + max_bbe = _p.get_max_sim_bb_eval(); + if ( _p.get_max_eval() > max_bbe ) + max_bbe = _p.get_max_eval(); + + if ( x ) + { + signature = x->get_signature(); + f = (feasible) ? x->get_f() : NOMAD::INF; + sol = x; + bbo = &(x->get_bb_outputs()); + + if (bbe < _last_stats_bbe && ! multi_obj) + return; + + _last_stats_tag = x->get_tag(); + _last_stats_bbe = bbe; + } + + + std::string s1 , format; + std::list<std::string>::const_iterator it , end = stats.end(); + for ( it = stats.begin() ; it != end ; ++it ) + { + + if ( it->empty() ) + { #ifndef R_VERSION - out << "\t"; + out << "\t"; #endif - } - else { - - if ( header ) - { + } + else + { + + + if ( header ) + { #ifndef R_VERSION - s1 = *it; - NOMAD::Display::extract_display_format ( s1 , format ); - out << s1; + s1 = *it; + NOMAD::Display::extract_display_format ( s1 , format ); + out << s1; #endif - } - - else - { - - // get the stats type: - NOMAD::display_stats_type dst - = NOMAD::Display::get_display_stats_type ( *it ); - - // some stats types are disables in the multi-objective case: - if ( multi_obj && - ( dst == NOMAD::DS_SIM_BBE || - dst == NOMAD::DS_BBE || - dst == NOMAD::DS_SGTE || - dst == NOMAD::DS_EVAL || - dst == NOMAD::DS_TIME || - dst == NOMAD::DS_STAT_SUM || - dst == NOMAD::DS_STAT_AVG ) ) - dst = NOMAD::DS_UNDEFINED; - - // display the stats: - switch ( dst ) + } + + else + { + + // get the stats type: + NOMAD::display_stats_type dst + = NOMAD::Display::get_display_stats_type ( *it ); + + // some stats types are disables in the multi-objective case: + if ( multi_obj && + ( dst == NOMAD::DS_SIM_BBE || + dst == NOMAD::DS_BBE || + dst == NOMAD::DS_SGTE || + dst == NOMAD::DS_EVAL || + dst == NOMAD::DS_TIME || + dst == NOMAD::DS_STAT_SUM || + dst == NOMAD::DS_STAT_AVG ) ) + dst = NOMAD::DS_UNDEFINED; + + // display the stats: + switch ( dst ) { - case NOMAD::DS_UNDEFINED: - s1 = *it; - NOMAD::Display::extract_display_format ( s1 , format ); - out << s1; - break; - case NOMAD::DS_OBJ: - if ( multi_obj ) - display_stats_point ( out , stats , it , multi_obj ); - else + case NOMAD::DS_UNDEFINED: + s1 = *it; + NOMAD::Display::extract_display_format ( s1 , format ); + out << s1; + break; + case NOMAD::DS_OBJ: + if ( multi_obj ) + display_stats_point ( out , stats , it , multi_obj ); + else { #ifdef R_VERSION - { - std::ostringstream oss; - display_stats_real ( oss , f , format ); - Rprintf ( "%s" , oss.str().c_str() ); - } + { + std::ostringstream oss; + display_stats_real ( oss , f , format ); + Rprintf ( "%s" , oss.str().c_str() ); + } #else - display_stats_real ( out , f , format ); + display_stats_real ( out , f , format ); #endif - format.clear(); - } - break; - case NOMAD::DS_MESH_INDEX: - { - if ( signature ) - { - NOMAD::Point mesh_indices=signature->get_mesh()->get_mesh_indices(); - display_stats_point ( out , stats , it , &mesh_indices ); - } - else - out << "-"; - - - break; - } - case NOMAD::DS_DELTA_M: - case NOMAD::DS_MESH_SIZE: - { - if ( signature ) - { - NOMAD::Point delta; - signature->get_mesh()->get_delta ( delta ); - display_stats_point ( out , stats , it , &delta ); - } - else - out << "-"; - } - break; - case NOMAD::DS_DELTA_P: - case NOMAD::DS_POLL_SIZE: - { - if ( signature ) - { - NOMAD::Point Delta; - signature->get_mesh()->get_Delta ( Delta ); - display_stats_point ( out , stats , it , &Delta ); - - } - else - out << "-"; - } - break; - case NOMAD::DS_SIM_BBE: - display_stats_int ( out , _stats.get_sim_bb_eval() , max_bbe , format ); - format.clear(); - break; - case NOMAD::DS_BBE: - + format.clear(); + } + break; + case NOMAD::DS_MESH_INDEX: + { + + if ( signature ) + { + NOMAD::Point mesh_indices=signature->get_mesh()->get_mesh_indices(); + display_stats_point ( out , stats , it , &mesh_indices ); + } + else + out << "-"; + + + break; + } + case NOMAD::DS_DELTA_M: + case NOMAD::DS_MESH_SIZE: + { + if ( signature ) + { + NOMAD::Point delta; + signature->get_mesh()->get_delta ( delta ); + display_stats_point ( out , stats , it , &delta ); + } + else + out << "-"; + } + break; + case NOMAD::DS_DELTA_P: + case NOMAD::DS_POLL_SIZE: + { + if ( signature ) + { + NOMAD::Point Delta; + signature->get_mesh()->get_Delta ( Delta ); + display_stats_point ( out , stats , it , &Delta ); + + } + else + out << "-"; + } + break; + case NOMAD::DS_SIM_BBE: + display_stats_int ( out , _stats.get_sim_bb_eval() , max_bbe , format ); + format.clear(); + break; + case NOMAD::DS_BBE: + #ifdef R_VERSION - { - std::ostringstream oss; - display_stats_int ( oss , bbe , max_bbe , format ); - Rprintf ( "\t%s " , oss.str().c_str() ); - } + { + std::ostringstream oss; + display_stats_int ( oss , bbe , max_bbe , format ); + Rprintf ( "\t%s " , oss.str().c_str() ); + } #else - { - display_stats_int ( out , bbe , max_bbe , format ); - } + { + display_stats_int ( out , bbe , max_bbe , format ); + } #endif - format.clear(); - break; + format.clear(); + break; case NOMAD::DS_BLK_EVA: - { - display_stats_int ( out , blk_bbe , max_bbe , format ); - } - format.clear(); - break; - - case NOMAD::DS_SGTE: - //display_stats_int ( out , sgte_bbe , max_bbe , format ); - display_stats_int ( out , _stats.get_sgte_eval() , max_bbe , format ); - format.clear(); - break; - case NOMAD::DS_EVAL: - display_stats_int ( out , _stats.get_eval() , max_bbe , format ); - format.clear(); - break; - case NOMAD::DS_TIME: - display_stats_int ( out , real_time , 3600 , format ); - format.clear(); - break; - case NOMAD::DS_STAT_SUM: - display_stats_real ( out , _stats.get_stat_sum() , format ); - format.clear(); - break; - case NOMAD::DS_STAT_AVG: - display_stats_real ( out , _stats.get_stat_avg() , format ); - format.clear(); - break; - case NOMAD::DS_BBO: - display_stats_point ( out , stats , it , bbo ); - break; - case NOMAD::DS_SOL: - display_stats_point ( out , stats , it , sol , signature->get_input_type() ); - break; - case NOMAD::DS_VAR: - ++it; - NOMAD::atoi ( *it , i ); - if ( sol ) - if (format.empty()) - display_stats_type ( out , (*sol)[i] , (signature->get_input_type())[i] ); - else - display_stats_real ( out , (*sol)[i] , format ); - else - out << "-"; - format.clear(); - break; - } - } - } - } - - if ( !header ) + { + display_stats_int ( out , blk_bbe , max_bbe , format ); + } + format.clear(); + break; + + case NOMAD::DS_SGTE: + display_stats_int ( out , _stats.get_sgte_eval() , max_bbe , format ); + format.clear(); + break; + case NOMAD::DS_EVAL: + display_stats_int ( out , _stats.get_eval() , max_bbe , format ); + format.clear(); + break; + case NOMAD::DS_TIME: + display_stats_int ( out , real_time , 3600 , format ); + format.clear(); + break; + case NOMAD::DS_STAT_SUM: + display_stats_real ( out , _stats.get_stat_sum() , format ); + format.clear(); + break; + case NOMAD::DS_STAT_AVG: + display_stats_real ( out , _stats.get_stat_avg() , format ); + format.clear(); + break; + case NOMAD::DS_BBO: + display_stats_point ( out , stats , it , bbo ); + break; + case NOMAD::DS_SOL: + display_stats_point ( out , stats , it , sol , signature->get_input_types() ); + break; + case NOMAD::DS_VAR: + ++it; + NOMAD::atoi ( *it , i ); + if ( sol ) + if (format.empty()) + display_stats_type ( out , (*sol)[i] , (signature->get_input_types())[i] ); + else + display_stats_real ( out , (*sol)[i] , format ); + else + out << "-"; + format.clear(); + break; + } + } + } + } + + if ( !header ) #ifdef R_VERSION - Rprintf("\n"); + Rprintf("\n"); #else - out << std::endl; + out << std::endl; #endif } /*-----------------------------------------------------*/ /* display a number with type */ /*-----------------------------------------------------*/ -void NOMAD::Evaluator_Control::display_stats_type -( const NOMAD::Display & out , - const NOMAD::Double & d , - const NOMAD::bb_input_type & bbType ) const +void NOMAD::Evaluator_Control::display_stats_type ( const NOMAD::Display & out , + const NOMAD::Double & d , + const NOMAD::bb_input_type & bbType ) const { - - // Default based on bbType - std::string format2; - switch (bbType) - { - case NOMAD::CONTINUOUS: - format2 = "%0." + NOMAD::itos(DISPLAY_PRECISION_STD) + "g"; - break; - case NOMAD::INTEGER || NOMAD::BINARY || NOMAD::CATEGORICAL: - format2 = "%i"; - break; - default: - break; - } - d.display ( out , format2 ); - + + // Default based on bbType + std::string format2; + switch (bbType) + { + case NOMAD::CONTINUOUS: + format2 = "%0." + NOMAD::itos(DISPLAY_PRECISION_STD) + "g"; + break; + case NOMAD::INTEGER || NOMAD::BINARY || NOMAD::CATEGORICAL: + format2 = "%i"; + break; + default: + break; + } + d.display ( out , format2 ); + } /*-----------------------------------------------------*/ /* display a real with DISPLAY_STATS (or STATS_FILE) */ /*-----------------------------------------------------*/ -void NOMAD::Evaluator_Control::display_stats_real -( const NOMAD::Display & out , - const NOMAD::Double & d , - const std::string & format ) const +void NOMAD::Evaluator_Control::display_stats_real ( const NOMAD::Display & out , + const NOMAD::Double & d , + const std::string & format ) const { - if ( format.empty() ) - { - std::string format2 = "%0." + NOMAD::itos(DISPLAY_PRECISION_STD) + "g"; - d.display ( out , format2 ); - } - else - d.display ( out , format ); + if ( format.empty() ) + { + std::string format2 = "%0." + NOMAD::itos(DISPLAY_PRECISION_STD) + "g"; + d.display ( out , format2 ); + } + else + d.display ( out , format ); } /*---------------------------------------------------------*/ /* display an integer with DISPLAY_STATS (or STATS_FILE) */ /*---------------------------------------------------------*/ -void NOMAD::Evaluator_Control::display_stats_int -( const NOMAD::Display & out , - int i , - int max_i , - const std::string & format ) const +void NOMAD::Evaluator_Control::display_stats_int ( const NOMAD::Display & out , + int i , + int max_i , + const std::string & format ) const { - if ( format.empty() ) - out.display_int_w ( i , max_i ); - else { - NOMAD::Double d = i; - d.display ( out , format ); - } + if ( format.empty() ) + out.display_int_w ( i , max_i ); + else + { + + NOMAD::Double d = i; + d.display ( out , format ); + } } /*---------------------------------------------------------*/ /* display a point with DISPLAY_STATS (or STATS_FILE) */ /*---------------------------------------------------------*/ -void NOMAD::Evaluator_Control::display_stats_point -( const NOMAD::Display & out , - const std::list<std::string> & display_stats , - std::list<std::string>::const_iterator & it , - const NOMAD::Point * x , - const std::vector<NOMAD::bb_input_type> & bbType ) const +void NOMAD::Evaluator_Control::display_stats_point ( const NOMAD::Display & out , + const std::list<std::string> & display_stats , + std::list<std::string>::const_iterator & it , + const NOMAD::Point * x , + const std::vector<NOMAD::bb_input_type> & bbType ) const { - if ( x ) - { - - unsigned int n = x->size() , bbn = static_cast<int>(bbType.size()); - - if ( bbn!=0 && n != bbn ) - throw NOMAD::Exception ( "Evaluator_Control.cpp" , __LINE__ , - "Evaluator_Control::display_stats_point(): bbType and x have different size" ); - - - // s1 is the string displayed befores and after - // one coordinate (it may include format): - std::string s1; - if ( it != display_stats.begin() ) - { - s1 = *(--it); - ++it; + if ( x ) + { + + unsigned int n = x->size() , bbn = static_cast<int>(bbType.size()); + + if ( bbn!=0 && n != bbn ) + throw NOMAD::Exception ( "Evaluator_Control.cpp" , __LINE__ , + "Evaluator_Control::display_stats_point(): bbType and x have different size" ); + + + // s1 is the string displayed befores and after + // one coordinate (it may include format): + std::string s1; + if ( it != display_stats.begin() ) + { + s1 = *(--it); + ++it; + } + + // extract the display format from s1: + std::string format; + if ( !s1.empty() ) + NOMAD::Display::extract_display_format ( s1 , format ); + + // s2 is the string displayed between two coordinates: + std::string s2; + ++it; + if ( it != display_stats.end() ) + s2 = *it; + else if ( s2.empty() ) + --it; + + for ( unsigned int i = 0 ; i < n ; ++i ) + { + if ( !s1.empty() && i > 0 ) + out << s1; + + if (bbn!=0 && format.empty()) + display_stats_type ( out , (*x)[i] , bbType[i]); + else + display_stats_real (out, (*x)[i] , format ); + + if ( !s1.empty() ) + out << s1; + if ( !s2.empty() && i < n-1 && s2.find("(VNS)")==std::string::npos && s2.find("(PhaseOne)")==std::string::npos && s2.find("(LH)")==std::string::npos && s2.find("(ExtendedPoll)")==std::string::npos ) + out << " " << s2; + out << " "; + } + if ( !s2.empty() && (s2.find("(VNS)")!=std::string::npos || s2.find("(PhaseOne)")!=std::string::npos || s2.find("(LH)")!=std::string::npos || s2.find("(ExtendedPoll)")!=std::string::npos)) + out << s2; } - - // extract the display format from s1: - std::string format; - if ( !s1.empty() ) - NOMAD::Display::extract_display_format ( s1 , format ); - - // s2 is the string displayed between two coordinates: - std::string s2; - ++it; - if ( it != display_stats.end() ) - s2 = *it; - else if ( s2.empty() ) - --it; - - for ( unsigned int i = 0 ; i < n ; ++i ) - { - if ( !s1.empty() && i > 0 ) - out << s1; - - if (bbn!=0 && format.empty()) - display_stats_type ( out , (*x)[i] , bbType[i]); - else - display_stats_real (out, (*x)[i] , format ); - - if ( !s1.empty() ) - out << s1; - if ( !s2.empty() && i < n-1 && s2.find("(VNS)")==std::string::npos && s2.find("(PhaseOne)")==std::string::npos && s2.find("(LH)")==std::string::npos && s2.find("(ExtendedPoll)")==std::string::npos ) - out << " " << s2; - out << " "; - } - if ( !s2.empty() && (s2.find("(VNS)")!=std::string::npos || s2.find("(PhaseOne)")!=std::string::npos || s2.find("(LH)")!=std::string::npos || s2.find("(ExtendedPoll)")!=std::string::npos)) - out << s2; - } } /*------------------------------------------*/ /* save the solution file (SOLUTION_FILE) */ /*------------------------------------------*/ void NOMAD::Evaluator_Control::write_solution_file ( const NOMAD::Eval_Point & x, - bool display_bimv) const + bool display_bimv) const { - const std::string & sol_file = _p.get_solution_file(); - if ( !sol_file.empty() && ( x.is_feasible ( _p.get_h_min() ) || display_bimv ) ) - write_sol_or_his_file ( _p.get_problem_dir() + sol_file , x , true , display_bimv ); + const std::string & sol_file = _p.get_solution_file(); + if ( !sol_file.empty() && ( x.is_feasible ( _p.get_h_min() ) || display_bimv ) ) + write_sol_or_his_file ( _p.get_problem_dir() + sol_file , x , true , display_bimv ); } /*----------------------------------------------*/ @@ -764,170 +769,170 @@ void NOMAD::Evaluator_Control::write_solution_file ( const NOMAD::Eval_Point & x /* or update the history file (HISTORY_FILE ) */ /* (private) */ /*----------------------------------------------*/ -void NOMAD::Evaluator_Control::write_sol_or_his_file -( const std::string & file_name , - const NOMAD::Eval_Point & x , - bool is_sol , - bool display_bimv ) const +void NOMAD::Evaluator_Control::write_sol_or_his_file ( const std::string & file_name , + const NOMAD::Eval_Point & x , + bool is_sol , + bool display_bimv ) const { - // if is_sol == true: save the solution file - // else: update the history file - bool failed = false; - std::ofstream fout; - - if ( is_sol ) - fout.open ( file_name.c_str() ); - else - fout.open ( file_name.c_str() , std::ios::app ); - - if ( !fout.fail() ) { - - fout.setf ( std::ios::fixed ); - fout.precision ( NOMAD::DISPLAY_PRECISION_BB ); - - // solution display: - if ( is_sol ) - { - if ( _p.get_bb_input_include_seed() ) - fout << _p.get_seed() << std::endl; - if ( _p.get_bb_input_include_tag() ) - fout << x.get_tag() << std::endl; - x.Point::display ( fout , "\n" , -1 , -1 ); - if (display_bimv) - fout << std::endl << "warning: best infeasible solution (min. violation)"; - fout << std::endl; - } - - // history display: - else { - x.Point::display ( fout , " " , -1 , -1 ); - fout << " "; - x.get_bb_outputs().Point::display ( fout , " " , -1 , -1 ); - fout << std::endl; - } - - if ( fout.fail() ) - failed = true; - } - else - failed = true; - - fout.close(); - - if ( failed && _p.out().get_gen_dd() != NOMAD::NO_DISPLAY && _p.out().get_gen_dd() != NOMAD::MINIMAL_DISPLAY) - _p.out() << std::endl - << "Warning (" << "Evaluator_Control.cpp" << ", " << __LINE__ - << "): could not " - << ( is_sol ? "save the current solution" : - "update the history" ) - << " in \'" - << file_name << "\'" << std::endl << std::endl; + // if is_sol == true: save the solution file + // else: update the history file + bool failed = false; + std::ofstream fout; + + if ( is_sol ) + fout.open ( file_name.c_str() ); + else + fout.open ( file_name.c_str() , std::ios::app ); + + if ( !fout.fail() ) + { + + fout.setf ( std::ios::fixed ); + fout.precision ( NOMAD::DISPLAY_PRECISION_BB ); + + // solution display: + if ( is_sol ) + { + if ( _p.get_bb_input_include_seed() ) + fout << _p.get_seed() << std::endl; + if ( _p.get_bb_input_include_tag() ) + fout << x.get_tag() << std::endl; + x.Point::display ( fout , "\n" , -1 , -1 ); + if (display_bimv) + fout << std::endl << "warning: best infeasible solution (min. violation)"; + fout << std::endl; + } + + // history display: + else + { + x.Point::display ( fout , " " , -1 , -1 ); + fout << " "; + x.get_bb_outputs().Point::display ( fout , " " , -1 , -1 ); + fout << std::endl; + } + + if ( fout.fail() ) + failed = true; + } + else + failed = true; + + fout.close(); + + if ( failed && _p.out().get_gen_dd() != NOMAD::NO_DISPLAY && _p.out().get_gen_dd() != NOMAD::MINIMAL_DISPLAY) + _p.out() << std::endl + << "Warning (" << "Evaluator_Control.cpp" << ", " << __LINE__ + << "): could not " + << ( is_sol ? "save the current solution" : + "update the history" ) + << " in \'" + << file_name << "\'" << std::endl << std::endl; } /*---------------------------------------------------------*/ /* display evaluation result (private) */ /*---------------------------------------------------------*/ -void NOMAD::Evaluator_Control::display_eval_result -( const NOMAD::Eval_Point & x , - NOMAD::dd_type display_degree , - NOMAD::search_type search , - NOMAD::success_type one_eval_success , - NOMAD::success_type success ) const +void NOMAD::Evaluator_Control::display_eval_result ( const NOMAD::Eval_Point & x , + NOMAD::dd_type display_degree , + NOMAD::search_type search , + NOMAD::success_type one_eval_success , + NOMAD::success_type success ) const { - const NOMAD::Display & out = _p.out(); - int cur_bbe; - - // surrogate evaluation: - if ( x.get_eval_type() == NOMAD::SGTE ) - { - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - out << std::endl << "point #" << x.get_tag() << " sgte eval: "; - if ( x.is_eval_ok() ) - { - out << "h="; - if ( x.get_h().is_defined() ) - out << x.get_h(); - else - out << "inf (extr. barrier)"; - out << " f=" << x.get_f(); - } - else - out << "failed"; - out << std::endl; - } - if ( !_p.get_opt_only_sgte() ) - return; - - cur_bbe = _stats.get_sgte_eval(); - } - else - cur_bbe = _stats.get_eval(); - - const std::string & stats_file_name = _p.get_stats_file_name(); - bool feas_x = x.is_feasible ( _p.get_h_min() ); - - // update the history file: - // (contains surrogate evaluations if opt_only_sgte==true) - const std::string & his_file = _p.get_history_file(); - if ( !his_file.empty() && cur_bbe > _last_history_bbe) - { - write_sol_or_his_file ( _p.get_problem_dir() + his_file , x , false ); - _last_history_bbe = cur_bbe; - } - - // success displays: - if ( one_eval_success != NOMAD::UNSUCCESSFUL && - one_eval_success >= success ) - { - - // save the current solution in file: - write_solution_file ( x ); - - bool ds_ok = ( cur_bbe > _last_stats_bbe) && - ( _p.get_display_all_eval() || - ( one_eval_success == NOMAD::FULL_SUCCESS && feas_x ) ); - - // normal display and minimal: - if ( (display_degree == NOMAD::NORMAL_DISPLAY || display_degree == NOMAD::MINIMAL_DISPLAY ) && ds_ok ) - display_stats ( false , out , _p.get_display_stats() , &x , feas_x , NULL ); - // detailed display: - else if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << search << " " << one_eval_success - << " point " << x; - - // stats file: - if ( ds_ok && !stats_file_name.empty() ) - stats_file ( stats_file_name , &x , feas_x , NULL ); - - } - else - { - - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - out << search << " " << one_eval_success - << " point #" << x.get_tag(); - if ( x.is_eval_ok() ) - out << " [ h=" << x.get_h() - << " f=" << x.get_f() << " ]" << std::endl; - else if (x.check_rejected()) - out << ": evaluation rejected by user (this may alter convergence properties!)" << std::endl; - else - out << ": evaluation failed (you may need to check the source of the problem)." << std::endl; - } - - if ( _p.get_display_all_eval() && cur_bbe > _last_stats_bbe ) - { - - if ( display_degree == NOMAD::NORMAL_DISPLAY || display_degree == NOMAD::MINIMAL_DISPLAY ) - display_stats ( false , out , _p.get_display_stats() , &x , feas_x , NULL ); - - if ( !stats_file_name.empty() ) - stats_file ( stats_file_name , &x , feas_x , NULL ); - } - } + const NOMAD::Display & out = _p.out(); + int cur_bbe; + + // surrogate evaluation: + if ( x.get_eval_type() == NOMAD::SGTE ) + { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + out << std::endl << "point #" << x.get_tag() << " sgte eval: "; + if ( x.is_eval_ok() ) + { + out << "h="; + if ( x.get_h().is_defined() ) + out << x.get_h(); + else + out << "inf (extr. barrier)"; + out << " f=" << x.get_f(); + } + else + out << "failed"; + out << std::endl; + } + if ( !_p.get_opt_only_sgte() ) + return; + + cur_bbe = _stats.get_sgte_eval(); + } + else + cur_bbe = _stats.get_eval(); + + const std::string & stats_file_name = _p.get_stats_file_name(); + bool feas_x = x.is_feasible ( _p.get_h_min() ); + + // update the history file: + // (contains surrogate evaluations if opt_only_sgte==true) + const std::string & his_file = _p.get_history_file(); + if ( !his_file.empty() && cur_bbe > _last_history_bbe) + { + write_sol_or_his_file ( _p.get_problem_dir() + his_file , x , false ); + _last_history_bbe = cur_bbe; + } + + // success displays: + if ( one_eval_success != NOMAD::UNSUCCESSFUL && + one_eval_success >= success ) + { + + // save the current solution in file: + write_solution_file ( x ); + + bool ds_ok = ( cur_bbe > _last_stats_bbe) && + ( _p.get_display_all_eval() || + ( one_eval_success == NOMAD::FULL_SUCCESS && feas_x ) ); + + // normal display and minimal: + if ( (display_degree == NOMAD::NORMAL_DISPLAY || display_degree == NOMAD::MINIMAL_DISPLAY ) && ds_ok ) + display_stats ( false , out , _p.get_display_stats() , &x , feas_x , NULL ); + // detailed display: + else if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl << search << " " << one_eval_success + << " point " << x; + + // stats file: + if ( ds_ok && !stats_file_name.empty() ) + stats_file ( stats_file_name , &x , feas_x , NULL ); + + } + else + { + + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + out << search << " " << one_eval_success + << " point #" << x.get_tag(); + if ( x.is_eval_ok() ) + out << " [ h=" << x.get_h() + << " f=" << x.get_f() << " ]" << std::endl; + else if (x.check_rejected()) + out << ": evaluation rejected by user (this may alter convergence properties!)" << std::endl; + else + out << ": evaluation failed (you may need to check the source of the problem)." << std::endl; + } + + if ( _p.get_display_all_eval() && cur_bbe > _last_stats_bbe ) + { + + if ( display_degree == NOMAD::NORMAL_DISPLAY || display_degree == NOMAD::MINIMAL_DISPLAY ) + display_stats ( false , out , _p.get_display_stats() , &x , feas_x , NULL ); + + if ( !stats_file_name.empty() ) + stats_file ( stats_file_name , &x , feas_x , NULL ); + } + } } @@ -937,14 +942,13 @@ void NOMAD::Evaluator_Control::display_eval_result /* . return true if the point is in cache */ /* . private method */ /*-------------------------------------------*/ -bool NOMAD::Evaluator_Control::cache_check -( const NOMAD::Eval_Point *& x , - NOMAD::Barrier & true_barrier , - NOMAD::Barrier & sgte_barrier , - NOMAD::Pareto_Front * pareto_front , - bool & count_eval , - const NOMAD::Double & h_max , - NOMAD::dd_type display_degree ) const +bool NOMAD::Evaluator_Control::cache_check ( const NOMAD::Eval_Point *& x , + NOMAD::Barrier & true_barrier , + NOMAD::Barrier & sgte_barrier , + NOMAD::Pareto_Front * pareto_front , + bool & count_eval , + const NOMAD::Double & h_max , + NOMAD::dd_type display_degree ) const { NOMAD::eval_type x_eval_type = x->get_eval_type(); const NOMAD::Eval_Point * cache_x = NULL; @@ -980,6 +984,8 @@ bool NOMAD::Evaluator_Control::cache_check modifiable_cache_x->set_signature ( x->get_signature () ); modifiable_cache_x->set_direction ( x->get_direction () ); + + // The point in cache is updated for the poll center to correspond to the new poll center of x (important for poll reduction) modifiable_cache_x->set_poll_center ( x->get_poll_center () ); modifiable_cache_x->set_poll_center_type ( x->get_poll_center_type () ); modifiable_cache_x->set_user_eval_priority ( x->get_user_eval_priority() ); @@ -1003,9 +1009,9 @@ bool NOMAD::Evaluator_Control::cache_check cache_x->get_h().is_defined() && cache_x->get_h() < h_max ) ) ) { - x = cache_x; - cache_x = NULL; - } + x = cache_x; + cache_x = NULL; + } // point in cache: if ( cache_x ) @@ -1046,235 +1052,240 @@ bool NOMAD::Evaluator_Control::cache_check /* eval a point (private) */ /*----------------------------------------------------*/ void NOMAD::Evaluator_Control::eval_point ( NOMAD::Eval_Point & x , - NOMAD::Barrier & true_barrier , - NOMAD::Barrier & sgte_barrier , - NOMAD::Pareto_Front * pareto_front , - bool & count_eval , - bool & stop , - NOMAD::stop_type & stop_reason , - const NOMAD::Double & h_max ) + NOMAD::Barrier & true_barrier , + NOMAD::Barrier & sgte_barrier , + NOMAD::Pareto_Front * pareto_front , + bool & count_eval , + bool & stop , + NOMAD::stop_type & stop_reason , + const NOMAD::Double & h_max ) { - int max_bb_eval = _p.get_max_bb_eval(); - int max_sgte_eval = _p.get_max_sgte_eval(); - - // blackbox or surrogate evaluations are allowed: - if ( ( x.get_eval_type() == NOMAD::TRUTH && max_bb_eval != 0 ) || - ( x.get_eval_type() == NOMAD::SGTE && max_sgte_eval != 0 ) ) - { - - NOMAD::Eval_Point * eval_x = &NOMAD::Cache::get_modifiable_point ( x ); - - // get the signature: - NOMAD::Signature * signature = x.get_signature(); - if ( !signature ) - throw NOMAD::Exception ( "Evaluator_Control.cpp" , __LINE__ , - "Evaluator_Control::eval_point(): the point has no signature" ); - - // evaluation of the point: - // ------------------------ - bool eval_ok = true; + int max_bb_eval = _p.get_max_bb_eval(); + int max_sgte_eval = _p.get_max_sgte_eval(); + + // blackbox or surrogate evaluations are allowed: + if ( ( x.get_eval_type() == NOMAD::TRUTH && max_bb_eval != 0 ) || + ( x.get_eval_type() == NOMAD::SGTE && max_sgte_eval != 0 ) ) + { + + NOMAD::Eval_Point * eval_x = &NOMAD::Cache::get_modifiable_point ( x ); + + // get the signature: + NOMAD::Signature * signature = x.get_signature(); + if ( !signature ) + throw NOMAD::Exception ( "Evaluator_Control.cpp" , __LINE__ , + "Evaluator_Control::eval_point(): the point has no signature" ); + + // evaluation of the point: + // ------------------------ + bool eval_ok = true; NOMAD::Evaluator_Control::_force_evaluation_failure=false; - - { - // 1. scaling: - bool do_scaling = signature->get_scaling().is_defined(); - if ( do_scaling ) - eval_x->scale(); - - // 2.1. evaluation: - try - { - eval_ok = _ev->eval_x ( *eval_x , h_max , count_eval ); - - } + + { + // 1. scaling: + bool do_scaling = signature->get_scaling().is_defined(); + if ( do_scaling ) + eval_x->scale(); + + // 2.1. evaluation: + try + { + eval_ok = _ev->eval_x ( *eval_x , h_max , count_eval ); + + } catch ( exception & e ) { throw NOMAD::Exception ( "Evaluator_control.cpp" , __LINE__ , e.what() ); } - - // 2.2. check the nan's: - if ( eval_ok && eval_x->check_nan() ) - eval_ok = false; + + // 2.2. check the nan's: + if ( eval_ok && eval_x->check_nan() ) + eval_ok = false; if ( _force_evaluation_failure ) eval_ok = false; - - // 3. unscaling: - if ( do_scaling ) - eval_x->unscale(); - } - - if ( eval_ok ) - { - - eval_x->set_eval_status ( NOMAD::EVAL_OK ); - - // set_f, set_h and set_EB_ok: - _ev->compute_f ( *eval_x ); - _ev->compute_h ( *eval_x ); - - } - else - { - eval_x->set_eval_status ( NOMAD::EVAL_FAIL ); - _stats.add_failed_eval(); - } - - // insertion in cache even if is_eval_ok == false: - if ( !x.is_in_cache() ) - { - - int size_before , size_after; - - if ( x.get_eval_type() == NOMAD::SGTE ) { - size_before = _sgte_cache->size(); - _sgte_cache->insert(x); - size_after = _sgte_cache->size(); - } - else { - size_before = _cache->size(); - _cache->insert(x); - size_after = _cache->size(); - } - - if ( size_after == size_before ) - x.set_in_cache ( false ); - } - - } - + + // 3. unscaling: + if ( do_scaling ) + eval_x->unscale(); + } + + if ( eval_ok ) + { + + eval_x->set_eval_status ( NOMAD::EVAL_OK ); + + // set_f, set_h and set_EB_ok: + _ev->compute_f ( *eval_x ); + _ev->compute_h ( *eval_x ); + + } + else + { + eval_x->set_eval_status ( NOMAD::EVAL_FAIL ); + _stats.add_failed_eval(); + } + + // insertion in cache even if is_eval_ok == false: + if ( !x.is_in_cache() ) + { + + int size_before , size_after; + + if ( x.get_eval_type() == NOMAD::SGTE ) + { + size_before = _sgte_cache->size(); + _sgte_cache->insert(x); + size_after = _sgte_cache->size(); + } + else + { + + size_before = _cache->size(); + _cache->insert(x); + size_after = _cache->size(); + } + + if ( size_after == size_before ) + x.set_in_cache ( false ); + } + + } + } /*----------------------------------------------------*/ /* eval points in a list (private) */ /*----------------------------------------------------*/ -void NOMAD::Evaluator_Control::eval_points ( std::list<NOMAD::Eval_Point *> & list_eval , - NOMAD::Barrier & true_barrier , - NOMAD::Barrier & sgte_barrier , - NOMAD::Pareto_Front * pareto_front , - std::list<bool> & count_list_eval, - bool & stop , - NOMAD::stop_type & stop_reason , - const NOMAD::Double & h_max ) +void NOMAD::Evaluator_Control::eval_points ( std::list<NOMAD::Eval_Point *> & list_eval , + NOMAD::Barrier & true_barrier , + NOMAD::Barrier & sgte_barrier , + NOMAD::Pareto_Front * pareto_front , + std::list<bool> & count_list_eval , + bool & stop , + NOMAD::stop_type & stop_reason , + const NOMAD::Double & h_max ) { - int max_bb_eval = _p.get_max_bb_eval(); - int max_sgte_eval = _p.get_max_sgte_eval(); - - std::list<NOMAD::Eval_Point*>::iterator it_begin=list_eval.begin(); - - if ( ( (*it_begin)->get_eval_type() == NOMAD::TRUTH && max_bb_eval != 0 ) || - ( (*it_begin)->get_eval_type() == NOMAD::SGTE && max_sgte_eval != 0 ) ) - { - - // 1. Pre-evaluation tests and scaling - for ( std::list<NOMAD::Eval_Point*>::iterator it=it_begin;it!=list_eval.end();++it) - { - // get the signature: - NOMAD::Signature * signature = (*it)->get_signature(); - if ( !signature ) - throw NOMAD::Exception ( "Evaluator_Control.cpp" , __LINE__ , - "Evaluator_Control::eval_points(): the point has no signature" ); - - // Scaling before evaluation of the points: - bool do_scaling = signature->get_scaling().is_defined(); - if ( do_scaling ) - (*it)->scale(); - - } - - // 2. list evaluation: - bool eval_list_ok = true; + int max_bb_eval = _p.get_max_bb_eval(); + int max_sgte_eval = _p.get_max_sgte_eval(); + + std::list<NOMAD::Eval_Point*>::iterator it_begin=list_eval.begin(); + + // blackbox or surrogate evaluations are allowed: + if ( ( (*it_begin)->get_eval_type() == NOMAD::TRUTH && max_bb_eval != 0 ) || + ( (*it_begin)->get_eval_type() == NOMAD::SGTE && max_sgte_eval != 0 ) ) + { + + // 1. Pre-evaluation tests and scaling + for ( std::list<NOMAD::Eval_Point*>::iterator it=it_begin;it!=list_eval.end();++it) + { + // get the signature: + NOMAD::Signature * signature = (*it)->get_signature(); + if ( !signature ) + throw NOMAD::Exception ( "Evaluator_Control.cpp" , __LINE__ , + "Evaluator_Control::eval_points(): the point has no signature" ); + + // Scaling before evaluation of the points: + bool do_scaling = signature->get_scaling().is_defined(); + if ( do_scaling ) + (*it)->scale(); + + } + + // 2. list evaluation: + bool eval_list_ok = true; + NOMAD::Evaluator_Control::_force_evaluation_failure=false; - try - { - eval_list_ok=_ev->eval_x ( list_eval , h_max,count_list_eval ); - } + try + { + eval_list_ok=_ev->eval_x ( list_eval , h_max,count_list_eval ); + } catch ( exception & e ) { throw NOMAD::Exception ( "Evaluator_control.cpp" , __LINE__ , e.what() ); } - + if ( _force_evaluation_failure ) eval_list_ok = false; - - // One block of evaluations is counted - if ( eval_list_ok ) - _stats.add_one_block_eval(); - - - // 3. Post list evaluation checks and operation - std::list<bool>::iterator it_count=count_list_eval.begin(); - for ( std::list<NOMAD::Eval_Point*>::iterator it=it_begin;it!=list_eval.end();++it,++it_count) - { - bool eval_ok=true; - bool eval_rejected=false; - - // 3.1. check the nan's and list evaluation failure: - if ( !eval_list_ok || (*it)->check_nan() ) - eval_ok = false; - - if ((*it)->check_rejected()) - { - eval_rejected=true; - eval_ok=false; - } - - // 3.2 unscaling: - if ( (*it)->get_signature()->get_scaling().is_defined() ) - (*it)->unscale(); - - - if ( eval_ok && (*it)->get_eval_status()!=NOMAD::EVAL_FAIL ) - { - (*it)->set_eval_status ( NOMAD::EVAL_OK ); - - // set_f, set_h and set_EB_ok: - _ev->compute_f ( *(*it) ); - _ev->compute_h ( *(*it)); - - } - else if (!eval_rejected) - { - (*it)->set_eval_status ( NOMAD::EVAL_FAIL ); - _stats.add_failed_eval(); - } // Do nothing if eval has been rejected - - // insertion in cache even if is_eval_ok == false. Exception: a point that has been rejected by user is not put in the cache. - if ( !(*it)->is_in_cache() && !eval_rejected ) - { - - int size_before , size_after; - - if ( (*it)->get_eval_type() == NOMAD::SGTE ) - { - size_before = _sgte_cache->size(); - _sgte_cache->insert(*(*it)); - size_after = _sgte_cache->size(); - } - else - { - size_before = _cache->size(); - _cache->insert(*(*it)); - size_after = _cache->size(); - } - - if ( size_after == size_before ) - (*it)->set_in_cache ( false ); - } - - - // count the output stats (STAT_SUM and STAT_AVG): - if ( (_p.check_stat_sum() || _p.check_stat_avg()) && !eval_rejected) - count_output_stats(*(*it)); - - } - } + // One block of evaluations is counted + if ( eval_list_ok ) + _stats.add_one_block_eval(); + + + + // 3. Post list evaluation checks and operation + std::list<bool>::iterator it_count=count_list_eval.begin(); + for ( std::list<NOMAD::Eval_Point*>::iterator it=it_begin;it!=list_eval.end();++it,++it_count) + { + bool eval_ok=true; + bool eval_rejected=false; + + // 3.1. check the nan's and list evaluation failure: + if ( !eval_list_ok || (*it)->check_nan() ) + eval_ok = false; + + if ((*it)->check_rejected()) + { + eval_rejected=true; + eval_ok=false; + } + + // 3.2 unscaling: + if ( (*it)->get_signature()->get_scaling().is_defined() ) + (*it)->unscale(); + + // Check that everything is ok and also that the user did not set the evaluation as failed + if ( eval_ok && (*it)->get_eval_status()!=NOMAD::EVAL_FAIL ) + { + (*it)->set_eval_status ( NOMAD::EVAL_OK ); + + // set_f, set_h and set_EB_ok: + _ev->compute_f ( *(*it) ); + _ev->compute_h ( *(*it)); + + } + else if (!eval_rejected) + { + (*it)->set_eval_status ( NOMAD::EVAL_FAIL ); + _stats.add_failed_eval(); + } // Do nothing if eval has been rejected + + // insertion in cache even if is_eval_ok == false. Exception: a point that has been rejected by user is not put in the cache. + if ( !(*it)->is_in_cache() && !eval_rejected ) + { + + int size_before , size_after; + + if ( (*it)->get_eval_type() == NOMAD::SGTE ) + { + size_before = _sgte_cache->size(); + _sgte_cache->insert(*(*it)); + size_after = _sgte_cache->size(); + } + else + { + size_before = _cache->size(); + _cache->insert(*(*it)); + size_after = _cache->size(); + } + + if ( size_after == size_before ) + (*it)->set_in_cache ( false ); + } + + + // count the output stats (STAT_SUM and STAT_AVG): + if ( (_p.check_stat_sum() || _p.check_stat_avg()) && !eval_rejected) + count_output_stats(*(*it)); + + } + } } @@ -1284,221 +1295,228 @@ void NOMAD::Evaluator_Control::eval_points ( std::list<NOMAD::Eval_Point *> & li /*-------------------------------------------*/ void NOMAD::Evaluator_Control::check_stopping_criteria ( NOMAD::search_type search , - bool count_eval , - const NOMAD::Eval_Point & x , - bool & stop , - NOMAD::stop_type & stop_reason ) const + bool count_eval , + const NOMAD::Eval_Point & x , + bool & stop , + NOMAD::stop_type & stop_reason ) const { - // check the time: - if ( !stop && - _p.get_max_time() > 0 && - _stats.get_real_time() >= _p.get_max_time() ) - { - stop = true; - stop_reason = NOMAD::MAX_TIME_REACHED; - } - - // count an evaluation or a simulated blackbox evaluation: - if ( x.get_eval_type() == NOMAD::TRUTH ) - { - _stats.add_eval(); - if ( count_eval && !x.get_current_run() ) - _stats.add_sim_bb_eval(); - } - - - // check STAT_SUM_TARGET: - if ( !stop && - (_p.check_stat_sum() || _p.check_stat_avg())) - { - - NOMAD::Double sum_target = _p.get_stat_sum_target(); - if ( sum_target.is_defined() ) - { - NOMAD::Double sum = _stats.get_stat_sum(); - if ( sum.is_defined() && sum >= sum_target ) - { - stop = true; - stop_reason = NOMAD::STAT_SUM_TARGET_REACHED; - } - } - } - - // check the number of blackbox evaluations: - if ( !stop ) - { - int max_bb_eval = _p.get_max_bb_eval(); - int max_sgte_eval = _p.get_max_sgte_eval(); - if ( max_bb_eval > 0 && _stats.get_bb_eval() >= max_bb_eval ) - { - stop = true; - stop_reason = NOMAD::MAX_BB_EVAL_REACHED; - } - if ( max_sgte_eval > 0 && _stats.get_sgte_eval() >= max_sgte_eval ) - { - stop = true; - stop_reason = NOMAD::MAX_SGTE_EVAL_REACHED; - } - } - - // check the stopping condition MAX_EVAL: - if ( !stop && - _p.get_max_eval() > 0 && - _stats.get_eval() >= _p.get_max_eval() ) - { - stop = true; - stop_reason = NOMAD::MAX_EVAL_REACHED; - } - - // check the stopping condition MAX_SIM_BB_EVAL: - if ( !stop && - _p.get_max_sim_bb_eval() > 0 && - _stats.get_sim_bb_eval() >= _p.get_max_sim_bb_eval() ) - { - stop = true; - stop_reason = NOMAD::MAX_SIM_BB_EVAL_REACHED; - } - - // check the stopping conditions F_TARGET and FEAS_REACHED - // (for phase one: the evaluations must stop if all EB - // constraints are satisfied, but some PB constraints can - // be violated) - if ( !stop && - x.is_eval_ok() && - ( _p.get_opt_only_sgte() || - x.get_eval_type() == NOMAD::TRUTH ) ) - { - - bool feasible = x.is_feasible ( _p.get_h_min() ); - - // check FEAS_REACHED: - if ( feasible && _p.get_stop_if_feasible() ) - { - stop = true; - stop_reason = NOMAD::FEAS_REACHED; - } - - // check F_TARGET: - { - const NOMAD::Point & f_target = _p.get_f_target(); - const std::list<int> & index_obj = _p.get_index_obj(); - std::list<int>::const_iterator index_obj_end = index_obj.end(); - bool check_f_target = f_target.is_defined(); - int nb_to_check = (check_f_target) ? - f_target.nb_defined() : 0; - - if ( check_f_target && ( feasible || search == NOMAD::LH_SEARCH_P1 ) ) - { - const NOMAD::Point & bbo = x.get_bb_outputs(); - bool chk = true; - int k = 0; - int cnt = 0; - for ( std::list<int>::const_iterator it = index_obj.begin(); - it != index_obj_end ; ++it , ++k ) - { - if ( bbo[*it].is_defined() && f_target[k].is_defined() ) - { - if ( f_target[k] < bbo[*it] ) - { - chk = false; - break; - } - cnt++; - } - } - - if ( chk && cnt == nb_to_check ) - { - stop = true; - stop_reason = NOMAD::F_TARGET_REACHED; - } - } - } - } + // check the time: + if ( !stop && + _p.get_max_time() > 0 && + _stats.get_real_time() >= _p.get_max_time() ) + { + stop = true; + stop_reason = NOMAD::MAX_TIME_REACHED; + } + + // count an evaluation or a simulated blackbox evaluation: + if ( x.get_eval_type() == NOMAD::TRUTH ) + { + _stats.add_eval(); + if ( count_eval && !x.get_current_run() ) + _stats.add_sim_bb_eval(); + } + + + // check STAT_SUM_TARGET: + if ( !stop && + (_p.check_stat_sum() || _p.check_stat_avg())) + { + + NOMAD::Double sum_target = _p.get_stat_sum_target(); + if ( sum_target.is_defined() ) + { + NOMAD::Double sum = _stats.get_stat_sum(); + if ( sum.is_defined() && sum >= sum_target ) + { + stop = true; + stop_reason = NOMAD::STAT_SUM_TARGET_REACHED; + } + } + } + + // check the number of blackbox evaluations: + if ( !stop ) + { + int max_bb_eval = _p.get_max_bb_eval(); + int max_sgte_eval = _p.get_max_sgte_eval(); + if ( max_bb_eval > 0 && _stats.get_bb_eval() >= max_bb_eval ) + { + stop = true; + stop_reason = NOMAD::MAX_BB_EVAL_REACHED; + } + if ( max_sgte_eval > 0 && _stats.get_sgte_eval() >= max_sgte_eval ) + { + stop = true; + stop_reason = NOMAD::MAX_SGTE_EVAL_REACHED; + } + } + + // check the stopping condition MAX_EVAL: + if ( !stop && + _p.get_max_eval() > 0 && + _stats.get_eval() >= _p.get_max_eval() ) + { + stop = true; + stop_reason = NOMAD::MAX_EVAL_REACHED; + } + + // check the stopping condition MAX_SIM_BB_EVAL: + if ( !stop && + _p.get_max_sim_bb_eval() > 0 && + _stats.get_sim_bb_eval() >= _p.get_max_sim_bb_eval() ) + { + stop = true; + stop_reason = NOMAD::MAX_SIM_BB_EVAL_REACHED; + } + + // check the stopping conditions F_TARGET and FEAS_REACHED + // (for phase one: the evaluations must stop if all EB + // constraints are satisfied, but some PB constraints can + // be violated) + if ( !stop && + x.is_eval_ok() && + ( _p.get_opt_only_sgte() || + x.get_eval_type() == NOMAD::TRUTH ) ) + { + + bool feasible = x.is_feasible ( _p.get_h_min() ); + + // check FEAS_REACHED: + if ( feasible && _p.get_stop_if_feasible() ) + { + stop = true; + stop_reason = NOMAD::FEAS_REACHED; + } + + // check F_TARGET: + { + const NOMAD::Point & f_target = _p.get_f_target(); + const std::list<int> & index_obj = _p.get_index_obj(); + std::list<int>::const_iterator index_obj_end = index_obj.end(); + bool check_f_target = f_target.is_defined(); + int nb_to_check = (check_f_target) ? + f_target.nb_defined() : 0; + + if ( check_f_target && ( feasible || search == NOMAD::LH_SEARCH_P1 ) ) + { + const NOMAD::Point & bbo = x.get_bb_outputs(); + bool chk = true; + int k = 0; + int cnt = 0; + for ( std::list<int>::const_iterator it = index_obj.begin(); + it != index_obj_end ; ++it , ++k ) + { + if ( bbo[*it].is_defined() && f_target[k].is_defined() ) + { + if ( f_target[k] < bbo[*it] ) + { + chk = false; + break; + } + cnt++; + } + } + + if ( chk && cnt == nb_to_check ) + { + stop = true; + stop_reason = NOMAD::F_TARGET_REACHED; + } + } + } + } } /*-------------------------------------------------------*/ /* receive an evaluation result from a slave (private) */ /*-------------------------------------------------------*/ #ifdef USE_MPI -void NOMAD::Evaluator_Control::receive_eval_result -( NOMAD::search_type search , - NOMAD::Eval_Point * x , - NOMAD::Barrier & true_barrier , - NOMAD::Barrier & sgte_barrier , - NOMAD::Pareto_Front * pareto_front , - int slave_rank , - bool & stop , - NOMAD::stop_type & stop_reason ) +void NOMAD::Evaluator_Control::receive_eval_result ( NOMAD::search_type search , + NOMAD::Eval_Point * x , + NOMAD::Barrier & true_barrier , + NOMAD::Barrier & sgte_barrier , + NOMAD::Pareto_Front * pareto_front , + int slave_rank , + bool & stop , + NOMAD::stop_type & stop_reason ) { - bool eval_ok , count_eval; - - - // receive the evaluation result: - _slave->receive_eval_result ( slave_rank , x , eval_ok , count_eval ); - - // process the evaluation: - if ( eval_ok ) { - - // set_f, set_h and set_EB_ok: - _ev->compute_f ( *x ); - _ev->compute_h ( *x ); - - // process the evaluated point: - process_eval_point ( *x , - (x->get_eval_type()==NOMAD::TRUTH) ? - true_barrier : sgte_barrier , - pareto_front ); - } - else - _stats.add_failed_eval(); - - // insertion in cache even if !eval_ok: - if ( !x->is_in_cache() ) - ( ( x->get_eval_type() == NOMAD::SGTE ) ? - _sgte_cache : _cache)->insert ( *x ); - - // count the bb evaluation: - if ( count_eval ) { - if ( x->get_eval_type() == NOMAD::SGTE ) - _stats.add_sgte_eval(); + bool eval_ok , count_eval; + + + // receive the evaluation result: + _slave->receive_eval_result ( slave_rank , x , eval_ok , count_eval ); + + // process the evaluation: + if ( eval_ok ) + { + + // set_f, set_h and set_EB_ok: + _ev->compute_f ( *x ); + _ev->compute_h ( *x ); + + // process the evaluated point: + process_eval_point ( *x , + (x->get_eval_type()==NOMAD::TRUTH) ? + true_barrier : sgte_barrier , + pareto_front ); + } else - _stats.add_bb_eval(); - } - - // count the output stats (STAT_SUM and STAT_AVG): - if ( _p.check_stat_sum() || _p.check_stat_avg() ) { - - count_output_stats ( *x ); - - // check STAT_SUM_TARGET: - NOMAD::Double sum_target = _p.get_stat_sum_target(); - if ( sum_target.is_defined() ) { - NOMAD::Double sum = _stats.get_stat_sum(); - if ( !stop && sum.is_defined() && sum >= sum_target ) { - stop = true; - stop_reason = NOMAD::STAT_SUM_TARGET_REACHED; - } - } - } - - // check stopping criteria: - if ( !stop ) { - - int max_bb_eval = _p.get_max_bb_eval(); - int max_sgte_eval = _p.get_max_sgte_eval(); + _stats.add_failed_eval(); + + // insertion in cache even if !eval_ok: + if ( !x->is_in_cache() ) + ( ( x->get_eval_type() == NOMAD::SGTE ) ? + _sgte_cache : _cache)->insert ( *x ); - if ( max_bb_eval > 0 && _stats.get_bb_eval() >= max_bb_eval ) { - stop = true; - stop_reason = NOMAD::MAX_BB_EVAL_REACHED; + // count the bb evaluation: + if ( count_eval ) + { + if ( x->get_eval_type() == NOMAD::SGTE ) + _stats.add_sgte_eval(); + else + _stats.add_bb_eval(); } - if ( max_sgte_eval > 0 && _stats.get_sgte_eval() >= max_sgte_eval ) { - stop = true; - stop_reason = NOMAD::MAX_SGTE_EVAL_REACHED; + + // count the output stats (STAT_SUM and STAT_AVG): + if ( _p.check_stat_sum() || _p.check_stat_avg() ) + { + + count_output_stats ( *x ); + + // check STAT_SUM_TARGET: + NOMAD::Double sum_target = _p.get_stat_sum_target(); + if ( sum_target.is_defined() ) + { + NOMAD::Double sum = _stats.get_stat_sum(); + if ( !stop && sum.is_defined() && sum >= sum_target ) + { + stop = true; + stop_reason = NOMAD::STAT_SUM_TARGET_REACHED; + } + } } - } - - check_stopping_criteria ( search , count_eval , *x , stop , stop_reason ); + + // check stopping criteria: + if ( !stop ) + { + + int max_bb_eval = _p.get_max_bb_eval(); + int max_sgte_eval = _p.get_max_sgte_eval(); + + if ( max_bb_eval > 0 && _stats.get_bb_eval() >= max_bb_eval ) + { + stop = true; + stop_reason = NOMAD::MAX_BB_EVAL_REACHED; + } + if ( max_sgte_eval > 0 && _stats.get_sgte_eval() >= max_sgte_eval ) + { + stop = true; + stop_reason = NOMAD::MAX_SGTE_EVAL_REACHED; + } + } + + check_stopping_criteria ( search , count_eval , *x , stop , stop_reason ); } #endif @@ -1506,100 +1524,99 @@ void NOMAD::Evaluator_Control::receive_eval_result /* wait for evaluations in progress */ /*----------------------------------------------------*/ #ifdef USE_MPI -void NOMAD::Evaluator_Control::wait_for_evaluations -( NOMAD::search_type search , - NOMAD::Barrier & true_barrier , - NOMAD::Barrier & sgte_barrier , - NOMAD::Pareto_Front * pareto_front , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - std::list<const NOMAD::Eval_Point *> & evaluated_pts ) -{ - if ( _nb_in_progress == 0 ) - return; - - // display degree: - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_display_degree ( search ); - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << NOMAD::open_block ( "wait for evaluations" ); - - NOMAD::Barrier & barrier = ( _p.get_opt_only_sgte() ) ? - sgte_barrier : true_barrier; - char signal; - int source; - NOMAD::Eval_Point * eval_x; - NOMAD::success_type one_eval_success; - - while ( _nb_in_progress > 0 ) - { - - source = NOMAD::Slave::receive_signal ( signal ); - eval_x = _eval_in_progress[source]; - - if ( eval_x ) - { - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << "receive eval point #" << eval_x->get_tag() - << " from slave " << source << std::endl << std::endl; - - receive_eval_result ( search , - eval_x , - true_barrier , - sgte_barrier , - pareto_front , - source , - stop , - stop_reason ); - - // list of processed points: - if ( eval_x->is_in_cache() ) - evaluated_pts.push_back ( eval_x ); - - // success: - one_eval_success = barrier.get_one_eval_succ(); - success = barrier.get_success(); - - // asynchronous success count: - if ( success == NOMAD::FULL_SUCCESS && - _elop_tag != _slaves_elop_tags[source] ) - _stats.add_asynchronous_success(); - - // displays: - display_eval_result ( *eval_x , - display_degree , - search , - one_eval_success , - success ); - - if ( !_eval_in_progress[source]->is_in_cache() ) - delete _eval_in_progress[source]; - _eval_in_progress[source] = NULL; - _slaves_elop_tags[source] = -1; - --_nb_in_progress; - - // force quit (by pressing ctrl-c): - if ( !stop && ( NOMAD::Evaluator_Control::_force_quit || NOMAD::Evaluator::get_force_quit() ) ) - { - stop = true; - stop_reason = NOMAD::CTRL_C; - break; - } - - if ( stop && ( stop_reason==NOMAD::ERROR || - stop_reason==NOMAD::UNKNOWN_STOP_REASON ) ) - break; - } - else - NOMAD::Slave::send_signal ( NOMAD::WAIT_SIGNAL , source ); - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out.close_block(); +void NOMAD::Evaluator_Control::wait_for_evaluations ( NOMAD::search_type search , + NOMAD::Barrier & true_barrier , + NOMAD::Barrier & sgte_barrier , + NOMAD::Pareto_Front * pareto_front , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + std::list<const NOMAD::Eval_Point *> & evaluated_pts ) +{ + if ( _nb_in_progress == 0 ) + return; + + // display degree: + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_display_degree ( search ); + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl + << NOMAD::open_block ( "wait for evaluations" ); + + NOMAD::Barrier & barrier = ( _p.get_opt_only_sgte() ) ? + sgte_barrier : true_barrier; + char signal; + int source; + NOMAD::Eval_Point * eval_x; + NOMAD::success_type one_eval_success; + + while ( _nb_in_progress > 0 ) + { + + source = NOMAD::Slave::receive_signal ( signal ); + eval_x = _eval_in_progress[source]; + + if ( eval_x ) + { + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl << "receive eval point #" << eval_x->get_tag() + << " from slave " << source << std::endl << std::endl; + + receive_eval_result ( search , + eval_x , + true_barrier , + sgte_barrier , + pareto_front , + source , + stop , + stop_reason ); + + // list of processed points: + if ( eval_x->is_in_cache() ) + evaluated_pts.push_back ( eval_x ); + + // success: + one_eval_success = barrier.get_one_eval_succ(); + success = barrier.get_success(); + + // asynchronous success count: + if ( success == NOMAD::FULL_SUCCESS && + _elop_tag != _slaves_elop_tags[source] ) + _stats.add_asynchronous_success(); + + // displays: + display_eval_result ( *eval_x , + display_degree , + search , + one_eval_success , + success ); + + if ( !_eval_in_progress[source]->is_in_cache() ) + delete _eval_in_progress[source]; + _eval_in_progress[source] = NULL; + _slaves_elop_tags[source] = -1; + --_nb_in_progress; + + // force quit (by pressing ctrl-c): + if ( !stop && ( NOMAD::Evaluator_Control::_force_quit || NOMAD::Evaluator::get_force_quit() ) ) + { + stop = true; + stop_reason = NOMAD::CTRL_C; + break; + } + + if ( stop && ( stop_reason==NOMAD::ERROR || + stop_reason==NOMAD::UNKNOWN_STOP_REASON ) ) + break; + } + else + NOMAD::Slave::send_signal ( NOMAD::WAIT_SIGNAL , source ); + } + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out.close_block(); } #endif @@ -1608,21 +1625,21 @@ void NOMAD::Evaluator_Control::wait_for_evaluations /* (private) */ /*----------------------------------------------------------------*/ #ifdef USE_MPI -bool NOMAD::Evaluator_Control::already_in_progress -( const NOMAD::Eval_Point & x ) const +bool NOMAD::Evaluator_Control::already_in_progress ( const NOMAD::Eval_Point & x ) const { - if ( _eval_in_progress ) { - - int x_tag = x.get_tag(); - int np = NOMAD::Slave::get_nb_processes(); - - for ( int i = 0 ; i < np ; ++i ) - if ( _eval_in_progress[i] && - ( _eval_in_progress[i]->get_tag() == x_tag || - _eval_in_progress[i]->Point::operator == ( x ) ) ) - return true; - } - return false; + if ( _eval_in_progress ) + { + + int x_tag = x.get_tag(); + int np = NOMAD::Slave::get_nb_processes(); + + for ( int i = 0 ; i < np ; ++i ) + if ( _eval_in_progress[i] && + ( _eval_in_progress[i]->get_tag() == x_tag || + _eval_in_progress[i]->Point::operator == ( x ) ) ) + return true; + } + return false; } #endif @@ -1630,586 +1647,583 @@ bool NOMAD::Evaluator_Control::already_in_progress /* eval_list_of_points, private version (parallel version) */ /*----------------------------------------------------------------*/ #ifdef USE_MPI -void NOMAD::Evaluator_Control::private_eval_list_of_points -( NOMAD::search_type search , // IN : search type - NOMAD::Barrier & true_barrier , // IN/OUT : the barrier - NOMAD::Barrier & sgte_barrier , // IN/OUT : the surrogate barrier - NOMAD::Pareto_Front * pareto_front , // IN/OUT : the Pareto front - // (can be NULL) - bool & stop , // IN/OUT : stopping criterion - NOMAD::stop_type & stop_reason , // OUT : stopping reason - const NOMAD::Eval_Point *& new_feas_inc , // OUT : new feasible incumbent - const NOMAD::Eval_Point *& new_infeas_inc , // OUT : new infeas. incumbent - NOMAD::success_type & success , // OUT : type of success - std::list<const NOMAD::Eval_Point *> - & evaluated_pts ) // OUT : list of processed pts +void NOMAD::Evaluator_Control::private_eval_list_of_points ( NOMAD::search_type search , // IN : search type + NOMAD::Barrier & true_barrier , // IN/OUT : the barrier + NOMAD::Barrier & sgte_barrier , // IN/OUT : the surrogate barrier + NOMAD::Pareto_Front * pareto_front , // IN/OUT : the Pareto front // (can be NULL) + bool & stop , // IN/OUT : stopping criterion + NOMAD::stop_type & stop_reason , // OUT : stopping reason + const NOMAD::Eval_Point *& new_feas_inc , // OUT : new feasible incumbent + const NOMAD::Eval_Point *& new_infeas_inc , // OUT : new infeas. incumbent + NOMAD::success_type & success , // OUT : type of success + std::list<const NOMAD::Eval_Point *> + & evaluated_pts ) // OUT : list of processed pts { - if ( stop || _eval_lop.empty() ) - { - stop_reason = NOMAD::UNKNOWN_STOP_REASON; - ++_elop_tag; - return; - } - - evaluated_pts.clear(); - - - // initial display: - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_display_degree ( search ); - - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - std::ostringstream msg; - msg << "list of points evaluation (" << search << ")"; - out << std::endl << NOMAD::open_block ( msg.str() ); - } - - // call the Evaluator (virtual) preprocessing of a list of points: - _ev->list_of_points_preprocessing ( _eval_lop ); - - const NOMAD::Eval_Point * old_feasible_incumbent = NULL; - const NOMAD::Eval_Point * old_infeasible_incumbent = NULL; - - // active barrier: - NOMAD::Barrier & barrier = ( _p.get_opt_only_sgte() ) ? + if ( stop || _eval_lop.empty() ) + { + stop_reason = NOMAD::UNKNOWN_STOP_REASON; + ++_elop_tag; + return; + } + + evaluated_pts.clear(); + + + // initial display: + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_display_degree ( search ); + + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + std::ostringstream msg; + msg << "list of points evaluation (" << search << ")"; + out << std::endl << NOMAD::open_block ( msg.str() ); + } + + // call the Evaluator (virtual) preprocessing of a list of points: + _ev->list_of_points_preprocessing ( _eval_lop ); + + const NOMAD::Eval_Point * old_feasible_incumbent = NULL; + const NOMAD::Eval_Point * old_infeasible_incumbent = NULL; + + // active barrier: + NOMAD::Barrier & barrier = ( _p.get_opt_only_sgte() ) ? sgte_barrier : true_barrier; - - old_feasible_incumbent = barrier.get_best_feasible(); - old_infeasible_incumbent = barrier.get_best_infeasible(); - - NOMAD::Double f0; - if ( _p.get_opportunistic_min_f_imprvmt().is_defined() && - old_feasible_incumbent ) - f0 = old_feasible_incumbent->get_f(); - - new_feas_inc = NULL; - new_infeas_inc = NULL; - stop = false; - success = NOMAD::UNSUCCESSFUL; - stop_reason = NOMAD::NO_STOP; - - const NOMAD::Eval_Point * x; - NOMAD::check_failed_type check_failed_reason; - bool count_eval; - std::vector<const NOMAD::Eval_Point *> - to_be_evaluated; - NOMAD::success_type one_eval_success; - bool one_for_luck = false; - bool opp_stop = false; - int init_nb_eval = _stats.get_eval(); - int nb_success = 0; - int k = 0; - int nb_points = static_cast<int> ( _eval_lop.size() ); - int max_bb_eval = _p.get_max_bb_eval(); - - // loop #1: search in cache: - // ------------------------- - std::set<NOMAD::Priority_Eval_Point>::iterator + + old_feasible_incumbent = barrier.get_best_feasible(); + old_infeasible_incumbent = barrier.get_best_infeasible(); + + NOMAD::Double f0; + if ( _p.get_opportunistic_min_f_imprvmt().is_defined() && + old_feasible_incumbent ) + f0 = old_feasible_incumbent->get_f(); + + new_feas_inc = NULL; + new_infeas_inc = NULL; + stop = false; + success = NOMAD::UNSUCCESSFUL; + stop_reason = NOMAD::NO_STOP; + + const NOMAD::Eval_Point * x; + NOMAD::check_failed_type check_failed_reason; + bool count_eval; + std::vector<const NOMAD::Eval_Point *> + to_be_evaluated; + NOMAD::success_type one_eval_success; + bool one_for_luck = false; + bool opp_stop = false; + int init_nb_eval = _stats.get_eval(); + int nb_success = 0; + int k = 0; + int nb_points = static_cast<int> ( _eval_lop.size() ); + int max_bb_eval = _p.get_max_bb_eval(); + + // loop #1: search in cache: + // ------------------------- + std::set<NOMAD::Priority_Eval_Point>::iterator it = _eval_lop.begin() , end = _eval_lop.end(); - while ( !stop && !opp_stop && it != end ) - { - - x = it->get_point(); - - x->set_current_run ( true ); - - // displays: - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - - // open the evaluation block: - { - std::ostringstream oss; - if ( x->get_eval_type() == NOMAD::SGTE ) - oss << "surrogate "; - oss << "evaluation " << k+1 << "/" << nb_points; - out << std::endl << NOMAD::open_block ( oss.str() ); - } - - out << std::endl << "point #" << x->get_tag() << " ( "; - x->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); - out << " )" << std::endl; - if ( x->get_direction() ) - { - out << "direction : " << *x->get_direction() << std::endl; - NOMAD::Point delta; - x->get_signature()->get_mesh()->get_delta(delta); - out << "direction d : ( " << *x->get_direction()/delta << " )" << std::endl; - } - if ( x->get_signature() ) - out << "mesh indices: ( " << x->get_signature()->get_mesh()->get_mesh_indices() << " )" << std::endl; - out << std::endl; - - - - } - - // check if the evaluation at this point is already in progress: - if ( !already_in_progress ( *x ) ) - { - - // current point check (# of bb outputs, bounds, integer values, fixed-vars): - if ( x->check ( _p.get_bb_nb_outputs() , check_failed_reason ) ) - { - - count_eval = true; - - // point in cache: - if ( cache_check ( x , - true_barrier , - sgte_barrier , - pareto_front , - count_eval , - barrier.get_h_max() , - display_degree ) ) - - { - - // list of processed points: - evaluated_pts.push_back ( x ); - - // check stopping criteria: - check_stopping_criteria ( search , count_eval , *x , stop , stop_reason ); - - // success: - one_eval_success = barrier.get_one_eval_succ(); - success = barrier.get_success(); - - // displays: - display_eval_result ( *x , - display_degree , - search , - one_eval_success , - success ); - - // stop the evaluations (opportunistic strategy) ? - if ( stop_evaluations ( *x , - search , - k , - nb_points , - stop , - display_degree , - one_eval_success , - success , - init_nb_eval , - f0 , - barrier , - nb_success , - one_for_luck ) ) - { - _stats.add_interrupted_eval(); - opp_stop = true; // will break loop #1 - } - - // close the evaluation block: - if ( display_degree == NOMAD::FULL_DISPLAY ) - out.close_block(); - } - - // point not in cache (the point is saved for loop #2): - else - { - - // blackbox or surrogate evaluations are allowed: - if ( ( x->get_eval_type() == NOMAD::TRUTH && max_bb_eval != 0 ) || - ( x->get_eval_type() == NOMAD::SGTE && _p.get_max_sgte_eval() != 0 ) ) - to_be_evaluated.push_back ( x ); - - // close the evaluation block: - if ( display_degree == NOMAD::FULL_DISPLAY ) - out.close_block(); - } - } - - // points[k]->check() failed (close the evaluation block): - else if ( display_degree == NOMAD::FULL_DISPLAY ) - { - std::ostringstream oss; - oss << "check failed (" << check_failed_reason << ")"; - out.close_block ( oss.str() ); - } - } - - // evaluation already in progress (close the evaluation block): - else if ( display_degree == NOMAD::FULL_DISPLAY ) - { - std::ostringstream oss; - oss << "evaluation of point #" << x->get_tag() - << " already in progress"; - out.close_block ( oss.str() ); - } - - ++it; - ++k; - - // force quit (by pressing ctrl-c): - if ( !stop && (NOMAD::Evaluator_Control::_force_quit || NOMAD::Evaluator::get_force_quit()) ) - { - stop = true; - stop_reason = NOMAD::CTRL_C; - } - - } // end of loop #1 - // -------------- - - // loop #2: evaluations: - // --------------------- - int nb_to_evaluate = static_cast<int> ( to_be_evaluated.size() ); - int nb_evaluated = 0; - int cur = 0; - int source; - char signal; - NOMAD::Eval_Point * eval_x; - - while ( !stop && !opp_stop && nb_evaluated < nb_to_evaluate ) - { - - source = NOMAD::Slave::receive_signal ( signal ); - - // 2.1: send the RESULT signal, receive and process the evaluation result: - // ----------------------------------------------------------------------- - eval_x = _eval_in_progress[source]; - if ( eval_x ) - { - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << "receive eval point #" << eval_x->get_tag() - << " from slave " << source << std::endl << std::endl; - - receive_eval_result ( search , - eval_x , - true_barrier , - sgte_barrier , - pareto_front , - source , - stop , - stop_reason ); - - - // list of processed points: - if ( eval_x->is_in_cache() ) - evaluated_pts.push_back ( eval_x ); - - // success: - one_eval_success = barrier.get_one_eval_succ(); - success = barrier.get_success(); - - // asynchronous success count: - if ( success == NOMAD::FULL_SUCCESS && - _elop_tag != _slaves_elop_tags[source] ) - _stats.add_asynchronous_success(); - - // displays: - display_eval_result ( *eval_x , - display_degree , - search , - one_eval_success , - success ); - - // stop the evaluations (opportunistic strategy) ? - if ( stop_evaluations ( *eval_x , - search , - nb_evaluated , - nb_to_evaluate , - stop , - display_degree , - one_eval_success , - success , - init_nb_eval , - f0 , - barrier , - nb_success , - one_for_luck ) ) - { - _stats.add_interrupted_eval(); - opp_stop = true; // will break loop #2 - } - - _eval_in_progress[source] = NULL; - _slaves_elop_tags[source] = -1; - --_nb_in_progress; - ++nb_evaluated; - } - - // 2.2: send the EVAL signal and launch a new evaluation: - // ------------------------------------------------------ - else - { - - // do not launch a new evaluation if... - - // there is no more points to be evaluated: - if ( cur == nb_to_evaluate ) - NOMAD::Slave::send_signal ( NOMAD::WAIT_SIGNAL , source ); - - // or if bbe+_nb_in_progress >= max_bb_eval: - else if ( to_be_evaluated[cur]->get_eval_type() == NOMAD::TRUTH && - max_bb_eval > 0 && - _stats.get_bb_eval() + _nb_in_progress >= max_bb_eval ) - { - stop = true; - stop_reason = NOMAD::MAX_BB_EVAL_REACHED; - NOMAD::Slave::send_signal ( NOMAD::WAIT_SIGNAL , source ); - } - - else - { - - // get the signature: - NOMAD::Signature * signature = to_be_evaluated[cur]->get_signature(); - - // there is no signature (error): - if ( !signature ) - { - stop = true; - stop_reason = NOMAD::ERROR; - if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - out << std::endl - << "Error in Evaluator_Control::private_eval_list_of_points():" - << " the point #" << to_be_evaluated[cur]->get_tag() - << " has no signature" << std::endl << std::endl; - NOMAD::Slave::send_signal ( NOMAD::WAIT_SIGNAL , source ); - } - - else - { - - NOMAD::Slave::send_signal ( NOMAD::EVAL_SIGNAL , source ); - - eval_x = &NOMAD::Cache::get_modifiable_point ( *to_be_evaluated[cur++] ); - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << "send eval point #" << eval_x->get_tag() - << " to slave " << source << std::endl; - - // 1. scaling: - bool do_scaling = signature->get_scaling().is_defined(); - if ( do_scaling ) - eval_x->scale(); - - // 2. send the point: - _slave->send_eval_point ( eval_x , source , barrier.get_h_max() ); - - // 3. unscaling: - if ( do_scaling ) - eval_x->unscale(); - - eval_x->set_eval_status ( NOMAD::EVAL_IN_PROGRESS ); - - _eval_in_progress[source] = eval_x; - _slaves_elop_tags[source] = _elop_tag; - ++_nb_in_progress; - } - } - } - - // force quit (by pressing ctrl-c): - if ( !stop && ( NOMAD::Evaluator_Control::_force_quit || NOMAD::Evaluator::get_force_quit() )) - { - stop = true; - stop_reason = NOMAD::CTRL_C; - } - - } // end of loop #2 - // -------------- - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << "number of evaluations in progress: " << _nb_in_progress - << std::endl << std::endl; - - // the algorithm is not asynchronous: we have - // to wait for all the evaluations in progress: - if ( !_p.get_asynchronous() ) - - wait_for_evaluations ( search , - true_barrier , - sgte_barrier , - pareto_front , - stop , - stop_reason , - success , - evaluated_pts ); - - // barriers update: - if ( !stop ) - { - true_barrier.update_and_reset_success(); - sgte_barrier.update_and_reset_success(); - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << NOMAD::close_block ( "end of evaluations" ) << std::endl; - - // incumbents update: - const NOMAD::Eval_Point * bf = barrier.get_best_feasible (); - const NOMAD::Eval_Point * bi = barrier.get_best_infeasible(); - if ( bf && bf != old_feasible_incumbent ) - new_feas_inc = bf; - if ( bi && bi != old_infeasible_incumbent ) - new_infeas_inc = bi; - - // the list of eval. points is deleted (only points in the cache are kept): - clear_eval_lop(); - - // update the unique eval_lop() tag: - ++_elop_tag; - + while ( !stop && !opp_stop && it != end ) + { + + x = it->get_point(); + + x->set_current_run ( true ); + + // displays: + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + + // open the evaluation block: + { + std::ostringstream oss; + if ( x->get_eval_type() == NOMAD::SGTE ) + oss << "surrogate "; + oss << "evaluation " << k+1 << "/" << nb_points; + out << std::endl << NOMAD::open_block ( oss.str() ); + } + + out << std::endl << "point #" << x->get_tag() << " ( "; + x->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); + out << " )" << std::endl; + if ( x->get_direction() ) + { + out << "direction : " << *x->get_direction() << std::endl; + NOMAD::Point delta; + x->get_signature()->get_mesh()->get_delta(delta); + out << "direction/delta : ( " << *x->get_direction()/delta << " )" << std::endl; + } + if ( x->get_signature() ) + out << "mesh indices : ( " << x->get_signature()->get_mesh()->get_mesh_indices() << " )" << std::endl; + out << std::endl; + + + + } + + // check if the evaluation at this point is already in progress: + if ( !already_in_progress ( *x ) ) + { + + // current point check (# of bb outputs, bounds, integer values, fixed-vars): + if ( x->check ( _p.get_bb_nb_outputs() , check_failed_reason ) ) + { + + count_eval = true; + + // point in cache: + if ( cache_check ( x , + true_barrier , + sgte_barrier , + pareto_front , + count_eval , + barrier.get_h_max() , + display_degree ) ) + + { + + // list of processed points: + evaluated_pts.push_back ( x ); + + // check stopping criteria: + check_stopping_criteria ( search , count_eval , *x , stop , stop_reason ); + + // success: + one_eval_success = barrier.get_one_eval_succ(); + success = barrier.get_success(); + + // displays: + display_eval_result ( *x , + display_degree , + search , + one_eval_success , + success ); + + // stop the evaluations (opportunistic strategy) ? + if ( stop_evaluations ( *x , + search , + k , + nb_points , + stop , + display_degree , + one_eval_success , + success , + init_nb_eval , + f0 , + barrier , + nb_success , + one_for_luck ) ) + { + _stats.add_interrupted_eval(); + opp_stop = true; // will break loop #1 + } + + // close the evaluation block: + if ( display_degree == NOMAD::FULL_DISPLAY ) + out.close_block(); + } + + // point not in cache (the point is saved for loop #2): + else + { + + // blackbox or surrogate evaluations are allowed: + if ( ( x->get_eval_type() == NOMAD::TRUTH && max_bb_eval != 0 ) || + ( x->get_eval_type() == NOMAD::SGTE && _p.get_max_sgte_eval() != 0 ) ) + to_be_evaluated.push_back ( x ); + + // close the evaluation block: + if ( display_degree == NOMAD::FULL_DISPLAY ) + out.close_block(); + } + } + + // points[k]->check() failed (close the evaluation block): + else if ( display_degree == NOMAD::FULL_DISPLAY ) + { + std::ostringstream oss; + oss << "check failed (" << check_failed_reason << ")"; + out.close_block ( oss.str() ); + } + } + + // evaluation already in progress (close the evaluation block): + else if ( display_degree == NOMAD::FULL_DISPLAY ) + { + std::ostringstream oss; + oss << "evaluation of point #" << x->get_tag() + << " already in progress"; + out.close_block ( oss.str() ); + } + + ++it; + ++k; + + // force quit (by pressing ctrl-c): + if ( !stop && (NOMAD::Evaluator_Control::_force_quit || NOMAD::Evaluator::get_force_quit()) ) + { + stop = true; + stop_reason = NOMAD::CTRL_C; + } + + } // end of loop #1 + // -------------- + + // loop #2: evaluations: + // --------------------- + int nb_to_evaluate = static_cast<int> ( to_be_evaluated.size() ); + int nb_evaluated = 0; + int cur = 0; + int source; + char signal; + NOMAD::Eval_Point * eval_x; + + while ( !stop && !opp_stop && nb_evaluated < nb_to_evaluate ) + { + + source = NOMAD::Slave::receive_signal ( signal ); + + // 2.1: send the RESULT signal, receive and process the evaluation result: + // ----------------------------------------------------------------------- + eval_x = _eval_in_progress[source]; + if ( eval_x ) + { + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl << "receive eval point #" << eval_x->get_tag() + << " from slave " << source << std::endl << std::endl; + + receive_eval_result ( search , + eval_x , + true_barrier , + sgte_barrier , + pareto_front , + source , + stop , + stop_reason ); + + + // list of processed points: + if ( eval_x->is_in_cache() ) + evaluated_pts.push_back ( eval_x ); + + // success: + one_eval_success = barrier.get_one_eval_succ(); + success = barrier.get_success(); + + // asynchronous success count: + if ( success == NOMAD::FULL_SUCCESS && + _elop_tag != _slaves_elop_tags[source] ) + _stats.add_asynchronous_success(); + + // displays: + display_eval_result ( *eval_x , + display_degree , + search , + one_eval_success , + success ); + + // stop the evaluations (opportunistic strategy) ? + if ( stop_evaluations ( *eval_x , + search , + nb_evaluated , + nb_to_evaluate , + stop , + display_degree , + one_eval_success , + success , + init_nb_eval , + f0 , + barrier , + nb_success , + one_for_luck ) ) + { + _stats.add_interrupted_eval(); + opp_stop = true; // will break loop #2 + } + + _eval_in_progress[source] = NULL; + _slaves_elop_tags[source] = -1; + --_nb_in_progress; + ++nb_evaluated; + } + + // 2.2: send the EVAL signal and launch a new evaluation: + // ------------------------------------------------------ + else + { + + // do not launch a new evaluation if... + + // there is no more points to be evaluated: + if ( cur == nb_to_evaluate ) + NOMAD::Slave::send_signal ( NOMAD::WAIT_SIGNAL , source ); + + // or if bbe+_nb_in_progress >= max_bb_eval: + else if ( to_be_evaluated[cur]->get_eval_type() == NOMAD::TRUTH && + max_bb_eval > 0 && + _stats.get_bb_eval() + _nb_in_progress >= max_bb_eval ) + { + stop = true; + stop_reason = NOMAD::MAX_BB_EVAL_REACHED; + NOMAD::Slave::send_signal ( NOMAD::WAIT_SIGNAL , source ); + } + + else + { + + // get the signature: + NOMAD::Signature * signature = to_be_evaluated[cur]->get_signature(); + + // there is no signature (error): + if ( !signature ) + { + stop = true; + stop_reason = NOMAD::ERROR; + if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + out << std::endl + << "Error in Evaluator_Control::private_eval_list_of_points():" + << " the point #" << to_be_evaluated[cur]->get_tag() + << " has no signature" << std::endl << std::endl; + NOMAD::Slave::send_signal ( NOMAD::WAIT_SIGNAL , source ); + } + + else + { + + NOMAD::Slave::send_signal ( NOMAD::EVAL_SIGNAL , source ); + + eval_x = &NOMAD::Cache::get_modifiable_point ( *to_be_evaluated[cur++] ); + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl + << "send eval point #" << eval_x->get_tag() + << " to slave " << source << std::endl; + + // 1. scaling: + bool do_scaling = signature->get_scaling().is_defined(); + if ( do_scaling ) + eval_x->scale(); + + // 2. send the point: + _slave->send_eval_point ( eval_x , source , barrier.get_h_max() ); + + // 3. unscaling: + if ( do_scaling ) + eval_x->unscale(); + + eval_x->set_eval_status ( NOMAD::EVAL_IN_PROGRESS ); + + _eval_in_progress[source] = eval_x; + _slaves_elop_tags[source] = _elop_tag; + ++_nb_in_progress; + } + } + } + + // force quit (by pressing ctrl-c): + if ( !stop && ( NOMAD::Evaluator_Control::_force_quit || NOMAD::Evaluator::get_force_quit() )) + { + stop = true; + stop_reason = NOMAD::CTRL_C; + } + + } // end of loop #2 + // -------------- + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl + << "number of evaluations in progress: " << _nb_in_progress + << std::endl << std::endl; + + // the algorithm is not asynchronous: we have + // to wait for all the evaluations in progress: + if ( !_p.get_asynchronous() ) + + wait_for_evaluations ( search , + true_barrier , + sgte_barrier , + pareto_front , + stop , + stop_reason , + success , + evaluated_pts ); + + // barriers update: + if ( !stop ) + { + true_barrier.update_and_reset_success(); + sgte_barrier.update_and_reset_success(); + } + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << NOMAD::close_block ( "end of evaluations" ) << std::endl; + + // incumbents update: + const NOMAD::Eval_Point * bf = barrier.get_best_feasible (); + const NOMAD::Eval_Point * bi = barrier.get_best_infeasible(); + if ( bf && bf != old_feasible_incumbent ) + new_feas_inc = bf; + if ( bi && bi != old_infeasible_incumbent ) + new_infeas_inc = bi; + + // the list of eval. points is deleted (only points in the cache are kept): + clear_eval_lop(); + + // update the unique eval_lop() tag: + ++_elop_tag; + } // end of eval_lop() parallel version -// C. Tribes may 28, 2014 --- method for points block evaluation of a given max size /*----------------------------------------------------------------*/ /* eval_list_of_points, private version (scalar version) */ /*----------------------------------------------------------------*/ #else -void NOMAD::Evaluator_Control::private_eval_list_of_points -( NOMAD::search_type search , // IN : search type - NOMAD::Barrier & true_barrier , // IN/OUT : the barrier - NOMAD::Barrier & sgte_barrier , // IN/OUT : the surrogate barrier - NOMAD::Pareto_Front * pareto_front , // IN/OUT : the Pareto front - // (can be NULL) - bool & stop , // IN/OUT : stopping criterion - NOMAD::stop_type & stop_reason , // OUT : stopping reason - const NOMAD::Eval_Point *& new_feas_inc , // OUT : new feasible incumbent - const NOMAD::Eval_Point *& new_infeas_inc , // OUT : new infeas. incumbent - NOMAD::success_type & success , // OUT : type of success - std::list<const NOMAD::Eval_Point *> - & evaluated_pts ) // OUT : list of processed pts +void NOMAD::Evaluator_Control::private_eval_list_of_points ( NOMAD::search_type search , // IN : search type + NOMAD::Barrier & true_barrier , // IN/OUT : the barrier + NOMAD::Barrier & sgte_barrier , // IN/OUT : the surrogate barrier + NOMAD::Pareto_Front * pareto_front , // IN/OUT : the Pareto front + // (can be NULL) + bool & stop , // IN/OUT : stopping criterion + NOMAD::stop_type & stop_reason , // OUT : stopping reason + const NOMAD::Eval_Point *& new_feas_inc , // OUT : new feasible incumbent + const NOMAD::Eval_Point *& new_infeas_inc , // OUT : new infeas. incumbent + NOMAD::success_type & success , // OUT : type of success + std::list<const NOMAD::Eval_Point *> + & evaluated_pts ) // OUT : list of processed pts { - if ( stop || _eval_lop.empty() ) - { - stop_reason = NOMAD::UNKNOWN_STOP_REASON; - return; - } - - evaluated_pts.clear(); - - // initial display: - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_display_degree ( search ); - - - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - std::ostringstream oss; - oss << "list of points evaluation (" << search << ")"; - out << std::endl << NOMAD::open_block ( oss.str() ); - } - - // call the Evaluator (virtual) preprocessing of a list of points: - _ev->list_of_points_preprocessing ( _eval_lop ); - - const NOMAD::Eval_Point * old_feasible_incumbent = NULL; - const NOMAD::Eval_Point * old_infeasible_incumbent = NULL; - - // active barrier: - NOMAD::Barrier & barrier = ( _p.get_opt_only_sgte() ) ? sgte_barrier : true_barrier; - - old_feasible_incumbent = barrier.get_best_feasible(); - old_infeasible_incumbent = barrier.get_best_infeasible(); - - NOMAD::Double f0; - if ( _p.get_opportunistic_min_f_imprvmt().is_defined() && - old_feasible_incumbent ) - f0 = old_feasible_incumbent->get_f(); - - new_feas_inc = NULL; - new_infeas_inc = NULL; - stop = false; - success = NOMAD::UNSUCCESSFUL; - stop_reason = NOMAD::NO_STOP; - - const NOMAD::Eval_Point * x; - NOMAD::check_failed_type check_failed_reason; - bool one_for_luck = false; - bool stop_evals = false; - int init_nb_eval = _stats.get_eval(); - int nb_success = 0; - int k = 0; - int k_block = 0; - int nb_points = get_nb_eval_points(); - int block_size = _p.get_bb_max_block_size(); - int block_nb = 1; - - // main loop (on the list of points): - // ---------------------------------- - std::set<NOMAD::Priority_Eval_Point>::iterator it = _eval_lop.begin() , end = _eval_lop.end(); - std::list<NOMAD::Eval_Point *> list_x,list_eval; - std::list<bool> count_list_eval; - - while ( !stop_evals && !stop && it != end ) - { - - - if ( block_size > 1 && display_degree == NOMAD::FULL_DISPLAY ) - { - std::ostringstream oss; - oss << "Block of evaluations (" << block_nb <<")"; - out << std::endl << NOMAD::open_block ( oss.str() ); - } - - // Creation of a block of evaluations from the list - //---------------------- - k_block=k; + if ( stop || _eval_lop.empty() ) + { + stop_reason = NOMAD::UNKNOWN_STOP_REASON; + return; + } + + evaluated_pts.clear(); + + // initial display: + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_display_degree ( search ); + + + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + std::ostringstream oss; + oss << "list of points evaluation (" << search << ")"; + out << std::endl << NOMAD::open_block ( oss.str() ); + } + + // call the Evaluator (virtual) preprocessing of a list of points: + _ev->list_of_points_preprocessing ( _eval_lop ); + + const NOMAD::Eval_Point * old_feasible_incumbent = NULL; + const NOMAD::Eval_Point * old_infeasible_incumbent = NULL; + + // active barrier: + NOMAD::Barrier & barrier = ( _p.get_opt_only_sgte() ) ? sgte_barrier : true_barrier; + + old_feasible_incumbent = barrier.get_best_feasible(); + old_infeasible_incumbent = barrier.get_best_infeasible(); + + NOMAD::Double f0; + if ( _p.get_opportunistic_min_f_imprvmt().is_defined() && + old_feasible_incumbent ) + f0 = old_feasible_incumbent->get_f(); + + new_feas_inc = NULL; + new_infeas_inc = NULL; + stop = false; + success = NOMAD::UNSUCCESSFUL; + stop_reason = NOMAD::NO_STOP; + + const NOMAD::Eval_Point * x; + NOMAD::check_failed_type check_failed_reason; + bool one_for_luck = false; + bool stop_evals = false; + int init_nb_eval = _stats.get_eval(); + int nb_success = 0; + int k = 0; + int k_block = 0; + int nb_points = get_nb_eval_points(); + int block_size = _p.get_bb_max_block_size(); + int block_nb = 1; + + // main loop (on the list of points): + // ---------------------------------- + std::set<NOMAD::Priority_Eval_Point>::iterator it = _eval_lop.begin() , end = _eval_lop.end(); + std::list<NOMAD::Eval_Point *> list_x,list_eval; + std::list<bool> count_list_eval; + + while ( !stop_evals && !stop && it != end ) + { + + + if ( block_size > 1 && display_degree == NOMAD::FULL_DISPLAY ) + { + std::ostringstream oss; + oss << "Block of evaluations (" << block_nb <<")"; + out << std::endl << NOMAD::open_block ( oss.str() ); + } + + // Creation of a block of evaluations from the list + //---------------------- + k_block=k; bool opportunistic_success_from_cache_point=false; - while (list_eval.size()!=static_cast<size_t>(block_size) && it != end && ! stop_evals) - { - - x = it->get_point(); - x->set_current_run ( true ); - - // displays: - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - { - // open the evaluation block: - std::ostringstream oss; - oss << "submitted "; - if ( x->get_eval_type() == NOMAD::SGTE ) - oss << "surrogate "; - oss << "evaluation " << k+1 << "/" << nb_points; - out << std::endl << NOMAD::open_block ( oss.str() ); - } - - out << std::endl << "point #" << x->get_tag() << " ( "; - x->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); - out << " )" << std::endl; - if ( x->get_direction() ) - { - out << "direction : " << *x->get_direction() << std::endl; - NOMAD::Point delta; - x->get_signature()->get_mesh()->get_delta(delta); - out << "direction d : ( " << *x->get_direction()/delta << " )" << std::endl; - } - if ( x->get_signature() ) - out << "mesh indices: ( " << x->get_signature()->get_mesh()->get_mesh_indices() << " )" << std::endl; - out << std::endl; - - } - - // current point check (# of bb outputs, bounds, integer values, fixed-vars): - if ( x->check ( _p.get_bb_nb_outputs() , check_failed_reason ) ) - { - bool count_eval = true; - bool has_been_in_cache=cache_check ( x , - true_barrier , - sgte_barrier , - pareto_front , - count_eval , - barrier.get_h_max() , - display_degree ); - - - // put the point in a block list for evaluation: - if ( !has_been_in_cache ) - list_eval.push_back(&NOMAD::Cache::get_modifiable_point ( *x )); - else - { - // check stopping criteria for points in cache - check_stopping_criteria ( search , count_eval , *x , stop , stop_reason ); + while (list_eval.size()!=static_cast<size_t>(block_size) && it != end && ! stop_evals) + { + + x = it->get_point(); + x->set_current_run ( true ); + + // displays: + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + { + // open the evaluation block: + std::ostringstream oss; + oss << "submitted "; + if ( x->get_eval_type() == NOMAD::SGTE ) + oss << "surrogate "; + oss << "evaluation " << k+1 << "/" << nb_points; + out << std::endl << NOMAD::open_block ( oss.str() ); + } + + out << std::endl << "point #" << x->get_tag() << " ( "; + x->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); + out << " )" << std::endl; + if ( x->get_direction() ) + { + out << "direction : " << *x->get_direction() << std::endl; + NOMAD::Point delta; + x->get_signature()->get_mesh()->get_delta(delta); + out << "direction/delta: ( " << *x->get_direction()/delta << " )" << std::endl; + } + if ( x->get_signature() ) + out << "mesh indices : ( " << x->get_signature()->get_mesh()->get_mesh_indices() << " )" << std::endl; + out << std::endl; + + } + + // current point check (# of bb outputs, bounds, integer values, fixed-vars): + if ( x->check ( _p.get_bb_nb_outputs() , check_failed_reason ) ) + { + bool count_eval = true; + bool has_been_in_cache=cache_check ( x , + true_barrier , + sgte_barrier , + pareto_front , + count_eval , + barrier.get_h_max() , + display_degree ); + + + // put the point in a block list for evaluation: + if ( !has_been_in_cache ) + list_eval.push_back(&NOMAD::Cache::get_modifiable_point ( *x )); + else + { + // check stopping criteria for points in cache + check_stopping_criteria ( search , count_eval , *x , stop , stop_reason ); + // process the evaluated point: process_eval_point ( *x , @@ -2221,26 +2235,25 @@ void NOMAD::Evaluator_Control::private_eval_list_of_points NOMAD::success_type one_eval_success = barrier.get_one_eval_succ(); success = barrier.get_success(); - + opportunistic_success_from_cache_point = stop_evaluations ( *x , - search , - k , - nb_points , - stop , - display_degree , - one_eval_success , - success , - init_nb_eval , - f0 , - barrier , - nb_success , - one_for_luck ); - - - } - - if (!stop) - list_x.push_back(&NOMAD::Cache::get_modifiable_point ( *x )); + search , + k , + nb_points , + stop , + display_degree , + one_eval_success , + success , + init_nb_eval , + f0 , + barrier , + nb_success , + one_for_luck ); + + } + + if (!stop) + list_x.push_back(&NOMAD::Cache::get_modifiable_point ( *x )); if ( opportunistic_success_from_cache_point ) { @@ -2249,213 +2262,209 @@ void NOMAD::Evaluator_Control::private_eval_list_of_points if ( block_size > 1 && display_degree == NOMAD::FULL_DISPLAY ) out << NOMAD::close_block (); - + stop_evals = true; break; } - - } - // points[k]->check() failed: - else if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "check failed (" << check_failed_reason << ")" << std::endl; - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << NOMAD::close_block(); - - - ++it; - ++k; - } - if (list_eval.size()!=0) - { - - count_list_eval.assign(list_eval.size(), false); - - if (_p.eval_points_as_block()) - { - eval_points ( list_eval , - true_barrier , - sgte_barrier , - pareto_front , - count_list_eval , - stop , - stop_reason , - barrier.get_h_max() ); - - // check stopping criteria for points NOT in cache - std::list<NOMAD::Eval_Point *>::iterator it_eval; - } - else - { - // bool count_eval=false; - x=*(list_eval.begin()); - eval_point ( NOMAD::Cache::get_modifiable_point ( *x ) , - true_barrier , - sgte_barrier , - pareto_front , - count_list_eval.front() , - stop , - stop_reason , - barrier.get_h_max() ); - - } - - } - + } + // points[k]->check() failed: + else if ( display_degree == NOMAD::FULL_DISPLAY ) + out << "check failed (" << check_failed_reason << ")" << std::endl; + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << NOMAD::close_block(); + + + ++it; + ++k; + } + if ( list_eval.size() != 0 ) + { + + count_list_eval.assign( list_eval.size(), false); + + if (_p.eval_points_as_block()) + { + eval_points ( list_eval , + true_barrier , + sgte_barrier , + pareto_front , + count_list_eval , + stop , + stop_reason , + barrier.get_h_max()); + } + else + { + // bool count_eval=false; + x=*(list_eval.begin()); + eval_point ( NOMAD::Cache::get_modifiable_point ( *x ) , + true_barrier , + sgte_barrier , + pareto_front , + count_list_eval.front() , + stop , + stop_reason , + barrier.get_h_max() ); + + } + + } + // Stop evals and exit the loop if ( stop_evals ) break; - - // Check all the points in the evaluation block - std::list<NOMAD::Eval_Point *>::iterator it_x,it_eval; - k=k_block; - it_eval=list_eval.begin(); - for(it_x=list_x.begin();it_x!=list_x.end();++it_x) - { - - x=(*it_x); - - // process the evaluated point: - if ( x->is_eval_ok() && x->is_in_cache() ) - process_eval_point ( *x , - ( x->get_eval_type() == NOMAD::TRUTH ) ? - true_barrier : sgte_barrier , - pareto_front ); - - - - - // success: - NOMAD::success_type one_eval_success = barrier.get_one_eval_succ(); - success = barrier.get_success(); - - // list of processed points: - if ( x->is_in_cache() ) - evaluated_pts.push_back ( x ); - else - { - // this situation may occur on very thin meshes: - // the point has not been found in the cache - // and it failed to be inserted. - one_eval_success = NOMAD::UNSUCCESSFUL; - } - - // displays: - if ( block_size > 0 && display_degree == NOMAD::FULL_DISPLAY ) - { - // open the evaluation block: - std::ostringstream oss; - if ( x->get_eval_type() == NOMAD::SGTE ) - oss << "surrogate "; - oss << "evaluation " << k+1 << "/" << nb_points; - out << std::endl << NOMAD::open_block ( oss.str() ); - out << std::endl << "point #" << x->get_tag() << std::endl; - } - - std::list<bool>::iterator it_count=count_list_eval.begin(); - for(it_eval=list_eval.begin();it_eval!=list_eval.end();++it_eval,++it_count) - { - if ((*it_eval)==x) - { - - // count the bb evaluation: - if ( *it_count ) - { - if ( (*it_eval)->get_eval_type() == NOMAD::SGTE ) - _stats.add_sgte_eval(); - else - { - // current mads bbe evaluation - _stats.add_bb_eval(); - } - - // count the output stats (STAT_SUM and STAT_AVG): - if ( _p.check_stat_sum() || _p.check_stat_avg() ) - count_output_stats(*(*it_eval)); - } - - check_stopping_criteria ( search , *it_count ,*(*it_eval) , stop , stop_reason ); - - if ( *it_count ) - display_eval_result ( *x, display_degree, search, one_eval_success, success ); - - break; - } - } - - - - // close the evaluation block: - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << NOMAD::close_block (); - - // stop the evaluations (opportunistic strategy) ? - if ( !stop_evals && stop_evaluations ( *x , - search , - k , - nb_points , - stop , - display_degree , - one_eval_success , - success , - init_nb_eval , - f0 , - barrier , - nb_success , - one_for_luck ) ) - { - _stats.add_interrupted_eval(); - stop_evals = true; - } - - - ++k; - - } - - if ( block_size > 1 && display_degree == NOMAD::FULL_DISPLAY ) - out << NOMAD::close_block (); - - - // force quit (by pressing ctrl-c): - if ( !stop && ( NOMAD::Evaluator_Control::_force_quit || NOMAD::Evaluator::get_force_quit()) ) - { - stop = true; - stop_reason = NOMAD::CTRL_C; - } - - list_x.clear(); - list_eval.clear(); - - ++block_nb; - - }// end of test for list evaluation - - // barriers update: - if ( !stop ) - { - true_barrier.update_and_reset_success(); - sgte_barrier.update_and_reset_success(); - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << NOMAD::close_block ( "end of evaluations" ) - << std::endl; - - // incumbents update: - const NOMAD::Eval_Point * bf = barrier.get_best_feasible (); - const NOMAD::Eval_Point * bi = barrier.get_best_infeasible(); - if ( bf && bf != old_feasible_incumbent ) - new_feas_inc = bf; - if ( bi && bi != old_infeasible_incumbent ) - new_infeas_inc = bi; - - // the list of eval. points is deleted (only points in the cache are kept): - clear_eval_lop(); - + + // Check all the points in the evaluation block + std::list<NOMAD::Eval_Point *>::iterator it_x,it_eval; + k=k_block; + it_eval=list_eval.begin(); + for(it_x=list_x.begin();it_x!=list_x.end();++it_x) + { + + x=(*it_x); + + // process the evaluated point: + if ( x->is_eval_ok() && x->is_in_cache() ) + process_eval_point ( *x , + ( x->get_eval_type() == NOMAD::TRUTH ) ? + true_barrier : sgte_barrier , + pareto_front ); + + + + + // success: + NOMAD::success_type one_eval_success = barrier.get_one_eval_succ(); + success = barrier.get_success(); + + // list of processed points: + if ( x->is_in_cache() ) + evaluated_pts.push_back ( x ); + else + { + // this situation may occur on very thin meshes: + // the point has not been found in the cache + // and it failed to be inserted. + one_eval_success = NOMAD::UNSUCCESSFUL; + } + + // displays: + if ( block_size > 0 && display_degree == NOMAD::FULL_DISPLAY ) + { + // open the evaluation block: + std::ostringstream oss; + if ( x->get_eval_type() == NOMAD::SGTE ) + oss << "surrogate "; + oss << "evaluation " << k+1 << "/" << nb_points; + out << std::endl << NOMAD::open_block ( oss.str() ); + out << std::endl << "point #" << x->get_tag() << std::endl; + } + + + std::list<bool>::iterator it_count=count_list_eval.begin(); + for(it_eval=list_eval.begin();it_eval!=list_eval.end();++it_eval,++it_count) + { + if ((*it_eval)==x) + { + + // count the bb evaluation: + if ( *it_count ) + { + if ( (*it_eval)->get_eval_type() == NOMAD::SGTE ) + _stats.add_sgte_eval(); + else + { + // current mads bbe evaluation + _stats.add_bb_eval(); + } + + // count the output stats (STAT_SUM and STAT_AVG): + if ( _p.check_stat_sum() || _p.check_stat_avg() ) + count_output_stats(*(*it_eval)); + } + + check_stopping_criteria ( search , *it_count ,*(*it_eval) , stop , stop_reason ); + + if ( *it_count ) + display_eval_result ( *x, display_degree, search, one_eval_success, success ); + + break; + } + } + + + + // close the evaluation block: + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << NOMAD::close_block (); + + // stop the evaluations (opportunistic strategy) ? + if ( !stop_evals && stop_evaluations ( *x , + search , + k , + nb_points , + stop , + display_degree , + one_eval_success , + success , + init_nb_eval , + f0 , + barrier , + nb_success , + one_for_luck ) ) + { + _stats.add_interrupted_eval(); + stop_evals = true; + } + + + ++k; + + } + + if ( block_size > 1 && display_degree == NOMAD::FULL_DISPLAY ) + out << NOMAD::close_block (); + + + // force quit (by pressing ctrl-c): + if ( !stop && ( NOMAD::Evaluator_Control::_force_quit || NOMAD::Evaluator::get_force_quit()) ) + { + stop = true; + stop_reason = NOMAD::CTRL_C; + } + + list_x.clear(); + list_eval.clear(); + + ++block_nb; + + }// end of test for list evaluation + + // barriers update: + if ( !stop ) + { + true_barrier.update_and_reset_success(); + sgte_barrier.update_and_reset_success(); + } + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl << NOMAD::close_block ( "end of evaluations" ) + << std::endl; + + // incumbents update: + const NOMAD::Eval_Point * bf = barrier.get_best_feasible (); + const NOMAD::Eval_Point * bi = barrier.get_best_infeasible(); + if ( bf && bf != old_feasible_incumbent ) + new_feas_inc = bf; + if ( bi && bi != old_infeasible_incumbent ) + new_infeas_inc = bi; + + // the list of eval. points is deleted (only points in the cache are kept): + clear_eval_lop(); + } // end of eval_lop() scalar version - #endif /*-------------------------------------------------*/ @@ -2470,6 +2479,7 @@ void NOMAD::Evaluator_Control::reduce_eval_lop ( int n ) const NOMAD::Eval_Point * x; std::set<NOMAD::Priority_Eval_Point>::iterator it = _eval_lop.end(); + for( int i=0;i<nb_eval_pts-n;i++) { --it; @@ -2480,959 +2490,653 @@ void NOMAD::Evaluator_Control::reduce_eval_lop ( int n ) _eval_lop.erase( it,_eval_lop.end()); } + + /*-------------------------------------------------*/ -/* TGP model ordering (private) */ +/* model_np1_quad_epsilon (private) */ /*-------------------------------------------------*/ -void NOMAD::Evaluator_Control::TGP_model_ordering ( NOMAD::dd_type display_degree , - bool & modified_list ) +void NOMAD::Evaluator_Control::quad_model_ordering ( NOMAD::dd_type display_degree , + bool & modified_list ) { - modified_list = false; - - if ( _p.get_opt_only_sgte() ) - return; - -#ifdef USE_TGP - - // display: - const NOMAD::Display & out = _p.out(); - - // model stats: - NOMAD::Model_Stats model_stats; - NOMAD::Clock clock; - -#ifdef TGP_DEBUG - out << std::endl << NOMAD::open_block ( "TGP model ordering") << std::endl; -#endif - - const std::vector<NOMAD::bb_output_type> & bbot = _p.get_bb_output_type(); - int i , j , n_XX = 0 , m = bbot.size(); - - // construct prediction set (XX): - // ------------------------------ - std::vector<NOMAD::Eval_Point *> XX; - NOMAD::Point lb_XX , ub_XX; - - // save _eval_lop in XX and other_pts: - const NOMAD::Eval_Point * x; - std::list<const NOMAD::Eval_Point *> other_pts; - const NOMAD::Signature * signature = NULL; - int n = -1; - - std::set<NOMAD::Priority_Eval_Point>::const_iterator it , end = _eval_lop.end(); - for ( it = _eval_lop.begin() ; it != end ; ++it ) { - x = it->get_point(); - if ( n < 0 ) { - signature = x->get_signature(); - if ( !signature ) { -#ifdef TGP_DEBUG - out << NOMAD::close_block ( "failure (no signature)" ) << std::endl; -#endif - return; - } - n = signature->get_n(); - - lb_XX = ub_XX = NOMAD::Point(n); - } - - if ( x->size () == n && - x->get_m () == m && - x->get_eval_type () == NOMAD::TRUTH && - !x->get_bb_outputs().is_defined() ) { - - XX.push_back ( &NOMAD::Cache::get_modifiable_point ( *x ) ); - - for ( i = 0 ; i < n ; ++i ) { - if ( !lb_XX[i].is_defined() || (*x)[i] < lb_XX[i] ) - lb_XX[i] = (*x)[i]; - if ( !ub_XX[i].is_defined() || (*x)[i] > ub_XX[i] ) - ub_XX[i] = (*x)[i]; - } - } - else - other_pts.push_back ( x ); - } - - n_XX = XX.size(); - - if ( n_XX <= 1 ) { -#ifdef TGP_DEBUG - out << NOMAD::close_block ( "failure (size(XX) <= 1)" ) << std::endl; + const NOMAD::Display & out = _p.out(); + +#ifdef DEBUG + out << std::endl << NOMAD::open_block ( "model_np1_quad_epsilon") << std::endl; #endif - return; - } - - // the TGP model: - NOMAD::TGP_Model * model; - - // Reuse the last TGP model from the TGP model search: - if ( _last_TGP_model && _p.get_model_tgp_reuse_model() ) { - - model = _last_TGP_model; - - // individual predictions for XX points: - for ( i = 0 ; i < n_XX ; ++i ) - if ( !model->predict ( *XX[i] , false ) ) // pred_outside_bnds = false - for ( j = 0 ; j < m ; ++j ) - XX[i]->set_bb_output ( j , NOMAD::Double() ); - } - - // creation of a new TGP model: - else { - model = new NOMAD::TGP_Model ( n , bbot , out , _p.get_model_tgp_mode() ); - - NOMAD::Point center(n); - for ( i = 0 ; i < n ; ++i ) - center[i] = ( lb_XX[i] + ub_XX[i] ) / 2.0; - - // construct interpolation set (X): - // -------------------------------- - if ( !model->set_X ( *_cache , - ¢er , - _p.get_seed() , - true ) ) { // remove_fv = true - - if ( model->get_p() <= model->get_n() ) - model_stats.add_not_enough_pts(); -#ifdef TGP_DEBUG - out << NOMAD::close_block ( "failure: " + model->get_error_str() ) - << std::endl; + // save _eval_lop in pts and other_pts: + // ------------------------------------ + NOMAD::Point min , max , center , interpolation_radius; + const NOMAD::Eval_Point * y; + std::list<const NOMAD::Eval_Point *> pts , other_pts; + const NOMAD::Signature * signature = NULL; + const NOMAD::Double & radius_factor = _p.get_model_quad_radius_factor(); + NOMAD::eval_type ev_type = NOMAD::TRUTH; + int i , n = -1; + + std::set<NOMAD::Priority_Eval_Point>::const_iterator it , end = _eval_lop.end(); + for ( it = _eval_lop.begin() ; it != end ; ++it ) + { + y = it->get_point(); + if ( n < 0 ) + { + signature = y->get_signature(); + if ( !signature ) + { +#ifdef DEBUG + out << NOMAD::close_block ( "failure (no signature)" ) << std::endl; #endif - - delete model; - - return; + modified_list = false; + return; + } + n = signature->get_n(); + ev_type = y->get_eval_type(); + min.resize ( n ); + max.resize ( n ); + center.resize ( n ); + interpolation_radius.resize ( n ); + } + + if ( y->size() == n && y->get_eval_type() == ev_type ) + { + pts.push_back(y); + for ( i = 0 ; i < n ; ++i ) + { + if ( !min[i].is_defined() || (*y)[i] < min[i] ) + min[i] = (*y)[i]; + if ( !max[i].is_defined() || (*y)[i] > max[i] ) + max[i] = (*y)[i]; + } + } + else + other_pts.push_back ( y ); } - int p = model->get_p(); - - // display sets X and XX: - // ---------------------- -#ifdef TGP_DEBUG + for ( i = 0 ; i < n ; ++i ) { - // max number of points displayed: - const int set_display_limit = 15; // set to -1 for no limit - - // X: - model->display_X ( out , set_display_limit ); - - // XX: - out << NOMAD::open_block ( "prediction points (XX)"); - for ( i = 0 ; i < n_XX ; ++i ) { - out << "#"; - out.display_int_w ( i , n_XX ); - out << " x=("; - XX[i]->NOMAD::Point::display ( out , " " , 15 , -1 ); - out << " )" << std::endl; - } - std::ostringstream oss; - oss << "(size=" << n_XX << ")"; - out << NOMAD::close_block ( oss.str() ) << std::endl; + center [i] = ( min[i] + max[i] ) / 2.0; + interpolation_radius[i] = ( max[i] - min[i] ) * radius_factor / 2.0; } + +#ifdef DEBUG + out << NOMAD::open_block ( "points used to define interpolation radius") + << "type of eval. : " << ev_type << std::endl + << "number of points: " << pts.size() << std::endl + << "min. coordinates: ( "; + min.display ( out , " " , 2 ); + out << " )" << std::endl + << "max. coordinates: ( "; + max.display ( out , " " , 2 ); + out << " )" << std::endl + << "center : ( "; + center.display ( out , " " , 2 ); + out << " )" << std::endl + << "interp. radius : ( "; + interpolation_radius.display ( out , " " , 2 ); + out << " )" << std::endl + << NOMAD::close_block() << std::endl; #endif - - // TGP model construction: - // ----------------------- -#ifdef TGP_DEBUG - out << "TGP model construction ..."; - out.flush(); -#endif - - if ( !model->compute ( XX , - false , // compute_Ds2x = false - false , // compute_improv = false - false ) ) { // pred_outside_bnds = false - model_stats.add_construction_error(); - -#ifdef TGP_DEBUG - out << "... error: " << model->get_error_str() << std::endl - << NOMAD::close_block() << std::endl; + // create model: + // ------------- + NOMAD::Clock clock; + NOMAD::Model_Stats model_stats; + NOMAD::Quad_Model model ( out , + _p.get_bb_output_type() , + (ev_type==NOMAD::TRUTH) ? *_cache : *_sgte_cache , + *signature ); + + int max_Y_size = _p.get_model_quad_max_Y_size(); + int min_Y_size = _p.get_model_quad_min_Y_size(); + bool use_WP = _p.get_model_quad_use_WP (); + + // construct interpolation set Y: + model.construct_Y ( center , + interpolation_radius , + max_Y_size ); + + int nY = model.get_nY(); + +#ifdef DEBUG + out << "number of points in Y: " << nY + << " (p=" << nY-1; + if ( nY < 2 ) out << ", not enough"; + out << ")" << std::endl; #endif - - // reset XX outputs: - for ( i = 0 ; i < n_XX ; ++i ) - for ( j = 0 ; j < m ; ++j ) - XX[i]->set_bb_output ( j , NOMAD::Double() ); - - delete model; - - // check if ctrl-c has been pressed: - if ( NOMAD::TGP_Output_Model::get_force_quit() ) - NOMAD::Evaluator_Control::_force_quit = true; - - return; + + // not enough points: + if ( nY < 2 ) + { + modified_list = false; + model_stats.add_not_enough_pts(); } -#ifdef TGP_DEBUG - out << "... OK" << std::endl << std::endl; -#endif - - // update model stats: - model_stats.add_construction_time ( clock.get_CPU_time() ); - model_stats.update_nY ( p ); - model_stats.update_ES_stats ( n_XX , n_XX ); - model_stats.add_nb_truth(); - model_stats.add_nb_TGP(); - } - - // open display block for model predictions: -#ifdef TGP_DEBUG - out << NOMAD::open_block ( "TGP predictions (XX+ZZ)"); -#endif - - // clear then fill _eval_lop again: - // -------------------------------- - NOMAD::Double f_model , h_model; - const NOMAD::Double & h_min = _p.get_h_min(); - NOMAD::hnorm_type h_norm = _p.get_h_norm(); - bool snap_to_bounds = _p.get_snap_to_bounds(); - - modified_list = true; - _eval_lop.clear(); - - for ( i = 0 ; i < n_XX ; ++i ) { - - // compute model h and f values: - model->eval_hf ( XX[i]->get_bb_outputs() , - h_min , - h_norm , - h_model , - f_model ); - - // display model predictions: -#ifdef TGP_DEBUG - out << "#"; - out.display_int_w ( i , n_XX ); - out << " x=("; - XX[i]->NOMAD::Point::display ( out , " " , 15 , -1 ); - out << " ) m(x)=["; - XX[i]->get_bb_outputs().display ( out , " " , 15 , -1 ); - out << " ]"; - - if ( h_model.is_defined() && f_model.is_defined() ) - out << " hm=" << std::setw(15) << h_model - << " fm=" << std::setw(15) << f_model; else - out << " no model value"; - out << std::endl; -#endif - - // add the evaluation point: - add_eval_point ( XX[i] , - display_degree , - snap_to_bounds , - NOMAD::Double() , - NOMAD::Double() , - f_model , - h_model ); - -#ifdef MODEL_STATS - if ( XX[i] && f_model.is_defined() && h_model.is_defined() ) { - XX[i]->set_mod_use ( 2 ); // 2 for model ordering - XX[i]->set_Yw ( model->get_Yw () ); - XX[i]->set_nY ( p ); - XX[i]->set_mh ( h_model ); - XX[i]->set_mf ( f_model ); - } -#endif - } - -#ifdef TGP_DEBUG - { - // close display block for model predictions: - std::ostringstream oss; - oss << "(size=" << n_XX << ")"; - out << NOMAD::close_block ( oss.str() ) << std::endl; - - // compute and display prediction errors: - out << NOMAD::open_block ( "prediction relative errors on X(%)" ); - model->display_X_errors ( out ); - out << NOMAD::close_block() << std::endl; - } -#endif - - // other points that have been previously discarded and have no model values: - NOMAD::Eval_Point * y; - std::list<const NOMAD::Eval_Point *>::const_iterator it2 , end2 = other_pts.end(); - for ( it2 = other_pts.begin() ; it2 != end2 ; ++it2 ) { - y = &NOMAD::Cache::get_modifiable_point (**it2); - add_eval_point ( y , - display_degree , - snap_to_bounds , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() ); - } - - _stats.update_model_stats ( model_stats ); - _model_ordering_stats.update ( model_stats ); - - if ( model != _last_TGP_model ) - delete model; - -#ifdef TGP_DEBUG - out << NOMAD::close_block() << std::endl; -#else - if ( display_degree == NOMAD::FULL_DISPLAY ) { - out << std::endl << "model ordering"; - if ( !modified_list ) - out << " (no modification)"; - out << std::endl; - } -#endif -#endif -} - -/*-------------------------------------------------*/ -/* model_np1_quad_epsilon (private) */ -/*-------------------------------------------------*/ -void NOMAD::Evaluator_Control::quad_model_ordering ( NOMAD::dd_type display_degree , - bool & modified_list ) -{ - const NOMAD::Display & out = _p.out(); - -#ifdef DEBUG - out << std::endl << NOMAD::open_block ( "model_np1_quad_epsilon") << std::endl; -#endif - - // save _eval_lop in pts and other_pts: - // ------------------------------------ - NOMAD::Point min , max , center , interpolation_radius; - const NOMAD::Eval_Point * y; - std::list<const NOMAD::Eval_Point *> pts , other_pts; - const NOMAD::Signature * signature = NULL; - const NOMAD::Double & radius_factor = _p.get_model_quad_radius_factor(); - NOMAD::eval_type ev_type = NOMAD::TRUTH; - int i , n = -1; - - std::set<NOMAD::Priority_Eval_Point>::const_iterator it , end = _eval_lop.end(); - for ( it = _eval_lop.begin() ; it != end ; ++it ) - { - y = it->get_point(); - if ( n < 0 ) - { - signature = y->get_signature(); - if ( !signature ) - { + { + #ifdef DEBUG - out << NOMAD::close_block ( "failure (no signature)" ) << std::endl; + out << std::endl; + model.display_Y ( out , "unscaled interpolation set Y" ); #endif - modified_list = false; - return; - } - n = signature->get_n(); - ev_type = y->get_eval_type(); - min.resize ( n ); - max.resize ( n ); - center.resize ( n ); - interpolation_radius.resize ( n ); - } - - if ( y->size() == n && y->get_eval_type() == ev_type ) { - pts.push_back(y); - for ( i = 0 ; i < n ; ++i ) { - if ( !min[i].is_defined() || (*y)[i] < min[i] ) - min[i] = (*y)[i]; - if ( !max[i].is_defined() || (*y)[i] > max[i] ) - max[i] = (*y)[i]; - } - } - else - other_pts.push_back ( y ); - } - - for ( i = 0 ; i < n ; ++i ) - { - center [i] = ( min[i] + max[i] ) / 2.0; - interpolation_radius[i] = ( max[i] - min[i] ) * radius_factor / 2.0; - } - -#ifdef DEBUG - out << NOMAD::open_block ( "points used to define interpolation radius") - << "type of eval. : " << ev_type << std::endl - << "number of points: " << pts.size() << std::endl - << "min. coordinates: ( "; - min.display ( out , " " , 2 ); - out << " )" << std::endl - << "max. coordinates: ( "; - max.display ( out , " " , 2 ); - out << " )" << std::endl - << "center : ( "; - center.display ( out , " " , 2 ); - out << " )" << std::endl - << "interp. radius : ( "; - interpolation_radius.display ( out , " " , 2 ); - out << " )" << std::endl - << NOMAD::close_block() << std::endl; - #endif - - // create model: - // ------------- - NOMAD::Clock clock; - NOMAD::Model_Stats model_stats; - NOMAD::Quad_Model model ( out , - _p.get_bb_output_type() , - (ev_type==NOMAD::TRUTH) ? *_cache : *_sgte_cache , - *signature ); - - int max_Y_size = _p.get_model_quad_max_Y_size(); - int min_Y_size = _p.get_model_quad_min_Y_size(); - bool use_WP = _p.get_model_quad_use_WP (); - - // construct interpolation set Y: - model.construct_Y ( center , - interpolation_radius , - max_Y_size ); - - int nY = model.get_nY(); - -#ifdef DEBUG - out << "number of points in Y: " << nY - << " (p=" << nY-1; - if ( nY < 2 ) out << ", not enough"; - out << ")" << std::endl; - #endif - - // not enough points: - if ( nY < 2 ) - { - modified_list = false; - model_stats.add_not_enough_pts(); - } - else - { - + + // define scaling: + model.define_scaling ( radius_factor ); + #ifdef DEBUG - out << std::endl; - model.display_Y ( out , "unscaled interpolation set Y" ); + out << std::endl; + model.display_Y ( out , "scaled interpolation set Ys" ); #endif - - // define scaling: - model.define_scaling ( radius_factor ); - + + // model error flag: + if ( model.get_error_flag() ) + { + model_stats.add_construction_error(); + modified_list = false; + } + else + { + // not enough points: + if ( nY < 2 || ( min_Y_size < 0 && nY <= model.get_nfree() ) ) + { + model_stats.add_not_enough_pts(); + modified_list = false; + } + // enough points and no error: + else + { + + bool cautious = _p.get_model_eval_sort_cautious(); + int nb_inside_radius = 0; + + // check that there is at least two trial points inside the trust radius + // (cautious strategy): + nb_inside_radius = 0; + std::list<const NOMAD::Eval_Point *>::const_iterator it2 , end2 = pts.end(); + if ( cautious ) + { + for ( it2 = pts.begin() ; it2 != end2 ; ++it2 ) + { + NOMAD::Point scaled_pt ( **it2 ); + model.scale ( scaled_pt ); + if ( model.is_within_trust_radius ( scaled_pt ) ) + { + if ( ++nb_inside_radius == 2 ) + break; + } + } + } + + // not enough points inside trust radius: + if ( cautious && nb_inside_radius < 2 ) + modified_list = false; + + // at least two trial points are inside trust radius: + else + { + // construct model: + // ---------------- + model.construct ( use_WP , NOMAD::SVD_EPS , NOMAD::SVD_MAX_MPN , max_Y_size ); + model_stats.add_construction_time ( clock.get_CPU_time() ); + model_stats.update_nY ( model.get_nY() ); + + // display model characteristics: #ifdef DEBUG - out << std::endl; - model.display_Y ( out , "scaled interpolation set Ys" ); + out << std::endl; + model.display_model_coeffs ( out ); + out << std::endl; + model.display_Y_error ( out ); #endif - - // model error flag: - if ( model.get_error_flag() ) - { - model_stats.add_construction_error(); - modified_list = false; - } - else - { - // not enough points: - if ( nY < 2 || ( min_Y_size < 0 && nY <= model.get_nfree() ) ) - { - model_stats.add_not_enough_pts(); - modified_list = false; - } - // enough points and no error: - else - { - - bool cautious = _p.get_model_eval_sort_cautious(); - int nb_inside_radius = 0; - - // check that there is at least two trial points inside the trust radius - // (cautious strategy): - nb_inside_radius = 0; - std::list<const NOMAD::Eval_Point *>::const_iterator it2 , end2 = pts.end(); - if ( cautious ) - { - for ( it2 = pts.begin() ; it2 != end2 ; ++it2 ) - { - NOMAD::Point scaled_pt ( **it2 ); - model.scale ( scaled_pt ); - if ( model.is_within_trust_radius ( scaled_pt ) ) - { - if ( ++nb_inside_radius == 2 ) - break; - } - } - } - - // not enough points inside trust radius: - if ( cautious && nb_inside_radius < 2 ) - modified_list = false; - - // at least two trial points are inside trust radius: - else - { - // construct model: - // ---------------- - model.construct ( use_WP , NOMAD::SVD_EPS , NOMAD::SVD_MAX_MPN , max_Y_size ); - model_stats.add_construction_time ( clock.get_CPU_time() ); - model_stats.update_nY ( model.get_nY() ); - - // display model characteristics: + + // count model: + if ( ev_type == NOMAD::TRUTH ) + model_stats.add_nb_truth(); + else + model_stats.add_nb_sgte(); + + switch ( model.get_interpolation_type() ) + { + case NOMAD::MFN: + model_stats.add_nb_MFN(); + break; + case NOMAD::WP_REGRESSION: + model_stats.add_nb_WP_regression(); + break; + case NOMAD::REGRESSION: + model_stats.add_nb_regression(); + break; + default: + break; + } + + // check model error flag: + const NOMAD::Double & cond = model.get_cond(); + if ( model.get_error_flag() || + !cond.is_defined() || + cond > NOMAD::SVD_MAX_COND ) + { + modified_list = false; + if ( model.get_error_flag() ) + model_stats.add_construction_error(); + else + model_stats.add_bad_cond(); + } + else + { + // clear then fill _eval_lop again: + // -------------------------------- + NOMAD::Double f_model , h_model; + NOMAD::Eval_Point * x; + bool snap_to_bounds = _p.get_snap_to_bounds(); + + modified_list = true; + _eval_lop.clear(); + + nb_inside_radius = 0; + #ifdef DEBUG - out << std::endl; - model.display_model_coeffs ( out ); - out << std::endl; - model.display_Y_error ( out ); + out << std::endl << NOMAD::open_block ( "original trial points" ); #endif - - // count model: - if ( ev_type == NOMAD::TRUTH ) - model_stats.add_nb_truth(); - else - model_stats.add_nb_sgte(); - - switch ( model.get_interpolation_type() ) - { - case NOMAD::MFN: - model_stats.add_nb_MFN(); - break; - case NOMAD::WP_REGRESSION: - model_stats.add_nb_WP_regression(); - break; - case NOMAD::REGRESSION: - model_stats.add_nb_regression(); - break; - default: - break; - } - - // check model error flag: - const NOMAD::Double & cond = model.get_cond(); - if ( model.get_error_flag() || - !cond.is_defined() || - cond > NOMAD::SVD_MAX_COND ) - { - modified_list = false; - if ( model.get_error_flag() ) - model_stats.add_construction_error(); - else - model_stats.add_bad_cond(); - } - else - { - // clear then fill _eval_lop again: - // -------------------------------- - NOMAD::Double f_model , h_model; - NOMAD::Eval_Point * x; - bool snap_to_bounds = _p.get_snap_to_bounds(); - - modified_list = true; - _eval_lop.clear(); - - nb_inside_radius = 0; - + + NOMAD::Quad_Model_Evaluator *quad_model_ev=new NOMAD::Quad_Model_Evaluator(_p , model); + + for ( it2 = pts.begin() ; it2 != end2 ; ++it2 ) + { + NOMAD::Point scaled_pt ( **it2 ); + model.scale ( scaled_pt ); + + + + f_model.clear(); + h_model.clear(); + + + if ( !cautious || model.is_within_trust_radius ( scaled_pt ) ) + { + + int m = static_cast<int>(_p.get_bb_output_type().size()); + NOMAD::Eval_Point x_eval(scaled_pt,m); + for (int i = 0 ; i < x_eval.size() ; ++i ) + x_eval[i] = scaled_pt[i].value() * 1000.0; + + bool count_eval; + + bool success=quad_model_ev->eval_x(x_eval,0.0,count_eval); + if (success) + { + _ev->compute_f(x_eval); + _ev->compute_h(x_eval); + + f_model=x_eval.get_f(); + h_model=x_eval.get_h(); + } + + ++nb_inside_radius; + } + + x = &NOMAD::Cache::get_modifiable_point (**it2); + #ifdef DEBUG - out << std::endl << NOMAD::open_block ( "original trial points" ); + x->display_tag ( out ); + out << ": ( "; + x->NOMAD::Point::display ( out , " " , 2 ); + out << " ) scaled: ("; + scaled_pt.NOMAD::Point::display ( out , " " , 2 ); + out << ") "; + if ( h_model.is_defined() && f_model.is_defined() ) + out << "hm=" << h_model << " fm=" << f_model; + else + out << "no model value"; + out << std::endl; #endif - - NOMAD::Quad_Model_Evaluator *quad_model_ev=new NOMAD::Quad_Model_Evaluator(_p , model); - - for ( it2 = pts.begin() ; it2 != end2 ; ++it2 ) - { - NOMAD::Point scaled_pt ( **it2 ); - model.scale ( scaled_pt ); - - - - f_model.clear(); - h_model.clear(); - - - if ( !cautious || model.is_within_trust_radius ( scaled_pt ) ) - { - - int m = static_cast<int>(_p.get_bb_output_type().size()); - NOMAD::Eval_Point x_eval(scaled_pt,m); - for (int i = 0 ; i < x_eval.size() ; ++i ) - x_eval[i] = scaled_pt[i].value() * 1000.0; - - bool count_eval; - - bool success=quad_model_ev->eval_x(x_eval,0.0,count_eval); - if (success) - { - _ev->compute_f(x_eval); - _ev->compute_h(x_eval); - - f_model=x_eval.get_f(); - h_model=x_eval.get_h(); - } - - ++nb_inside_radius; - } - - x = &NOMAD::Cache::get_modifiable_point (**it2); - -#ifdef DEBUG - x->display_tag ( out ); - out << ": ( "; - x->NOMAD::Point::display ( out , " " , 2 ); - out << " ) scaled: ("; - scaled_pt.NOMAD::Point::display ( out , " " , 2 ); - out << ") "; - if ( h_model.is_defined() && f_model.is_defined() ) - out << "hm=" << h_model << " fm=" << f_model; - else - out << "no model value"; - out << std::endl; -#endif - - // add the evaluation point: - add_eval_point ( x , - display_degree , - snap_to_bounds , - NOMAD::Double() , - NOMAD::Double() , - f_model , - h_model ); - + + // add the evaluation point: + add_eval_point ( x , + display_degree , + snap_to_bounds , + NOMAD::Double() , + NOMAD::Double() , + f_model , + h_model ); + #ifdef MODEL_STATS - if ( x && f_model.is_defined() && h_model.is_defined() ) - { - x->set_mod_use ( 2 ); // 2 for model ordering - x->set_cond ( model.get_cond() ); - x->set_Yw ( model.get_Yw () ); - x->set_nY ( model.get_nY () ); - x->set_mh ( h_model ); - x->set_mf ( f_model ); - } + if ( x && f_model.is_defined() && h_model.is_defined() ) + { + x->set_mod_use ( 2 ); // 2 for model ordering + x->set_cond ( model.get_cond() ); + x->set_Yw ( model.get_Yw () ); + x->set_nY ( model.get_nY () ); + x->set_mh ( h_model ); + x->set_mf ( f_model ); + } #endif - } - - delete quad_model_ev; - - // other points that have been previously discarded - // and have no model values: - end2 = other_pts.end(); - for ( it2 = other_pts.begin() ; it2 != end2 ; ++it2 ) - { - - x = &NOMAD::Cache::get_modifiable_point (**it2); + } + + delete quad_model_ev; + + // other points that have been previously discarded + // and have no model values: + end2 = other_pts.end(); + for ( it2 = other_pts.begin() ; it2 != end2 ; ++it2 ) + { + + x = &NOMAD::Cache::get_modifiable_point (**it2); #ifdef DEBUG - x->display_tag ( out ); - out << ": ( "; - x->NOMAD::Point::display ( out , " " , 2 ); - out << " ) no model value" << std::endl; -#endif - add_eval_point ( x , - display_degree , - snap_to_bounds , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() ); - } + x->display_tag ( out ); + out << ": ( "; + x->NOMAD::Point::display ( out , " " , 2 ); + out << " ) no model value" << std::endl; +#endif + add_eval_point ( x , + display_degree , + snap_to_bounds , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() ); + } #ifdef DEBUG - out.close_block(); + out.close_block(); #endif - } - } - model_stats.update_ES_stats ( nb_inside_radius , static_cast<int>(pts.size()) ); - } - } - } - - _stats.update_model_stats ( model_stats ); - _model_ordering_stats.update ( model_stats ); - + } + } + model_stats.update_ES_stats ( nb_inside_radius , static_cast<int>(pts.size()) ); + } + } + } + + _stats.update_model_stats ( model_stats ); + _model_ordering_stats.update ( model_stats ); + #ifdef DEBUG - out << NOMAD::close_block() << std::endl; + out << NOMAD::close_block() << std::endl; #else - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - out << std::endl << "model ordering"; - if ( !modified_list ) - out << " (no modification)"; - out << std::endl; - } + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + out << std::endl << "model ordering"; + if ( !modified_list ) + out << " (no modification)"; + out << std::endl; + } #endif } + /*----------------------------------------------------------------------------------*/ /* evaluation of a list of points (public version that calls the private version) */ /*----------------------------------------------------------------------------------*/ -void NOMAD::Evaluator_Control::eval_list_of_points -( NOMAD::search_type search , // IN : search type - NOMAD::Barrier & true_barrier , // IN/OUT: truth barrier - NOMAD::Barrier & sgte_barrier , // IN/OUT: surrogate barrier - NOMAD::Pareto_Front * pareto_front , // IN/OUT: Pareto front - // (can be NULL) - bool & stop , // IN/OUT: stopping criterion - NOMAD::stop_type & stop_reason , // OUT : stopping reason - const NOMAD::Eval_Point *& new_feas_inc , // OUT : new feas. incumbent - const NOMAD::Eval_Point *& new_infeas_inc , // OUT : new infeas. incumb. - NOMAD::success_type & success , // OUT : type of success - std::list<const NOMAD::Eval_Point *> - * evaluated_pts ) // OUT : list of processed - // pts (can be NULL) +void NOMAD::Evaluator_Control::eval_list_of_points ( NOMAD::search_type search , // IN : search type + NOMAD::Barrier & true_barrier , // IN/OUT: truth barrier + NOMAD::Barrier & sgte_barrier , // IN/OUT: surrogate barrier + NOMAD::Pareto_Front * pareto_front , // IN/OUT: Pareto front + // (can be NULL) + bool & stop , // IN/OUT: stopping criterion + NOMAD::stop_type & stop_reason , // OUT : stopping reason + const NOMAD::Eval_Point *& new_feas_inc , // OUT : new feas. incumbent + const NOMAD::Eval_Point *& new_infeas_inc , // OUT : new infeas. incumb. + NOMAD::success_type & success , // OUT : type of success + std::list<const NOMAD::Eval_Point *> + * evaluated_pts ) // OUT : list of processed // pts (can be NULL) { - - bool del_evaluated_pts = false; - if ( !evaluated_pts ) - { - evaluated_pts = new std::list<const NOMAD::Eval_Point *>; - del_evaluated_pts = true; - } - - bool sgte_eval_sort = _p.get_sgte_eval_sort() && _eval_lop.size() > 1; - bool opt_only_sgte = _p.get_opt_only_sgte (); - bool snap_to_bounds = _p.get_snap_to_bounds(); - bool modified_list = false; - - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_display_degree ( search ); - - // reset the success type: - true_barrier.reset_success(); - sgte_barrier.reset_success(); - - // define all points as surrogates: - if ( opt_only_sgte || sgte_eval_sort ) - { - for ( std::set<NOMAD::Priority_Eval_Point>::iterator it = _eval_lop.begin() ; - it != _eval_lop.end() ; ++it ) - NOMAD::Cache::get_modifiable_point(*it->get_point()).set_eval_type(NOMAD::SGTE); - } - - // use the surrogates to sort the eval. points: - if ( !opt_only_sgte && sgte_eval_sort ) - { - - // evaluate the surrogate: - private_eval_list_of_points ( search , - true_barrier , - sgte_barrier , - NULL , // Pareto front = NULL - stop , - stop_reason , - new_feas_inc , - new_infeas_inc , - success , - *evaluated_pts ); - if ( stop ) - { - if ( del_evaluated_pts ) - delete evaluated_pts; - return; - } - - NOMAD::Eval_Point * x; - - // construct a new list of trial points that will be - // ordered using surrogate values: - std::list<const NOMAD::Eval_Point *>::const_iterator - end = evaluated_pts->end() , it2; - for ( it2 = evaluated_pts->begin() ; it2 != end ; ++it2 ) { - - // Eval_Point construction: - x = new NOMAD::Eval_Point; - x->set ( (*it2)->size() , _p.get_bb_nb_outputs() ); - x->set_signature ( (*it2)->get_signature () ); - x->set_direction ( (*it2)->get_direction () ); - x->Point::operator = ( **it2 ); - - modified_list = true; - - // add the new point to the ordered list of trial points: - add_eval_point ( x , - display_degree , - snap_to_bounds , - (*it2)->get_f() , - (*it2)->get_h() , - NOMAD::Double() , - NOMAD::Double() ); - } - } - - if ( stop ) { - if ( del_evaluated_pts ) - delete evaluated_pts; - return; - } - - // model ordering: - // --------------- - if ( !modified_list && _model_eval_sort && _eval_lop.size() > 1 ) - { - switch ( _p.get_model_eval_sort() ) { - case NOMAD::TGP_MODEL: - TGP_model_ordering ( display_degree , modified_list ); - if ( NOMAD::Evaluator_Control::_force_quit || NOMAD::Evaluator::get_force_quit() ) - { - stop = true; - stop_reason = NOMAD::CTRL_C; - } - break; - case NOMAD::QUADRATIC_MODEL: - quad_model_ordering ( display_degree , modified_list ); - break; - case NOMAD::NO_MODEL:; - } - } - - // this test is true if ctrl-c has been pressed: - if ( stop ) { - if ( del_evaluated_pts ) - delete evaluated_pts; - return; - } - - // display the re-ordered list of trial points: - if ( modified_list && display_degree == NOMAD::FULL_DISPLAY ) { - - const NOMAD::Eval_Point * y; - - std::ostringstream oss; - oss << "re-ordered list of " << _eval_lop.size() - << " " << search << " trial points"; - - out << NOMAD::open_block ( oss.str() ) << std::endl; - - std::set<NOMAD::Priority_Eval_Point>::const_iterator - end = _eval_lop.end() , it; - for ( it = _eval_lop.begin() ; it != end ; ++it ) { - y = it->get_point(); - y->display_tag ( out ); - out << ": ( "; - y->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); - out << " )"; - if ( y->get_direction() ) - out << " (dir " << y->get_direction()->get_index() << ")"; - out << std::endl; + + bool del_evaluated_pts = false; + if ( !evaluated_pts ) + { + evaluated_pts = new std::list<const NOMAD::Eval_Point *>; + del_evaluated_pts = true; } - out.close_block(); - } - - // evaluate the list of points on the 'true' function: - private_eval_list_of_points ( search , - true_barrier , - sgte_barrier , - pareto_front , - stop , - stop_reason , - new_feas_inc , - new_infeas_inc , - success , - *evaluated_pts ); - + + bool sgte_eval_sort = _p.get_sgte_eval_sort() && _eval_lop.size() > 1; + bool opt_only_sgte = _p.get_opt_only_sgte (); + bool snap_to_bounds = _p.get_snap_to_bounds(); + bool modified_list = false; + + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_display_degree ( search ); + + // reset the success type: + true_barrier.reset_success(); + sgte_barrier.reset_success(); + + // define all points as surrogates: + if ( opt_only_sgte || sgte_eval_sort ) + { + for ( std::set<NOMAD::Priority_Eval_Point>::iterator it = _eval_lop.begin() ; + it != _eval_lop.end() ; ++it ) + NOMAD::Cache::get_modifiable_point(*it->get_point()).set_eval_type(NOMAD::SGTE); + } + + // use the surrogates to sort the eval. points: + if ( !opt_only_sgte && sgte_eval_sort ) + { + + // evaluate the surrogate: + private_eval_list_of_points ( search , + true_barrier , + sgte_barrier , + NULL , // Pareto front = NULL + stop , + stop_reason , + new_feas_inc , + new_infeas_inc , + success , + *evaluated_pts ); + if ( stop ) + { + if ( del_evaluated_pts ) + delete evaluated_pts; + return; + } + + NOMAD::Eval_Point * x; + + // construct a new list of trial points that will be + // ordered using surrogate values: + std::list<const NOMAD::Eval_Point *>::const_iterator + end = evaluated_pts->end() , it2; + for ( it2 = evaluated_pts->begin() ; it2 != end ; ++it2 ) + { + + // Eval_Point construction: + x = new NOMAD::Eval_Point; + x->set ( (*it2)->size() , _p.get_bb_nb_outputs() ); + x->set_signature ( (*it2)->get_signature () ); + x->set_direction ( (*it2)->get_direction () ); + x->Point::operator = ( **it2 ); + + modified_list = true; + + // add the new point to the ordered list of trial points: + add_eval_point ( x , + display_degree , + snap_to_bounds , + (*it2)->get_f() , + (*it2)->get_h() , + NOMAD::Double() , + NOMAD::Double() ); + } + } + + if ( stop ) + { + if ( del_evaluated_pts ) + delete evaluated_pts; + return; + } + + // model ordering: + // --------------- + if ( !modified_list && _model_eval_sort && _eval_lop.size() > 1 ) + { + switch ( _p.get_model_eval_sort() ) + { + case NOMAD::QUADRATIC_MODEL: + quad_model_ordering ( display_degree , modified_list ); + break; + case NOMAD::NO_MODEL:; + } + } + + // this test is true if ctrl-c has been pressed: + if ( stop ) + { + if ( del_evaluated_pts ) + delete evaluated_pts; + return; + } + + // display the re-ordered list of trial points: + if ( modified_list && display_degree == NOMAD::FULL_DISPLAY ) + { + + const NOMAD::Eval_Point * y; + + std::ostringstream oss; + oss << "re-ordered list of " << _eval_lop.size() + << " " << search << " trial points"; + + out << NOMAD::open_block ( oss.str() ) << std::endl; + + std::set<NOMAD::Priority_Eval_Point>::const_iterator + end = _eval_lop.end() , it; + for ( it = _eval_lop.begin() ; it != end ; ++it ) + { + y = it->get_point(); + y->display_tag ( out ); + out << ": ( "; + y->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); + out << " )"; + if ( y->get_direction() ) + out << " (dir " << y->get_direction()->get_index() << ")"; + out << std::endl; + } + out.close_block(); + } + + // evaluate the list of points on the 'true' function: + private_eval_list_of_points ( search , + true_barrier , + sgte_barrier , + pareto_front , + stop , + stop_reason , + new_feas_inc , + new_infeas_inc , + success , + *evaluated_pts ); + #ifdef MODEL_STATS - display_model_stats ( *evaluated_pts ); + display_model_stats ( *evaluated_pts ); #endif - - if ( del_evaluated_pts ) - delete evaluated_pts; + + if ( del_evaluated_pts ) + delete evaluated_pts; } /*------------------------------------------------------------------------------------*/ /* ordering of a list of points based on surrogate (1st) or model (2nd) evaluations */ /*------------------------------------------------------------------------------------*/ - void NOMAD::Evaluator_Control::ordering_lop ( NOMAD::search_type search , // IN : search type - bool & stop , // IN/OUT: stopping criterion - NOMAD::stop_type & stop_reason , // OUT : stopping reason - NOMAD::Barrier & true_barrier , // IN/OUT: truth barrier - NOMAD::Barrier & sgte_barrier // IN/OUT: surrogate barrier - ) - + bool & stop , // IN/OUT: stopping criterion + NOMAD::stop_type & stop_reason , // OUT : stopping reason + NOMAD::Barrier & true_barrier , // IN/OUT: truth barrier + NOMAD::Barrier & sgte_barrier // IN/OUT: surrogate barrier +) { - std::list<const NOMAD::Eval_Point *> * evaluated_pts = new std::list<const NOMAD::Eval_Point *>; - - bool sgte_eval_sort = _p.get_sgte_eval_sort() && _eval_lop.size() > 1; - bool opt_only_sgte = _p.get_opt_only_sgte (); - bool snap_to_bounds = _p.get_snap_to_bounds(); - bool modified_list = false; - - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_display_degree ( search ); - - NOMAD::success_type success ; - const NOMAD::Eval_Point *new_feas_inc ; - const NOMAD::Eval_Point *new_infeas_inc; - - - // reset the success type: - true_barrier.reset_success(); - sgte_barrier.reset_success(); - - - // use the surrogates to sort the eval. points: - if ( !opt_only_sgte && sgte_eval_sort ) - { - - for ( std::set<NOMAD::Priority_Eval_Point>::iterator it = _eval_lop.begin() ; it != _eval_lop.end() ; ++it ) - NOMAD::Cache::get_modifiable_point(*it->get_point()).set_eval_type(NOMAD::SGTE); - - - // evaluate the surrogate: - private_eval_list_of_points ( search , - true_barrier , - sgte_barrier , - NULL , // Pareto front = NULL - stop , - stop_reason , - new_feas_inc , - new_infeas_inc , - success , - *evaluated_pts ); - if ( stop ) - { - delete evaluated_pts; - return; - } - - NOMAD::Eval_Point * x; - - // construct a new list of trial points that will be - // ordered using surrogate values: - std::list<const NOMAD::Eval_Point *>::const_iterator - end = evaluated_pts->end() , it2; - for ( it2 = evaluated_pts->begin() ; it2 != end ; ++it2 ) - { - - // Eval_Point construction: - x = new NOMAD::Eval_Point; - x->set ( (*it2)->size() , _p.get_bb_nb_outputs() ); - x->set_signature ( (*it2)->get_signature () ); - x->set_direction ( (*it2)->get_direction () ); - x->set_poll_center( (*it2)->get_poll_center () ); // Poll center is needed for further testing (not needed when evaluating points) - x->set_poll_center_type ( (*it2)->get_poll_center_type () ); - x->Point::operator = ( **it2 ); - - modified_list = true; - - // add the new point to the ordered list of trial points: - add_eval_point ( x , - display_degree , - snap_to_bounds , - (*it2)->get_f() , - (*it2)->get_h() , - NOMAD::Double() , - NOMAD::Double() ); - } - } - - // model ordering: - // --------------- - if ( !modified_list && _model_eval_sort && _eval_lop.size() > 1 ) { - switch ( _p.get_model_eval_sort() ) { - case NOMAD::TGP_MODEL: - TGP_model_ordering ( display_degree , modified_list ); - break; - case NOMAD::QUADRATIC_MODEL: - quad_model_ordering ( display_degree , modified_list ); - break; - case NOMAD::NO_MODEL:; - } - } - - if ( NOMAD::Evaluator_Control::_force_quit || NOMAD::Evaluator::get_force_quit() ) - { - stop = true; - stop_reason = NOMAD::CTRL_C; - } - - delete evaluated_pts; + std::list<const NOMAD::Eval_Point *> * evaluated_pts = new std::list<const NOMAD::Eval_Point *>; + + bool sgte_eval_sort = _p.get_sgte_eval_sort() && _eval_lop.size() > 1; + bool opt_only_sgte = _p.get_opt_only_sgte (); + bool snap_to_bounds = _p.get_snap_to_bounds(); + bool modified_list = false; + + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_display_degree ( search ); + + NOMAD::success_type success ; + const NOMAD::Eval_Point *new_feas_inc ; + const NOMAD::Eval_Point *new_infeas_inc; + + + // reset the success type: + true_barrier.reset_success(); + sgte_barrier.reset_success(); + + + // use the surrogates to sort the eval. points: + if ( !opt_only_sgte && sgte_eval_sort ) + { + + for ( std::set<NOMAD::Priority_Eval_Point>::iterator it = _eval_lop.begin() ; it != _eval_lop.end() ; ++it ) + NOMAD::Cache::get_modifiable_point(*it->get_point()).set_eval_type(NOMAD::SGTE); + + + // evaluate the surrogate: + private_eval_list_of_points ( search , + true_barrier , + sgte_barrier , + NULL , // Pareto front = NULL + stop , + stop_reason , + new_feas_inc , + new_infeas_inc , + success , + *evaluated_pts ); + if ( stop ) + { + delete evaluated_pts; + return; + } + + NOMAD::Eval_Point * x; + + // construct a new list of trial points that will be + // ordered using surrogate values: + std::list<const NOMAD::Eval_Point *>::const_iterator + end = evaluated_pts->end() , it2; + for ( it2 = evaluated_pts->begin() ; it2 != end ; ++it2 ) + { + + // Eval_Point construction: + x = new NOMAD::Eval_Point; + x->set ( (*it2)->size() , _p.get_bb_nb_outputs() ); + x->set_signature ( (*it2)->get_signature () ); + x->set_direction ( (*it2)->get_direction () ); + x->set_poll_center( (*it2)->get_poll_center () ); // Poll center is needed for further testing (not needed when evaluating points) + x->set_poll_center_type ( (*it2)->get_poll_center_type () ); + x->Point::operator = ( **it2 ); + + modified_list = true; + + // add the new point to the ordered list of trial points: + add_eval_point ( x , + display_degree , + snap_to_bounds , + (*it2)->get_f() , + (*it2)->get_h() , + NOMAD::Double() , + NOMAD::Double() ); + } + } + + // model ordering: + // --------------- + if ( !modified_list && _model_eval_sort && _eval_lop.size() > 1 ) + { + switch ( _p.get_model_eval_sort() ) + { + case NOMAD::QUADRATIC_MODEL: + quad_model_ordering ( display_degree , modified_list ); + break; + case NOMAD::NO_MODEL:; + } + } + + if ( NOMAD::Evaluator_Control::_force_quit || NOMAD::Evaluator::get_force_quit() ) + { + stop = true; + stop_reason = NOMAD::CTRL_C; + } + + delete evaluated_pts; } @@ -3443,17 +3147,18 @@ void NOMAD::Evaluator_Control::ordering_lop ( NOMAD::search_type sea /*--------------------------------------------------------------*/ bool NOMAD::Evaluator_Control::is_opportunistic ( NOMAD::search_type t ) const { - switch ( t ) { - case NOMAD::X0_EVAL: + switch ( t ) + { + case NOMAD::X0_EVAL: + return false; + case NOMAD::LH_SEARCH: + return _p.get_opportunistic_LH(); + case NOMAD::CACHE_SEARCH: + return _p.get_opportunistic_cache_search(); + default: + return _p.get_opportunistic_eval(); + } return false; - case NOMAD::LH_SEARCH: - return _p.get_opportunistic_LH(); - case NOMAD::CACHE_SEARCH: - return _p.get_opportunistic_cache_search(); - default: - return _p.get_opportunistic_eval(); - } - return false; } /*----------------------------------------------------------------*/ @@ -3462,54 +3167,54 @@ bool NOMAD::Evaluator_Control::is_opportunistic ( NOMAD::search_type t ) const /* . check the opportunistic strategy stopping criterion */ /* . private method */ /*----------------------------------------------------------------*/ -bool NOMAD::Evaluator_Control::stop_evaluations -( const NOMAD::Eval_Point & x , - NOMAD::search_type search , - int k , - int nb_points , - bool stop , - NOMAD::dd_type display_degree , - NOMAD::success_type one_eval_success , - NOMAD::success_type success , - int init_nb_eval , - const NOMAD::Double & f0 , - const NOMAD::Barrier & barrier , - int & nb_success , - bool & one_for_luck ) const +bool NOMAD::Evaluator_Control::stop_evaluations ( const NOMAD::Eval_Point & x , + NOMAD::search_type search , + int k , + int nb_points , + bool stop , + NOMAD::dd_type display_degree , + NOMAD::success_type one_eval_success , + NOMAD::success_type success , + int init_nb_eval , + const NOMAD::Double & f0 , + const NOMAD::Barrier & barrier , + int & nb_success , + bool & one_for_luck ) const { - // opportunistic evaluation ? - bool opportunistic = is_opportunistic ( search ); - - if ( k < nb_points - 1 ) { - - if ( stop ) - return true; - - if ( opportunistic && - ( x.get_eval_type() == NOMAD::TRUTH || _p.get_opt_only_sgte() ) ) - { - - if ( one_for_luck && one_eval_success != NOMAD::FULL_SUCCESS ) - { - if ( display_degree == NOMAD::FULL_DISPLAY ) - _p.out() << std::endl - << "opportunistic termination of evaluations (lucky eval)" - << std::endl; - return true; - } - - if ( success == NOMAD::FULL_SUCCESS && - check_opportunistic_criterion ( display_degree , - one_eval_success , - init_nb_eval , - f0 , - barrier , - nb_success , - one_for_luck ) ) - return true; - } - } - return false; + // opportunistic evaluation ? + bool opportunistic = is_opportunistic ( search ); + + if ( k < nb_points - 1 ) + { + + if ( stop ) + return true; + + if ( opportunistic && + ( x.get_eval_type() == NOMAD::TRUTH || _p.get_opt_only_sgte() ) ) + { + + if ( one_for_luck && one_eval_success != NOMAD::FULL_SUCCESS ) + { + if ( display_degree == NOMAD::FULL_DISPLAY ) + _p.out() << std::endl + << "opportunistic termination of evaluations (lucky eval)" + << std::endl; + return true; + } + + if ( success == NOMAD::FULL_SUCCESS && + check_opportunistic_criterion ( display_degree , + one_eval_success , + init_nb_eval , + f0 , + barrier , + nb_success , + one_for_luck ) ) + return true; + } + } + return false; } /*-----------------------------------------------------------------*/ @@ -3517,114 +3222,113 @@ bool NOMAD::Evaluator_Control::stop_evaluations /* return true to stop the evaluations */ /* return false to continue the evaluations */ /*-----------------------------------------------------------------*/ -bool NOMAD::Evaluator_Control::check_opportunistic_criterion -( NOMAD::dd_type display_degree , - NOMAD::success_type one_eval_success , - int init_nb_eval , - const NOMAD::Double & f0 , - const NOMAD::Barrier & barrier , - int & nb_success , - bool & one_for_luck ) const +bool NOMAD::Evaluator_Control::check_opportunistic_criterion ( NOMAD::dd_type display_degree , + NOMAD::success_type one_eval_success , + int init_nb_eval , + const NOMAD::Double & f0 , + const NOMAD::Barrier & barrier , + int & nb_success , + bool & one_for_luck ) const { - - int min_nb_success = _p.get_opportunistic_min_nb_success(); - int min_eval = _p.get_opportunistic_min_eval(); - NOMAD::Double min_f_imprvmt = _p.get_opportunistic_min_f_imprvmt(); - bool lucky_eval = _p.get_opportunistic_lucky_eval(); - const NOMAD::Display & out = _p.out(); - - // min_nb_success: - if ( min_nb_success > 0 ) - { - - if ( one_eval_success == NOMAD::FULL_SUCCESS ) - ++nb_success; - - if ( nb_success < min_nb_success ) - { - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << "opport. strategy (nb_success=" << nb_success - << " < min_nb_success=" << min_nb_success - << "): continue evaluations" - << std::endl; - - return false; - } - } - - // min_eval: - if ( min_eval > 0 ) - { - - int eval = _stats.get_eval() - init_nb_eval; - - if ( eval < min_eval ) - { - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << "opport. strategy (eval=" << eval - << " < min_eval=" << min_eval - << "): continue evaluations" << std::endl; - return false; - } - } - - // min_f_imprvmt: - if ( min_f_imprvmt.is_defined() ) - { - - const NOMAD::Eval_Point * bf = barrier.get_best_feasible(); - - if ( f0.is_defined() && bf ) - { - - NOMAD::Double f = bf->get_f(); - - if ( f.is_defined() ) - { - - NOMAD::Double f_imprvmt = f0.rel_err(f) * 100.0; - - if ( f_imprvmt < min_f_imprvmt ) - { - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << "opport. strategy (f_improvement=" - << f_imprvmt << " < min_f_imprvmt=" << min_f_imprvmt - << "): continue evaluations" << std::endl; - - return false; - } - } - } - } - - // lucky_eval: - if ( lucky_eval && one_eval_success == NOMAD::FULL_SUCCESS ) - { - one_for_luck = true; - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << "opport. strategy: one more evaluation for luck" - << std::endl; - - return false; - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - out << std::endl << "opport. strategy: stop evaluations" ; - if (_p.get_bb_max_block_size() > 1) - out << " at the end of the block evaluation"; - out << std::endl; - } - - return true; + + int min_nb_success = _p.get_opportunistic_min_nb_success(); + int min_eval = _p.get_opportunistic_min_eval(); + NOMAD::Double min_f_imprvmt = _p.get_opportunistic_min_f_imprvmt(); + bool lucky_eval = _p.get_opportunistic_lucky_eval(); + const NOMAD::Display & out = _p.out(); + + // min_nb_success: + if ( min_nb_success > 0 ) + { + + if ( one_eval_success == NOMAD::FULL_SUCCESS ) + ++nb_success; + + if ( nb_success < min_nb_success ) + { + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl + << "opport. strategy (nb_success=" << nb_success + << " < min_nb_success=" << min_nb_success + << "): continue evaluations" + << std::endl; + + return false; + } + } + + // min_eval: + if ( min_eval > 0 ) + { + + int eval = _stats.get_eval() - init_nb_eval; + + if ( eval < min_eval ) + { + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl + << "opport. strategy (eval=" << eval + << " < min_eval=" << min_eval + << "): continue evaluations" << std::endl; + return false; + } + } + + // min_f_imprvmt: + if ( min_f_imprvmt.is_defined() ) + { + + const NOMAD::Eval_Point * bf = barrier.get_best_feasible(); + + if ( f0.is_defined() && bf ) + { + + NOMAD::Double f = bf->get_f(); + + if ( f.is_defined() ) + { + + NOMAD::Double f_imprvmt = f0.rel_err(f) * 100.0; + + if ( f_imprvmt < min_f_imprvmt ) + { + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl + << "opport. strategy (f_improvement=" + << f_imprvmt << " < min_f_imprvmt=" << min_f_imprvmt + << "): continue evaluations" << std::endl; + + return false; + } + } + } + } + + // lucky_eval: + if ( lucky_eval && one_eval_success == NOMAD::FULL_SUCCESS ) + { + one_for_luck = true; + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl + << "opport. strategy: one more evaluation for luck" + << std::endl; + + return false; + } + + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + out << std::endl << "opport. strategy: stop evaluations" ; + if (_p.get_bb_max_block_size() > 1) + out << " at the end of the block evaluation"; + out << std::endl; + } + + return true; } /*---------------------------------------------------------------*/ @@ -3632,38 +3336,40 @@ bool NOMAD::Evaluator_Control::check_opportunistic_criterion /*---------------------------------------------------------------*/ void NOMAD::Evaluator_Control::display_eval_lop ( NOMAD::search_type t ) const { - const NOMAD::Display & out = _p.out(); - int cnt = 0 , nb = static_cast<int>(_eval_lop.size()); - - if ( nb == 0 ) { - out << std::endl << "no evaluation point" << std::endl; - return; - } - - // open indented block: - std::ostringstream oss; - if ( t != NOMAD::UNDEFINED_SEARCH ) - oss << t << " "; - oss << "evaluation point"; - if ( nb > 1 ) - oss << "s"; - out << std::endl << NOMAD::open_block ( oss.str() ) << std::endl; - - // display the points: - std::set<NOMAD::Priority_Eval_Point>::const_iterator it , end = _eval_lop.end(); - for ( it = _eval_lop.begin() ; it != end ; ++it ) { - out << "point "; - out.display_int_w ( ++cnt , nb ); - out << "/" << nb << ": ( "; - it->get_point()->Point::display ( out , - " " , - 2 , - NOMAD::Point::get_display_limit() ); - out << " )" << std::endl; - } - - // close indented block: - out.close_block(); + const NOMAD::Display & out = _p.out(); + int cnt = 0 , nb = static_cast<int>(_eval_lop.size()); + + if ( nb == 0 ) + { + out << std::endl << "no evaluation point" << std::endl; + return; + } + + // open indented block: + std::ostringstream oss; + if ( t != NOMAD::UNDEFINED_SEARCH ) + oss << t << " "; + oss << "evaluation point"; + if ( nb > 1 ) + oss << "s"; + out << std::endl << NOMAD::open_block ( oss.str() ) << std::endl; + + // display the points: + std::set<NOMAD::Priority_Eval_Point>::const_iterator it , end = _eval_lop.end(); + for ( it = _eval_lop.begin() ; it != end ; ++it ) + { + out << "point "; + out.display_int_w ( ++cnt , nb ); + out << "/" << nb << ": ( "; + it->get_point()->Point::display ( out , + " " , + 2 , + NOMAD::Point::get_display_limit() ); + out << " )" << std::endl; + } + + // close indented block: + out.close_block(); } /*--------------------------------------------------------------*/ @@ -3675,118 +3381,118 @@ void NOMAD::Evaluator_Control::display_eval_lop ( NOMAD::search_type t ) const /* . periodic variables are checked */ /*--------------------------------------------------------------*/ void NOMAD::Evaluator_Control::add_eval_point( NOMAD::Eval_Point *& x , - NOMAD::dd_type display_degree , - bool snap_to_bounds , - const NOMAD::Double & f_sgte , - const NOMAD::Double & h_sgte , - const NOMAD::Double & f_model , - const NOMAD::Double & h_model ) + NOMAD::dd_type display_degree , + bool snap_to_bounds , + const NOMAD::Double & f_sgte , + const NOMAD::Double & h_sgte , + const NOMAD::Double & f_model , + const NOMAD::Double & h_model ) { - if ( !x ) - return; - - const NOMAD::Display & out = _p.out(); - - // treat the periodic variables: - NOMAD::Direction * new_dir = NULL; - - if ( _p.has_periodic_variables() && - x->treat_periodic_variables ( new_dir ) ) - { - - if ( new_dir && new_dir->norm() == 0.0 ) - { - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "point #" << x->get_tag() - << " is flushed (||dir||==0)" - << std::endl; - - delete x; - x = NULL; - - delete new_dir; - - return; - } - } - delete new_dir; - - if ( snap_to_bounds && x->snap_to_bounds() ) - { - - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - out << std::endl << "point #" << x->get_tag() << " "; - if ( x->get_direction() && x->get_direction()->get_index() >= 0 ) - out << "(dir " << x->get_direction()->get_index() << ") "; - out << "has been snapped to bounds" << std::endl; - } - - if ( x->get_direction() && x->get_direction()->norm() == 0.0 ) - { - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "point #" << x->get_tag() - << " is flushed (||dir||==0)" - << std::endl; - delete x; - x = NULL; - - return; - } - } - - // creation of the Priority_Eval_Point: - NOMAD::Priority_Eval_Point pep ( x , _p.get_h_min() ); - - // ordering elements of Priority_Eval_Point's: - // ------------------------------------------- - - // 1. surrogate values for f and h: - pep.set_f_sgte ( f_sgte ); - pep.set_h_sgte ( h_sgte ); - - // 2. model values for f and h: - pep.set_f_model ( f_model ); - pep.set_h_model ( h_model ); - - if ( x->get_direction() ) - { - - // get the signature: - NOMAD::Signature * signature = x->get_signature(); - if ( !signature ) - throw NOMAD::Exception ( "Evaluator_Control.cpp" , __LINE__ , - "Evaluator_Control::add_eval_point(): the point has no signature" ); - - // angle with last successful directions (feasible) - const NOMAD::Direction & feas_success_dir = signature->get_feas_success_dir(); - if ( feas_success_dir.is_defined() && - x->get_poll_center_type() == NOMAD::FEASIBLE ) - pep.set_angle_success_dir ( feas_success_dir.get_angle ( *x->get_direction() ) ); - - // angle with last infeasible success direction: - const NOMAD::Direction & infeas_success_dir = signature->get_infeas_success_dir(); - if ( infeas_success_dir.is_defined() && - x->get_poll_center_type() == NOMAD::INFEASIBLE ) - pep.set_angle_success_dir ( infeas_success_dir.get_angle ( *x->get_direction() ) ); - - } - - - - // insertion of the point in _eval_lop: - // ------------------------------------ - size_t size_before = _eval_lop.size(); - - _eval_lop.insert ( pep ); - - if ( _eval_lop.size() == size_before ) - { - delete x; - x = NULL; - } + if ( !x ) + return; + + const NOMAD::Display & out = _p.out(); + + // treat the periodic variables: + NOMAD::Direction * new_dir = NULL; + + if ( _p.has_periodic_variables() && + x->treat_periodic_variables ( new_dir ) ) + { + + if ( new_dir && new_dir->norm() == 0.0 ) + { + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << "point #" << x->get_tag() + << " is flushed (||dir||==0)" + << std::endl; + + delete x; + x = NULL; + + delete new_dir; + + return; + } + } + delete new_dir; + + if ( snap_to_bounds && x->snap_to_bounds() ) + { + + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + out << std::endl << "point #" << x->get_tag() << " "; + if ( x->get_direction() && x->get_direction()->get_index() >= 0 ) + out << "(dir " << x->get_direction()->get_index() << ") "; + out << "has been snapped to bounds" << std::endl; + } + + if ( x->get_direction() && x->get_direction()->norm() == 0.0 ) + { + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << "point #" << x->get_tag() + << " is flushed (||dir||==0)" + << std::endl; + delete x; + x = NULL; + + return; + } + } + + // creation of the Priority_Eval_Point: + NOMAD::Priority_Eval_Point pep ( x , _p.get_h_min() ); + + // ordering elements of Priority_Eval_Point's: + // ------------------------------------------- + + // 1. surrogate values for f and h: + pep.set_f_sgte ( f_sgte ); + pep.set_h_sgte ( h_sgte ); + + // 2. model values for f and h: + pep.set_f_model ( f_model ); + pep.set_h_model ( h_model ); + + if ( x->get_direction() ) + { + + // get the signature: + NOMAD::Signature * signature = x->get_signature(); + if ( !signature ) + throw NOMAD::Exception ( "Evaluator_Control.cpp" , __LINE__ , + "Evaluator_Control::add_eval_point(): the point has no signature" ); + + // angle with last successful directions (feasible) + const NOMAD::Direction & feas_success_dir = signature->get_feas_success_dir(); + if ( feas_success_dir.is_defined() && + x->get_poll_center_type() == NOMAD::FEASIBLE ) + pep.set_angle_success_dir ( feas_success_dir.get_angle ( *x->get_direction() ) ); + + // angle with last infeasible success direction: + const NOMAD::Direction & infeas_success_dir = signature->get_infeas_success_dir(); + if ( infeas_success_dir.is_defined() && + x->get_poll_center_type() == NOMAD::INFEASIBLE ) + pep.set_angle_success_dir ( infeas_success_dir.get_angle ( *x->get_direction() ) ); + + } + + + + // insertion of the point in _eval_lop: + // ------------------------------------ + size_t size_before = _eval_lop.size(); + + _eval_lop.insert ( pep ); + + if ( _eval_lop.size() == size_before ) + { + delete x; + x = NULL; + } } #ifdef MODEL_STATS @@ -3807,50 +3513,55 @@ void NOMAD::Evaluator_Control::add_eval_point( NOMAD::Eval_Point *& x void NOMAD::Evaluator_Control::display_model_stats ( const std::list<const NOMAD::Eval_Point *> & evaluated_pts ) const { - const NOMAD::Display & out = _p.out(); - - NOMAD::Double h , mh , eh , f , mf , ef; - - std::list<const NOMAD::Eval_Point *>::const_iterator it , end = evaluated_pts.end(); - for ( it = evaluated_pts.begin() ; it != end ; ++it ) { - if ( *it && (*it)->get_mod_use() >= 0 ) { - - if ( _p.has_constraints() ) { - h = (*it)->get_h (); - mh = (*it)->get_mh(); - } - else - h = mh = 0.0; - - f = (*it)->get_f (); - mf = (*it)->get_mf(); - - if ( h.is_defined() && mh.is_defined() && f.is_defined() && mf.is_defined() ) { - - ef = f.rel_err ( mf ) * 100.0; - - out << (*it)->get_mod_use() - << " " << std::setw(3) << NOMAD::Mesh::get_mesh_index() - << " " << std::setw(4) << (*it)->get_nY() - << " "; - - (*it)->get_Yw ().display ( out , "%12.3g" ); out << " "; - (*it)->get_cond().display ( out , "%12.3g" ); out << " "; - if ( _p.has_constraints() ) { - eh = h.rel_err ( mh ) * 100.0; - h.display ( out , "%14.3g" ); out << " "; - mh.display ( out , "%14.3g" ); out << " "; - eh.display ( out , "%14.3g" ); out << " "; - } - f.display ( out , "%14.3g" ); out << " "; - mf.display ( out , "%14.3g" ); out << " "; - ef.display ( out , "%14.3g" ); - - out << std::endl; - } - - (*it)->clear_model_data(); + const NOMAD::Display & out = _p.out(); + + NOMAD::Double h , mh , eh , f , mf , ef; + + std::list<const NOMAD::Eval_Point *>::const_iterator it , end = evaluated_pts.end(); + for ( it = evaluated_pts.begin() ; it != end ; ++it ) + { + if ( *it && (*it)->get_mod_use() >= 0 ) + { + + if ( _p.has_constraints() ) + { + h = (*it)->get_h (); + mh = (*it)->get_mh(); + } + else + h = mh = 0.0; + + f = (*it)->get_f (); + mf = (*it)->get_mf(); + + if ( h.is_defined() && mh.is_defined() && f.is_defined() && mf.is_defined() ) + { + + ef = f.rel_err ( mf ) * 100.0; + + out << (*it)->get_mod_use() + << " " << std::setw(3) << NOMAD::Mesh::get_mesh_index() + << " " << std::setw(4) << (*it)->get_nY() + << " "; + + (*it)->get_Yw ().display ( out , "%12.3g" ); out << " "; + (*it)->get_cond().display ( out , "%12.3g" ); out << " "; + if ( _p.has_constraints() ) + { + eh = h.rel_err ( mh ) * 100.0; + h.display ( out , "%14.3g" ); out << " "; + mh.display ( out , "%14.3g" ); out << " "; + eh.display ( out , "%14.3g" ); out << " "; + } + f.display ( out , "%14.3g" ); out << " "; + mf.display ( out , "%14.3g" ); out << " "; + ef.display ( out , "%14.3g" ); + + out << std::endl; + } + + (*it)->clear_model_data(); + } } - } } #endif diff --git a/src/Evaluator_Control.hpp b/src/Evaluator_Control.hpp index d0bfb6f123a7b83222563505cd8cbe8ce622baa5..7ec88a0e4a35b394c06c6b1a66ec5009b1032017 100644 --- a/src/Evaluator_Control.hpp +++ b/src/Evaluator_Control.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -48,10 +55,6 @@ #include "Slave.hpp" #include "Quad_Model.hpp" -#ifdef USE_TGP -#include "TGP_Model.hpp" -#endif - #ifdef R_VERSION extern "C" { #include <Rinternals.h> @@ -112,10 +115,6 @@ namespace NOMAD { NOMAD::Slave * _slave; // Slave object for master process #endif -#ifdef USE_TGP - NOMAD::TGP_Model * _last_TGP_model; ///< Last TGP model from the model search. -#endif - NOMAD::Model_Stats _model_ordering_stats; ///< Model ordering stats. NOMAD::Stats & _stats; ///< Algorithm stats. @@ -145,11 +144,11 @@ namespace NOMAD { /// Save the solution file or update the history file. /** - \param file_name Name of the file -- \b IN. - \param x Lattest solution -- \b IN. - \param is_sol Flag equal to \c true if the file is - a solution file; otherwise it is a history file. - \param display_bimv Display best infeasible (min. viol.) if \c true + \param file_name Name of the file -- \b IN. + \param x Lattest solution -- \b IN. + \param is_sol Flag equal to \c true if the file is + a solution file; otherwise it is a history file. -- \b IN. + \param display_bimv Display best infeasible (min. viol.)(optional) if \c true */ void write_sol_or_his_file ( const std::string & file_name , const NOMAD::Eval_Point & x , @@ -235,13 +234,7 @@ namespace NOMAD { void quad_model_ordering ( NOMAD::dd_type display_degree , bool & modified_list ); - /// TGP model ordering (parameter \c MODEL_EVAL_SORT). - /** - \param display_degree Display degree -- \b IN. - \param modified_list To indicate a change in the evaluation list -- \b OUT. - */ - void TGP_model_ordering ( NOMAD::dd_type display_degree , - bool & modified_list ); + /// Count the output stats (STAT_SUM and STAT_AVG). /** @@ -294,24 +287,24 @@ namespace NOMAD { /// Evaluate points. /* - \param list_x The list of points -- \b IN/OUT. - \param true_barrier Barrier for true evaluations -- \b IN/OUT. - \param sgte_barrier Barrier for surrogate evaluations -- \b IN/OUT. - \param pareto_front A pointer to the Pareto front -- \b IN/OUT + \param list_x The list of points -- \b IN/OUT. + \param true_barrier Barrier for true evaluations -- \b IN/OUT. + \param sgte_barrier Barrier for surrogate evaluations -- \b IN/OUT. + \param pareto_front A pointer to the Pareto front -- \b IN/OUT (may be \c NULL). - \param list_count_eval A list of bool for counted evaluations -- \b OUT. - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - \param h_max Maximal feasibility value -- \b IN. + \param list_count_eval A list of bool for counted evaluations -- \b OUT. + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + \param h_max Maximal feasibility value -- \b IN. */ - void eval_points ( std::list<NOMAD::Eval_Point *> & list_x , - NOMAD::Barrier & true_barrier , - NOMAD::Barrier & sgte_barrier , - NOMAD::Pareto_Front * pareto_front , - std::list<bool> & list_count_eval , - bool & stop , - NOMAD::stop_type & stop_reason , - const NOMAD::Double & h_max ); + void eval_points ( std::list<NOMAD::Eval_Point *> & list_x , + NOMAD::Barrier & true_barrier , + NOMAD::Barrier & sgte_barrier , + NOMAD::Pareto_Front * pareto_front , + std::list<bool> & list_count_eval , + bool & stop , + NOMAD::stop_type & stop_reason , + const NOMAD::Double & h_max ); @@ -388,17 +381,16 @@ namespace NOMAD { \param success Success for these evaluations -- \b OUT. \param evaluated_pts List of processed points -- \b OUT. */ - void private_eval_list_of_points - ( NOMAD::search_type search , - NOMAD::Barrier & true_barrier , - NOMAD::Barrier & sgte_barrier , - NOMAD::Pareto_Front * pareto_front , - bool & stop , - NOMAD::stop_type & stop_reason , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc , - NOMAD::success_type & success , - std::list<const NOMAD::Eval_Point *> & evaluated_pts ); + void private_eval_list_of_points ( NOMAD::search_type search , + NOMAD::Barrier & true_barrier , + NOMAD::Barrier & sgte_barrier , + NOMAD::Pareto_Front * pareto_front , + bool & stop , + NOMAD::stop_type & stop_reason , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc , + NOMAD::success_type & success , + std::list<const NOMAD::Eval_Point *> & evaluated_pts ); #ifdef MODEL_STATS @@ -435,7 +427,7 @@ namespace NOMAD { Evaluator_Control::_force_quit = true; } - /// Force evaluation failure. + /// Force evaluation failure! static void force_evaluation_failure ( void ) { Evaluator_Control::_force_evaluation_failure = true; @@ -539,8 +531,8 @@ namespace NOMAD { /// Update the solution file. /** - \param x The lattest solution -- \b IN. - \param display_bimv Required to display least infeasible (default=false) -- \b IN + \param x The lattest solution -- \b IN. + \param display_bimv Required to display least infeasible (default=false) -- \b IN */ void write_solution_file ( const NOMAD::Eval_Point & x , bool display_bimv=false) const; @@ -613,13 +605,6 @@ namespace NOMAD { */ void set_evaluator ( NOMAD::Evaluator * e ) { _ev = e; } -#ifdef USE_TGP - /// Set the last TGP model from the model search. - /** - \param m The last TGP model -- \b IN. - */ - void set_last_TGP_model ( NOMAD::TGP_Model * m ) { _last_TGP_model = m; } -#endif /// Reset. void reset ( void ); @@ -633,13 +618,12 @@ namespace NOMAD { \param true_barrier Barrier for true evaluations -- \b IN/OUT. \param sgte_barrier Barrier for surrogate evaluations -- \b IN/OUT. */ - void ordering_lop - ( NOMAD::search_type search , // IN : search type - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::Barrier & true_barrier , // IN/OUT: truth barrier - NOMAD::Barrier & sgte_barrier // IN/OUT: surrogate barrier - ); + void ordering_lop ( NOMAD::search_type search , // IN : search type + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::Barrier & true_barrier , // IN/OUT: truth barrier + NOMAD::Barrier & sgte_barrier ); // IN/OUT: surrogate barrier + @@ -658,17 +642,16 @@ namespace NOMAD { \param success Success for this series of evaluations -- \b OUT. \param evaluated_pts List of processed points -- \b OUT. */ - void eval_list_of_points - ( NOMAD::search_type search , - NOMAD::Barrier & true_barrier , - NOMAD::Barrier & sgte_barrier , - NOMAD::Pareto_Front * pareto_front , - bool & stop , - NOMAD::stop_type & stop_reason , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc , - NOMAD::success_type & success , - std::list<const NOMAD::Eval_Point *> * evaluated_pts = NULL ); + void eval_list_of_points ( NOMAD::search_type search , + NOMAD::Barrier & true_barrier , + NOMAD::Barrier & sgte_barrier , + NOMAD::Pareto_Front * pareto_front , + bool & stop , + NOMAD::stop_type & stop_reason , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc , + NOMAD::success_type & success , + std::list<const NOMAD::Eval_Point *> * evaluated_pts = NULL ); /// Add a point to the list of points to be evaluated. /** @@ -765,8 +748,7 @@ namespace NOMAD { bool & stop , NOMAD::stop_type & stop_reason , NOMAD::success_type & success , - std::list<const NOMAD::Eval_Point *> - & evaluated_pts ); + std::list<const NOMAD::Eval_Point *> & evaluated_pts ); #endif }; } diff --git a/src/Exception.cpp b/src/Exception.cpp index cd72299d1872cabf5f7d67bead6ebe28225f54fd..b455c0dd774c1ca49e2ba3956b72297c6d004099 100644 --- a/src/Exception.cpp +++ b/src/Exception.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Exception.cpp - \brief custom class for exceptions (implementation) - \author Sebastien Le Digabel - \date 2010-03-29 - \see Exception.hpp -*/ + \file Exception.cpp + \brief custom class for exceptions (implementation) + \author Sebastien Le Digabel + \date 2010-03-29 + \see Exception.hpp + */ #include "Exception.hpp" /*----------------------------------------------------------------*/ @@ -47,10 +54,10 @@ /*----------------------------------------------------------------*/ const char * NOMAD::Exception::what ( void ) const throw() { - std::ostringstream oss; - oss << "NOMAD::Exception thrown (" << _file << ", " << _line << ")"; - if ( !_what.empty() ) - oss << " " << _what; - _what = oss.str(); - return _what.c_str(); + std::ostringstream oss; + oss << "NOMAD::Exception thrown (" << _file << ", " << _line << ")"; + if ( !_what.empty() ) + oss << " " << _what; + _what = oss.str(); + return _what.c_str(); } diff --git a/src/Exception.hpp b/src/Exception.hpp index 5e32917a133ade0f9a9de0f41d41e9ccce4784ab..84f0c7fd8ef589ce7410df7151b7622f325bd506 100644 --- a/src/Exception.hpp +++ b/src/Exception.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,62 +41,62 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Exception.hpp - \brief Custom class for exceptions (headers) - \author Sebastien Le Digabel - \date 2010-03-29 - \see Exception.cpp -*/ + \file Exception.hpp + \brief Custom class for exceptions (headers) + \author Sebastien Le Digabel + \date 2010-03-29 + \see Exception.cpp + */ #ifndef __NOMAD_EXCEPTION__ #define __NOMAD_EXCEPTION__ #include <sstream> namespace NOMAD { - - /// Custom class for exceptions. - /** + + /// Custom class for exceptions. + /** NOMAD uses this type of exceptions. It indicates the file and line number at which a throw is made. - + \b Example - + \code throw NOMAD::Exception ( __FILE__ , __LINE__ , "an error message" ); \endcode - */ - class Exception : public std::exception { - - private: - - mutable std::string _what; ///< Error message. - std::string _file; ///< File where the exception is thrown. - int _line; ///< Line number at which the exception is thrown. - - public: - - /// Constructor. - /** - \param file A string corresponding to the file where the - exception is thrown -- \b IN - \param line An integer corresponding to the line number - at which the exception is thrown -- \b IN. - \param msg A string corresponding to the error message -- \b IN. */ - Exception ( const std::string & file , int line , const std::string & msg ) - : _what ( msg ) , - _file ( file ) , - _line ( line ) {} - - /// Destructor. - virtual ~Exception ( void ) throw() {} - - /// Access to the error message. - /** - \return A string with the error message. - */ - const char * what ( void ) const throw(); - }; + class Exception : public std::exception { + + private: + + mutable std::string _what; ///< Error message. + std::string _file; ///< File where the exception is thrown. + int _line; ///< Line number at which the exception is thrown. + + public: + + /// Constructor. + /** + \param file A string corresponding to the file where the + exception is thrown -- \b IN + \param line An integer corresponding to the line number + at which the exception is thrown -- \b IN. + \param msg A string corresponding to the error message -- \b IN. + */ + Exception ( const std::string & file , int line , const std::string & msg ) + : _what ( msg ) , + _file ( file ) , + _line ( line ) {} + + /// Destructor. + virtual ~Exception ( void ) throw() {} + + /// Access to the error message. + /** + \return A string with the error message. + */ + const char * what ( void ) const throw(); + }; } #endif diff --git a/src/Extended_Poll.cpp b/src/Extended_Poll.cpp index 4344e92f9641779caf9acb06a7a8e8191193a6df..f09390fea7623f9e8a48bda7bb0d733b946440b4 100644 --- a/src/Extended_Poll.cpp +++ b/src/Extended_Poll.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -126,12 +133,13 @@ void NOMAD::Extended_Poll::add_extended_poll_point ( NOMAD::Point & ep , // new eval point: // --------------- NOMAD::Eval_Point * pt = new NOMAD::Eval_Point; - pt->set ( ep , _p.get_bb_nb_outputs() ); - pt->set_signature ( new_s ); + pt->set ( ep , _p.get_bb_nb_outputs() ); + pt->set_signature ( new_s ); + for ( int i = 0 ; i < pt->get_n() ; ++i ) { - if ( (pt->get_signature()->get_input_type())[i] != NOMAD::CONTINUOUS && ! (*pt)[i].is_integer() ) + if ( (pt->get_signature()->get_input_types())[i] != NOMAD::CONTINUOUS && ! (*pt)[i].is_integer() ) throw NOMAD::Exception ( "Extended_Poll.cpp" , __LINE__ , "NOMAD::Extended_Poll::add_extended_points(): the categorical variables of the added point must be an integer." ); @@ -292,8 +300,8 @@ void NOMAD::Extended_Poll::descent ( const NOMAD::Eval_Point * y // Set mesh indices to 0 - NOMAD::Point delta( signature->get_n(), 0 ); - descent_p.get_signature()->get_mesh()->set_mesh_indices( delta ); + NOMAD::Point zero_mesh_indices( signature->get_n(), 0 ); + descent_p.get_signature()->get_mesh()->set_mesh_indices( zero_mesh_indices ); // Use best_feasible or best_infeasible limit mesh index as a termination criterion for descent const NOMAD::Eval_Point * old_bf = mads.get_best_feasible(); @@ -303,9 +311,10 @@ void NOMAD::Extended_Poll::descent ( const NOMAD::Eval_Point * y l1 = static_cast<int>((old_bf->get_signature()->get_mesh()->get_min_mesh_indices())[0].value()); // index same for all variables when using categorical variable else if ( old_bi ) l2 = static_cast<int>((old_bi->get_signature()->get_mesh()->get_min_mesh_indices())[0].value()); - descent_p.get_signature()->get_mesh()->set_limit_mesh_index( min( l1, l2) ); + descent_p.get_signature()->get_mesh()->set_limit_mesh_index( std::min( l1, l2) ); + // Evaluator_Control object: NOMAD::Evaluator_Control & ev_control = mads.get_evaluator_control(); @@ -508,10 +517,9 @@ void NOMAD::Extended_Poll::descent ( const NOMAD::Eval_Point * y /*----------------------------------------------------------------*/ /* create the descent parameters (private) */ /*----------------------------------------------------------------*/ -void NOMAD::Extended_Poll::set_descent_parameters -( const NOMAD::Eval_Point * y , - const NOMAD::Stats & stats , - NOMAD::Parameters & descent_p ) const +void NOMAD::Extended_Poll::set_descent_parameters ( const NOMAD::Eval_Point * y , + const NOMAD::Stats & stats , + NOMAD::Parameters & descent_p ) const { // extended poll center signature @@ -527,6 +535,7 @@ void NOMAD::Extended_Poll::set_descent_parameters descent_p.set_LOWER_BOUND ( epc_signature->get_lb() ); descent_p.set_UPPER_BOUND ( epc_signature->get_ub() ); descent_p.set_FIXED_VARIABLE ( epc_signature->get_fixed_variables() ); + descent_p.set_GRANULARITY ( epc_signature->get_granularity() ); descent_p.set_PERIODIC_VARIABLE ( epc_signature->get_periodic_variables() ); descent_p.set_VARIABLE_GROUP ( epc_signature->get_var_groups() ); descent_p.set_BB_OUTPUT_TYPE ( _p.get_bb_output_type() ); @@ -565,9 +574,9 @@ void NOMAD::Extended_Poll::set_descent_parameters descent_p.set_MODEL_EVAL_SORT ( _p.get_model_eval_sort()); descent_p.set_MODEL_SEARCH (_p.has_model_search()); - } + descent_p.set_LH_SEARCH ( 0 , 0 ); int bbe = stats.get_bb_eval(); @@ -619,8 +628,8 @@ void NOMAD::Extended_Poll::set_descent_parameters descent_p.set_OPPORTUNISTIC_MIN_F_IMPRVMT ( _p.get_opportunistic_min_f_imprvmt() ); descent_p.set_OPPORTUNISTIC_MIN_NB_SUCCESS ( _p.get_opportunistic_min_nb_success() ); - if (_p.eval_points_as_block()) - descent_p.set_BB_MAX_BLOCK_SIZE( _p.get_bb_max_block_size() ); + if ( _p.eval_points_as_block() ) + descent_p.set_BB_MAX_BLOCK_SIZE( _p.get_bb_max_block_size() ); descent_p.set_CACHE_FILE ( _p.get_cache_file() ); @@ -632,7 +641,7 @@ void NOMAD::Extended_Poll::set_descent_parameters descent_p.set_DISPLAY_ALL_EVAL(_p.get_display_all_eval()); if ( _p.out().get_poll_dd() == NOMAD::FULL_DISPLAY ) descent_p.set_DISPLAY_DEGREE ( NOMAD::NORMAL_DISPLAY ); - else if (_p.out().get_poll_dd() == NOMAD::NORMAL_DISPLAY ) + else if ( _p.out().get_poll_dd() == NOMAD::NORMAL_DISPLAY ) descent_p.set_DISPLAY_DEGREE ( NOMAD::MINIMAL_DISPLAY ); else descent_p.set_DISPLAY_DEGREE ( _p.out().get_poll_dd()); @@ -680,8 +689,7 @@ void NOMAD::Extended_Poll::set_descent_parameters const OrthogonalMesh * mesh = epc_signature->get_mesh(); descent_p.set_MIN_MESH_SIZE ( mesh->get_min_mesh_size() ); descent_p.set_MIN_POLL_SIZE ( mesh->get_min_poll_size() ); - descent_p.set_INITIAL_POLL_SIZE ( mesh->get_initial_poll_size() , false ); - + descent_p.set_INITIAL_POLL_SIZE ( mesh->get_initial_poll_size() , false ); } // check the parameters: @@ -703,14 +711,13 @@ void NOMAD::Extended_Poll::set_descent_parameters /*----------------------------------------------------------------*/ /* evaluation of an extended poll point (private) */ /*----------------------------------------------------------------*/ -const NOMAD::Eval_Point * NOMAD::Extended_Poll::eval_epp -( NOMAD::Eval_Point * y , - Mads & mads , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ) const +const NOMAD::Eval_Point * NOMAD::Extended_Poll::eval_epp ( NOMAD::Eval_Point * y , + Mads & mads , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ) const { NOMAD::Evaluator_Control & ev_control = mads.get_evaluator_control(); const NOMAD::Display & out = _p.out(); @@ -804,7 +811,8 @@ void NOMAD::Extended_Poll::run ( Mads & mads , out << std::endl << NOMAD::open_block ( oss.str() ) << std::endl; } - if ( has_sgte ) { + if ( has_sgte ) + { _p.set_SGTE_EVAL_SORT ( false ); // this ensures that only surrogate _p.force_check_flag(); // evaluations are performed } @@ -855,7 +863,8 @@ void NOMAD::Extended_Poll::run ( Mads & mads , &evaluated_pts ); if ( has_sgte ) { - if ( !_p.get_opt_only_sgte() ) { + if ( !_p.get_opt_only_sgte() ) + { success = NOMAD::UNSUCCESSFUL; new_feas_inc = new_infeas_inc = NULL; } @@ -982,8 +991,7 @@ void NOMAD::Extended_Poll::run ( Mads & mads , /* sort the extended poll points after they have been evaluated */ /* (private) */ /*----------------------------------------------------------------*/ -void NOMAD::Extended_Poll::sort_epp -( const std::list<const NOMAD::Eval_Point *> & evaluated_pts ) +void NOMAD::Extended_Poll::sort_epp ( const std::list<const NOMAD::Eval_Point *> & evaluated_pts ) { const NOMAD::Display & out = _p.out(); NOMAD::dd_type display_degree = out.get_poll_dd(); @@ -1034,7 +1042,7 @@ void NOMAD::Extended_Poll::sort_epp y->Point::operator = ( *cur ); // display: - if ( display_degree == NOMAD::FULL_DISPLAY ) + if ( display_degree == NOMAD::FULL_DISPLAY ) { out << "point #"; out.display_int_w ( ++i , nb_pts ); @@ -1056,11 +1064,12 @@ void NOMAD::Extended_Poll::sort_epp /*--------------------------------------------------------------------*/ bool NOMAD::Extended_Poll::set_neighbors_exe ( std::string & error_str ) { - error_str.clear(); + error_str.clear(); _neighbors_exe = _p.get_neighbors_exe(); - if ( _neighbors_exe.empty() ) { + if ( _neighbors_exe.empty() ) + { error_str = "categorical variables: parameter NEIGHBORS_EXE is undefined"; return false; } @@ -1071,16 +1080,18 @@ bool NOMAD::Extended_Poll::set_neighbors_exe ( std::string & error_str ) NOMAD::get_words ( _neighbors_exe , neighbors_exe_words ); // _neighbors_exe is composed of several words (it is a command): - if ( neighbors_exe_words.size() > 1 ) + if ( neighbors_exe_words.size() > 1 ) { _neighbors_exe.clear(); std::list<std::string>::const_iterator it = neighbors_exe_words.begin() , end = neighbors_exe_words.end(); - while (true) { + while (true) + { - if ( (*it)[0] != '$' ) { + if ( (*it)[0] != '$' ) + { _neighbors_exe += "\"" + problem_dir; _neighbors_exe += *it + "\""; } @@ -1148,7 +1159,7 @@ void NOMAD::Extended_Poll::construct_extended_points ( const NOMAD::Eval_Point & // input file writing: // ------------------- std::string input_file_name = - tmp_dir + NOMAD::BLACKBOX_INPUT_FILE_PREFIX + tmp_dir + NOMAD::BLACKBOX_INPUT_FILE_PREFIX + sint + NOMAD::BLACKBOX_INPUT_FILE_EXT; std::string output_file_name = @@ -1170,7 +1181,7 @@ void NOMAD::Extended_Poll::construct_extended_points ( const NOMAD::Eval_Point & fout.close(); - if ( fout.fail() ) + if ( fout.fail() ) { remove ( input_file_name.c_str () ); std::string err = "could not write file neighbors input file " + input_file_name; @@ -1207,7 +1218,7 @@ void NOMAD::Extended_Poll::construct_extended_points ( const NOMAD::Eval_Point & std::ifstream fin ( output_file_name.c_str() ); - if ( fin.fail() ) + if ( fin.fail() ) { remove ( input_file_name.c_str () ); remove ( output_file_name.c_str() ); @@ -1220,13 +1231,14 @@ void NOMAD::Extended_Poll::construct_extended_points ( const NOMAD::Eval_Point & while ( true ) { NOMAD::Point y(n); - try - { + try + { fin >> y; } catch ( NOMAD::Point::Bad_Input & ) { - if ( y.is_defined() ) { + if ( y.is_defined() ) + { remove ( input_file_name.c_str () ); remove ( output_file_name.c_str() ); std::string err = "error with neighbor in file " + output_file_name; diff --git a/src/Extended_Poll.hpp b/src/Extended_Poll.hpp index 55cdae4c83a92656acc2c6527081b9cfbaf8128c..93df428b79306e86b4ec7f1c07a832c06df90953 100644 --- a/src/Extended_Poll.hpp +++ b/src/Extended_Poll.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Extended_Poll.hpp - \brief Extended poll for categorical variables (headers) - \author Sebastien Le Digabel - \date 2010-04-14 - \see Extended_Poll.cpp -*/ + \file Extended_Poll.hpp + \brief Extended poll for categorical variables (headers) + \author Sebastien Le Digabel + \date 2010-04-14 + \see Extended_Poll.cpp + */ #ifndef __EXTENDED_POLL__ #define __EXTENDED_POLL__ @@ -47,189 +54,188 @@ #include "Signature_Element.hpp" namespace NOMAD { - - /// Generic class for the extended poll. - /** - This is an abstract class (it is not possible to create - NOMAD::Extended_Poll objects). - */ - class Extended_Poll : public NOMAD::Uncopyable { - - protected: - - /// Parameters (includes the standard signature). - NOMAD::Parameters & _p; - - /// Add an extended poll point. - /** - Get, check and register the extended point and its signature - created by the user in \c construct_extended_points(). - \param ep Extended poll point -- \b IN. - \param s Associated signature -- \b IN. - */ - void add_extended_poll_point ( NOMAD::Point & ep , NOMAD::Signature & s ); - - /*---------------------------------------------------------------------*/ - - private: - - /// Executable for getting neighbors in batch mode. - std::string _neighbors_exe; - - /// Set of signatures (does not include the standard signature). - std::set<NOMAD::Signature_Element> _signatures; - - /// Signatures used during one poll step. - std::set<NOMAD::Signature_Element> _poll_signatures; - - /// Extended points for one poll step. - std::list<NOMAD::Eval_Point *> _extended_points; - - /*---------------------------------------------------------------------*/ - - /// Evaluation of an extended poll point. - /** - \param y The extended poll point -- \b IN/OUT. - \param mads NOMAD::Mads object invoking the poll -- \b IN/OUT. - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - \param success Type of success -- \b OUT. - \param new_feas_inc New feasible incumbent -- \b IN/OUT. - \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. - \return A pointer to the evaluated point; may be \c NULL if - the evaluation failed. - */ - const NOMAD::Eval_Point * eval_epp - ( NOMAD::Eval_Point * y , - Mads & mads , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ) const; - - /// Sort the evaluated extended poll points. - /** - \param evaluated_pts The list of evaluated extended poll points -- \b IN/OUT. - */ - void sort_epp ( const std::list<const NOMAD::Eval_Point *> & evaluated_pts ); - - /// Check the extended poll trigger. - /** - \param old_bf A pointer to the old best feasible point -- \b IN. - \param old_bi A pointer to the old best infeasible point -- \b IN. - \param y A pointer to the extended poll center -- \b IN. - \return A boolean equal to \c true if the extended poll has to be performed. - */ - bool check_trigger ( const NOMAD::Eval_Point * old_bf , - const NOMAD::Eval_Point * old_bi , - const NOMAD::Eval_Point * y ) const; - - /// Check only the \c f values for the extended poll trigger. - /** - \param old_f Old \c f value -- \b IN. - \param new_f New \c f value -- \b IN. - \return A boolean equal to \c true if the extended poll has to be performed. - */ - bool check_trigger_on_f ( const NOMAD::Double & old_f , - const NOMAD::Double & new_f ) const; - /// Create the descent parameters. - /** - \param y Starting point -- \b IN. - \param stats Stats -- \b IN. - \param descent_p Descent parameters -- \b IN/OUT. - */ - void set_descent_parameters ( const NOMAD::Eval_Point * y , - const NOMAD::Stats & stats , - NOMAD::Parameters & descent_p ) const; - - /// Descent from the extended poll center. - /** - \param y Extended poll center -- \b IN. - \param mads NOMAD::Mads object invoking the poll -- \b IN/OUT. - \param nb_ext_poll_pts Number of extended poll points -- \b IN/OUT. - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - \param success Type of success -- \b OUT. - \param new_feas_inc New feasible incumbent -- \b IN/OUT. - \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. - */ - void descent ( const NOMAD::Eval_Point * y , - Mads & mads , - int & nb_ext_poll_pts , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ); - - /*---------------------------------------------------------------------*/ - - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - */ - Extended_Poll ( NOMAD::Parameters & p ) : _p ( p ) {} - - /// Destructor. - virtual ~Extended_Poll ( void ); - - /// Construct the extended poll points. + /// Generic class for the extended poll. /** - - Has to be implemented by every NOMAD::Extended_Poll subclass. - - The extended poll points are the neighbors of \c xk where + This is an abstract class (it is not possible to create + NOMAD::Extended_Poll objects). + */ + class Extended_Poll : public NOMAD::Uncopyable { + + protected: + + /// Parameters (includes the standard signature). + NOMAD::Parameters & _p; + + /// Add an extended poll point. + /** + Get, check and register the extended point and its signature + created by the user in \c construct_extended_points(). + \param ep Extended poll point -- \b IN. + \param s Associated signature -- \b IN. + */ + void add_extended_poll_point ( NOMAD::Point & ep , NOMAD::Signature & s ); + + /*---------------------------------------------------------------------*/ + + private: + + /// Executable for getting neighbors in batch mode. + std::string _neighbors_exe; + + /// Set of signatures (does not include the standard signature). + std::set<NOMAD::Signature_Element> _signatures; + + /// Signatures used during one poll step. + std::set<NOMAD::Signature_Element> _poll_signatures; + + /// Extended points for one poll step. + std::list<NOMAD::Eval_Point *> _extended_points; + + /*---------------------------------------------------------------------*/ + + /// Evaluation of an extended poll point. + /** + \param y The extended poll point -- \b IN/OUT. + \param mads NOMAD::Mads object invoking the poll -- \b IN/OUT. + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + \param success Type of success -- \b OUT. + \param new_feas_inc New feasible incumbent -- \b IN/OUT. + \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. + \return A pointer to the evaluated point; may be \c NULL if + the evaluation failed. + */ + const NOMAD::Eval_Point * eval_epp ( NOMAD::Eval_Point * y , + Mads & mads , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ) const; + + /// Sort the evaluated extended poll points. + /** + \param evaluated_pts The list of evaluated extended poll points -- \b IN/OUT. + */ + void sort_epp ( const std::list<const NOMAD::Eval_Point *> & evaluated_pts ); + + /// Check the extended poll trigger. + /** + \param old_bf A pointer to the old best feasible point -- \b IN. + \param old_bi A pointer to the old best infeasible point -- \b IN. + \param y A pointer to the extended poll center -- \b IN. + \return A boolean equal to \c true if the extended poll has to be performed. + */ + bool check_trigger ( const NOMAD::Eval_Point * old_bf , + const NOMAD::Eval_Point * old_bi , + const NOMAD::Eval_Point * y ) const; + + /// Check only the \c f values for the extended poll trigger. + /** + \param old_f Old \c f value -- \b IN. + \param new_f New \c f value -- \b IN. + \return A boolean equal to \c true if the extended poll has to be performed. + */ + bool check_trigger_on_f ( const NOMAD::Double & old_f , + const NOMAD::Double & new_f ) const; + + /// Create the descent parameters. + /** + \param y Starting point -- \b IN. + \param stats Stats -- \b IN. + \param descent_p Descent parameters -- \b IN/OUT. + */ + void set_descent_parameters ( const NOMAD::Eval_Point * y , + const NOMAD::Stats & stats , + NOMAD::Parameters & descent_p ) const; + + /// Descent from the extended poll center. + /** + \param y Extended poll center -- \b IN. + \param mads NOMAD::Mads object invoking the poll -- \b IN/OUT. + \param nb_ext_poll_pts Number of extended poll points -- \b IN/OUT. + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + \param success Type of success -- \b OUT. + \param new_feas_inc New feasible incumbent -- \b IN/OUT. + \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. + */ + void descent ( const NOMAD::Eval_Point * y , + Mads & mads , + int & nb_ext_poll_pts , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ); + + /*---------------------------------------------------------------------*/ + + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + */ + Extended_Poll ( NOMAD::Parameters & p ) : _p ( p ) {} + + /// Destructor. + virtual ~Extended_Poll ( void ); + + /// Construct the extended poll points. + /** + - Has to be implemented by every NOMAD::Extended_Poll subclass. + - The extended poll points are the neighbors of \c xk where categorical variables have different values. - - The default implementation of this method uses parameter NEIGHBORS_EXE. - \param xk Poll center. - */ - virtual void construct_extended_points ( const NOMAD::Eval_Point & xk ); - - /// Set the neighbors executable name for the default implementation. - /** - \param error_str A string containing a possible error message -- \b OUT. - \return \c true if no error. - */ - bool set_neighbors_exe ( std::string & error_str ); - - /// Reset. - void reset ( void ); - - /// Poll reset. - /** - Before the extended poll is launched. - */ - void poll_reset ( void ); - - /// Access to the poll signatures. - /** - \return The set of poll signatures. - */ - const std::set<NOMAD::Signature_Element> & get_poll_signatures ( void ) const - { - return _poll_signatures; - } - - /// Run the extended poll. - /** - \param mads NOMAD::Mads object invoking this poll -- \b IN/OUT. - \param nb_ext_poll_pts Number of extended poll points -- \b OUT. - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - \param success Type of success -- \b OUT. - \param new_feas_inc New feasible incumbent -- \b IN/OUT. - \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. - */ - void run ( Mads & mads , - int & nb_ext_poll_pts , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ); - }; + - The default implementation of this method uses parameter NEIGHBORS_EXE. + \param xk Poll center. + */ + virtual void construct_extended_points ( const NOMAD::Eval_Point & xk ); + + /// Set the neighbors executable name for the default implementation. + /** + \param error_str A string containing a possible error message -- \b OUT. + \return \c true if no error. + */ + bool set_neighbors_exe ( std::string & error_str ); + + /// Reset. + void reset ( void ); + + /// Poll reset. + /** + Before the extended poll is launched. + */ + void poll_reset ( void ); + + /// Access to the poll signatures. + /** + \return The set of poll signatures. + */ + const std::set<NOMAD::Signature_Element> & get_poll_signatures ( void ) const + { + return _poll_signatures; + } + + /// Run the extended poll. + /** + \param mads NOMAD::Mads object invoking this poll -- \b IN/OUT. + \param nb_ext_poll_pts Number of extended poll points -- \b OUT. + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + \param success Type of success -- \b OUT. + \param new_feas_inc New feasible incumbent -- \b IN/OUT. + \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. + */ + void run ( Mads & mads , + int & nb_ext_poll_pts , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ); + }; } #endif diff --git a/src/Filter_Point.hpp b/src/Filter_Point.hpp index 3e74cc433c55df5cf8be3ba9a5dc1df7604859a6..58de3cfeeb9a7ef885d7641e0927b69fd3c65549 100644 --- a/src/Filter_Point.hpp +++ b/src/Filter_Point.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ diff --git a/src/LH_Search.cpp b/src/LH_Search.cpp index 43d76d1240a81ece985a8f4de60ec3520f07d18d..745015550b0d7517543186c8934c6847b7b2cd26 100644 --- a/src/LH_Search.cpp +++ b/src/LH_Search.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -137,7 +144,7 @@ void NOMAD::LH_Search::search ( NOMAD::Mads & mads , int m = _p.get_bb_nb_outputs(); int pm1 = p-1; - // mesh sizes: + // mesh size: NOMAD::Point delta_max = signature->get_mesh()->get_delta_max (); NOMAD::Double delta_i; NOMAD::Point delta; @@ -180,7 +187,7 @@ void NOMAD::LH_Search::search ( NOMAD::Mads & mads , { pts[i] = new NOMAD::Point ( p ); - // for the initial mesh: delta is not used and there will + // for the initial mesh: delta_m is not used and there will // be no projection on mesh: if ( !_initial_search ) delta_i = delta[i]; diff --git a/src/LH_Search.hpp b/src/LH_Search.hpp index 685141a60f535323f055a492bc40299bb9caee1e..a3704ee34fd24483587c6e00d626e9be919aa36d 100644 --- a/src/LH_Search.hpp +++ b/src/LH_Search.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,100 +41,100 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file LH_Search.hpp - \brief Latin-Hypercube search (headers) - \author Sebastien Le Digabel - \date 2010-04-09 - \see LH_Search.cpp -*/ + \file LH_Search.hpp + \brief Latin-Hypercube search (headers) + \author Sebastien Le Digabel + \date 2010-04-09 + \see LH_Search.cpp + */ #ifndef __LH_SEARCH__ #define __LH_SEARCH__ #include "Search.hpp" #include "Mads.hpp" -#include "RNG.hpp" +#include "RNG.hpp" namespace NOMAD { - - /// Class for the Latin-Hypercube search. - class LH_Search : public NOMAD::Search , private NOMAD::Uncopyable { - - private: - - bool _initial_search; /// Initial search flag (for display only). - - /// Decide \c p values for one variable. - /** - If no bounds, values are scaled with the largest Delta^m_k value obtained so far. - \param p Number of values to decide -- \b IN. - \param delta_m Delta^m_k (for the projection to the mesh) -- \b IN. - \param delta_m_max Largest Delta^m_k value -- \b IN. - \param bbit Black-box input type -- \b IN. - \param lb Lower bound -- \b IN. - \param ub Upper bound -- \b IN. - \param x The \p values -- \b OUT. - */ - void values_for_var_i ( int p , - const NOMAD::Double & delta_m , - const NOMAD::Double & delta_m_max , - const NOMAD::bb_input_type & bbit , - const NOMAD::Double & lb , - const NOMAD::Double & ub , - NOMAD::Point & x ) const; - public: - /// Constructor. - /** - \param p Parameters -- \b IN. - \param initial_search Initial search flag -- \b IN. - \param phase_one Phase one flag -- \b IN. - */ - LH_Search ( NOMAD::Parameters & p , - bool initial_search , - bool phase_one ) - : NOMAD::Search ( p , phase_one ? NOMAD::LH_SEARCH_P1 : NOMAD::LH_SEARCH ) , - _initial_search ( initial_search ) {} - - /// Destructor. - virtual ~LH_Search ( void ) {} - - /// The Latin-Hypercube search. - /** - \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. - \param nb_search_pts Number of generated search points -- \b OUT. - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - \param success Type of success -- \b OUT. - \param count_search Count or not the search -- \b OUT. - \param new_feas_inc New feasible incumbent -- \b IN/OUT. - \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. - */ - virtual void search ( NOMAD::Mads & mads , - int & nb_search_pts , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - bool & count_search , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ); - - /// Simpler method used to generate a list of LH points. - /** - \param n Dimension -- \b IN. - \param m Number of outputs -- \b IN. - \param p Number of LH points -- \b IN. - \param lb Lower bounds -- \b IN. - \param ub Upper bounds -- \b IN. - \param pts LH points -- \b OUT. - \return A boolean equal to \c true if no error occured. - */ - static bool LH_points ( int n , - int m , - int p , - const NOMAD::Point & lb , - const NOMAD::Point & ub , - std::vector<NOMAD::Eval_Point *> & pts ); - }; + /// Class for the Latin-Hypercube search. + class LH_Search : public NOMAD::Search , private NOMAD::Uncopyable { + + private: + + bool _initial_search; /// Initial search flag (for display only). + + /// Decide \c p values for one variable. + /** + If no bounds, values are scaled with the largest Delta^m_k value obtained so far. + \param p Number of values to decide -- \b IN. + \param delta_m Delta^m_k (for the projection to the mesh) -- \b IN. + \param delta_m_max Largest Delta^m_k value -- \b IN. + \param bbit Black-box input type -- \b IN. + \param lb Lower bound -- \b IN. + \param ub Upper bound -- \b IN. + \param x The \p values -- \b OUT. + */ + void values_for_var_i ( int p , + const NOMAD::Double & delta_m , + const NOMAD::Double & delta_m_max , + const NOMAD::bb_input_type & bbit , + const NOMAD::Double & lb , + const NOMAD::Double & ub , + NOMAD::Point & x ) const; + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + \param initial_search Initial search flag -- \b IN. + \param phase_one Phase one flag -- \b IN. + */ + LH_Search ( NOMAD::Parameters & p , + bool initial_search , + bool phase_one ) + : NOMAD::Search ( p , phase_one ? NOMAD::LH_SEARCH_P1 : NOMAD::LH_SEARCH ) , + _initial_search ( initial_search ) {} + + /// Destructor. + virtual ~LH_Search ( void ) {} + + /// The Latin-Hypercube search. + /** + \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. + \param nb_search_pts Number of generated search points -- \b OUT. + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + \param success Type of success -- \b OUT. + \param count_search Count or not the search -- \b OUT. + \param new_feas_inc New feasible incumbent -- \b IN/OUT. + \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. + */ + virtual void search ( NOMAD::Mads & mads , + int & nb_search_pts , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + bool & count_search , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ); + + /// Simpler method used to generate a list of LH points. + /** + \param n Dimension -- \b IN. + \param m Number of outputs -- \b IN. + \param p Number of LH points -- \b IN. + \param lb Lower bounds -- \b IN. + \param ub Upper bounds -- \b IN. + \param pts LH points -- \b OUT. + \return A boolean equal to \c true if no error occured. + */ + static bool LH_points ( int n , + int m , + int p , + const NOMAD::Point & lb , + const NOMAD::Point & ub , + std::vector<NOMAD::Eval_Point *> & pts ); + }; } #endif diff --git a/src/L_Curve.cpp b/src/L_Curve.cpp index 0050f90742f09dcfac9ff2f2f8259e51052ba911..369b3ae5c0a93edac2b23ef24fef819eff453445 100644 --- a/src/L_Curve.cpp +++ b/src/L_Curve.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file L_Curve.cpp - \brief L_CURVE_TARGET stopping criterion (implementation) - \author Sebastien Le Digabel - \date 2010-04-09 - \see L_Curve.hpp -*/ + \file L_Curve.cpp + \brief L_CURVE_TARGET stopping criterion (implementation) + \author Sebastien Le Digabel + \date 2010-04-09 + \see L_Curve.hpp + */ #include "L_Curve.hpp" /*-----------------------------------------------*/ @@ -47,19 +54,24 @@ /*-----------------------------------------------*/ void NOMAD::L_Curve::insert ( int bbe , const NOMAD::Double & f ) { - if ( _f.empty() ) { - _f.push_back ( f ); - _bbe.push_back (bbe); - } - else { - size_t nm1 = _bbe.size()-1; - if ( _bbe[nm1] == bbe ) - _f[nm1] = f; - else { - _f.push_back ( f ); - _bbe.push_back (bbe); + if ( _f.empty() ) + { + _f.push_back ( f ); + _bbe.push_back (bbe); + } + else + { + + size_t nm1 = _bbe.size()-1; + if ( _bbe[nm1] == bbe ) + _f[nm1] = f; + else + { + + _f.push_back ( f ); + _bbe.push_back (bbe); + } } - } } /*---------------------------------------------------------------*/ @@ -69,27 +81,28 @@ void NOMAD::L_Curve::insert ( int bbe , const NOMAD::Double & f ) /*---------------------------------------------------------------*/ bool NOMAD::L_Curve::check_stop ( int bbe ) const { - // we check the p last successes and approximate the L-curve - // with a line joining the extremities: - const size_t p = 7; - - if ( _f.size() >= p ) { - - size_t n = _f.size(); - - NOMAD::Double f2 = _f[n-1]; - if ( f2 <= _target ) - return false; + // we check the p last successes and approximate the L-curve + // with a line joining the extremities: + const size_t p = 7; - size_t nmp = n-p; - int bbe1 = _bbe [ nmp ]; - NOMAD::Double f1 = _f [ nmp ]; - NOMAD::Double a = ( f2 - f1 ) / ( bbe - bbe1 ); - NOMAD::Double b = f1 - a * bbe1; - int bbe_target = static_cast<int> ( ceil ( ( ( _target - b ) / a ).value() ) ); - - // test: if ( bbe_target > bbe+(bbe-bbe1) ) - return ( bbe_target > 2*bbe - bbe1 ); - } - return false; + if ( _f.size() >= p ) + { + + size_t n = _f.size(); + + NOMAD::Double f2 = _f[n-1]; + if ( f2 <= _target ) + return false; + + size_t nmp = n-p; + int bbe1 = _bbe [ nmp ]; + NOMAD::Double f1 = _f [ nmp ]; + NOMAD::Double a = ( f2 - f1 ) / ( bbe - bbe1 ); + NOMAD::Double b = f1 - a * bbe1; + int bbe_target = static_cast<int> ( ceil ( ( ( _target - b ) / a ).value() ) ); + + // test: if ( bbe_target > bbe+(bbe-bbe1) ) + return ( bbe_target > 2*bbe - bbe1 ); + } + return false; } diff --git a/src/L_Curve.hpp b/src/L_Curve.hpp index 83305807241acc891a8a09d53ef7cad1925368e9..ee5a635830565785dff2ddd369421d43738a4a54 100644 --- a/src/L_Curve.hpp +++ b/src/L_Curve.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file L_Curve.hpp - \brief L_CURVE_TARGET stopping criterion (headers) - \author Sebastien Le Digabel - \date 2010-04-09 - \see L_Curve.cpp -*/ + \file L_Curve.hpp + \brief L_CURVE_TARGET stopping criterion (headers) + \author Sebastien Le Digabel + \date 2010-04-09 + \see L_Curve.cpp + */ #ifndef __L_CURVE__ #define __L_CURVE__ @@ -47,42 +54,42 @@ #include "Uncopyable.hpp" namespace NOMAD { - - /// Class implementing the L_CURVE_TARGET stopping criterion. - class L_Curve : private NOMAD::Uncopyable { - - private: - - NOMAD::Double _target; ///< L_CURVE_TARGET parameter value. - std::vector<NOMAD::Double> _f; ///< List of objective values. - std::vector<int > _bbe; ///< List of numbers of evaluations. - - public: - - /// Constructor. - /** - \param target L_CURVE_TARGET parameter value -- \b IN. - */ - L_Curve ( const NOMAD::Double & target ) : _target ( target ) {} - - /// Destructor. - virtual ~L_Curve ( void ) {} - - /// Insertion of a pair \c bbe/f in the lists \c _f and \c _bbe. - /** - \param bbe A new number of evaluations -- \b IN. - \param f A new objective value -- \b IN. - */ - void insert ( int bbe , const NOMAD::Double & f ); - - /// Check the L_CURVE_TARGET stopping criterion. - /** - \param bbe An integer indicating a number of blackbox evaluations - -- \b IN. - \return A boolean equal to \c true if the method detects that - the target will not be reached after bbe evaluations. - */ - bool check_stop ( int bbe ) const; - }; + + /// Class implementing the L_CURVE_TARGET stopping criterion. + class L_Curve : private NOMAD::Uncopyable { + + private: + + NOMAD::Double _target; ///< L_CURVE_TARGET parameter value. + std::vector<NOMAD::Double> _f; ///< List of objective values. + std::vector<int > _bbe; ///< List of numbers of evaluations. + + public: + + /// Constructor. + /** + \param target L_CURVE_TARGET parameter value -- \b IN. + */ + L_Curve ( const NOMAD::Double & target ) : _target ( target ) {} + + /// Destructor. + virtual ~L_Curve ( void ) {} + + /// Insertion of a pair \c bbe/f in the lists \c _f and \c _bbe. + /** + \param bbe A new number of evaluations -- \b IN. + \param f A new objective value -- \b IN. + */ + void insert ( int bbe , const NOMAD::Double & f ); + + /// Check the L_CURVE_TARGET stopping criterion. + /** + \param bbe An integer indicating a number of blackbox evaluations + -- \b IN. + \return A boolean equal to \c true if the method detects that + the target will not be reached after bbe evaluations. + */ + bool check_stop ( int bbe ) const; + }; } #endif diff --git a/src/Mads.cpp b/src/Mads.cpp index 5232644104a4dcd7b92779c29d0cfc1a5ad0bcda..5aae7c5c605d5c60766764e4399c28a1cb1299b5 100644 --- a/src/Mads.cpp +++ b/src/Mads.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -57,27 +64,24 @@ bool NOMAD::Mads::_flag_p1_active = false; /*---------------------------------------------------------*/ void NOMAD::Mads::force_quit ( int signalValue ) { - NOMAD::Mads::_force_quit = true; - NOMAD::Evaluator_Control::force_quit(); - NOMAD::Evaluator::force_quit(); - -#ifdef USE_TGP - NOMAD::TGP_Output_Model::force_quit(); -#endif + NOMAD::Mads::_force_quit = true; + NOMAD::Evaluator_Control::force_quit(); + NOMAD::Evaluator::force_quit(); + } /*---------------------------------------------------------*/ /* access to the flags (static) */ /*---------------------------------------------------------*/ void NOMAD::Mads::get_flags ( bool & flag_check_bimads , - bool & flag_reset_mesh , - bool & flag_reset_barriers , - bool & flag_p1_active ) + bool & flag_reset_mesh , + bool & flag_reset_barriers , + bool & flag_p1_active ) { - flag_check_bimads = _flag_check_bimads; - flag_reset_mesh = _flag_reset_mesh; - flag_reset_barriers = _flag_reset_barriers; - flag_p1_active = _flag_p1_active; + flag_check_bimads = _flag_check_bimads; + flag_reset_mesh = _flag_reset_mesh; + flag_reset_barriers = _flag_reset_barriers; + flag_p1_active = _flag_p1_active; } /*---------------------------------------------------------*/ @@ -88,53 +92,43 @@ void NOMAD::Mads::get_flags ( bool & flag_check_bimads , /*---------------------------------------------------------*/ void NOMAD::Mads::init ( void ) { - - NOMAD::Mads::_force_quit = false; - - if ( !NOMAD::Slave::is_master() ) - return; - - // Mads::force_quit() will be called if ctrl-c is pressed: - signal ( SIGINT , NOMAD::Mads::force_quit ); + + NOMAD::Mads::_force_quit = false; + + if ( !NOMAD::Slave::is_master() ) + return; + + // Mads::force_quit() will be called if ctrl-c is pressed: + signal ( SIGINT , NOMAD::Mads::force_quit ); #ifndef WINDOWS - signal ( SIGPIPE , NOMAD::Mads::force_quit ); // (ctrl-c during a "| more") + signal ( SIGPIPE , NOMAD::Mads::force_quit ); // (ctrl-c during a "| more") #endif #ifdef USE_MPI - signal ( SIGTERM , NOMAD::Mads::force_quit ); + signal ( SIGTERM , NOMAD::Mads::force_quit ); #endif - - // model searches initialization: - if ( _p.has_model_search() ) { -#ifdef USE_TGP - if ( _p.get_model_search(1) == NOMAD::TGP_MODEL ) - _model_search1 = new TGP_Model_Search ( _p ); -#endif - if ( _p.get_model_search(1) == NOMAD::QUADRATIC_MODEL ) - _model_search1 = new Quad_Model_Search ( _p ); -#ifdef USE_TGP - if ( _p.get_model_search(2) == NOMAD::TGP_MODEL ) - _model_search2 = new TGP_Model_Search ( _p ); -#endif - if ( _p.get_model_search(2) == NOMAD::QUADRATIC_MODEL ) - _model_search2 = new Quad_Model_Search ( _p ); - } - -#ifdef USE_TGP - _ev_control.set_last_TGP_model ( NULL ); -#endif - - // VNS search initialization: - if ( _p.get_VNS_search() ) - _VNS_search = new VNS_Search ( _p ); - - // cache search initialization: - if ( _p.get_cache_search() ) - _cache_search = new Cache_Search ( _p ); - - // Orthogonal mesh initialization - _mesh->reset(); - - + + // model searches initialization: + if ( _p.has_model_search() ) + { + if ( _p.get_model_search(1) == NOMAD::QUADRATIC_MODEL ) + _model_search1 = new Quad_Model_Search ( _p ); + + if ( _p.get_model_search(2) == NOMAD::QUADRATIC_MODEL ) + _model_search2 = new Quad_Model_Search ( _p ); + } + + // VNS search initialization: + if ( _p.get_VNS_search() ) + _VNS_search = new VNS_Search ( _p ); + + // cache search initialization: + if ( _p.get_cache_search() ) + _cache_search = new Cache_Search ( _p ); + + // Orthogonal mesh initialization + _mesh->reset(); + + } /*---------------------------------------------------------*/ @@ -142,15 +136,15 @@ void NOMAD::Mads::init ( void ) /*---------------------------------------------------------*/ NOMAD::Mads::~Mads ( void ) { - delete _pareto_front; - delete _model_search1; - delete _model_search2; - delete _VNS_search; - delete _cache_search; - delete _L_curve; - + delete _pareto_front; + delete _model_search1; + delete _model_search2; + delete _VNS_search; + delete _cache_search; + delete _L_curve; + if ( _extended_poll && !_user_ext_poll) - delete _extended_poll; + delete _extended_poll; } /*-------------------------------------------------------------*/ @@ -161,434 +155,416 @@ NOMAD::Mads::~Mads ( void ) /*-------------------------------------------------------------*/ void NOMAD::Mads::reset ( bool keep_barriers , bool keep_stats ) { - // evaluator control: -#ifdef USE_TGP - _ev_control.set_last_TGP_model ( NULL ); -#endif - - // user search: - _user_search = NULL; - - // model search #1: - if ( _p.get_model_search(1) != NOMAD::NO_MODEL ) - { - if ( _model_search1 ) - _model_search1->reset(); - else { - if ( _p.get_model_search(1) == NOMAD::TGP_MODEL ) - { -#ifdef USE_TGP - _model_search1 = new TGP_Model_Search ( _p ) ; -#endif - } - else - _model_search1 = new Quad_Model_Search ( _p ); - } - } - else - { - delete _model_search1; - _model_search1 = NULL; - } - - // model search #2: - if ( _p.get_model_search(2) != NOMAD::NO_MODEL ) - { - if ( _model_search2 ) - _model_search2->reset(); - else - { - if ( _p.get_model_search(2) == NOMAD::TGP_MODEL ) - { -#ifdef USE_TGP - _model_search2 = new TGP_Model_Search ( _p ) ; -#endif - } - else - _model_search2 = new Quad_Model_Search ( _p ); - } - } - else - { - delete _model_search2; - _model_search2 = NULL; - } - - // VNS search: - if ( _p.get_VNS_search() ) - { - if ( _VNS_search ) - _VNS_search->reset(); - else - _VNS_search = new VNS_Search ( _p ); - } - else { - delete _VNS_search; - _VNS_search = NULL; - } - - // cache search: - if ( _p.get_cache_search() ) - { - if ( _cache_search ) - _cache_search->reset(); - else - _cache_search = new Cache_Search ( _p ); - } - else - { - delete _cache_search; - _cache_search = NULL; - } - - // barriers: - _flag_reset_barriers = !keep_barriers; - if ( _flag_reset_barriers ) - { - _true_barrier.reset(); - _sgte_barrier.reset(); - } - - // stats: - if ( !keep_stats ) - _stats.reset(); - - + + // user search: + _user_search = NULL; + + // model search #1: + if ( _p.get_model_search(1) != NOMAD::NO_MODEL ) + { + if ( _model_search1 ) + _model_search1->reset(); + else + _model_search1 = new Quad_Model_Search ( _p ); + } + else + { + delete _model_search1; + _model_search1 = NULL; + } + + // model search #2: + if ( _p.get_model_search(2) != NOMAD::NO_MODEL ) + { + if ( _model_search2 ) + _model_search2->reset(); + else + _model_search2 = new Quad_Model_Search ( _p ); + } + else + { + delete _model_search2; + _model_search2 = NULL; + } + + // VNS search: + if ( _p.get_VNS_search() ) + { + if ( _VNS_search ) + _VNS_search->reset(); + else + _VNS_search = new VNS_Search ( _p ); + } + else + { + + delete _VNS_search; + _VNS_search = NULL; + } + + // cache search: + if ( _p.get_cache_search() ) + { + if ( _cache_search ) + _cache_search->reset(); + else + _cache_search = new Cache_Search ( _p ); + } + else + { + delete _cache_search; + _cache_search = NULL; + } + + // barriers: + _flag_reset_barriers = !keep_barriers; + if ( _flag_reset_barriers ) + { + _true_barrier.reset(); + _sgte_barrier.reset(); + } + + // stats: + if ( !keep_stats ) + _stats.reset(); + + _mesh->reset(); - + } - /* algorithm execution (single-objective) */ /*---------------------------------------------------------*/ NOMAD::stop_type NOMAD::Mads::run ( void ) { - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_gen_dd(); - NOMAD::stop_type stop_reason = NOMAD::UNKNOWN_STOP_REASON; - + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_gen_dd(); + NOMAD::stop_type stop_reason = NOMAD::UNKNOWN_STOP_REASON; + #ifdef USE_MPI - - if ( NOMAD::Slave::get_nb_processes() < 2 ) - { - out << NOMAD::open_block("ERROR:") << "Incorrect command to run with MPI." << std::endl - << "Usage: mpirun -np p exeName" << std::endl ; - out << NOMAD::close_block(); - return stop_reason; - } - - - // init the slaves: - bool stop_slaves_here = false; - - if ( NOMAD::Slave::is_master() ) - { - if ( !NOMAD::Slave::are_running() ) - { - NOMAD::Slave::init_slaves ( out ); - stop_slaves_here = true; - } - } - else - { - NOMAD::Slave s ( _p , _ev_control.get_evaluator() ); - s.run(); - return stop_reason; - } - + + if ( NOMAD::Slave::get_nb_processes() < 2 ) + { + out << NOMAD::open_block("ERROR:") << "Incorrect command to run with MPI." << std::endl + << "Usage: mpirun -np p exeName" << std::endl ; + out << NOMAD::close_block(); + return stop_reason; + } + + + // init the slaves: + bool stop_slaves_here = false; + + if ( NOMAD::Slave::is_master() ) + { + if ( !NOMAD::Slave::are_running() ) + { + NOMAD::Slave::init_slaves ( out ); + stop_slaves_here = true; + } + } + else + { + NOMAD::Slave s ( _p , _ev_control.get_evaluator() ); + s.run(); + return stop_reason; + } + #endif - - try - { - - // check an extended poll if there are categorical - // variables and disable extended poll otherwise: - if ( _p.get_signature()->has_categorical() ) - { - - if ( _user_ext_poll && !_extended_poll ) - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , - "categorical variables: user extended poll object is NULL" ); - - if ( _p.get_extended_poll_enabled() && !_user_ext_poll ) - { - if (!_extended_poll) - _extended_poll = new NOMAD::Extended_Poll ( _p ); // extended poll created only once with the signatures of _p - - std::string error_str; - if ( !_extended_poll->set_neighbors_exe ( error_str ) ) - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , error_str ); - } - } - else if ( _extended_poll ) - { - if ( !_user_ext_poll ) - delete _extended_poll; - _extended_poll = NULL; - } - - // check if Mads::run() has been called for multi-objective: - if ( NOMAD::Mads::_flag_check_bimads && _p.get_nb_obj() > 1 ) - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , - "Mads::run() called for multi-objective instead of Mads::multi_run()" ); - + + try + { + + // check an extended poll if there are categorical + // variables and disable extended poll otherwise: + if ( _p.get_signature()->has_categorical() ) + { + + if ( _user_ext_poll && !_extended_poll ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "categorical variables: user extended poll object is NULL" ); + + if ( _p.get_extended_poll_enabled() && !_user_ext_poll ) + { + if (!_extended_poll) + _extended_poll = new NOMAD::Extended_Poll ( _p ); // extended poll created only once with the signatures of _p + + std::string error_str; + if ( !_extended_poll->set_neighbors_exe ( error_str ) ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , error_str ); + } + } + else if ( _extended_poll ) + { + if ( !_user_ext_poll ) + delete _extended_poll; + _extended_poll = NULL; + } + + // check if Mads::run() has been called for multi-objective: + if ( NOMAD::Mads::_flag_check_bimads && _p.get_nb_obj() > 1 ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "Mads::run() called for multi-objective instead of Mads::multi_run()" ); + #ifndef R_VERSION - if ( display_degree == NOMAD::NORMAL_DISPLAY || display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << NOMAD::open_block ( "MADS run" ); - - if ( display_degree == NOMAD::NORMAL_DISPLAY ) { - _ev_control.display_stats ( true , - out , - _p.get_display_stats() , - NULL , - false , - NULL ); - out << std::endl << std::endl; - } + if ( display_degree == NOMAD::NORMAL_DISPLAY || display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl << NOMAD::open_block ( "MADS run" ); + + if ( display_degree == NOMAD::NORMAL_DISPLAY ) + { + _ev_control.display_stats ( true , + out , + _p.get_display_stats() , + NULL , + false , + NULL ); + out << std::endl << std::endl; + } #endif - - // barriers init: - if ( _flag_reset_barriers ) - { - _true_barrier.reset(); - _sgte_barrier.reset(); - } - - // evaluator control init: - _ev_control.reset(); - - // reset the extended poll: - if ( _extended_poll && _p.get_extended_poll_enabled() ) - _extended_poll->reset(); - - // mesh init/reset: - if ( _flag_reset_mesh ) + + // barriers init: + if ( _flag_reset_barriers ) + { + _true_barrier.reset(); + _sgte_barrier.reset(); + } + + // evaluator control init: + _ev_control.reset(); + + // reset the extended poll: + if ( _extended_poll && _p.get_extended_poll_enabled() ) + _extended_poll->reset(); + + // mesh init/reset: + if ( _flag_reset_mesh ) _mesh->reset(); - - NOMAD::success_type success , last_success; - int nb_search_pts; - bool count_search; - bool stop = false; - const NOMAD::Eval_Point * new_feas_inc = NULL; - const NOMAD::Eval_Point * new_infeas_inc = NULL; - - stop_reason = NOMAD::NO_STOP; - - // x0 eval: - eval_x0 ( stop , stop_reason ); - - // phase one: if no feasible starting point: - bool phase_one_done = false; - if (stop && - stop_reason == NOMAD::X0_FAIL && - _p.has_EB_constraints() && - ( _stats.get_eval() > 0 || ( _p.get_opt_only_sgte() && _stats.get_sgte_eval() > 0 ) ) ) - { - - phase_one_done = true; - Phase_One_Search p1s ( _p ); - p1s.search ( *this , - nb_search_pts , - stop , - stop_reason , - success , - count_search , - new_feas_inc , - new_infeas_inc ); - - _mesh->reset(); - - } - - // initial Latin-Hypercube (LH) search: - if ( !stop && !phase_one_done && _p.get_LH_search_p0() > 0 ) - { - - LH_Search lh ( _p , true , _flag_p1_active ); - int nb_search_pts; - - lh.search ( *this , - nb_search_pts , - stop , - stop_reason , - success , - count_search , - new_feas_inc , - new_infeas_inc ); - - if ( success == NOMAD::FULL_SUCCESS ) - _stats.add_LH_success(); - - if ( count_search ) - _stats.add_nb_LH_searches(); - - _stats.add_LH_pts ( nb_search_pts ); - } - - // no iterations allowed: - if ( !stop && _p.get_max_iterations() == 0 ) - { - stop = true; - stop_reason = NOMAD::MAX_ITER_REACHED; - } - - // L_curve initialization: - delete _L_curve; - _L_curve = NULL; - const NOMAD::Double L_curve_target = _p.get_L_curve_target(); - if ( L_curve_target.is_defined() ) - { - _L_curve = new NOMAD::L_Curve ( L_curve_target ); - const NOMAD::Eval_Point * best_feasible = get_best_feasible(); - if ( best_feasible ) - _L_curve->insert ( _stats.get_bb_eval() , best_feasible->get_f() ); - } - - int max_cfi = _p.get_max_consecutive_failed_iterations(); - int nb_cfi = 0; - - success = last_success = NOMAD::UNSUCCESSFUL; - - // MADS iterations: - while ( !stop ) - { - - iteration ( stop , - stop_reason , - success , - new_feas_inc , - new_infeas_inc ); - - if ( success == NOMAD::UNSUCCESSFUL && last_success == NOMAD::UNSUCCESSFUL ) - ++nb_cfi; - else - nb_cfi = (success == NOMAD::UNSUCCESSFUL) ? 1 : 0; - - last_success = success; - - // check the consecutive number of failed iterations: - if ( max_cfi > 0 && nb_cfi > max_cfi ) - { - stop = true; - stop_reason = NOMAD::MAX_CONS_FAILED_ITER; - } - - } - - // parallel version: + + NOMAD::success_type success , last_success; + int nb_search_pts; + bool count_search; + bool stop = false; + const NOMAD::Eval_Point * new_feas_inc = NULL; + const NOMAD::Eval_Point * new_infeas_inc = NULL; + + stop_reason = NOMAD::NO_STOP; + + // x0 eval: + eval_x0 ( stop , stop_reason ); + + // phase one: if no feasible starting point: + bool phase_one_done = false; + if (stop && + stop_reason == NOMAD::X0_FAIL && + _p.has_EB_constraints() && + ( _stats.get_eval() > 0 || ( _p.get_opt_only_sgte() && _stats.get_sgte_eval() > 0 ) ) ) + { + + phase_one_done = true; + Phase_One_Search p1s ( _p ); + p1s.search ( *this , + nb_search_pts , + stop , + stop_reason , + success , + count_search , + new_feas_inc , + new_infeas_inc ); + + _mesh->reset(); + + } + + // initial Latin-Hypercube (LH) search: + if ( !stop && !phase_one_done && _p.get_LH_search_p0() > 0 ) + { + + LH_Search lh ( _p , true , _flag_p1_active ); + int nb_search_pts; + + lh.search ( *this , + nb_search_pts , + stop , + stop_reason , + success , + count_search , + new_feas_inc , + new_infeas_inc ); + + if ( success == NOMAD::FULL_SUCCESS ) + _stats.add_LH_success(); + + if ( count_search ) + _stats.add_nb_LH_searches(); + + _stats.add_LH_pts ( nb_search_pts ); + } + + // no iterations allowed: + if ( !stop && _p.get_max_iterations() == 0 ) + { + stop = true; + stop_reason = NOMAD::MAX_ITER_REACHED; + } + + // L_curve initialization: + delete _L_curve; + _L_curve = NULL; + const NOMAD::Double L_curve_target = _p.get_L_curve_target(); + if ( L_curve_target.is_defined() ) + { + _L_curve = new NOMAD::L_Curve ( L_curve_target ); + const NOMAD::Eval_Point * best_feasible = get_best_feasible(); + if ( best_feasible ) + _L_curve->insert ( _stats.get_bb_eval() , best_feasible->get_f() ); + } + + int max_cfi = _p.get_max_consecutive_failed_iterations(); + int nb_cfi = 0; + + success = last_success = NOMAD::UNSUCCESSFUL; + + // MADS iterations: + while ( !stop ) + { + + iteration ( stop , + stop_reason , + success , + new_feas_inc , + new_infeas_inc ); + + if ( success == NOMAD::UNSUCCESSFUL && last_success == NOMAD::UNSUCCESSFUL ) + ++nb_cfi; + else + nb_cfi = (success == NOMAD::UNSUCCESSFUL) ? 1 : 0; + + last_success = success; + + // check the consecutive number of failed iterations: + if ( max_cfi > 0 && nb_cfi > max_cfi ) + { + stop = true; + stop_reason = NOMAD::MAX_CONS_FAILED_ITER; + } + + } + + // parallel version: #ifdef USE_MPI - - // asynchronous mode: wait for the evaluations in progress: - if ( _p.get_asynchronous() ) - { - std::list<const NOMAD::Eval_Point *> evaluated_pts; - _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , - _true_barrier , - _sgte_barrier , - _pareto_front , - stop , - stop_reason , - success , - evaluated_pts ); - } - - // update stats: - _stats.set_MPI_data_size ( NOMAD::Slave::get_data_sent() + - NOMAD::Slave::get_data_rcvd() ); - + + // asynchronous mode: wait for the evaluations in progress: + if ( _p.get_asynchronous() ) + { + std::list<const NOMAD::Eval_Point *> evaluated_pts; + _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , + _true_barrier , + _sgte_barrier , + _pareto_front , + stop , + stop_reason , + success , + evaluated_pts ); + } + + // update stats: + _stats.set_MPI_data_size ( NOMAD::Slave::get_data_sent() + + NOMAD::Slave::get_data_rcvd() ); + #endif - - // final cache save (overwrite=true): - _ev_control.save_caches ( true ); - - // final displays: - const NOMAD::Eval_Point * bf = get_best_feasible(); - bool write_stats = bf && - ( bf->get_tag() != _ev_control.get_last_stats_tag() || - _stats.get_bb_eval() != _ev_control.get_last_stats_bbe() ); - - const std::string & stats_file_name = _p.get_stats_file_name(); - - if ( !stats_file_name.empty() ) - { - if ( write_stats && !_p.get_display_all_eval() ) - { - _ev_control.stats_file ( stats_file_name , bf , true , NULL ); - } + + // final cache save (overwrite=true): + _ev_control.save_caches ( true ); + + // final displays: + const NOMAD::Eval_Point * bf = get_best_feasible(); + bool write_stats = bf && + ( bf->get_tag() != _ev_control.get_last_stats_tag() || + _stats.get_bb_eval() != _ev_control.get_last_stats_bbe() ); + + const std::string & stats_file_name = _p.get_stats_file_name(); + + if ( !stats_file_name.empty() ) + { + if ( write_stats && !_p.get_display_all_eval() ) + { + _ev_control.stats_file ( stats_file_name , bf , true , NULL ); + } + if ( !bf && display_degree > NOMAD::MINIMAL_DISPLAY ) - { - std::ofstream fout ( (_p.get_problem_dir() + stats_file_name).c_str() ); - if ( fout.fail() ) - { - out << std::endl - << "Warning (" << "Mads.cpp" << ", " << __LINE__ - << "): could not save information in stats file \'" - << stats_file_name << "\'" << std::endl << std::endl; - } - else - fout << "no feasible solution has been found after " - << _stats.get_bb_eval() << " evaluations" - << std::endl; - fout.close(); - } - - } - - if ( display_degree > NOMAD::MINIMAL_DISPLAY) - { - - // final stats: - if ( display_degree == NOMAD::NORMAL_DISPLAY && bf && write_stats && !_p.get_display_all_eval() ) - _ev_control.display_stats ( false, - out, - _p.get_display_stats() , - bf , - true , - NULL ); + { + std::ofstream fout ( (_p.get_problem_dir() + stats_file_name).c_str() ); + if ( fout.fail() ) + { + out << std::endl + << "Warning (" << "Mads.cpp" << ", " << __LINE__ + << "): could not save information in stats file \'" + << stats_file_name << "\'" << std::endl << std::endl; + } + else + fout << "no feasible solution has been found after " + << _stats.get_bb_eval() << " evaluations" + << std::endl; + fout.close(); + } + + } + + if ( display_degree > NOMAD::MINIMAL_DISPLAY) + { + + // final stats: + if ( display_degree == NOMAD::NORMAL_DISPLAY && bf && write_stats && !_p.get_display_all_eval() ) + _ev_control.display_stats ( false, + out, + _p.get_display_stats() , + bf , + true , + NULL ); #ifndef R_VERSION - std::ostringstream msg; - msg << "end of run (" << stop_reason << ")"; - out << std::endl << NOMAD::close_block ( msg.str() ); + std::ostringstream msg; + msg << "end of run (" << stop_reason << ")"; + out << std::endl << NOMAD::close_block ( msg.str() ); #endif - } - - // mono-objective final displays: - if ( _p.get_nb_obj() == 1 ) - { - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << NOMAD::open_block ( "NOMAD final display" ); - + } + + // mono-objective final displays: + if ( _p.get_nb_obj() == 1 ) + { + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl << NOMAD::open_block ( "NOMAD final display" ); + #ifndef R_VERSION - display(); + display(); #endif - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out.close_block(); - } - - } // end of the try block - - catch ( std::exception & e ) + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out.close_block(); + } + + } // end of the try block + + catch ( std::exception & e ) { - + #ifdef USE_MPI - if ( NOMAD::Slave::are_running() ) - NOMAD::Slave::stop_slaves ( out ); + if ( NOMAD::Slave::are_running() ) + NOMAD::Slave::stop_slaves ( out ); #endif - - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , e.what() ); - } - - // stop the slaves: + + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , e.what() ); + } + + // stop the slaves: #ifdef USE_MPI - if ( NOMAD::Slave::are_running() && stop_slaves_here ) - NOMAD::Slave::stop_slaves ( out ); + if ( NOMAD::Slave::are_running() && stop_slaves_here ) + NOMAD::Slave::stop_slaves ( out ); #endif - - return stop_reason; + + return stop_reason; } /*----------------------------------------------------------------------*/ @@ -599,153 +575,152 @@ NOMAD::stop_type NOMAD::Mads::run ( void ) /* been set to zero */ /* . private method */ /*----------------------------------------------------------------------*/ -void NOMAD::Mads::multi_launch_single_opt -( NOMAD::dd_type display_degree , - int mads_runs , - int overall_bbe , - NOMAD::Multi_Obj_Evaluator & ev , - int & stagnation_cnt , - NOMAD::Stats & multi_stats , - bool & stop , - NOMAD::stop_type & stop_reason ) +void NOMAD::Mads::multi_launch_single_opt ( NOMAD::dd_type display_degree , + int mads_runs , + int overall_bbe , + NOMAD::Multi_Obj_Evaluator & ev , + int & stagnation_cnt , + NOMAD::Stats & multi_stats , + bool & stop , + NOMAD::stop_type & stop_reason ) { - // max number of bb evaluations for one MADS run: - int max_bbe = _p.get_max_bb_eval(); - - // size of the Pareto front before the MADS run: - int tmp = _pareto_front->size(); - - // current MADS run: - int cur_mads_run = multi_stats.get_mads_runs(); - - // displays: - const NOMAD::Display & out = _p.out(); - - if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - { - out << "MADS run " << std::setw(2) << cur_mads_run + 1; - if ( mads_runs > 0 ) - out << "/" << mads_runs; - out << " ..."; - } - - // run single-objective MADS (it also updates the Pareto front): - NOMAD::Mads::set_flag_check_bimads ( false ); - NOMAD::stop_type single_run_stop_reason = run(); - NOMAD::Mads::set_flag_check_bimads ( true ); - - if ( single_run_stop_reason == NOMAD::CTRL_C || - single_run_stop_reason == NOMAD::ERROR || - single_run_stop_reason == NOMAD::UNKNOWN_STOP_REASON || - single_run_stop_reason == NOMAD::X0_FAIL || - single_run_stop_reason == NOMAD::F_TARGET_REACHED || - single_run_stop_reason == NOMAD::P1_FAIL ) - { - stop = true; - stop_reason = single_run_stop_reason; - } - - // update MULTI-MADS stats from MADS stats: - multi_stats.update ( _stats , false ); // for_search = false - multi_stats.add_mads_run(); - - int nb_new_pts = _pareto_front->size() - tmp; - int global_bbe = multi_stats.get_bb_eval(); - - // displays: - if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - { - - // display basic stats on the terminated run: - out << "... OK [bb eval=" << std::setw(3) << _stats.get_bb_eval() - << "] [overall bb eval=" << std::setw(5) << global_bbe - << "] [# dominant pts=" << std::setw(4) << _pareto_front->size() - << "] [# new pts=" << std::setw(4) << nb_new_pts << "]"; - - // display f1, f2, and f: - const NOMAD::Eval_Point * bf = get_best_feasible(); - if ( bf ) - { - - const NOMAD::Point & bbo = bf->get_bb_outputs(); - - out << " [f1=" << bbo[ev.get_i1()] - << " f2=" << bbo[ev.get_i2()]; - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << " f=" << bf->get_f(); - out << "]"; - } - out << std::endl; - } - - if ( _stats.get_bb_eval() == 0 && nb_new_pts == 0 ) - ++stagnation_cnt; - else - stagnation_cnt = 0; - - // stop ? - if ( !stop ) - { - - // test the number of MADS runs: - if ( mads_runs > 0 ) - { - if ( multi_stats.get_mads_runs() >= mads_runs ) - { - stop = true; - stop_reason = NOMAD::MULTI_NB_MADS_RUNS_REACHED; - } - } - - // test if no new Pareto point has been generated for 50*n MADS runs: - else - { - if ( stagnation_cnt > 50 * _p.get_nb_free_variables() ) - { - stop = true; - stop_reason = NOMAD::MULTI_STAGNATION; - } - } - } - - if ( overall_bbe >= 0 && global_bbe >= overall_bbe ) - { - stop = true; - stop_reason = NOMAD::MULTI_MAX_BB_REACHED; - } - - bool user_calls_enabled = _p.get_user_calls_enabled(); - - if ( !stop ) - { - - // ell is the mesh index on which the last run terminated: - // int ell = NOMAD::Mesh::get_mesh_index(); - - // reset MADS: - reset(); - - // this strategy deciding the initial mesh size - // was used with versions < 3.4 - // if ( cur_mads_run > 1 ) - // _p.set_INITIAL_MESH_INDEX ( (ell > 5) ? 5 : ell ); - - // modify MAX_BB_EVAL for single runs (in order to have - // less than overall_bbe blackbox evaluations): - if ( overall_bbe >= 0 && global_bbe + max_bbe > overall_bbe ) - _p.set_MAX_BB_EVAL ( overall_bbe - global_bbe ); - } - - // set the number of MADS runs for the general Stats object: - _stats.set_mads_runs ( multi_stats.get_mads_runs() ); - - // call the user-defined function Multi_Obj_Evaluator::update_mads_run(): - if ( user_calls_enabled ) - ev.update_mads_run ( _stats , - _ev_control , - _true_barrier , - _sgte_barrier , - *_pareto_front ); + // max number of bb evaluations for one MADS run: + int max_bbe = _p.get_max_bb_eval(); + + // size of the Pareto front before the MADS run: + int tmp = _pareto_front->size(); + + // current MADS run: + int cur_mads_run = multi_stats.get_mads_runs(); + + // displays: + const NOMAD::Display & out = _p.out(); + + if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + { + out << "MADS run " << std::setw(2) << cur_mads_run + 1; + if ( mads_runs > 0 ) + out << "/" << mads_runs; + out << " ..."; + } + + // run single-objective MADS (it also updates the Pareto front): + NOMAD::Mads::set_flag_check_bimads ( false ); + NOMAD::stop_type single_run_stop_reason = run(); + NOMAD::Mads::set_flag_check_bimads ( true ); + + if ( single_run_stop_reason == NOMAD::CTRL_C || + single_run_stop_reason == NOMAD::ERROR || + single_run_stop_reason == NOMAD::UNKNOWN_STOP_REASON || + single_run_stop_reason == NOMAD::X0_FAIL || + single_run_stop_reason == NOMAD::F_TARGET_REACHED || + single_run_stop_reason == NOMAD::P1_FAIL ) + { + stop = true; + stop_reason = single_run_stop_reason; + } + + // update MULTI-MADS stats from MADS stats: + multi_stats.update ( _stats , false ); // for_search = false + multi_stats.add_mads_run(); + + int nb_new_pts = _pareto_front->size() - tmp; + int global_bbe = multi_stats.get_bb_eval(); + + // displays: + if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + { + + // display basic stats on the terminated run: + out << "... OK [bb eval=" << std::setw(3) << _stats.get_bb_eval() + << "] [overall bb eval=" << std::setw(5) << global_bbe + << "] [# dominant pts=" << std::setw(4) << _pareto_front->size() + << "] [# new pts=" << std::setw(4) << nb_new_pts << "]"; + + // display f1, f2, and f: + const NOMAD::Eval_Point * bf = get_best_feasible(); + if ( bf ) + { + + const NOMAD::Point & bbo = bf->get_bb_outputs(); + + out << " [f1=" << bbo[ev.get_i1()] + << " f2=" << bbo[ev.get_i2()]; + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << " f=" << bf->get_f(); + out << "]"; + } + out << std::endl; + } + + if ( _stats.get_bb_eval() == 0 && nb_new_pts == 0 ) + ++stagnation_cnt; + else + stagnation_cnt = 0; + + // stop ? + if ( !stop ) + { + + // test the number of MADS runs: + if ( mads_runs > 0 ) + { + if ( multi_stats.get_mads_runs() >= mads_runs ) + { + stop = true; + stop_reason = NOMAD::MULTI_NB_MADS_RUNS_REACHED; + } + } + + // test if no new Pareto point has been generated for 50*n MADS runs: + else + { + if ( stagnation_cnt > 50 * _p.get_nb_free_variables() ) + { + stop = true; + stop_reason = NOMAD::MULTI_STAGNATION; + } + } + } + + if ( overall_bbe >= 0 && global_bbe >= overall_bbe ) + { + stop = true; + stop_reason = NOMAD::MULTI_MAX_BB_REACHED; + } + + bool user_calls_enabled = _p.get_user_calls_enabled(); + + if ( !stop ) + { + + // ell is the mesh index on which the last run terminated: + // int ell = NOMAD::Mesh::get_mesh_index(); + + // reset MADS: + reset(); + + // this strategy deciding the initial mesh size + // was used with versions < 3.4 + // if ( cur_mads_run > 1 ) + // _p.set_INITIAL_MESH_INDEX ( (ell > 5) ? 5 : ell ); + + // modify MAX_BB_EVAL for single runs (in order to have + // less than overall_bbe blackbox evaluations): + if ( overall_bbe >= 0 && global_bbe + max_bbe > overall_bbe ) + _p.set_MAX_BB_EVAL ( overall_bbe - global_bbe ); + } + + // set the number of MADS runs for the general Stats object: + _stats.set_mads_runs ( multi_stats.get_mads_runs() ); + + // call the user-defined function Multi_Obj_Evaluator::update_mads_run(): + if ( user_calls_enabled ) + ev.update_mads_run ( _stats , + _ev_control , + _true_barrier , + _sgte_barrier , + *_pareto_front ); } /*--------------------------------------------------------------------------*/ @@ -753,33 +728,34 @@ void NOMAD::Mads::multi_launch_single_opt /* (private) */ /*--------------------------------------------------------------------------*/ void NOMAD::Mads::multi_set_min_poll_size ( const NOMAD::Point & lb , - const NOMAD::Point & ub , - const NOMAD::Point & Delta_0 , - NOMAD::Double delta_j ) + const NOMAD::Point & ub , + const NOMAD::Point & Delta_0 , + NOMAD::Double delta_j ) { - delta_j /= sqrt ( _mesh->get_update_basis() ); - - int n = Delta_0.size(); - NOMAD::Point Delta_min (n); - - for ( int i = 0 ; i < n ; ++i ) - { - - // set a relative value: - if ( lb[i].is_defined() && ub[i].is_defined() ) - Delta_min[i] = delta_j * ( ub[i] - lb[i] ); - - // set an absolute value: - else - Delta_min[i] = delta_j; - - // compare to Delta_0: - if ( Delta_min[i] > Delta_0[i] ) - Delta_min[i] = Delta_0[i]; - } - - _p.set_MIN_POLL_SIZE ( Delta_min ); + + delta_j /= sqrt ( _mesh->get_update_basis() ); + + int n = Delta_0.size(); + NOMAD::Point Delta_min (n); + + for ( int i = 0 ; i < n ; ++i ) + { + + // set a relative value: + if ( lb[i].is_defined() && ub[i].is_defined() ) + Delta_min[i] = delta_j * ( ub[i] - lb[i] ); + + // set an absolute value: + else + Delta_min[i] = delta_j; + + // compare to Delta_0: + if ( Delta_min[i] > Delta_0[i] ) + Delta_min[i] = Delta_0[i]; + } + + _p.set_MIN_POLL_SIZE ( Delta_min ); } /*---------------------------------------------------------*/ @@ -787,1066 +763,1072 @@ void NOMAD::Mads::multi_set_min_poll_size ( const NOMAD::Point & lb , /*---------------------------------------------------------*/ NOMAD::stop_type NOMAD::Mads::multi_run ( void ) { - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_gen_dd(); - NOMAD::stop_type stop_reason = NOMAD::UNKNOWN_STOP_REASON; - - // init the slaves: + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_gen_dd(); + NOMAD::stop_type stop_reason = NOMAD::UNKNOWN_STOP_REASON; + + // init the slaves: #ifdef USE_MPI - - if ( NOMAD::Slave::get_nb_processes() < 2 ) - { - out << NOMAD::open_block("ERROR:") << "Incorrect command to run with MPI." << std::endl - << "Usage: mpirun -np p exeName" << std::endl ; - out << NOMAD::close_block(); - return stop_reason; - } - - bool stop_slaves_here = false; - - if ( NOMAD::Slave::is_master() ) - { - if ( !NOMAD::Slave::are_running() ) - { - NOMAD::Slave::init_slaves ( out ); - stop_slaves_here = true; - } - } - else - { - NOMAD::Slave s ( _p , _ev_control.get_evaluator() ); - s.run(); - return stop_reason; - } - + + if ( NOMAD::Slave::get_nb_processes() < 2 ) + { + out << NOMAD::open_block("ERROR:") << "Incorrect command to run with MPI." << std::endl + << "Usage: mpirun -np p exeName" << std::endl ; + out << NOMAD::close_block(); + return stop_reason; + } + + bool stop_slaves_here = false; + + if ( NOMAD::Slave::is_master() ) + { + if ( !NOMAD::Slave::are_running() ) + { + NOMAD::Slave::init_slaves ( out ); + stop_slaves_here = true; + } + } + else + { + NOMAD::Slave s ( _p , _ev_control.get_evaluator() ); + s.run(); + return stop_reason; + } + #endif - - try { - - // objective indexes: - NOMAD::Multi_Obj_Evaluator::set_obj_indexes ( _p.get_index_obj() ); - - // bounds: - const NOMAD::Point & lb = _p.get_lb(); - const NOMAD::Point & ub = _p.get_ub(); - - // MULTI-MADS stopping criteria: - int mads_runs = _p.get_multi_nb_mads_runs(); // max number of MADS runs - int overall_bbe = _p.get_multi_overall_bb_eval(); // max number of total bb eval. - bool use_delta_crit = _p.get_multi_use_delta_crit(); // use the delta term. crit. - int stagnation_cnt = 0; - - if ( mads_runs == 0 ) - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , - "Mads::multi_run(): parameter MULTI_NB_MADS_RUNS is not positive" ); - - if ( _p.get_nb_obj() != 2 ) - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , - "Mads::multi_run(): NOMAD current version handles a maximum of two objectives" ); - - // remember cache save period: - int old_csp = _p.get_cache_save_period(); - - // remember L_CURVE_TARGET: - NOMAD::Double old_lct = _p.get_L_curve_target(); - - // remember solution file: - std::string old_sol_file = _p.get_solution_file(); - - // remember the original LH search parameters: - int lh_p0 = _p.get_LH_search_p0(); - int lh_pi = _p.get_LH_search_pi(); - - // remember the original minimal poll size: - const NOMAD::Point original_min_poll_size = _p.get_min_poll_size(); - - // remember display degrees: - NOMAD::dd_type iter_dd = out.get_iter_dd(); - std::string old_dd; - out.get_display_degree ( old_dd ); - - // save list of starting points: - std::string x0_cache_file = _p.get_x0_cache_file(); - std::vector<NOMAD::Point *> x0s; - { - const std::vector<NOMAD::Point *> & x0s_tmp = _p.get_x0s(); - size_t nx0 = x0s_tmp.size() , k; - for ( k = 0 ; k < nx0 ; ++k ) - x0s.push_back ( new Point ( *x0s_tmp[k] ) ); - } - - NOMAD::Point Delta_0 = _mesh->get_initial_poll_size (); - - - if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - out << std::endl << NOMAD::open_block ( "multi-MADS run" ) << std::endl; - - bool stop = false; - stop_reason = NOMAD::NO_STOP; - - // MULTI-MADS stats: - NOMAD::Stats multi_stats ( _stats ); - - // access to the evaluator (downcast to a Multi_Obj_Evaluator): - NOMAD::Multi_Obj_Evaluator * ev = - static_cast<NOMAD::Multi_Obj_Evaluator*> ( _ev_control.get_evaluator() ); - if ( !ev->is_multi_obj() ) - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , - "Mads::multi_run(): associated Evaluator object is not a Multi_Obj_Evaluator" ); - - // parameters modifications: - // ------------------------- - - // STATS_FILE: - const std::string old_stats_file_name = _p.get_stats_file_name(); - const std::list<std::string> old_stats_file = _p.get_stats_file(); - _p.reset_stats_file(); - - // MAX_BB_EVAL: - int max_bbe = _p.get_max_bb_eval(); - if ( overall_bbe >= 0 && ( max_bbe < 0 || overall_bbe < max_bbe ) ) - _p.set_MAX_BB_EVAL ( overall_bbe ); - - // disable display: - _p.set_DISPLAY_DEGREE ( NOMAD::NO_DISPLAY ); - - // disable solution file: - _p.set_SOLUTION_FILE ( "" ); - - // disable CACHE_SAVE_PERIOD: - _p.set_CACHE_SAVE_PERIOD ( -1 ); - - // disable L_CURVE_TARGET: - _p.set_L_CURVE_TARGET ( NOMAD::Double() ); - - // LH_SEARCH and MAX_BB_EVAL adjustment: - if ( lh_p0 > 0 ) - { - _p.set_LH_SEARCH ( lh_p0 , 0 ); - if ( max_bbe >= 0 ) - { - int bbe = max_bbe + lh_p0; - if ( overall_bbe >= 0 && bbe > overall_bbe ) - bbe = overall_bbe; - _p.set_MAX_BB_EVAL ( bbe ); - } - } - - // parameters validation: - _p.check ( true , // remove_history_file = true - true , // remove_solution_file = true - true ); // remove_stats_file = true - - // Pareto front initialization: - delete _pareto_front; - _pareto_front = new NOMAD::Pareto_Front; + + try { - // Problem has categorical variables ? (Si why this flag is needed below) - bool hasCategoricalVar=_p.get_signature()->has_categorical(); - - // initial optimizations ( minimize f1(x) or f2(x) ): - // -------------------------------------------------- - const NOMAD::Eval_Point * best_f2; - int i; - - for ( i = 0 ; i < 2 ; ++i ) - { - - if ( stop ) - break; - - // minimize f2: - if ( i == 1 ) - { - - // new starting point: - best_f2 = _pareto_front->get_best_f2(); - if ( best_f2 ) - { - _p.set_EXTERN_SIGNATURE ( best_f2->get_signature() ); - _p.reset_X0(); - _p.set_X0 ( *best_f2 ); - } - - // LH_SEARCH: - if ( lh_pi > 0 ) - _p.set_LH_SEARCH ( lh_pi , 0 ); - else if ( lh_p0 > 0 ) - _p.set_LH_SEARCH ( 0 , 0 ); - - // MAX_BB_EVAL: - if ( max_bbe >= 0 ) - { - int bbe = max_bbe + ( (lh_pi > 0 ) ? lh_pi : 0 ); - if ( overall_bbe >= 0 ) - { - if ( bbe > overall_bbe ) - bbe = overall_bbe; - int global_bbe = multi_stats.get_bb_eval(); - if ( global_bbe + bbe > overall_bbe ) - bbe = overall_bbe - global_bbe; - } - _p.set_MAX_BB_EVAL ( bbe ); - } - - if ( _p.to_be_checked() ) - _p.check ( false , // remove_history_file = false - true , // remove_solution_file = true - true ); // remove_stats_file = true - - _mesh=_p.get_signature()->get_mesh(); - - } - - // set weights/reference: - ev->set_weights ( 1-i , i ); - ev->set_ref ( NULL ); - - // launch the single optimization: - multi_launch_single_opt ( iter_dd , - mads_runs , - overall_bbe , - *ev , - stagnation_cnt , - multi_stats , - stop , - stop_reason ); - } - - const NOMAD::Point * ref; - const NOMAD::Pareto_Point * xj; - NOMAD::Double delta_j; - - // the LH search is disabled: - _p.set_LH_SEARCH ( 0 , 0 ); - - // MAX_BB_EVAL reset: - if ( max_bbe > 0 && ( lh_p0 > 0 || lh_pi > 0 ) ) - { - int bbe = max_bbe; - if ( overall_bbe >= 0 ) - { - if ( bbe > overall_bbe ) - bbe = overall_bbe; - - int global_bbe = multi_stats.get_bb_eval(); - if ( global_bbe + bbe > overall_bbe ) - bbe = overall_bbe - global_bbe; - } - _p.set_MAX_BB_EVAL ( bbe ); - } - - // MULTI-MADS main loop: - // --------------------- - const NOMAD::Eval_Point * x0_tmp; - - while ( !stop ) - { - - // get the reference point from the Pareto front: - ref = _pareto_front->get_ref ( xj , delta_j ); - - if ( !xj ) - { - stop = true; - stop_reason = NOMAD::MULTI_NO_PARETO_PTS; - break; - } - - // use delta as stopping criterion: - if ( use_delta_crit ) - { - if ( delta_j.is_defined() && delta_j > 0.0 ) - multi_set_min_poll_size ( lb , ub , Delta_0 , delta_j ); - else - _p.set_MIN_POLL_SIZE ( original_min_poll_size ); - } - - // new starting point: - x0_tmp = xj->get_element(); - _p.set_EXTERN_SIGNATURE ( x0_tmp->get_signature() ); - _p.reset_X0(); - _p.set_X0 ( *x0_tmp ); - - _p.check ( false , // remove_history_file = false - true , // remove_solution_file = true - true ); // remove_stats_file = true - - // a reference point has been found: optimization - // with reference-based function: - if ( ref ) - { - - // set reference: - ev->set_ref ( ref ); - - // launch the single optimization: - multi_launch_single_opt ( iter_dd , - mads_runs , - overall_bbe , - *ev , - stagnation_cnt , - multi_stats , - stop , - stop_reason ); - - delete ref; - ev->set_ref ( NULL ); - } - - // no reference available: two optimizations ( f1(x) and f2(x) ): - else - { - - // for the stagnation check: - const NOMAD::Eval_Point * pp_before; - int stagnation_cnt_before , overall_bbe_before; - bool check_1 = false; - - // loop on f1 and f2: - for ( i = 0 ; i < 2 ; ++i ) - { - - if ( stop ) - break; - - // minimize f2: - if ( i == 1 ) - { - - // new starting point: - best_f2 = _pareto_front->get_best_f2(); - if ( best_f2 ) - { - _p.set_EXTERN_SIGNATURE ( best_f2->get_signature() ); - _p.reset_X0(); - _p.set_X0 ( *best_f2 ); - } - else - _p.set_X0 ( *x0_tmp ); - - _p.check ( false , // remove_history_file = false - true , // remove_solution_file = true - true ); // remove_stats_file = true - } - - // set weights/reference: - ev->set_weights ( 1-i , i ); - ev->set_ref ( NULL ); - - stagnation_cnt_before = stagnation_cnt; - overall_bbe_before = overall_bbe; - pp_before = ( _pareto_front->size() == 1 ) ? - _pareto_front->begin() : NULL; - - // launch the single optimization: - multi_launch_single_opt ( iter_dd , - mads_runs , - overall_bbe , - *ev , - stagnation_cnt , - multi_stats , - stop , - stop_reason ); - - // stagnation check: - if ( stagnation_cnt > stagnation_cnt_before && - overall_bbe == overall_bbe_before && - _pareto_front->size() == 1 && - _pareto_front->begin() == pp_before ) - { - - if ( i == 0 ) - check_1 = true; - else if ( check_1 ) - { - stop = true; - stop_reason = NOMAD::MULTI_STAGNATION; - } - } - } - } - - } // end of MULTI-MADS main loop - // --------------------------- - + // objective indexes: + NOMAD::Multi_Obj_Evaluator::set_obj_indexes ( _p.get_index_obj() ); - // parameters re-initialization and final displays: - if ( ! hasCategoricalVar ) // Dimension may change when categorical variables are present. This may pose problem for the check. Hence we add a test -> when categorical variables are present, the parameters are not set back to their initial state at the end of the multi-objective optimization. - { - _p.reset_X0(); - size_t nx0 = x0s.size(); - if ( nx0 > 0 ) - { - for ( size_t k = 0 ; k < nx0 ; ++k ) - { - _p.set_X0 ( *x0s[k] ); - delete x0s[k]; - } - } - else if ( !x0_cache_file.empty() ) - _p.set_X0 ( x0_cache_file ); + // bounds: + const NOMAD::Point & lb = _p.get_lb(); + const NOMAD::Point & ub = _p.get_ub(); + + // MULTI-MADS stopping criteria: + int mads_runs = _p.get_multi_nb_mads_runs(); // max number of MADS runs + int overall_bbe = _p.get_multi_overall_bb_eval(); // max number of total bb eval. + bool use_delta_crit = _p.get_multi_use_delta_crit(); // use the delta term. crit. + int stagnation_cnt = 0; + + if ( mads_runs == 0 ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "Mads::multi_run(): parameter MULTI_NB_MADS_RUNS is not positive" ); + + if ( _p.get_nb_obj() != 2 ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "Mads::multi_run(): NOMAD current version handles a maximum of two objectives" ); + + // remember cache save period: + int old_csp = _p.get_cache_save_period(); + + // remember L_CURVE_TARGET: + NOMAD::Double old_lct = _p.get_L_curve_target(); + + // remember solution file: + std::string old_sol_file = _p.get_solution_file(); + + // remember the original LH search parameters: + int lh_p0 = _p.get_LH_search_p0(); + int lh_pi = _p.get_LH_search_pi(); + + // remember the original minimal poll size: + const NOMAD::Point original_min_poll_size = _p.get_min_poll_size(); + + // remember display degrees: + NOMAD::dd_type iter_dd = out.get_iter_dd(); + std::string old_dd; + out.get_display_degree ( old_dd ); + + // save list of starting points: + std::string x0_cache_file = _p.get_x0_cache_file(); + std::vector<NOMAD::Point *> x0s; + { + const std::vector<NOMAD::Point *> & x0s_tmp = _p.get_x0s(); + size_t nx0 = x0s_tmp.size() , k; + for ( k = 0 ; k < nx0 ; ++k ) + x0s.push_back ( new Point ( *x0s_tmp[k] ) ); + } + + NOMAD::Point Delta_0 = _mesh->get_initial_poll_size (); + + + if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + out << std::endl << NOMAD::open_block ( "multi-MADS run" ) << std::endl; + + bool stop = false; + stop_reason = NOMAD::NO_STOP; + + // MULTI-MADS stats: + NOMAD::Stats multi_stats ( _stats ); + + // access to the evaluator (downcast to a Multi_Obj_Evaluator): + NOMAD::Multi_Obj_Evaluator * ev = + static_cast<NOMAD::Multi_Obj_Evaluator*> ( _ev_control.get_evaluator() ); + if ( !ev->is_multi_obj() ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "Mads::multi_run(): associated Evaluator object is not a Multi_Obj_Evaluator" ); + + // parameters modifications: + // ------------------------- + + // STATS_FILE: + const std::string old_stats_file_name = _p.get_stats_file_name(); + const std::list<std::string> old_stats_file = _p.get_stats_file(); + _p.reset_stats_file(); + + // MAX_BB_EVAL: + int max_bbe = _p.get_max_bb_eval(); + if ( overall_bbe >= 0 && ( max_bbe < 0 || overall_bbe < max_bbe ) ) + _p.set_MAX_BB_EVAL ( overall_bbe ); + + // disable display: + _p.set_DISPLAY_DEGREE ( NOMAD::NO_DISPLAY ); + + // disable solution file: + _p.set_SOLUTION_FILE ( "" ); + + // disable CACHE_SAVE_PERIOD: + _p.set_CACHE_SAVE_PERIOD ( -1 ); + + // disable L_CURVE_TARGET: + _p.set_L_CURVE_TARGET ( NOMAD::Double() ); + + // LH_SEARCH and MAX_BB_EVAL adjustment: + if ( lh_p0 > 0 ) + { + _p.set_LH_SEARCH ( lh_p0 , 0 ); + if ( max_bbe >= 0 ) + { + int bbe = max_bbe + lh_p0; + if ( overall_bbe >= 0 && bbe > overall_bbe ) + bbe = overall_bbe; + _p.set_MAX_BB_EVAL ( bbe ); + } + } + + // parameters validation: + _p.check ( true , // remove_history_file = true + true , // remove_solution_file = true + true ); // remove_stats_file = true + + // Pareto front initialization: + delete _pareto_front; + _pareto_front = new NOMAD::Pareto_Front; + + // Problem has categorical variables ? (Si why this flag is needed below) + bool hasCategoricalVar=_p.get_signature()->has_categorical(); + + // initial optimizations ( minimize f1(x) or f2(x) ): + // -------------------------------------------------- + const NOMAD::Eval_Point * best_f2; + int i; + + for ( i = 0 ; i < 2 ; ++i ) + { + + if ( stop ) + break; + + // minimize f2: + if ( i == 1 ) + { + + // new starting point: + best_f2 = _pareto_front->get_best_f2(); + if ( best_f2 ) + { + _p.set_EXTERN_SIGNATURE ( best_f2->get_signature() ); + _p.reset_X0(); + _p.set_X0 ( *best_f2 ); + } + + // LH_SEARCH: + if ( lh_pi > 0 ) + _p.set_LH_SEARCH ( lh_pi , 0 ); + else if ( lh_p0 > 0 ) + _p.set_LH_SEARCH ( 0 , 0 ); + + // MAX_BB_EVAL: + if ( max_bbe >= 0 ) + { + int bbe = max_bbe + ( (lh_pi > 0 ) ? lh_pi : 0 ); + if ( overall_bbe >= 0 ) + { + if ( bbe > overall_bbe ) + bbe = overall_bbe; + int global_bbe = multi_stats.get_bb_eval(); + if ( global_bbe + bbe > overall_bbe ) + bbe = overall_bbe - global_bbe; + } + _p.set_MAX_BB_EVAL ( bbe ); + } + + if ( _p.to_be_checked() ) + _p.check ( false , // remove_history_file = false + true , // remove_solution_file = true + true ); // remove_stats_file = true + + _mesh=_p.get_signature()->get_mesh(); + + } + + // set weights/reference: + ev->set_weights ( 1-i , i ); + ev->set_ref ( NULL ); + + // launch the single optimization: + multi_launch_single_opt ( iter_dd , + mads_runs , + overall_bbe , + *ev , + stagnation_cnt , + multi_stats , + stop , + stop_reason ); + } + + const NOMAD::Point * ref; + const NOMAD::Pareto_Point * xj; + NOMAD::Double delta_j; + + // the LH search is disabled: + _p.set_LH_SEARCH ( 0 , 0 ); + + // MAX_BB_EVAL reset: + if ( max_bbe > 0 && ( lh_p0 > 0 || lh_pi > 0 ) ) + { + int bbe = max_bbe; + if ( overall_bbe >= 0 ) + { + if ( bbe > overall_bbe ) + bbe = overall_bbe; + + int global_bbe = multi_stats.get_bb_eval(); + if ( global_bbe + bbe > overall_bbe ) + bbe = overall_bbe - global_bbe; + } + _p.set_MAX_BB_EVAL ( bbe ); + } + + // MULTI-MADS main loop: + // --------------------- + const NOMAD::Eval_Point * x0_tmp; + + while ( !stop ) + { + + // get the reference point from the Pareto front: + ref = _pareto_front->get_ref ( xj , delta_j ); + + if ( !xj ) + { + stop = true; + stop_reason = NOMAD::MULTI_NO_PARETO_PTS; + break; + } + + // use delta as stopping criterion: + if ( use_delta_crit ) + { + if ( delta_j.is_defined() && delta_j > 0.0 ) + multi_set_min_poll_size ( lb , ub , Delta_0 , delta_j ); + else + _p.set_MIN_POLL_SIZE ( original_min_poll_size ); + } + + // new starting point: + x0_tmp = xj->get_element(); + _p.set_EXTERN_SIGNATURE ( x0_tmp->get_signature() ); + _p.reset_X0(); + _p.set_X0 ( *x0_tmp ); + + _p.check ( false , // remove_history_file = false + true , // remove_solution_file = true + true ); // remove_stats_file = true + + // a reference point has been found: optimization + // with reference-based function: + if ( ref ) + { + + // set reference: + ev->set_ref ( ref ); + + // launch the single optimization: + multi_launch_single_opt ( iter_dd , + mads_runs , + overall_bbe , + *ev , + stagnation_cnt , + multi_stats , + stop , + stop_reason ); + + delete ref; + ev->set_ref ( NULL ); + } + + // no reference available: two optimizations ( f1(x) and f2(x) ): + else + { + + // for the stagnation check: + const NOMAD::Eval_Point * pp_before; + int stagnation_cnt_before , overall_bbe_before; + bool check_1 = false; + + // loop on f1 and f2: + for ( i = 0 ; i < 2 ; ++i ) + { + + if ( stop ) + break; + + // minimize f2: + if ( i == 1 ) + { + + // new starting point: + best_f2 = _pareto_front->get_best_f2(); + if ( best_f2 ) + { + _p.set_EXTERN_SIGNATURE ( best_f2->get_signature() ); + _p.reset_X0(); + _p.set_X0 ( *best_f2 ); + } + else + _p.set_X0 ( *x0_tmp ); + + _p.check ( false , // remove_history_file = false + true , // remove_solution_file = true + true ); // remove_stats_file = true + } + + // set weights/reference: + ev->set_weights ( 1-i , i ); + ev->set_ref ( NULL ); + + stagnation_cnt_before = stagnation_cnt; + overall_bbe_before = overall_bbe; + pp_before = ( _pareto_front->size() == 1 ) ? + _pareto_front->begin() : NULL; + + // launch the single optimization: + multi_launch_single_opt ( iter_dd , + mads_runs , + overall_bbe , + *ev , + stagnation_cnt , + multi_stats , + stop , + stop_reason ); + + // stagnation check: + if ( stagnation_cnt > stagnation_cnt_before && + overall_bbe == overall_bbe_before && + _pareto_front->size() == 1 && + _pareto_front->begin() == pp_before ) + { + + if ( i == 0 ) + check_1 = true; + else if ( check_1 ) + { + stop = true; + stop_reason = NOMAD::MULTI_STAGNATION; + } + } + } + } + + } // end of MULTI-MADS main loop + // --------------------------- + + + // parameters re-initialization and final displays: + if ( ! hasCategoricalVar ) // Dimension may change when categorical variables are present. This may pose problem for the check. Hence we add a test -> when categorical variables are present, the parameters are not set back to their initial state at the end of the multi-objective optimization. + { + _p.reset_X0(); + size_t nx0 = x0s.size(); + if ( nx0 > 0 ) + { + for ( size_t k = 0 ; k < nx0 ; ++k ) + { + _p.set_X0 ( *x0s[k] ); + delete x0s[k]; + } + } + else if ( !x0_cache_file.empty() ) + _p.set_X0 ( x0_cache_file ); if ( use_delta_crit ) _p.set_MIN_POLL_SIZE ( original_min_poll_size ); - - } - _p.set_MAX_BB_EVAL ( max_bbe ); - _p.set_DISPLAY_DEGREE ( old_dd ); - _p.set_STATS_FILE ( old_stats_file_name , old_stats_file ); - _p.set_SOLUTION_FILE ( old_sol_file ); - _p.set_LH_SEARCH ( lh_p0 , lh_pi ); - _p.set_CACHE_SAVE_PERIOD ( old_csp ); - _p.set_L_CURVE_TARGET ( old_lct ); - - - _p.check ( false , // remove_history_file = false - true , // remove_solution_file = true - true ); // remove_stats_file = true - - // reset MADS stats from MULTI-MADS stats: - _stats = multi_stats; - - // final cache save (overwrite=true): - _ev_control.save_caches ( true ); - + + } + _p.set_MAX_BB_EVAL ( max_bbe ); + _p.set_DISPLAY_DEGREE ( old_dd ); + _p.set_STATS_FILE ( old_stats_file_name , old_stats_file ); + _p.set_SOLUTION_FILE ( old_sol_file ); + _p.set_LH_SEARCH ( lh_p0 , lh_pi ); + _p.set_CACHE_SAVE_PERIOD ( old_csp ); + _p.set_L_CURVE_TARGET ( old_lct ); + + + _p.check ( false , // remove_history_file = false + true , // remove_solution_file = true + true ); // remove_stats_file = true + + // reset MADS stats from MULTI-MADS stats: + _stats = multi_stats; + + // final cache save (overwrite=true): + _ev_control.save_caches ( true ); + #ifndef R_VERSION - if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - { - std::ostringstream msg; - msg << "end of run (" << stop_reason << ")"; - out << std::endl << NOMAD::close_block ( msg.str() ) << std::endl; - } + if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + { + std::ostringstream msg; + msg << "end of run (" << stop_reason << ")"; + out << std::endl << NOMAD::close_block ( msg.str() ) << std::endl; + } #endif - // multi-objective final displays: - if ( _p.get_nb_obj() > 1 ) - { - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out.open_block ( "NOMAD final display" ); - - display(); - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out.close_block(); - } - - } // end of the try block - - catch ( std::exception & e ) + // multi-objective final displays: + if ( _p.get_nb_obj() > 1 ) + { + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out.open_block ( "NOMAD final display" ); + + display(); + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out.close_block(); + } + + } // end of the try block + + catch ( std::exception & e ) { #ifdef USE_MPI - if ( NOMAD::Slave::are_running() ) - NOMAD::Slave::stop_slaves ( out ); + if ( NOMAD::Slave::are_running() ) + NOMAD::Slave::stop_slaves ( out ); #endif - - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , e.what() ); - } - - // stop the slaves: + + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , e.what() ); + } + + // stop the slaves: #ifdef USE_MPI - if ( NOMAD::Slave::are_running() && stop_slaves_here ) - NOMAD::Slave::stop_slaves ( out ); + if ( NOMAD::Slave::are_running() && stop_slaves_here ) + NOMAD::Slave::stop_slaves ( out ); #endif - - return stop_reason; + + return stop_reason; } /*---------------------------------------------------------*/ /* one MADS iteration (private) */ /*---------------------------------------------------------*/ void NOMAD::Mads::iteration ( bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ) + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ) { - - bool forbid_poll_size_stop = false; - - // force quit (by pressing ctrl-c): - if ( !stop && NOMAD::Mads::_force_quit ) - { - stop = true; - stop_reason = NOMAD::CTRL_C; - return; - } - - // poll center selection: - ( ( _p.get_opt_only_sgte() ) ? - _sgte_barrier : _true_barrier ).select_poll_center ( success ); - - // displays: - const NOMAD::Display & out = _p.out(); - if ( out.get_iter_dd() == NOMAD::FULL_DISPLAY ) - out << std::endl - << NOMAD::open_block ( "MADS iteration " - + NOMAD::itos ( _stats.get_iterations() ) ) - << std::endl; - display_iteration_begin(); - - // SEARCH: - // ------- - search ( stop , stop_reason , success , new_feas_inc , new_infeas_inc ); - - // POLL: - // ----- - if ( success != NOMAD::FULL_SUCCESS ) - poll ( stop , - stop_reason , - success , - new_feas_inc , - new_infeas_inc , - forbid_poll_size_stop ); - - // UPDATES: - // -------- - - NOMAD::Point old_r=_mesh->get_mesh_indices(); - - if ( !stop ) - { - // OrthogonalMesh update using success status and direction of success (when present) - if ( new_feas_inc ) + + bool forbid_poll_size_stop = false; + + // force quit (by pressing ctrl-c): + if ( !stop && NOMAD::Mads::_force_quit ) + { + stop = true; + stop_reason = NOMAD::CTRL_C; + return; + } + + // poll center selection: + ( ( _p.get_opt_only_sgte() ) ? + _sgte_barrier : _true_barrier ).select_poll_center ( success ); + + // displays: + const NOMAD::Display & out = _p.out(); + if ( out.get_iter_dd() == NOMAD::FULL_DISPLAY ) + out << std::endl + << NOMAD::open_block ( "MADS iteration " + + NOMAD::itos ( _stats.get_iterations() ) ) + << std::endl; + display_iteration_begin(); + + // SEARCH: + // ------- + search ( stop , stop_reason , success , new_feas_inc , new_infeas_inc ); + + // POLL: + // ----- + if ( success != NOMAD::FULL_SUCCESS ) + poll ( stop , + stop_reason , + success , + new_feas_inc , + new_infeas_inc , + forbid_poll_size_stop ); + + // UPDATES: + // -------- + + NOMAD::Point old_r=_mesh->get_mesh_indices(); + + if ( !stop ) + { + + // OrthogonalMesh update using success status and direction of success (when present) + if ( new_feas_inc ) { _mesh=new_feas_inc->get_signature()->get_mesh(); - _mesh->update ( success, new_feas_inc->get_direction() ); + _mesh->update ( success, new_feas_inc->get_direction() ); } - else if ( new_infeas_inc ) + else if ( new_infeas_inc ) { _mesh=new_infeas_inc->get_signature()->get_mesh(); - _mesh->update ( success, new_infeas_inc->get_direction()); - } - else - _mesh->update ( success ); - - - _mesh->check_min_mesh_sizes( stop , stop_reason ); - - // if the Delta_k^p stopping criterion is met with integer variables, - // the last set of directions must have a minimal coordinate of 1; - // otherwise the stopping criterion is disabled at this iteration: - if ( forbid_poll_size_stop && stop && stop_reason == NOMAD::DELTA_P_MIN_REACHED ) - { - stop = false; - stop_reason = NOMAD::NO_STOP; - } - - // display: - if ( _p.out().get_iter_dd() == NOMAD::FULL_DISPLAY ) - { - _p.out() << std::endl << NOMAD::open_block ( "Orthogonal mesh update" ) - << "previous mesh indices: ( " << old_r << " )" << std::endl - << "new mesh indices : ( " << _mesh->get_mesh_indices() << " )" << std::endl - << NOMAD::close_block() << std::endl; - } - - // periodic cache save (overwrite=false): - if ( _p.get_cache_save_period() > 0 && - _stats.get_iterations()%_p.get_cache_save_period() == - _p.get_cache_save_period() - 1 ) - _ev_control.save_caches ( false ); - } - - // number of iterations: - _stats.add_iteration(); - if ( !stop && - _p.get_max_iterations() > 0 && - _stats.get_iterations() >= _p.get_max_iterations() ) - { - stop = true; - stop_reason = NOMAD::MAX_ITER_REACHED; - } - - // max cache memory: - if ( !stop && - _p.get_max_cache_memory() > 0.0 && - _ev_control.get_cache().size_of() > 1048576*_p.get_max_cache_memory() ) - { - stop = true; - stop_reason = NOMAD::MAX_CACHE_MEMORY_REACHED; - } - - // L_CURVE_TARGET stopping criterion: - if ( _L_curve && !stop ) - { - int bbe = _stats.get_bb_eval(); - if ( success == NOMAD::FULL_SUCCESS ) - { - if ( new_feas_inc ) - _L_curve->insert ( bbe , new_feas_inc->get_f() ); - } - else if ( success == NOMAD::UNSUCCESSFUL && _L_curve->check_stop ( bbe ) ) - { - stop = true; - stop_reason = NOMAD::L_CURVE_TARGET_REACHED; - } - } - - // call the user-defined function Evaluator::update_iteration(): - if ( _p.get_user_calls_enabled() ) - { - bool stop_before = stop; + _mesh->update ( success, new_infeas_inc->get_direction()); + } + else + _mesh->update ( success ); + + // check the min mesh/poll sizes stopping criteria + _mesh->check_min_mesh_sizes( stop , stop_reason ); + + + // if the Delta_k^p stopping criterion is met with integer variables, + // the last set of directions must have a minimal coordinate of 1; + // otherwise the stopping criterion is disabled at this iteration: + if ( forbid_poll_size_stop && stop && stop_reason == NOMAD::DELTA_P_MIN_REACHED ) + { + stop = false; + stop_reason = NOMAD::NO_STOP; + } + + // display: + if ( _p.out().get_iter_dd() == NOMAD::FULL_DISPLAY ) + { + _p.out() << std::endl << NOMAD::open_block ( "OrthogonalMesh update" ) + << "previous mesh indices: ( " << old_r << " )" << std::endl + << "new mesh indices : ( " << _mesh->get_mesh_indices() << " )" << std::endl + << NOMAD::close_block() << std::endl; + } + + // periodic cache save (overwrite=false): + if ( _p.get_cache_save_period() > 0 && + _stats.get_iterations()%_p.get_cache_save_period() == + _p.get_cache_save_period() - 1 ) + _ev_control.save_caches ( false ); + } + + // number of iterations: + _stats.add_iteration(); + if ( !stop && + _p.get_max_iterations() > 0 && + _stats.get_iterations() >= _p.get_max_iterations() ) + { + stop = true; + stop_reason = NOMAD::MAX_ITER_REACHED; + } + + // max cache memory: + if ( !stop && + _p.get_max_cache_memory() > 0.0 && + _ev_control.get_cache().size_of() > 1048576*_p.get_max_cache_memory() ) + { + stop = true; + stop_reason = NOMAD::MAX_CACHE_MEMORY_REACHED; + } + + // L_CURVE_TARGET stopping criterion: + if ( _L_curve && !stop ) + { + int bbe = _stats.get_bb_eval(); + if ( success == NOMAD::FULL_SUCCESS ) + { + if ( new_feas_inc ) + _L_curve->insert ( bbe , new_feas_inc->get_f() ); + } + else if ( success == NOMAD::UNSUCCESSFUL && _L_curve->check_stop ( bbe ) ) + { + stop = true; + stop_reason = NOMAD::L_CURVE_TARGET_REACHED; + } + } + + // call the user-defined function Evaluator::update_iteration(): + if ( _p.get_user_calls_enabled() ) + { + bool stop_before = stop; NOMAD::Pareto_Front * pf = ( ( _pareto_front ) ? _pareto_front:(new NOMAD::Pareto_Front) ); - _ev_control.get_evaluator()->update_iteration ( success , - _stats , - _ev_control , - _true_barrier , - _sgte_barrier , + _ev_control.get_evaluator()->update_iteration ( success , + _stats , + _ev_control , + _true_barrier , + _sgte_barrier , *pf , - stop ); + stop ); if ( ! _pareto_front ) delete pf; - - if ( !stop_before && stop ) - stop_reason = NOMAD::USER_STOPPED; - } - - // if the algorithms stops, we set the mesh index to the value - // it had before the mesh update: - if ( stop ) - { - _mesh->set_mesh_indices( old_r ); - } - - // displays at the end of an iteration: - display_iteration_end ( stop , - stop_reason , - success , - new_feas_inc , - new_infeas_inc ); - - - - // displays: - if ( out.get_iter_dd() == NOMAD::FULL_DISPLAY ) - out << std::endl - << NOMAD::close_block ( "end of iteration " - + NOMAD::itos ( _stats.get_iterations()-1 ) ); + if ( !stop_before && stop ) + stop_reason = NOMAD::USER_STOPPED; + } + + // if the algorithms stops, we set the mesh index to the value + // it had before the mesh update: + if ( stop ) + _mesh->set_mesh_indices( old_r ); + + // displays at the end of an iteration: + display_iteration_end ( stop , + stop_reason , + success , + new_feas_inc , + new_infeas_inc ); + + + + // displays: + if ( out.get_iter_dd() == NOMAD::FULL_DISPLAY ) + out << std::endl + << NOMAD::close_block ( "end of iteration " + + NOMAD::itos ( _stats.get_iterations()-1 ) ); } /*---------------------------------------------------------*/ /* the poll (private) */ /*---------------------------------------------------------*/ void NOMAD::Mads::poll ( bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc , - bool & forbid_poll_size_stop ) + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc , + bool & forbid_poll_size_stop ) { - forbid_poll_size_stop = false; - - if ( stop ) - return; - - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_poll_dd(); - - success = NOMAD::UNSUCCESSFUL; - new_feas_inc = NULL; - new_infeas_inc = NULL; - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << NOMAD::open_block ( "MADS poll" ) << std::endl; - - - const NOMAD::Eval_Point * x; - size_t offset = 0; - - std::vector<NOMAD::Signature *> signatures; - - const NOMAD::Barrier & barrier = get_active_barrier(); - std::list<NOMAD::Direction>::const_iterator it , end; - - - // poll centers: - const NOMAD::Eval_Point * poll_centers[2] , * poll_center; - poll_centers[0] = barrier.get_poll_center(); - poll_centers[1] = (_p.use_sec_poll_center()) ? + forbid_poll_size_stop = false; + + if ( stop ) + return; + + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_poll_dd(); + + success = NOMAD::UNSUCCESSFUL; + new_feas_inc = NULL; + new_infeas_inc = NULL; + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl << NOMAD::open_block ( "MADS poll" ) << std::endl; + + + const NOMAD::Eval_Point * x; + size_t offset = 0; + + std::vector<NOMAD::Signature *> signatures; + + const NOMAD::Barrier & barrier = get_active_barrier(); + std::list<NOMAD::Direction>::const_iterator it , end; + + + // poll centers: + const NOMAD::Eval_Point * poll_centers[2] , * poll_center; + poll_centers[0] = barrier.get_poll_center(); + poll_centers[1] = (_p.use_sec_poll_center()) ? barrier.get_sec_poll_center() : NULL; - - if ( !poll_centers[0] && !poll_centers[1] ) - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , - "Mads::poll(): could not get a poll center" ); - - - // Keep original directions + reduction in reducedPollDirs - std::list<NOMAD::Direction> *dirs=new std::list<NOMAD::Direction>[2]; - std::list<NOMAD::Direction> *reducedPollDirs=new std::list<NOMAD::Direction>[2]; - std::list<NOMAD::Direction>::iterator itDir; - - - // loop on the two poll centers for creation of evaluation point - // ----------------------------- - NOMAD::poll_type i_pc = NOMAD::PRIMARY; - poll_center = poll_centers[NOMAD::PRIMARY]; - - bool reducePollToNDir=false; - - while ( true ) - { - if ( poll_center ) - { - // add the poll center signature - signatures.push_back(poll_center->get_signature()); - - // Creation of the poll directions - set_poll_directions ( dirs[i_pc] , i_pc , offset , *poll_center , stop , stop_reason ); - - // Reduction is applied only to achieve ortho n+1 - reducePollToNDir=dirs_have_orthomads_np1(dirs[i_pc]); - - // creation of the poll trial points in the evaluator control: - if (reducePollToNDir) - { - - // Keep poll directions unchanged (store directions even those that will be snaped to bounds) - reducedPollDirs[i_pc].assign(dirs[i_pc].begin(),dirs[i_pc].end()); - - _ev_control_for_sorting.clear_eval_lop(); - - - // Sort the directions only if mesh is not finest - if ( ! _mesh->is_finest() ) - { - - // 1st sorting of points based on feas. or infeas. success direction. IMPORTANT removes out of bounds -> this justifies to proceede in two steps - set_poll_trial_points(dirs[i_pc],offset,*poll_center,stop,stop_reason,true); - if (stop) - { - delete[] dirs; - delete[] reducedPollDirs; - return; - } - + + if ( !poll_centers[0] && !poll_centers[1] ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "Mads::poll(): could not get a poll center" ); + + + // Keep original directions + reduction in reducedPollDirs + std::list<NOMAD::Direction> *dirs=new std::list<NOMAD::Direction>[2]; + std::list<NOMAD::Direction> *reducedPollDirs=new std::list<NOMAD::Direction>[2]; + std::list<NOMAD::Direction>::iterator itDir; + + + // loop on the two poll centers for creation of evaluation point + // ----------------------------- + NOMAD::poll_type i_pc = NOMAD::PRIMARY; + poll_center = poll_centers[NOMAD::PRIMARY]; + + bool reducePollToNDir=false; + + while ( true ) + { + if ( poll_center ) + { + // add the poll center signature + signatures.push_back(poll_center->get_signature()); + + // Creation of the poll directions + set_poll_directions ( dirs[i_pc] , i_pc , offset , *poll_center , stop , stop_reason ); + + // Reduction is applied only to achieve ortho n+1 + reducePollToNDir=dirs_have_orthomads_np1_dyn(dirs[i_pc]); + + // creation of the poll trial points in the evaluator control: + if ( reducePollToNDir ) + { + + // Keep poll directions unchanged (store directions even those that will be snaped to bounds) + reducedPollDirs[i_pc].assign(dirs[i_pc].begin(),dirs[i_pc].end()); + + _ev_control_for_sorting.clear_eval_lop(); + + if ( ! _mesh->is_finest() ) + { + + // 1st sorting of points based on feas. or infeas. success direction. IMPORTANT removes out of bounds -> this justifies to proceede in two steps + set_poll_trial_points(dirs[i_pc],offset,*poll_center,stop,stop_reason,true); + if ( stop ) + { + delete[] dirs; + delete[] reducedPollDirs; + return; + } + #ifdef USE_MPI - // asynchronous mode: wait for truth evaluations in progress: - if ( _p.get_asynchronous() ) - { - std::list<const NOMAD::Eval_Point *> eval_pts; - _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , - _true_barrier , - _sgte_barrier , - _pareto_front , - stop , - stop_reason , - success , - eval_pts ); - } -#endif - - // 2nd sorting of points based on model and surrogate if available - _ev_control_for_sorting.ordering_lop( NOMAD::POLL,stop,stop_reason,_true_barrier,_sgte_barrier ); - if (stop) - { - delete[] dirs; - delete[] reducedPollDirs; - return; - } - } - - - - // reduce the number of poll direction using dir indices from ev_control_for_sorting and original poll directions (reducedPollDirs) - bool hasBeenReduced=set_reduced_poll_to_n_directions(reducedPollDirs[i_pc],*poll_center); - - - // if hasBeenReduced than reassign dirs for setting poll trial points (reduced) - // else original dirs are considered - if (hasBeenReduced) - dirs[i_pc].assign(reducedPollDirs[i_pc].begin(),reducedPollDirs[i_pc].end()); - - } - - set_poll_trial_points(dirs[i_pc],offset,*poll_center,stop,stop_reason,false); - offset = dirs[i_pc].size(); - - if (!reducePollToNDir) - { - // 2nd sorting of points based on model and surrogate if available - _ev_control.ordering_lop( NOMAD::POLL,stop,stop_reason,_true_barrier,_sgte_barrier ); + // asynchronous mode: wait for truth evaluations in progress: + if ( _p.get_asynchronous() ) + { + std::list<const NOMAD::Eval_Point *> eval_pts; + _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , + _true_barrier , + _sgte_barrier , + _pareto_front , + stop , + stop_reason , + success , + eval_pts ); + } +#endif + + // 2nd sorting of points based on model and surrogate if available + _ev_control_for_sorting.ordering_lop( NOMAD::POLL,stop,stop_reason,_true_barrier,_sgte_barrier ); + if ( stop ) + { + delete[] dirs; + delete[] reducedPollDirs; + return; + } + } + + + + // reduce the number of poll direction using dir indices from ev_control_for_sorting and original poll directions (reducedPollDirs) + bool hasBeenReduced=set_reduced_poll_to_n_directions(reducedPollDirs[i_pc],*poll_center); + + + // if hasBeenReduced than reassign dirs for setting poll trial points (reduced) + // else original dirs are considered + if ( hasBeenReduced ) + dirs[i_pc].assign(reducedPollDirs[i_pc].begin(),reducedPollDirs[i_pc].end()); + } - - - } - - if (stop) - { - delete[] dirs; - delete[] reducedPollDirs; - return; - } - - // loop increment: - if ( i_pc == NOMAD::PRIMARY) - { - i_pc = NOMAD::SECONDARY; - poll_center = poll_centers[NOMAD::SECONDARY]; - } - else - break; - } - - - // display the re-ordered list of poll trial points: - if ( display_degree == NOMAD::FULL_DISPLAY && !stop ) - { - const std::set<NOMAD::Priority_Eval_Point> & poll_pts = _ev_control.get_eval_lop(); - if (!reducePollToNDir) - out << std::endl << NOMAD::open_block ( "re-ordered list of " - + NOMAD::itos ( poll_pts.size() ) - + " poll trial points." ); - else - out << std::endl << NOMAD::open_block ( "re-ordered and reduced (dynamic directions may be added after evaluations) list of " - + NOMAD::itos ( poll_pts.size() ) - + " poll trial points" ); - - std::set<NOMAD::Priority_Eval_Point>::const_iterator end2 = poll_pts.end() , it2; - for ( it2 = poll_pts.begin() ; it2 != end2 ; ++it2 ) - { - x = it2->get_point(); - x->display_tag ( out ); - out << " : ( "; - x->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); - out << " )"; - if ( x->get_direction() ) - out << " (dir " << x->get_direction()->get_index() << ")"; - out << std::endl; - } - out.close_block(); - } - - - _stats.add_poll_pts ( _ev_control.get_nb_eval_points() ); - - // the directions are checked to satisfy a minimum - // poll size with integer variables: - check_directions ( forbid_poll_size_stop ); - - // eval_list_of_points (poll): - // --------------------------- - std::list<const NOMAD::Eval_Point *> *evaluated_pts=new std::list<const NOMAD::Eval_Point *>; - _ev_control.eval_list_of_points ( NOMAD::POLL , - _true_barrier , - _sgte_barrier , - _pareto_front , - stop , - stop_reason , - new_feas_inc , - new_infeas_inc , - success , - evaluated_pts ); - - - // If ortho mads n+1, complete poll with additional evaluations obtained dynamically - if (!stop && success !=NOMAD::FULL_SUCCESS && _p.has_dynamic_direction()) - { - _ev_control.reset(); - - // loop again on the two poll centers to obtain dynamic direction - // --------------------------------------------------------------------------- - i_pc = NOMAD::PRIMARY; - poll_center = poll_centers[NOMAD::PRIMARY]; - offset=0; - while ( true ) - { - if ( poll_center && NOMAD::Mads::dirs_have_orthomads_np1(reducedPollDirs[i_pc])) - { - std::list<NOMAD::Direction> dyn_dirs; - + + set_poll_trial_points(dirs[i_pc],offset,*poll_center,stop,stop_reason,false); + offset = dirs[i_pc].size(); + + if ( ( _p.get_intensification_type() == NOMAD::POLL_ONLY || _p.get_intensification_type() == NOMAD::POLL_AND_SEARCH ) && i_pc == NOMAD::PRIMARY ) + { + set_poll_intensification_points( *poll_center, offset, stop, stop_reason ); + } + + if ( !reducePollToNDir ) + { + // 2nd sorting of points based on model and surrogate if available + _ev_control.ordering_lop( NOMAD::POLL, stop, stop_reason, _true_barrier, _sgte_barrier ); + } + + + } + + if ( stop ) + { + delete[] dirs; + delete[] reducedPollDirs; + return; + } + + // loop increment: + if ( i_pc == NOMAD::PRIMARY) + { + i_pc = NOMAD::SECONDARY; + poll_center = poll_centers[NOMAD::SECONDARY]; + } + else + break; + } + + + // display the re-ordered list of poll trial points: + if ( display_degree == NOMAD::FULL_DISPLAY && !stop ) + { + const std::set<NOMAD::Priority_Eval_Point> & poll_pts = _ev_control.get_eval_lop(); + + if ( !reducePollToNDir ) + out << std::endl << NOMAD::open_block ( "re-ordered list of " + + NOMAD::itos ( poll_pts.size() ) + + " poll trial points." ); + else + out << std::endl << NOMAD::open_block ( "re-ordered and reduced (dynamic directions may be added after evaluations) list of " + + NOMAD::itos ( poll_pts.size() ) + + " poll trial points" ); + + std::set<NOMAD::Priority_Eval_Point>::const_iterator end2 = poll_pts.end() , it2; + for ( it2 = poll_pts.begin() ; it2 != end2 ; ++it2 ) + { + x = it2->get_point(); + x->display_tag ( out ); + out << " : ( "; + x->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); + out << " )"; + if ( x->get_direction() ) + out << " (dir " << x->get_direction()->get_index() << ")"; + out << std::endl; + } + out.close_block(); + } + + + _stats.add_poll_pts ( _ev_control.get_nb_eval_points() ); + + // the directions are checked to satisfy a minimum + // poll size with integer variables: + check_directions ( forbid_poll_size_stop ); + + // eval_list_of_points (poll): + // --------------------------- + std::list<const NOMAD::Eval_Point *> *evaluated_pts=new std::list<const NOMAD::Eval_Point *>; + _ev_control.eval_list_of_points ( NOMAD::POLL , + _true_barrier , + _sgte_barrier , + _pareto_front , + stop , + stop_reason , + new_feas_inc , + new_infeas_inc , + success , + evaluated_pts ); + + + // If ortho mads n+1, complete poll with additional evaluations obtained dynamically + if (!stop && success !=NOMAD::FULL_SUCCESS && _p.has_dynamic_direction()) + { + _ev_control.reset(); + + // loop again on the two poll centers to obtain dynamic direction + // --------------------------------------------------------------------------- + i_pc = NOMAD::PRIMARY; + poll_center = poll_centers[NOMAD::PRIMARY]; + offset=0; + while ( true ) + { + if ( poll_center && NOMAD::Mads::dirs_have_orthomads_np1_dyn( reducedPollDirs[i_pc] ) ) + { + std::list<NOMAD::Direction> dyn_dirs; + #ifdef USE_MPI - // asynchronous mode: wait for the evaluations in progress: - if ( _p.get_asynchronous() ) - { - _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , - _true_barrier , - _sgte_barrier , - _pareto_front , - stop , - stop_reason , - success , - *evaluated_pts ); - } -#endif - - bool hasNewDynDir=get_dynamic_directions (reducedPollDirs[i_pc], - dyn_dirs, - *poll_center); - - - // Set new poll points obtained dynamically - if (hasNewDynDir) - { - set_poll_trial_points(dyn_dirs, - offset, - *poll_center, - stop, - stop_reason, - false); - - if (stop) - { - delete evaluated_pts; - delete[] dirs; - delete[] reducedPollDirs; - return; - } - } - offset = dyn_dirs.size(); - } - // loop increment: - if ( i_pc == NOMAD::PRIMARY ) - { - i_pc = NOMAD::SECONDARY; - poll_center = poll_centers[NOMAD::SECONDARY]; - } - else - break; - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - const std::set<NOMAD::Priority_Eval_Point> & poll_pts = _ev_control.get_eval_lop(); - out << std::endl << NOMAD::open_block ( "re-ordered and complete (dynamic directions added) list of " - + NOMAD::itos ( poll_pts.size() ) - + " poll trial points" ); - - std::set<NOMAD::Priority_Eval_Point>::const_iterator end2 = poll_pts.end() , it2; - for ( it2 = poll_pts.begin() ; it2 != end2 ; ++it2 ) { - x = it2->get_point(); - x->display_tag ( out ); - out << " : ( "; - x->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); - out << " )"; - if ( x->get_direction() ) - out << " (dir " << x->get_direction()->get_index() << ")"; - out << std::endl; - } - out.close_block(); - } - - - - - // Eval additional point(s) : - // --------------------------- - _ev_control.eval_list_of_points ( NOMAD::POLL , - _true_barrier , - _sgte_barrier , - _pareto_front , - stop , - stop_reason , - new_feas_inc , - new_infeas_inc , - success ); - - if (success==NOMAD::FULL_SUCCESS) - _stats.add_nb_success_dyn_dir(); - - } - - delete evaluated_pts; - delete[] dirs; - delete[] reducedPollDirs; - - - // extended poll for categorical variables: - // ---------------------------------------- - if ( !stop && - _extended_poll && - success != NOMAD::FULL_SUCCESS && - _p.get_extended_poll_enabled() ) { - - // display: - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << NOMAD::open_block ( "MADS extended poll" ) << std::endl; - + // asynchronous mode: wait for the evaluations in progress: + if ( _p.get_asynchronous() ) + { + _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , + _true_barrier , + _sgte_barrier , + _pareto_front , + stop , + stop_reason , + success , + *evaluated_pts ); + } +#endif + + bool hasNewDynDir=get_dynamic_directions (reducedPollDirs[i_pc], + dyn_dirs, + *poll_center); + + + // Set new poll points obtained dynamically + if (hasNewDynDir) + { + set_poll_trial_points(dyn_dirs, + offset, + *poll_center, + stop, + stop_reason, + false); + + if (stop) + { + delete evaluated_pts; + delete[] dirs; + delete[] reducedPollDirs; + return; + } + } + offset = dyn_dirs.size(); + } + // loop increment: + if ( i_pc == NOMAD::PRIMARY ) + { + i_pc = NOMAD::SECONDARY; + poll_center = poll_centers[NOMAD::SECONDARY]; + } + else + break; + } + + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + const std::set<NOMAD::Priority_Eval_Point> & poll_pts = _ev_control.get_eval_lop(); + out << std::endl << NOMAD::open_block ( "re-ordered and complete (dynamic directions added) list of " + + NOMAD::itos ( poll_pts.size() ) + + " poll trial points" ); + + std::set<NOMAD::Priority_Eval_Point>::const_iterator end2 = poll_pts.end() , it2; + for ( it2 = poll_pts.begin() ; it2 != end2 ; ++it2 ) + { + x = it2->get_point(); + x->display_tag ( out ); + out << " : ( "; + x->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); + out << " )"; + if ( x->get_direction() ) + out << " (dir " << x->get_direction()->get_index() << ")"; + out << std::endl; + } + out.close_block(); + } + + + + + // Eval additional point(s) : + // --------------------------- + _ev_control.eval_list_of_points ( NOMAD::POLL , + _true_barrier , + _sgte_barrier , + _pareto_front , + stop , + stop_reason , + new_feas_inc , + new_infeas_inc , + success ); + + if (success==NOMAD::FULL_SUCCESS) + _stats.add_nb_success_dyn_dir(); + + } + + delete evaluated_pts; + delete[] dirs; + delete[] reducedPollDirs; + + + // extended poll for categorical variables: + // ---------------------------------------- + if ( !stop && + _extended_poll && + success != NOMAD::FULL_SUCCESS && + _p.get_extended_poll_enabled() ) + { + + // display: + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl << NOMAD::open_block ( "MADS extended poll" ) << std::endl; + #ifdef USE_MPI - // asynchronous mode: wait for the evaluations in progress: - if ( _p.get_asynchronous() ) { - std::list<const NOMAD::Eval_Point *> evaluated_pts; - _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , - _true_barrier , - _sgte_barrier , - _pareto_front , - stop , - stop_reason , - success , - evaluated_pts ); - } + // asynchronous mode: wait for the evaluations in progress: + if ( _p.get_asynchronous() ) + { + std::list<const NOMAD::Eval_Point *> evaluated_pts; + _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , + _true_barrier , + _sgte_barrier , + _pareto_front , + stop , + stop_reason , + success , + evaluated_pts ); + } #endif - - // reset the extended poll object: - _extended_poll->poll_reset(); - - // call the user defined method changing the categorical variables - // (this creates the list of extended poll points): - _extended_poll->construct_extended_points ( *barrier.get_poll_center() ); - - // add the signatures in use to the list of poll signatures: - { - const std::set<NOMAD::Signature_Element> & - tmp = _extended_poll->get_poll_signatures(); - std::set<NOMAD::Signature_Element>::const_iterator it , end = tmp.end(); - for ( it = tmp.begin() ; it != end ; ++it ) - signatures.push_back ( it->get_signature() ); - } - - // execute the extended poll: - int nb_ext_poll_pts; - _extended_poll->run ( *this , - nb_ext_poll_pts , - stop , - stop_reason , - success , - new_feas_inc , - new_infeas_inc ); - - // stats updates: - _stats.add_ext_poll_pts ( nb_ext_poll_pts ); - if ( success == NOMAD::FULL_SUCCESS ) - _stats.add_ext_poll_succ(); - _stats.add_nb_ext_polls(); - - // display: - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << NOMAD::close_block ( "end of extended poll" ) << std::endl; - } - - // stats updates: - if ( success == NOMAD::FULL_SUCCESS ) - _stats.add_poll_success(); - - _stats.add_nb_poll_searches(); - - // success directions (feasible and infeasible): - update_success_directions ( new_feas_inc , true ); - update_success_directions ( new_infeas_inc , false ); - + + // reset the extended poll object: + _extended_poll->poll_reset(); + + // call the user defined method changing the categorical variables + // (this creates the list of extended poll points): + _extended_poll->construct_extended_points ( *barrier.get_poll_center() ); + + // add the signatures in use to the list of poll signatures: + { + const std::set<NOMAD::Signature_Element> & + tmp = _extended_poll->get_poll_signatures(); + std::set<NOMAD::Signature_Element>::const_iterator it , end = tmp.end(); + for ( it = tmp.begin() ; it != end ; ++it ) + signatures.push_back ( it->get_signature() ); + } + + // execute the extended poll: + int nb_ext_poll_pts; + _extended_poll->run ( *this , + nb_ext_poll_pts , + stop , + stop_reason , + success , + new_feas_inc , + new_infeas_inc ); + + // stats updates: + _stats.add_ext_poll_pts ( nb_ext_poll_pts ); + if ( success == NOMAD::FULL_SUCCESS ) + _stats.add_ext_poll_succ(); + _stats.add_nb_ext_polls(); + + // display: + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl << NOMAD::close_block ( "end of extended poll" ) << std::endl; + } + + // stats updates: + if ( success == NOMAD::FULL_SUCCESS ) + _stats.add_poll_success(); + + _stats.add_nb_poll_searches(); + + // success directions (feasible and infeasible): + update_success_directions ( new_feas_inc , true ); + update_success_directions ( new_infeas_inc , false ); + #ifdef DEBUG - if ( !new_feas_inc && !new_infeas_inc ) - out << "No new feasible or infeasible incumbent" << std::endl << std::endl; + if ( !new_feas_inc && !new_infeas_inc ) + out << "No new feasible or infeasible incumbent" << std::endl << std::endl; #endif - - // check the PEB constraints: if we have a new best infeasible - // incumbent from another infeasible incumbent - // ( active_barrier.check_PEB_constraints() ): - if ( _p.get_barrier_type() == NOMAD::PEB_P && new_infeas_inc && - new_infeas_inc->get_poll_center_type() == NOMAD::INFEASIBLE ) - ( ( _p.get_opt_only_sgte() ) ? _sgte_barrier : _true_barrier ).check_PEB_constraints( *new_infeas_inc , display_degree==NOMAD::FULL_DISPLAY ); - - // final display: - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << NOMAD::close_block ( "end of poll" ); + + // check the PEB constraints: if we have a new best infeasible + // incumbent from another infeasible incumbent + // ( active_barrier.check_PEB_constraints() ): + if ( _p.get_barrier_type() == NOMAD::PEB_P && new_infeas_inc && + new_infeas_inc->get_poll_center_type() == NOMAD::INFEASIBLE ) + ( ( _p.get_opt_only_sgte() ) ? _sgte_barrier : _true_barrier ).check_PEB_constraints( *new_infeas_inc , display_degree==NOMAD::FULL_DISPLAY ); + + // final display: + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << NOMAD::close_block ( "end of poll" ); } /*---------------------------------------------------------*/ @@ -1856,109 +1838,111 @@ void NOMAD::Mads::poll ( bool & stop , /*---------------------------------------------------------*/ // A direction group corresponds to a variable group having directions. // A variable group of categorical variables does not possess directions. -bool NOMAD::Mads::set_reduced_poll_to_n_directions(std::list<NOMAD::Direction> & dirs, - const NOMAD::Eval_Point & poll_center) +bool NOMAD::Mads::set_reduced_poll_to_n_directions(std::list<NOMAD::Direction> & dirs, + const NOMAD::Eval_Point & poll_center) { - NOMAD::Signature * cur_signature = poll_center.get_signature(); - size_t n = cur_signature->get_n()-cur_signature->get_nb_fixed_variables() ; + + // get the number of free variables using the signature (because of extended poll and changing signature) + NOMAD::Signature * cur_signature = poll_center.get_signature(); + size_t n = cur_signature->get_n()-cur_signature->get_nb_fixed_variables() ; // No direction for categorical variables - size_t n_cat = cur_signature->get_n_categorical(); - - // Verify that enough directions for reduction are provided - if ( dirs.size()<n-n_cat ) - return false; - - // Maximum number of direction groups - std::list<NOMAD::Direction>::iterator itDirs; - size_t maxDirGroupIndex=0; - size_t dgi; - for (itDirs=dirs.begin();itDirs!=dirs.end() ; ++itDirs) - { - dgi=(*itDirs).get_dir_group_index(); - if (dgi>maxDirGroupIndex) maxDirGroupIndex=dgi; - } - + size_t n_cat = cur_signature->get_n_categorical(); + + // Verify that enough directions for reduction are provided + if ( dirs.size()<n-n_cat ) + return false; + + // Maximum number of direction groups + std::list<NOMAD::Direction>::iterator itDirs; + size_t maxDirGroupIndex=0; + size_t dgi; + for (itDirs=dirs.begin();itDirs!=dirs.end() ; ++itDirs) + { + dgi=(*itDirs).get_dir_group_index(); + if (dgi>maxDirGroupIndex) maxDirGroupIndex=dgi; + } + std::list<NOMAD::Direction> TmpDirs(dirs); dirs.clear(); - - // Loop on each direction group - for (dgi=0;dgi<=maxDirGroupIndex;++dgi) - { - - // Get all poll directions with a given direction group index + Get a vector of unique indices for those directions - std::vector<NOMAD::Direction> pollDirs; - std::vector<int> pollDirIndices; - bool containsOrthoMads=false; - for (itDirs=TmpDirs.begin();itDirs!=TmpDirs.end() ; ++itDirs) - { - if ( static_cast<size_t>((*itDirs).get_dir_group_index()) == dgi ) - { - pollDirs.push_back(*itDirs); - pollDirIndices.push_back((*itDirs).get_index()); - if (!containsOrthoMads) - containsOrthoMads=NOMAD::dir_is_orthomads((*itDirs).get_type()); - } - } - - - std::list<NOMAD::Direction> sortedDirs; + + // Loop on each direction group + for (dgi=0;dgi<=maxDirGroupIndex;++dgi) + { + + // Get all poll directions with a given direction group index + Get a vector of unique indices for those directions + std::vector<NOMAD::Direction> pollDirs; + std::vector<int> pollDirIndices; + bool containsOrthoMads = false; + for ( itDirs=TmpDirs.begin() ; itDirs != TmpDirs.end() ; ++itDirs) + { + if ( static_cast<size_t>((*itDirs).get_dir_group_index()) == dgi ) + { + pollDirs.push_back(*itDirs); + pollDirIndices.push_back((*itDirs).get_index()); + if (!containsOrthoMads) + containsOrthoMads=NOMAD::dir_is_orthomads((*itDirs).get_type()); + } + } + + + std::list<NOMAD::Direction> sortedDirs; std::list<NOMAD::Direction>::iterator itSortedDirs; - // Sort the directions only if mesh is not finest - if ( !_mesh->is_finest() ) - { - - const std::set<NOMAD::Priority_Eval_Point> & LOP=_ev_control_for_sorting.get_eval_lop(); - - if ( LOP.size()==0 ) - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , - "Mads::set_reduced_poll_to_n_directions(): the _ev_control_for_sorting does not have a list of evaluation points." ); - - - // Get all directions from ev_control ordered lop (list of evaluation points) with a given direction group index and given poll center - // Get a set of unique indices of those directions - std::list<int> sortedDirIndices; + // Sort the directions only if mesh is not finest + if ( !_mesh->is_finest() ) + { + + const std::set<NOMAD::Priority_Eval_Point> & LOP=_ev_control_for_sorting.get_eval_lop(); + + if ( LOP.size()==0 ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "Mads::set_reduced_poll_to_n_directions(): the _ev_control_for_sorting does not have a list of evaluation points." ); + + + // Get all directions from ev_control ordered lop (list of evaluation points) with a given direction group index and given poll center + // Get a set of unique indices of those directions + std::list<int> sortedDirIndices; std::set<int> indices; std::list<int>::iterator itSortedDirIndices; - std::set<NOMAD::Priority_Eval_Point>::const_iterator citLOP; - for (citLOP=LOP.begin();citLOP!=LOP.end();++citLOP) - { - const NOMAD::Eval_Point *eval_point=(*citLOP).get_point(); - if ( static_cast<size_t>(eval_point->get_direction()->get_dir_group_index()) == dgi && - *(eval_point->get_poll_center())==poll_center) + std::set<NOMAD::Priority_Eval_Point>::const_iterator citLOP; + for (citLOP=LOP.begin();citLOP!=LOP.end();++citLOP) + { + const NOMAD::Eval_Point *eval_point=(*citLOP).get_point(); + if ( static_cast<size_t>(eval_point->get_direction()->get_dir_group_index()) == dgi && + *(eval_point->get_poll_center())==poll_center) { int index=eval_point->get_direction()->get_index(); if ( indices.size() == 0 || indices.find(index) == indices.end() ) // if the index is already in indices no need to add it in sortedDirIndices to avoid duplicate. - sortedDirIndices.push_back(index); + sortedDirIndices.push_back(index); indices.insert(index); // If the index is already in the set IT IS NOT INSERTED --> set of unique sort integers - + } - - } - - if ( sortedDirIndices.size()==0 ) - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , - "Mads::set_reduced_poll_to_n_directions(): no directions with proper group index available from _ev_control_for_sorting!" ); - - // A direction from _ev_control may have been suppressed if it does not satisfy bound constraint and is not snapped to bounds - // --> complete sorted direction with remaining directions in poll dirs - // - // 2 - Add poll directions (from tmpDirs) in the same order as sorted direction indices (from ev_control) - std::vector<int>::iterator itPollDirIndices; - std::vector<NOMAD::Direction>::iterator itPollDirs=pollDirs.begin(); - size_t pos; - for ( itSortedDirIndices = sortedDirIndices.begin() ; itSortedDirIndices != sortedDirIndices.end() ; ++itSortedDirIndices) - { - itPollDirIndices=find(pollDirIndices.begin(),pollDirIndices.end(),*itSortedDirIndices); - if ( itPollDirIndices!=pollDirIndices.end() ) - { - pos=distance(pollDirIndices.begin(),itPollDirIndices); + + } + + if ( sortedDirIndices.size()==0 ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "Mads::set_reduced_poll_to_n_directions(): no directions with proper group index available from _ev_control_for_sorting!" ); + + // A direction from _ev_control may have been suppressed if it does not satisfy bound constraint and is not snapped to bounds + // --> complete sorted direction with remaining directions in poll dirs + // + // 2 - Add poll directions (from tmpDirs) in the same order as sorted direction indices (from ev_control) + std::vector<int>::iterator itPollDirIndices; + std::vector<NOMAD::Direction>::iterator itPollDirs=pollDirs.begin(); + size_t pos; + for ( itSortedDirIndices = sortedDirIndices.begin() ; itSortedDirIndices != sortedDirIndices.end() ; ++itSortedDirIndices) + { + itPollDirIndices=find(pollDirIndices.begin(),pollDirIndices.end(),*itSortedDirIndices); + if ( itPollDirIndices!=pollDirIndices.end() ) + { + pos=distance(pollDirIndices.begin(),itPollDirIndices); itPollDirs=pollDirs.begin(); std::advance(itPollDirs,pos); - sortedDirs.push_back(*itPollDirs); - } - } + sortedDirs.push_back(*itPollDirs); + } + } // 3 - complete with remaining pollDirs directions if ( sortedDirs.size() != pollDirs.size() ) { @@ -1971,48 +1955,47 @@ bool NOMAD::Mads::set_reduced_poll_to_n_directions(std::list<NOMAD::Direction> & sortedDirs.push_back(*itPollDirs); } } - - } + + } else sortedDirs.assign(pollDirs.begin(),pollDirs.end()); - - // Make a spanning set of directions (this is slightly different Ortho n+1 paper but still we have the garantee that Dk grows asymptotically dense because D^o_k has not been sorted if mesh_index_is_max) - // Sequentially add sorted directions that increase the rank in two situations: - // - If mesh is not finest -> consider all directions for adding -> n directions - // - If mesh is finest but some ORTHO MADS directions are present -> only consider ortho mads dir for adding -> n directions - // - Else, all directions are considered -> more than n directions - // See paper Ortho n+1 paper for details - - - size_t currentRank=get_rank_from_dirs(dirs); - for (itSortedDirs=sortedDirs.begin();itSortedDirs!=sortedDirs.end();++itSortedDirs) - { - dirs.push_back(*itSortedDirs); - if ( !_mesh->is_finest() || ( _mesh->is_finest() && containsOrthoMads)) - { - size_t rank=get_rank_from_dirs(dirs); - if (rank>currentRank && rank<=n-n_cat && NOMAD::dir_is_orthomads((*itSortedDirs).get_type())) - currentRank++; - else - dirs.pop_back(); - } - } - - - } - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_poll_dd(); - if ( dirs.size()!=n-n_cat ) - { - if (display_degree == NOMAD::FULL_DISPLAY ) - { - out << std::endl << NOMAD::open_block ( "The number of reduced directions is lower than n-n_categorical: "); - out << dirs.size() << ". No reduction is performed." << std::endl; - out << NOMAD::close_block(); - } - return false; - } - return true; + + // Make a spanning set of directions (this is slightly different Ortho n+1 paper but still we have the garantee that Dk grows asymptotically dense because D^o_k has not been sorted if mesh_index_is_max) + // Sequentially add sorted directions that increase the rank in two situations: + // - If mesh is not finest -> consider all directions for adding -> n directions + // - If mesh is finest but some ORTHO MADS directions are present -> only consider ortho mads dir for adding -> n directions + // - Else, all directions are considered -> more than n directions + // See paper Ortho n+1 paper for details + + size_t currentRank=get_rank_from_dirs(dirs); + for (itSortedDirs=sortedDirs.begin();itSortedDirs!=sortedDirs.end();++itSortedDirs) + { + dirs.push_back(*itSortedDirs); + if ( !_mesh->is_finest() || ( _mesh->is_finest() && containsOrthoMads)) + { + size_t rank=get_rank_from_dirs(dirs); + if (rank>currentRank && rank<=n-n_cat && NOMAD::dir_is_orthomads((*itSortedDirs).get_type())) + currentRank++; + else + dirs.pop_back(); + } + } + + + } + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_poll_dd(); + if ( dirs.size()!=n-n_cat ) + { + if (display_degree == NOMAD::FULL_DISPLAY ) + { + out << std::endl << NOMAD::open_block ( "The number of reduced directions is lower than n-n_categorical: "); + out << dirs.size() << ". No reduction is performed." << std::endl; + out << NOMAD::close_block(); + } + return false; + } + return true; } /*----------------------------------------------------------------*/ @@ -2020,34 +2003,34 @@ bool NOMAD::Mads::set_reduced_poll_to_n_directions(std::list<NOMAD::Direction> & /*----------------------------------------------------------------*/ int NOMAD::Mads::get_rank_from_dirs(const std::list<NOMAD::Direction> & dirs) { - if (dirs.size()==0) - return 0; - - std::list<NOMAD::Direction>::const_iterator it=dirs.begin(); - size_t m=(*it).size(); - size_t n=dirs.size(); - - double ** M = new double *[m]; - for (size_t i=0 ; i<m ; ++i ) - { - it=dirs.begin(); - M[i] = new double[n]; - for (size_t j = 0 ; j < n ; ++j ) - { - M[i][j] = (*it)[static_cast<int>(i)].value() ; - ++it; - } - } - - int rank=NOMAD::get_rank(M,m,n); - - for (size_t i = 0 ; i < m ; ++i ) - { - delete[] M[i]; - } - delete[] M; - return rank; - + if (dirs.size()==0) + return 0; + + std::list<NOMAD::Direction>::const_iterator it=dirs.begin(); + size_t m=(*it).size(); + size_t n=dirs.size(); + + double ** M = new double *[m]; + for (size_t i=0 ; i<m ; ++i ) + { + it=dirs.begin(); + M[i] = new double[n]; + for (size_t j = 0 ; j < n ; ++j ) + { + M[i][j] = (*it)[static_cast<int>(i)].value() ; + ++it; + } + } + + int rank=NOMAD::get_rank(M,m,n); + + for (size_t i = 0 ; i < m ; ++i ) + { + delete[] M[i]; + } + delete[] M; + return rank; + } /*---------------------------------------------------------------------------------------*/ @@ -2055,346 +2038,350 @@ int NOMAD::Mads::get_rank_from_dirs(const std::list<NOMAD::Direction> & dirs) /* (private) */ /*---------------------------------------------------------------------------------------*/ bool NOMAD::Mads::optimize_quad_model ( const NOMAD::Eval_Point & poll_center , - const std::list<NOMAD::Direction> & dirs , - NOMAD::Point & prospect_point ) + const std::list<NOMAD::Direction> & dirs , + NOMAD::Point & prospect_point ) { - const NOMAD::Display & out = _p.out(); - - // surrogate or truth model evaluations: - NOMAD::eval_type ev_type = + const NOMAD::Display & out = _p.out(); + + // surrogate or truth model evaluations: + NOMAD::eval_type ev_type = ( _p.get_opt_only_sgte() ) ? NOMAD::SGTE : NOMAD::TRUTH; - - // active cache: - const NOMAD::Cache & cache = get_cache(); - - NOMAD::Point delta,Delta; - NOMAD::Signature * signature=poll_center.get_signature(); - _mesh->get_delta ( delta ); - _mesh->get_Delta ( Delta ); - - // compute the interpolation radius: points in Y must be at - // a max distance of ms_radius_factor times Delta^k: - NOMAD::Point interpolation_radius = Delta; - interpolation_radius *= _p.get_model_quad_radius_factor(); - - - // Epsilon for quad model hypercube scaling - NOMAD::Double epsilon = _p.get_model_np1_quad_epsilon(); - + + // active cache: + const NOMAD::Cache & cache = get_cache(); + + NOMAD::Point delta,Delta; + NOMAD::Signature * signature=poll_center.get_signature(); + _mesh->get_delta ( delta ); + _mesh->get_Delta ( Delta ); + + // compute the interpolation radius: points in Y must be at + // a max distance of ms_radius_factor times Delta^k: + NOMAD::Point interpolation_radius = Delta; + interpolation_radius *= _p.get_model_quad_radius_factor(); + + + // Epsilon for quad model hypercube scaling + NOMAD::Double epsilon = _p.get_model_np1_quad_epsilon(); + #ifdef DEBUG - out << std::endl << NOMAD::open_block ( "Quadratic model for (n+1)th prospect point") << std::endl - << "model construction for " << ev_type << std::endl - << "nbr of cache pts: " << cache.size() << std::endl - << "mesh indices : ( " << _mesh->get_mesh_indices () << " )" << std::endl - << "poll center : ( " << poll_center << " )" << std::endl - << "poll size : ( " << Delta << " )" << std::endl - << "interpol. radius: ( " << interpolation_radius << " )" << std::endl - << "epsilon hypercube: ( " << epsilon << " )" << std::endl;; + out << std::endl << NOMAD::open_block ( "Quadratic model for (n+1)th prospect point") << std::endl + << "model construction for " << ev_type << std::endl + << "nbr of cache pts: " << cache.size() << std::endl + << "mesh indices : ( " << _mesh->get_mesh_indices () << " )" << std::endl + << "poll center : ( " << poll_center << " )" << std::endl + << "poll size : ( " << Delta << " )" << std::endl + << "interpol. radius: ( " << interpolation_radius << " )" << std::endl + << "epsilon hypercube: ( " << epsilon << " )" << std::endl;; #endif - - - // creation of the model for all bb outputs: - std::vector<NOMAD::bb_output_type> bbot = _p.get_bb_output_type(); - NOMAD::Quad_Model model ( out , bbot , cache , *signature ); - NOMAD::Model_Stats tmp_stats; - NOMAD::Clock clock; - - // flag to detect model or optimization errors: - bool error = true; - - // construct interpolation set Y: - int min_Y_size = _p.get_model_quad_min_Y_size(); - int max_Y_size = _p.get_model_quad_max_Y_size(); - - model.construct_Y ( poll_center , interpolation_radius , max_Y_size ); - - int nY = model.get_nY(); - + + + // creation of the model for all bb outputs: + std::vector<NOMAD::bb_output_type> bbot = _p.get_bb_output_type(); + NOMAD::Quad_Model model ( out , bbot , cache , *signature ); + NOMAD::Model_Stats tmp_stats; + NOMAD::Clock clock; + + // flag to detect model or optimization errors: + bool error = true; + + // construct interpolation set Y: + int min_Y_size = _p.get_model_quad_min_Y_size(); + int max_Y_size = _p.get_model_quad_max_Y_size(); + + model.construct_Y ( poll_center , interpolation_radius , max_Y_size ); + + int nY = model.get_nY(); + #ifdef DEBUG - out << std::endl << "number of points in Y: " << nY; - if ( nY < 2 || ( min_Y_size < 0 && nY <= model.get_nfree() ) ) - out << " (not enough)"; - out << std::endl; + out << std::endl << "number of points in Y: " << nY; + if ( nY < 2 || ( min_Y_size < 0 && nY <= model.get_nfree() ) ) + out << " (not enough)"; + out << std::endl; #endif - - if ( nY < 2 || ( min_Y_size < 0 && nY <= model.get_nfree() ) ) - tmp_stats.add_not_enough_pts(); - else - { + + if ( nY < 2 || ( min_Y_size < 0 && nY <= model.get_nfree() ) ) + tmp_stats.add_not_enough_pts(); + else + { #ifdef DEBUG - out << std::endl; - model.display_Y ( out , "unscaled interpolation set Y" ); + out << std::endl; + model.display_Y ( out , "unscaled interpolation set Y" ); #endif - - // define scaling with rotation: obtain an hypercube [0,1]^n formed by truncated directions - model.define_scaling_by_directions ( dirs, delta ,epsilon); - + + // define scaling with rotation: obtain an hypercube [0,1]^n formed by truncated directions + model.define_scaling_by_directions ( dirs, delta ,epsilon); + #ifdef DEBUG - out << std::endl; - model.display_Y ( out , "scaled interpolation set Ys" ); + out << std::endl; + model.display_Y ( out , "scaled interpolation set Ys" ); #endif - - // error check: - if ( model.get_error_flag() ) - tmp_stats.add_construction_error(); - - // no model error: - else { - - // construct model: - model.construct ( _p.get_model_quad_use_WP() , NOMAD::SVD_EPS , NOMAD::SVD_MAX_MPN , max_Y_size ); - tmp_stats.add_construction_time ( clock.get_CPU_time() ); - tmp_stats.update_nY ( model.get_nY() ); - - // display model characteristics: + + // error check: + if ( model.get_error_flag() ) + tmp_stats.add_construction_error(); + + // no model error: + else + { + + + // construct model: + model.construct ( _p.get_model_quad_use_WP() , NOMAD::SVD_EPS , NOMAD::SVD_MAX_MPN , max_Y_size ); + tmp_stats.add_construction_time ( clock.get_CPU_time() ); + tmp_stats.update_nY ( model.get_nY() ); + + // display model characteristics: #ifdef DEBUG - out << std::endl; - model.display_model_coeffs ( out ); - out << std::endl; - model.display_Y_error ( out ); + out << std::endl; + model.display_model_coeffs ( out ); + out << std::endl; + model.display_Y_error ( out ); #endif - - - // count model: - if ( ev_type == NOMAD::TRUTH ) - tmp_stats.add_nb_truth(); - else - tmp_stats.add_nb_sgte(); - - switch ( model.get_interpolation_type() ) - { - case NOMAD::MFN: - tmp_stats.add_nb_MFN(); - break; - case NOMAD::WP_REGRESSION: - tmp_stats.add_nb_WP_regression(); - break; - case NOMAD::REGRESSION: - tmp_stats.add_nb_regression(); - break; - default: - break; - } - - // check model error flag: - const NOMAD::Double & cond = model.get_cond(); - if ( model.get_error_flag() || - !cond.is_defined() || - cond > NOMAD::SVD_MAX_COND ) - { - if ( model.get_error_flag() ) - tmp_stats.add_construction_error(); - else - tmp_stats.add_bad_cond(); - } - else - { - int n = model.get_n(); - std::string error_str; - int i; - - // initial displays: - if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) - { - std::ostringstream oss; - oss << "Quad model optimization for prospect point"; - out << std::endl << NOMAD::open_block ( oss.str() ); - } - - // parameters creation: - NOMAD::Parameters model_param ( out ); - - // number of variables: - model_param.set_DIMENSION ( n ); - - // blackbox outputs: - model_param.set_BB_OUTPUT_TYPE ( bbot ); - - // barrier parameters: - model_param.set_H_MIN ( _p.get_h_min () ); - model_param.set_H_NORM ( _p.get_h_norm() ); - - // starting points: - model_param.set_X0 ( NOMAD::Point ( n , 500.0 ) ); - - // fixed variables: - for ( i = 0 ; i < n ; ++i ) - if ( model.variable_is_fixed(i) || _p.variable_is_fixed(i) ) - model_param.set_FIXED_VARIABLE(i); - - // no model search and no model ordering: - model_param.set_MODEL_SEARCH ( false ); - model_param.set_MODEL_EVAL_SORT ( false ); - model_param.set_DIRECTION_TYPE (NOMAD::ORTHO_2N); // use 2N for model search rather than the default Ortho n+1 - - // display: - model_param.set_DISPLAY_DEGREE ( NOMAD::NO_DISPLAY ); - - // mesh: use isotropic mesh - model_param.set_ANISOTROPIC_MESH ( false ); - model_param.set_MESH_UPDATE_BASIS ( 4.0 ); - model_param.set_MESH_COARSENING_EXPONENT ( 1 ); - model_param.set_MESH_REFINING_EXPONENT ( -1 ); - model_param.set_INITIAL_MESH_INDEX ( 0 ); - model_param.set_INITIAL_MESH_SIZE ( NOMAD::Point ( n , 100.0 ) ); - - // maximum number of evaluations: - model_param.set_MAX_BB_EVAL ( 50000 ); - - model_param.set_SNAP_TO_BOUNDS ( true ); - - // disable user calls: - model_param.set_USER_CALLS_ENABLED ( false ); - - // set flags: - bool flag_check_bimads , flag_reset_mesh , flag_reset_barriers , flag_p1_active; - NOMAD::Mads::get_flags ( flag_check_bimads , - flag_reset_mesh , - flag_reset_barriers , - flag_p1_active ); - - NOMAD::Mads::set_flag_check_bimads (false ); - NOMAD::Mads::set_flag_reset_mesh ( true ); - NOMAD::Mads::set_flag_reset_barriers ( true ); - NOMAD::Mads::set_flag_p1_active ( false ); - - // bounds to optimize away from n first direction - // Bound are consistent with model evaluator: x in [0;1000] for optimziation -> x in [-1;1] for model evaluation - NOMAD::Point lb ( n , 0.0 ); - NOMAD::Point ub ( n , 1000.0 ); - model_param.set_LOWER_BOUND ( lb ); - model_param.set_UPPER_BOUND ( ub ); - - try - { - - // parameters validation: - model_param.check(); - - // model evaluator creation: - NOMAD::Evaluator *ev; - if (model_param.get_nb_obj()==2) - ev =new NOMAD::Multi_Obj_Quad_Model_Evaluator( model_param , model ); - else - ev=new NOMAD::Single_Obj_Quad_Model_Evaluator( model_param , model ); - - // algorithm creation and execution: - NOMAD::Mads mads ( model_param , ev ); + + + // count model: + if ( ev_type == NOMAD::TRUTH ) + tmp_stats.add_nb_truth(); + else + tmp_stats.add_nb_sgte(); + + switch ( model.get_interpolation_type() ) + { + case NOMAD::MFN: + tmp_stats.add_nb_MFN(); + break; + case NOMAD::WP_REGRESSION: + tmp_stats.add_nb_WP_regression(); + break; + case NOMAD::REGRESSION: + tmp_stats.add_nb_regression(); + break; + default: + break; + } + + // check model error flag: + const NOMAD::Double & cond = model.get_cond(); + if ( model.get_error_flag() || + !cond.is_defined() || + cond > NOMAD::SVD_MAX_COND ) + { + if ( model.get_error_flag() ) + tmp_stats.add_construction_error(); + else + tmp_stats.add_bad_cond(); + } + else + { + int n = model.get_n(); + std::string error_str; + int i; + + // initial displays: + if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) + { + std::ostringstream oss; + oss << "Quad model optimization for prospect point"; + out << std::endl << NOMAD::open_block ( oss.str() ); + } + + // parameters creation: + NOMAD::Parameters model_param ( out ); + + // number of variables: + model_param.set_DIMENSION ( n ); + + // blackbox outputs: + model_param.set_BB_OUTPUT_TYPE ( bbot ); + + // barrier parameters: + model_param.set_H_MIN ( _p.get_h_min () ); + model_param.set_H_NORM ( _p.get_h_norm() ); + + // starting points: + model_param.set_X0 ( NOMAD::Point ( n , 500.0 ) ); + + // fixed variables: + for ( i = 0 ; i < n ; ++i ) + if ( model.variable_is_fixed(i) || _p.variable_is_fixed(i) ) + model_param.set_FIXED_VARIABLE(i); + + // no model search and no model ordering: + model_param.set_MODEL_SEARCH ( false ); + model_param.set_MODEL_EVAL_SORT ( false ); + model_param.set_DIRECTION_TYPE (NOMAD::ORTHO_2N); // use 2N for model search rather than the default Ortho n+1 + + // display: + model_param.set_DISPLAY_DEGREE ( NOMAD::NO_DISPLAY ); + + // mesh: use isotropic mesh + model_param.set_ANISOTROPIC_MESH ( false ); + model_param.set_MESH_UPDATE_BASIS ( 4.0 ); + model_param.set_MESH_COARSENING_EXPONENT ( 1 ); + model_param.set_MESH_REFINING_EXPONENT ( -1 ); + model_param.set_INITIAL_MESH_INDEX ( 0 ); + model_param.set_INITIAL_MESH_SIZE ( NOMAD::Point ( n , 100.0 ) ); + + // maximum number of evaluations: + model_param.set_MAX_BB_EVAL ( 50000 ); + + model_param.set_SNAP_TO_BOUNDS ( true ); + + // disable user calls: + model_param.set_USER_CALLS_ENABLED ( false ); + + // set flags: + bool flag_check_bimads , flag_reset_mesh , flag_reset_barriers , flag_p1_active; + NOMAD::Mads::get_flags ( flag_check_bimads , + flag_reset_mesh , + flag_reset_barriers , + flag_p1_active ); + + NOMAD::Mads::set_flag_check_bimads (false ); + NOMAD::Mads::set_flag_reset_mesh ( true ); + NOMAD::Mads::set_flag_reset_barriers ( true ); + NOMAD::Mads::set_flag_p1_active ( false ); + + // bounds to optimize away from n first direction + // Bound are consistent with model evaluator: x in [0;1000] for optimziation -> x in [-1;1] for model evaluation + NOMAD::Point lb ( n , 0.0 ); + NOMAD::Point ub ( n , 1000.0 ); + model_param.set_LOWER_BOUND ( lb ); + model_param.set_UPPER_BOUND ( ub ); + + try + { + + // parameters validation: + model_param.check(); - NOMAD::Phase_One_Evaluator * p1ev=NULL; - if ( model_param.get_nb_obj() >= 2 && ! flag_check_bimads ) - { - p1ev = new NOMAD::Phase_One_Evaluator ( model_param , *ev ); - mads.get_evaluator_control().set_evaluator ( p1ev ); - } - NOMAD::stop_type st = mads.run(); - - - delete ev; - if (p1ev) - delete p1ev; - - // reset flags: - NOMAD::Mads::set_flag_check_bimads ( flag_check_bimads ); - NOMAD::Mads::set_flag_reset_mesh ( flag_reset_mesh ); - NOMAD::Mads::set_flag_reset_barriers ( flag_reset_barriers ); - NOMAD::Mads::set_flag_p1_active ( flag_p1_active ); - - // check the stopping criterion: - if ( st == NOMAD::CTRL_C || st == NOMAD::MAX_CACHE_MEMORY_REACHED ) { - std::ostringstream oss; - oss << "quad model optimization for prospect point: " << st; - error_str = oss.str(); - error = true; - } - - // display solution: - if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) - { - NOMAD::Display out_tmp = out; - out_tmp.set_degrees ( NOMAD::NORMAL_DISPLAY ); - out_tmp.open_block("Optimization results"); - mads.display ( out_tmp ); - } - - // get the solution(s): - const NOMAD::Eval_Point * best_feas = mads.get_best_feasible (); - const NOMAD::Eval_Point * best_infeas = mads.get_best_infeasible(); - - - if ( best_infeas ) - { - prospect_point = *best_infeas; - prospect_point *= 0.001; - model.unscale ( prospect_point ); - - if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) - { - out << "best infeasible point before unscaling: ( "; - prospect_point.NOMAD::Point::display ( out ); - out << " )" << std::endl; - } - - - } - else if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) - out << "no infeasible solution" << std::endl; - - - if ( best_feas ) - { - prospect_point = *best_feas; - prospect_point *= 0.001; - model.unscale ( prospect_point ); - if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) - { - out << "best feasible point after unscaling : ( "; - prospect_point.NOMAD::Point::display ( out ); - out << " )" << std::endl; - } - - } - else if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) - out << "no feasible solution" << std::endl; - - - if ( !prospect_point.is_defined() ) - { - error = true; - error_str = "optimization error: no solution"; - } - else - error=false; - } - catch ( std::exception & e ) - { - error = true; - error_str = std::string ( "optimization error: " ) + e.what(); - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , error_str ); - } - } - } - } - - // update the stats: - _stats.update_model_stats ( tmp_stats ); - - if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) - { - out << std::endl << "Prospect point. from quad. model: "; - if ( !error) - out << "( " << prospect_point << " )" << std::endl; - else - out << "failure" << std::endl; - - out << NOMAD::close_block() << std::endl; - } - + // model evaluator creation: + NOMAD::Evaluator *ev; + if (model_param.get_nb_obj()==2) + ev =new NOMAD::Multi_Obj_Quad_Model_Evaluator( model_param , model ); + else + ev=new NOMAD::Single_Obj_Quad_Model_Evaluator( model_param , model ); + + // algorithm creation and execution: + NOMAD::Mads mads ( model_param , ev ); + + NOMAD::Phase_One_Evaluator * p1ev=NULL; + if ( model_param.get_nb_obj() >= 2 && ! flag_check_bimads ) + { + p1ev = new NOMAD::Phase_One_Evaluator ( model_param , *ev ); + mads.get_evaluator_control().set_evaluator ( p1ev ); + } + NOMAD::stop_type st = mads.run(); + + + delete ev; + if (p1ev) + delete p1ev; + + // reset flags: + NOMAD::Mads::set_flag_check_bimads ( flag_check_bimads ); + NOMAD::Mads::set_flag_reset_mesh ( flag_reset_mesh ); + NOMAD::Mads::set_flag_reset_barriers ( flag_reset_barriers ); + NOMAD::Mads::set_flag_p1_active ( flag_p1_active ); + + + // check the stopping criterion: + if ( st == NOMAD::CTRL_C || st == NOMAD::MAX_CACHE_MEMORY_REACHED ) + { + std::ostringstream oss; + oss << "quad model optimization for prospect point: " << st; + error_str = oss.str(); + error = true; + } + + // display solution: + if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) + { + NOMAD::Display out_tmp = out; + out_tmp.set_degrees ( NOMAD::NORMAL_DISPLAY ); + out_tmp.open_block("Optimization results"); + mads.display ( out_tmp ); + } + + // get the solution(s): + const NOMAD::Eval_Point * best_feas = mads.get_best_feasible (); + const NOMAD::Eval_Point * best_infeas = mads.get_best_infeasible(); + + + if ( best_infeas ) + { + prospect_point = *best_infeas; + prospect_point *= 0.001; + model.unscale ( prospect_point ); + + if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) + { + out << "best infeasible point before unscaling: ( "; + prospect_point.NOMAD::Point::display ( out ); + out << " )" << std::endl; + } + + + } + else if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) + out << "no infeasible solution" << std::endl; + + + if ( best_feas ) + { + prospect_point = *best_feas; + prospect_point *= 0.001; + model.unscale ( prospect_point ); + if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) + { + out << "best feasible point after unscaling : ( "; + prospect_point.NOMAD::Point::display ( out ); + out << " )" << std::endl; + } + + } + else if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) + out << "no feasible solution" << std::endl; + + + if ( !prospect_point.is_defined() ) + { + error = true; + error_str = "optimization error: no solution"; + } + else + error=false; + } + catch ( std::exception & e ) + { + error = true; + error_str = std::string ( "optimization error: " ) + e.what(); + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , error_str ); + } + } + } + } + + // update the stats: + _stats.update_model_stats ( tmp_stats ); + + if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) + { + out << std::endl << "Prospect point. from quad. model: "; + if ( !error) + out << "( " << prospect_point << " )" << std::endl; + else + out << "failure" << std::endl; + + out << NOMAD::close_block() << std::endl; + } + #ifdef DEBUG - out << NOMAD::close_block() << std::endl; + out << NOMAD::close_block() << std::endl; #endif - - return !error; + + return !error; } @@ -2402,96 +2389,212 @@ bool NOMAD::Mads::optimize_quad_model ( const NOMAD::Eval_Point & poll /* set the poll directions based on signatures (private) */ /*----------------------------------------------------------------*/ void NOMAD::Mads::set_poll_directions ( std::list<NOMAD::Direction> & dirs , - NOMAD::poll_type i_pc , + NOMAD::poll_type i_pc , size_t offset , - const NOMAD::Eval_Point & poll_center , - bool & stop , - NOMAD::stop_type & stop_reason ) + const NOMAD::Eval_Point & poll_center , + bool & stop , + NOMAD::stop_type & stop_reason ) { - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_poll_dd(); - - std::list<NOMAD::Direction>::const_iterator it , end; - - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - if ( i_pc == NOMAD::SECONDARY ) - out << "secondary "; - out << "poll center: ( "; - poll_center.Point::display ( out, " ", 2, NOMAD::Point::get_display_limit() ); - out << " )" << std::endl; - } - - // get the poll center's signature: - NOMAD::Signature * cur_signature = poll_center.get_signature(); - - if ( !cur_signature ) - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , - "Mads::poll(): could not get the poll center's signature" ); - - int n = cur_signature->get_n(); - - if ( n != poll_center.size() ) - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , - "Mads::poll(): the poll center has an incompatible signature" ); - - // get directions from the signature: - cur_signature->get_directions ( dirs , - i_pc , - poll_center ); + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_poll_dd(); - - - size_t k = 0; + std::list<NOMAD::Direction>::const_iterator it , end; + + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + if ( i_pc == NOMAD::SECONDARY ) + out << "secondary "; + out << "poll center: ( "; + poll_center.Point::display ( out, " ", 2, NOMAD::Point::get_display_limit() ); + out << " )" << std::endl; + } + + // get the poll center's signature: + NOMAD::Signature * cur_signature = poll_center.get_signature(); + + if ( !cur_signature ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "Mads::set_poll_directions(): could not get the poll center's signature" ); + + int n = cur_signature->get_n(); + + if ( n != poll_center.size() ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "Mads::set_poll_directions(): the poll center has an incompatible signature" ); + + + // get directions from the signature: + cur_signature->get_directions ( dirs , + i_pc , + poll_center ); + + size_t k = 0; for ( it = dirs.begin() ; it != dirs.end() ; ++it, ++k ) - it->set_index ( static_cast<int>(offset + k) ); + it->set_index ( static_cast<int>(offset + k) ); + + + if ( !stop && dirs.empty() ) + { + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << "Mads::set_poll_directions(): could not get directions: stop" + << std::endl << NOMAD::close_block() << std::endl; + stop = true; + stop_reason = NOMAD::MESH_PREC_REACHED; + return; + + } + + + // displays: + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + end = dirs.end(); + + int nb_dirs = static_cast<int>(dirs.size()); + + out << std::endl + << NOMAD::open_block ( "poll directions (include mesh size parameter)" ); + for ( it = dirs.begin() ; it != end ; ++it ) + { + out << "dir "; + out.display_int_w ( (*it).get_index() , nb_dirs ); + out << " : " << *it << std::endl; + } + out.close_block(); + } +} - - if ( !stop && dirs.empty() ) - { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "Mads::poll(): could not get directions: stop" - << std::endl << NOMAD::close_block() << std::endl; - stop = true; - stop_reason = NOMAD::MESH_PREC_REACHED; - return; - - } - - - // displays: - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - end = dirs.end(); - - int nb_dirs = static_cast<int>(dirs.size()); - - out << std::endl - << NOMAD::open_block ( "poll directions (include mesh size parameter)" ); - for ( it = dirs.begin() ; it != end ; ++it ) - { - out << "dir "; - out.display_int_w ( (*it).get_index() , nb_dirs ); - out << " : " << *it << std::endl; - } - out.close_block(); - } +/*----------------------------------------------------------------*/ +/* set the poll intensification points (private) */ +/*----------------------------------------------------------------*/ +void NOMAD::Mads::set_poll_intensification_points ( const NOMAD::Eval_Point & poll_center , + size_t & offset , + bool & stop , + NOMAD::stop_type & stop_reason ) +{ + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_poll_dd(); + + std::list<NOMAD::Direction>::const_iterator it , end; + + + // get the poll center's signature: + NOMAD::Signature * cur_signature = poll_center.get_signature(); + + if ( !cur_signature ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "Mads::set_poll_intensification_points(): could not get the poll center's signature" ); + + int n = cur_signature->get_n(); + + if ( n != poll_center.size() ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "Mads::set_poll_intensification_points(): the poll center has an incompatible signature" ); + + // Number of eval points already submitted for polling + int n_eval_sub = _ev_control.get_nb_eval_points(); + + // Number of extra intensification points + int n_max_size_poll_set = cur_signature->get_max_size_poll_set(); + int n_eval_tot = std::min( n_max_size_poll_set , _p.get_max_eval_intensification() ); + int n_extra = n_eval_tot - n_eval_sub ; + + if ( display_degree == NOMAD::FULL_DISPLAY && n_extra > 0 ) + { + out << std::endl << NOMAD::open_block ( "Poll intensification: " )<< std::endl; + + if ( n_extra == n_max_size_poll_set ) + out << "reduced to max size of poll set"<< std::endl; + out << "target number of poll points: " << n_extra << std::endl; + } + if ( display_degree == NOMAD::FULL_DISPLAY && n_extra <= 0 ) + { + out << std::endl << NOMAD::open_block ( "No poll intensification" )<< std::endl; + out << close_block(); + } + + if ( n_extra <= 0 ) + return; + + + // Loop for adding extra points + size_t k = offset; + int n_tries = 0; + int n_eval_cur = _ev_control.get_nb_eval_points(); + while ( n_eval_cur < n_eval_tot && n_tries < 2 * n_extra ) + { + + NOMAD::Direction dir( n, 0.0, NOMAD::UNDEFINED_DIRECTION ); + std::list<NOMAD::Direction> dirs; + + n_tries++; + + // get a direction for a randomly selected variable group + cur_signature->get_variable_group_direction ( dir, poll_center ); + + if ( dir.is_complete() ) + { + dir.set_type( NOMAD::ORTHO_1 ); + dir.set_index ( static_cast<int>(k++) ); + + offset++; + + dirs.push_back(dir); + } + + + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + if ( ! dir.is_defined() ) + out << "dir "<<k-1<<" : null" << std::endl ; + else + out << "dir "<<k-1<<" : " << dir << std::endl; + } + + if ( dirs.size() !=0 ) + set_poll_trial_points( dirs, offset, poll_center, stop, stop_reason, false ); + + int n_eval_tmp = _ev_control.get_nb_eval_points(); + + if ( n_eval_cur == n_eval_tmp ) + { + k--; + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << "reinsert a point"<< std::endl; + } + else + n_eval_cur = n_eval_tmp; + } + + if ( _ev_control.get_nb_eval_points() < n_eval_tot ) + out << " cannot reached the target number of points" <<std::endl; + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out.close_block(); + + // Failed intensification cannot stop algo. Force the stop to be false. + stop = false; + stop_reason = NOMAD::NO_STOP; + + + } -/*----------------------------------------------------------------------------------*/ -/* check if a set of directions includes one Ortho-MADS N+1 direction (private) */ -/* (true if at least one direction in the set is of type Ortho-MADS N+1) */ -/*----------------------------------------------------------------------------------*/ -bool NOMAD::Mads::dirs_have_orthomads_np1( const std::list<NOMAD::Direction> & dirs) + +/*------------------------------------------------------------------------------------------*/ +/* check if a set of directions includes one Ortho-MADS N+1 dynamic direction (private) */ +/* (true if at least one direction in the set is of type Ortho-MADS N+1) */ +/*------------------------------------------------------------------------------------------*/ +bool NOMAD::Mads::dirs_have_orthomads_np1_dyn( const std::list<NOMAD::Direction> & dirs) { - std::list<NOMAD::Direction>::const_iterator it , end = dirs.end(); - for ( it = dirs.begin() ; it != end ; ++it ) - if ( (*it).get_type()==NOMAD::ORTHO_NP1_QUAD || - (*it).get_type()==NOMAD::ORTHO_NP1_NEG) - return true; - return false; + std::list<NOMAD::Direction>::const_iterator it , end = dirs.end(); + for ( it = dirs.begin() ; it != end ; ++it ) + if ( (*it).get_type()==NOMAD::ORTHO_NP1_QUAD || + (*it).get_type()==NOMAD::ORTHO_NP1_NEG) + return true; + return false; } @@ -2501,11 +2604,11 @@ bool NOMAD::Mads::dirs_have_orthomads_np1( const std::list<NOMAD::Direction> & d /*-------------------------------------------------------------------------*/ bool NOMAD::Mads::dir_from_model_opt( const std::list<NOMAD::Direction> & dirs) { - std::list<NOMAD::Direction>::const_iterator it , end = dirs.end(); - for ( it = dirs.begin() ; it != end ; ++it ) - if ( (*it).get_type()!=NOMAD::ORTHO_NP1_QUAD ) - return false; - return true; + std::list<NOMAD::Direction>::const_iterator it , end = dirs.end(); + for ( it = dirs.begin() ; it != end ; ++it ) + if ( (*it).get_type()!=NOMAD::ORTHO_NP1_QUAD ) + return false; + return true; } @@ -2514,274 +2617,280 @@ bool NOMAD::Mads::dir_from_model_opt( const std::list<NOMAD::Direction> & dirs) /* set the poll trial points based on poll directions (private) */ /*----------------------------------------------------------------*/ void NOMAD::Mads::set_poll_trial_points (std::list<NOMAD::Direction> &dirs, - size_t offset, - const NOMAD::Eval_Point & poll_center, - bool & stop, - NOMAD::stop_type &stop_reason, - bool sorting) + size_t offset, + const NOMAD::Eval_Point & poll_center, + bool & stop, + NOMAD::stop_type &stop_reason, + bool sorting) { - NOMAD::Signature * cur_signature=poll_center.get_signature(); - NOMAD::poll_center_type pc_type=( poll_center.is_feasible ( _p.get_h_min() ) ) ? NOMAD::FEASIBLE : NOMAD::INFEASIBLE; - - int n = cur_signature->get_n(); - int m = _p.get_bb_nb_outputs(); - const std::vector<NOMAD::bb_input_type> & bbit = _p.get_bb_input_type(); - - std::list<NOMAD::Direction>::const_iterator it; - - const NOMAD::Direction * dir; - NOMAD::Eval_Point * pt; - - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_poll_dd(); - - int k=0; - for ( it = dirs.begin() ; it != dirs.end() ; ++it ) - { - dir = &(*it); - pt = new NOMAD::Eval_Point ( n , m ); - - // pt = poll_center + dir: with a particular case for binary variables - // equal to 1 with dir=1: the variables are set to 0 (1+1=0 in binary): - for (int i = 0 ; i < n ; ++i ) - (*pt)[i] = ( bbit[i]==NOMAD::BINARY && (*dir)[i]==1.0 && (poll_center)[i]==1.0 ) ? 0.0 : (*pt)[i] = (poll_center)[i] + (*dir)[i]; - - + + NOMAD::Signature * cur_signature=poll_center.get_signature(); + NOMAD::poll_center_type pc_type=( poll_center.is_feasible ( _p.get_h_min() ) ) ? NOMAD::FEASIBLE : NOMAD::INFEASIBLE; + + int n = cur_signature->get_n(); + int m = _p.get_bb_nb_outputs(); + const std::vector<NOMAD::bb_input_type> & bbit = _p.get_bb_input_type(); + + std::list<NOMAD::Direction>::const_iterator it; + + const NOMAD::Direction * dir; + NOMAD::Eval_Point * pt; + + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_poll_dd(); + + int k=0; + for ( it = dirs.begin() ; it != dirs.end() ; ++it ) + { + dir = &(*it); + pt = new NOMAD::Eval_Point ( n , m ); + + // pt = poll_center + dir: with a particular case for binary variables + // equal to 1 with dir=1: the variables are set to 0 (1+1=0 in binary): + for (int i = 0 ; i < n ; ++i ) + (*pt)[i] = ( bbit[i]==NOMAD::BINARY && (*dir)[i]==1.0 && (poll_center)[i]==1.0 ) ? 0.0 : (*pt)[i] = (poll_center)[i] + (*dir)[i]; + if ( pt->Point::operator == ( poll_center ) ) - delete pt; + delete pt; else { - pt->set_signature ( cur_signature ); - pt->set_direction ( dir ); - pt->set_poll_center_type ( pc_type ); - pt->set_poll_center ( &poll_center ); - - // random direction? - if ( NOMAD::dir_is_random ( dir->get_type() ) ) - { - int nb_dirs = static_cast<int>(dirs.size()); - NOMAD::Random_Pickup rp ( nb_dirs ); - pt->set_rand_eval_priority ( rp.pickup() ); - } - - if (!sorting) - _ev_control.add_eval_point ( pt , - display_degree , - _p.get_snap_to_bounds() , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() ); - else - { - _ev_control_for_sorting.add_eval_point ( pt , - display_degree , - _p.get_snap_to_bounds() , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() ); - } - - ++k; - } - } - + pt->set_signature ( cur_signature ); + pt->set_direction ( dir ); + pt->set_poll_center_type ( pc_type ); + pt->set_poll_center ( &poll_center ); + + // random direction? + if ( NOMAD::dir_is_random ( dir->get_type() ) ) + { + int nb_dirs = static_cast<int>(dirs.size()); + NOMAD::Random_Pickup rp ( nb_dirs ); + pt->set_rand_eval_priority ( rp.pickup() ); + } + + if ( !sorting ) + _ev_control.add_eval_point ( pt , + display_degree , + _p.get_snap_to_bounds() , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() ); + else + { + _ev_control_for_sorting.add_eval_point ( pt , + display_degree , + _p.get_snap_to_bounds() , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() ); + } + + ++k; + } + } + if ( k==0 ) { if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "Mads::poll(): could not generate poll trial points: stop" - << std::endl << NOMAD::close_block() << std::endl; + out << "Mads::set_poll_trial_points(): could not generate poll trial points" << std::endl; // << NOMAD::close_block() << std::endl; stop = true; stop_reason = NOMAD::MESH_PREC_REACHED; } - - - return; + + + return; } /*-------------------------------------------------------------*/ -/* compute the poll directions dynamically (private) */ +/* compute the poll directions dynamically (private) */ /*-------------------------------------------------------------*/ -bool NOMAD::Mads::get_dynamic_directions (const std::list<NOMAD::Direction> & dirs, - std::list<NOMAD::Direction> & newDirs, - const NOMAD::Eval_Point & poll_center ) +bool NOMAD::Mads::get_dynamic_directions (const std::list<NOMAD::Direction> & dirs , + std::list<NOMAD::Direction> & newDirs , + const NOMAD::Eval_Point & poll_center ) { - - const NOMAD::Signature * cur_signature=poll_center.get_signature(); - size_t n = cur_signature->get_n()-cur_signature->get_nb_fixed_variables(); - size_t n_cat = cur_signature->get_n_categorical(); - - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_poll_dd(); - - // Dynamic completion only if sufficient directions provided: (n-n_cat)->(n-n_cat)+1 - if ( dirs.size() < n-n_cat ) - return false; - - - // Get the maximum number of direction groups - std::list<NOMAD::Direction>::const_iterator itDir; - int maxDirGroupIndex=0; - int dgi; - for (itDir=dirs.begin();itDir!=dirs.end() ; ++itDir) - { - dgi=(*itDir).get_dir_group_index(); - if (dgi>maxDirGroupIndex) + + const NOMAD::Signature * cur_signature=poll_center.get_signature(); + + // get the number of free variables using the signature (because of extended poll and changing signature) + size_t n = cur_signature->get_n()-cur_signature->get_nb_fixed_variables(); + size_t n_cat = cur_signature->get_n_categorical(); + + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_poll_dd(); + + // Dynamic completion only if sufficient directions provided: (n-n_cat)->(n-n_cat)+1 + if ( dirs.size() < n-n_cat ) + return false; + + + // Get the maximum number of direction groups + std::list<NOMAD::Direction>::const_iterator itDir; + int maxDirGroupIndex=0; + int dgi; + for (itDir=dirs.begin();itDir!=dirs.end() ; ++itDir) + { + dgi=(*itDir).get_dir_group_index(); + if (dgi>maxDirGroupIndex) maxDirGroupIndex=dgi; - } - - // Loop on each direction group to obtain a new direction - for (dgi=0;dgi<=maxDirGroupIndex;++dgi) - { - int maxIndex=0; - - // 1 - Search directions having the same direction group index - std::list<NOMAD::Direction> rDirs; - std::list<NOMAD::Double>::iterator it_fv; - for (itDir=dirs.begin();itDir!=dirs.end() ; ++itDir) - { - if ((*itDir).get_index()>maxIndex) - maxIndex=(*itDir).get_index(); - if ((*itDir).get_dir_group_index()==dgi) - rDirs.push_back(*itDir); - } - - // 2 - add a dynamic direction from a quad model optimization or sum of direction negatives - NOMAD::Direction dyn_dir=get_single_dynamic_direction(rDirs,poll_center); - if ( dyn_dir.get_type()==NOMAD::DYN_ADDED ) - { - dyn_dir.set_index(maxIndex+1); - newDirs.push_back(dyn_dir); - } - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) + } + + // Loop on each direction group to obtain a new direction + for (dgi=0;dgi<=maxDirGroupIndex;++dgi) + { + int maxIndex=0; + + // 1 - Search directions having the same direction group index + std::list<NOMAD::Direction> rDirs; + std::list<NOMAD::Double>::iterator it_fv; + for (itDir=dirs.begin();itDir!=dirs.end() ; ++itDir) + { + if ( (*itDir).get_index()>maxIndex ) + maxIndex=(*itDir).get_index(); + if ( (*itDir).get_dir_group_index()==dgi ) + rDirs.push_back(*itDir); + } + + // 2 - add a dynamic direction from a quad model optimization or sum of direction negatives + NOMAD::Direction dyn_dir=get_single_dynamic_direction( rDirs , poll_center ); + if ( dyn_dir.get_type()==NOMAD::DYN_ADDED ) + { + dyn_dir.set_index(maxIndex+1); + newDirs.push_back(dyn_dir); + } + } + + if ( display_degree == NOMAD::FULL_DISPLAY ) { out << std::endl; if ( newDirs.size()!= 0 ) out << NOMAD::open_block ( "Added (n+1)th poll direction(s) (include mesh size parameter)" ); else out << NOMAD::open_block ( "Cannot generate a (n+1)th poll direction" ); - - for ( itDir = newDirs.begin() ; itDir != newDirs.end() ; ++itDir ) + + for ( itDir = newDirs.begin() ; itDir != newDirs.end() ; ++itDir ) { - out << "dir "; - out.display_int_w ( (*itDir).get_index() , static_cast<int>(newDirs.size()) ); - out << " : " << *itDir << std::endl; - } - out.close_block(); - out << std::endl; - - } + out << "dir "; + out.display_int_w ( (*itDir).get_index() , static_cast<int>(newDirs.size()) ); + out << " : " << *itDir << std::endl; + } + out.close_block(); + out << std::endl; + + } if ( newDirs.size()==0 ) return false; - - - return true; + + + return true; } /*------------------------------------------------------------------------------*/ -/* get a single dynamic direction from incomplete poll */ -/* directions by optimization of a quad model or sum of negative (private) */ +/* get a single dynamic direction from incomplete poll */ +/* directions by optimization of a quad model or sum of negative (private) */ /*------------------------------------------------------------------------------*/ /* The new direction calculation is described in paper from */ /* Audet, Ianni, Le Digabel and Tribes : Reducing the number of */ /* function evaluations in Mesh Adaptive Direct Search Algorithms*/ /*----------------------------------------------------------------*/ -NOMAD::Direction NOMAD::Mads::get_single_dynamic_direction (const std::list<NOMAD::Direction> & dirs, - const NOMAD::Eval_Point & poll_center) +NOMAD::Direction NOMAD::Mads::get_single_dynamic_direction (const std::list<NOMAD::Direction> & dirs, + const NOMAD::Eval_Point & poll_center) { - const NOMAD::Signature * cur_signature=poll_center.get_signature(); - int n=cur_signature->get_n(); - - NOMAD::Direction Vb1( n , 0.0 ,NOMAD::UNDEFINED_DIRECTION); - - - std::vector<NOMAD::Double> alpha; - NOMAD::Double f_pc=(poll_center.is_feasible(_p.get_h_min())) ? poll_center.get_f():poll_center.get_h(); - NOMAD::Double lambda=0; - std::list<NOMAD::Direction>::const_iterator itDir; - - // -sum(d^i) - for (itDir=dirs.begin();itDir!=dirs.end();++itDir) - { - for (int i=0; i<n; i++) - { - Vb1[i]-=(*itDir)[i].value(); - } - } - - // New direction - int dirGroupIndex=(*dirs.begin()).get_dir_group_index(); - NOMAD::Direction V( n , 0.0 ,NOMAD::DYN_ADDED,dirGroupIndex); - - // New direction obtained by quad model optimization or negative sum of directions - NOMAD::Point prospect_point; - bool success=false; - if (dir_from_model_opt(dirs)) - success=optimize_quad_model(poll_center,dirs,prospect_point); - for (int i=0; i<n; i++) - { - if (success) - V[i]=prospect_point[i].value()-poll_center[i].value(); - else - V[i]=Vb1[i]; // use -sum(d^i) if model optimization unsucessfull or no dynamic direction requested - } - - // Update the new directions depending on the input_types - const std::vector<NOMAD::bb_input_type> & input_types=cur_signature->get_input_types(); - - NOMAD::Point delta,Delta; - _mesh->get_delta ( delta ); - _mesh->get_Delta ( Delta ); - bool isZero=true; - for (int i=0; i<n; ++i) - { - NOMAD::Double v=V[i].value(),vb1=Vb1[i].value(),dm=delta[i].value(),dp=Delta[i].value(); - - // Continous variables ---> rounding towards mesh node. - if (input_types[i]==NOMAD::CONTINUOUS) - { - if ((vb1/dm).round()>=(v/dm).round()) - V[i] = (v/dm).ceil()*dm; - else - V[i] = (v/dm).floor()*dm; - } - // Integer variables: - else if ( input_types[i] == NOMAD::INTEGER ) - { - if ( v >= dp/3.0 ) - V[i] = v.ceil(); - else if ( v <= -dp/3.0 ) - V[i] = v.floor(); - else - V[i] = v.round(); - } - // binary variables: - else if ( input_types[i] == NOMAD::BINARY ) - { - if ( v != 0.0 ) V[i] = 1.0; - } - // categorical variables: set direction=0: - else if ( input_types[i] == NOMAD::CATEGORICAL ) - V[i] = 0.0; - - if (V[i]!=0) - isZero=false; - } - - if (isZero) - { - NOMAD::Direction Vzero( n , 0.0 ,NOMAD::UNDEFINED_DIRECTION); - return Vzero; - } - else - return V; + const NOMAD::Signature * cur_signature=poll_center.get_signature(); + int n=cur_signature->get_n(); + + NOMAD::Direction Vb1( n , 0.0 ,NOMAD::UNDEFINED_DIRECTION); + + + std::vector<NOMAD::Double> alpha; + NOMAD::Double f_pc=(poll_center.is_feasible(_p.get_h_min())) ? poll_center.get_f():poll_center.get_h(); + NOMAD::Double lambda=0; + std::list<NOMAD::Direction>::const_iterator itDir; + + // -sum(d^i) + for (itDir=dirs.begin();itDir!=dirs.end();++itDir) + { + for (int i=0; i<n; i++) + { + Vb1[i]-=(*itDir)[i].value(); + } + } + + // New direction + int dirGroupIndex=(*dirs.begin()).get_dir_group_index(); + NOMAD::Direction V( n , 0.0 ,NOMAD::DYN_ADDED,dirGroupIndex); + + // New direction obtained by quad model optimization or negative sum of directions + NOMAD::Point prospect_point; + bool success=false; + if (dir_from_model_opt(dirs)) + success=optimize_quad_model(poll_center,dirs,prospect_point); + for (int i=0; i<n; i++) + { + if (success) + V[i]=prospect_point[i].value()-poll_center[i].value(); + else + V[i]=Vb1[i]; // use -sum(d^i) if model optimization unsucessfull or no dynamic direction requested + } + + // Update the new directions depending on the input_types + const std::vector<NOMAD::bb_input_type> & input_types=cur_signature->get_input_types(); + + NOMAD::Point delta,Delta; + _mesh->get_delta ( delta ); + _mesh->get_Delta ( Delta ); + bool isZero=true; + for (int i=0; i<n; ++i) + { + NOMAD::Double v=V[i].value(),vb1=Vb1[i].value(),dm=delta[i].value(),dp=Delta[i].value(); + + // Continous variables ---> rounding towards mesh node. + if (input_types[i]==NOMAD::CONTINUOUS) + { + NOMAD::Double d1 = vb1/dm; + NOMAD::Double d2 = v/dm; + NOMAD::Double r1 = ( d1 < 0.0 ? -std::floor(.5-d1.value()) : std::floor(.5+d1.value() ) ); + NOMAD::Double r2 = ( d2 < 0.0 ? -std::floor(.5-d2.value()) : std::floor(.5+d2.value() ) ); + if ( r1 >= r2 ) + V[i] = (v/dm).ceil()*dm; + else + V[i] = (v/dm).floor()*dm; + } + // Integer variables: + else if ( input_types[i] == NOMAD::INTEGER ) + { + if ( v >= dp/3.0 ) + V[i] = v.ceil(); + else if ( v <= -dp/3.0 ) + V[i] = v.floor(); + else + V[i] = v.round(); + } + // binary variables: + else if ( input_types[i] == NOMAD::BINARY ) + { + if ( v != 0.0 ) + V[i] = 1.0; + } + // categorical variables: set direction=0: + else if ( input_types[i] == NOMAD::CATEGORICAL ) + V[i] = 0.0; + + if ( V[i]!=0 ) + isZero=false; + } + + if (isZero ) + { + NOMAD::Direction Vzero( n , 0.0 ,NOMAD::UNDEFINED_DIRECTION); + return Vzero; + } + else + return V; } @@ -2793,55 +2902,55 @@ NOMAD::Direction NOMAD::Mads::get_single_dynamic_direction (const std::list<NOMA /*----------------------------------------------------------------*/ void NOMAD::Mads::check_directions ( bool & forbid_poll_size_stop ) { - if ( !_p.get_min_poll_size_defined() ) - { - - NOMAD::Double v , min; - const NOMAD::Point * dir; - int i , n; - - const NOMAD::Signature * signature; - - const std::set<NOMAD::Priority_Eval_Point> & poll_pts = _ev_control.get_eval_lop(); - std::set<NOMAD::Priority_Eval_Point>::const_iterator end = poll_pts.end() , it; - for ( it = poll_pts.begin() ; it != end ; ++it ) - { - - signature = it->get_point()->get_signature(); - - if ( signature ) + if ( !_p.get_min_poll_size_defined() ) + { + + NOMAD::Double v , min; + const NOMAD::Point * dir; + int i , n; + + const NOMAD::Signature * signature; + + const std::set<NOMAD::Priority_Eval_Point> & poll_pts = _ev_control.get_eval_lop(); + std::set<NOMAD::Priority_Eval_Point>::const_iterator end = poll_pts.end() , it; + for ( it = poll_pts.begin() ; it != end ; ++it ) + { + + signature = it->get_point()->get_signature(); + + if ( signature ) { - - dir = it->get_point()->get_direction(); - - if ( dir ) + + dir = it->get_point()->get_direction(); + + if ( dir ) { - - n = dir->size(); - - if ( n == signature->get_n() ) + + n = dir->size(); + + if ( n == signature->get_n() ) { - - const std::vector<NOMAD::bb_input_type> & bbit - = signature->get_input_types(); - - for ( i = 0 ; i < n ; ++i ) + + const std::vector<NOMAD::bb_input_type> & bbit + = signature->get_input_types(); + + for ( i = 0 ; i < n ; ++i ) { - if ( bbit[i] == NOMAD::INTEGER ) + if ( bbit[i] == NOMAD::INTEGER ) { - v = (*dir)[i].abs(); - if ( v.is_defined() && v > 0.0 && ( !min.is_defined() || v < min ) ) - min = v; - } - } - } - } - } - } - - if ( min.is_defined() && min > 1.0 ) - forbid_poll_size_stop = true; - } + v = (*dir)[i].abs(); + if ( v.is_defined() && v > 0.0 && ( !min.is_defined() || v < min ) ) + min = v; + } + } + } + } + } + } + + if ( min.is_defined() && min > 1.0 ) + forbid_poll_size_stop = true; + } } /*---------------------------------------------------------*/ @@ -2849,25 +2958,25 @@ void NOMAD::Mads::check_directions ( bool & forbid_poll_size_stop ) /* (private) */ /*---------------------------------------------------------*/ void NOMAD::Mads::update_success_directions ( const NOMAD::Eval_Point * new_inc , - bool feasible ) const + bool feasible ) const { - if ( new_inc && new_inc->get_direction() ) - { - - const NOMAD::Direction * dir = new_inc->get_direction(); - NOMAD::Signature * signature = new_inc->get_signature(); - - - if ( !signature ) - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , - "Mads::update_success_directions(): new incumbent has no signature" ); - - if ( feasible ) - new_inc->get_signature()->set_feas_success_dir ( *dir ); - else - new_inc->get_signature()->set_infeas_success_dir ( *dir ); - - } + if ( new_inc && new_inc->get_direction() ) + { + + const NOMAD::Direction * dir = new_inc->get_direction(); + NOMAD::Signature * signature = new_inc->get_signature(); + + + if ( !signature ) + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , + "Mads::update_success_directions(): new incumbent has no signature" ); + + if ( feasible ) + new_inc->get_signature()->set_feas_success_dir ( *dir ); + else + new_inc->get_signature()->set_infeas_success_dir ( *dir ); + + } } @@ -2875,540 +2984,532 @@ void NOMAD::Mads::update_success_directions ( const NOMAD::Eval_Point * /* the search (private) */ /*---------------------------------------------------------*/ void NOMAD::Mads::search ( bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ) + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ) { - int nb_search_pts; - bool count_search; - int mads_iteration = _stats.get_iterations(); - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_search_dd(); - NOMAD::success_type last_it_success = success; - success = NOMAD::UNSUCCESSFUL; - - // first display: - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << NOMAD::open_block ( "MADS search" ); - - // 1. speculative search: - if ( _p.get_speculative_search() ) - { - if ( new_feas_inc || new_infeas_inc ) - { - Speculative_Search ss ( _p ); - - ss.search ( *this , - nb_search_pts , - stop , - stop_reason , - success , - count_search , - new_feas_inc , - new_infeas_inc ); - - if ( success == NOMAD::FULL_SUCCESS ) - _stats.add_spec_success(); - if ( count_search ) - _stats.add_nb_spec_searches(); - _stats.add_spec_pts ( nb_search_pts ); - } - } - - // 2. user search: - if ( success != NOMAD::FULL_SUCCESS && _user_search ) - { - - // initial user search display: - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - std::ostringstream oss; - oss << NOMAD::USER_SEARCH; - out << std::endl << NOMAD::open_block ( oss.str() ) << std::endl; - } - - // the search: - _user_search->search ( *this , - nb_search_pts , - stop , - stop_reason , - success , - count_search , - new_feas_inc , - new_infeas_inc ); - - // update stats: - if ( success == NOMAD::FULL_SUCCESS ) - _stats.add_usr_srch_success(); - if ( count_search ) - _stats.add_nb_usr_searches(); - _stats.add_usr_srch_pts ( nb_search_pts ); - - // final user search display: - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - std::ostringstream oss; - oss << "end of " << NOMAD::USER_SEARCH << " (" << success << ")"; - out << std::endl << NOMAD::close_block ( oss.str() ) << std::endl; - } - } - - // 3. cache search: - if ( success != NOMAD::FULL_SUCCESS && _p.get_cache_search() ) - { - - // the search: - _cache_search->search ( *this , - nb_search_pts , - stop , - stop_reason , - success , - count_search , - new_feas_inc , - new_infeas_inc ); - - // update stats: - if ( success == NOMAD::FULL_SUCCESS ) - _stats.add_CS_success(); - if ( count_search ) - _stats.add_nb_cache_searches(); - _stats.add_CS_pts ( nb_search_pts ); - } - - // 4. Model Searches (stats are updated inside the searches): - if ( success != NOMAD::FULL_SUCCESS && _p.has_model_search() ) - { - + int nb_search_pts; + bool count_search; + int mads_iteration = _stats.get_iterations(); + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_search_dd(); + NOMAD::success_type last_it_success = success; + success = NOMAD::UNSUCCESSFUL; + + // first display: + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl << NOMAD::open_block ( "MADS search" ); + + // 1. speculative search: + if ( _p.get_speculative_search() ) + { + if ( new_feas_inc || new_infeas_inc ) + { + Speculative_Search ss ( _p ); + + ss.search ( *this , + nb_search_pts , + stop , + stop_reason , + success , + count_search , + new_feas_inc , + new_infeas_inc ); + + if ( success == NOMAD::FULL_SUCCESS ) + _stats.add_spec_success(); + if ( count_search ) + _stats.add_nb_spec_searches(); + _stats.add_spec_pts ( nb_search_pts ); + } + } + + // 2. user search: + if ( success != NOMAD::FULL_SUCCESS && _user_search ) + { + + // initial user search display: + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + std::ostringstream oss; + oss << NOMAD::USER_SEARCH; + out << std::endl << NOMAD::open_block ( oss.str() ) << std::endl; + } + + // the search: + _user_search->search ( *this , + nb_search_pts , + stop , + stop_reason , + success , + count_search , + new_feas_inc , + new_infeas_inc ); + + // update stats: + if ( success == NOMAD::FULL_SUCCESS ) + _stats.add_usr_srch_success(); + if ( count_search ) + _stats.add_nb_usr_searches(); + _stats.add_usr_srch_pts ( nb_search_pts ); + + // final user search display: + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + std::ostringstream oss; + oss << "end of " << NOMAD::USER_SEARCH << " (" << success << ")"; + out << std::endl << NOMAD::close_block ( oss.str() ) << std::endl; + } + } + + // 3. cache search: + if ( success != NOMAD::FULL_SUCCESS && _p.get_cache_search() ) + { + + // the search: + _cache_search->search ( *this , + nb_search_pts , + stop , + stop_reason , + success , + count_search , + new_feas_inc , + new_infeas_inc ); + + // update stats: + if ( success == NOMAD::FULL_SUCCESS ) + _stats.add_CS_success(); + if ( count_search ) + _stats.add_nb_cache_searches(); + _stats.add_CS_pts ( nb_search_pts ); + } + + // 4. Model Searches (stats are updated inside the searches): + if ( success != NOMAD::FULL_SUCCESS && _p.has_model_search() ) + { + #ifdef USE_MPI - // asynchronous mode: wait for the evaluations in progress: - if ( _p.get_asynchronous() ) - { - std::list<const NOMAD::Eval_Point *> evaluated_pts; - _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , - _true_barrier , - _sgte_barrier , - _pareto_front , - stop , - stop_reason , - success , - evaluated_pts ); - } -#endif - - // model search #1: - _model_search1->search ( *this , - nb_search_pts , - stop , - stop_reason , - success , - count_search , - new_feas_inc , - new_infeas_inc ); - - // save the TGP model for the model ordering: - if ( _p.get_model_search(1) == NOMAD::TGP_MODEL ) - { -#ifdef USE_TGP - _ev_control.set_last_TGP_model - ( static_cast<NOMAD::TGP_Model_Search *>(_model_search1)->get_model() ); + // asynchronous mode: wait for the evaluations in progress: + if ( _p.get_asynchronous() ) + { + std::list<const NOMAD::Eval_Point *> evaluated_pts; + _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , + _true_barrier , + _sgte_barrier , + _pareto_front , + stop , + stop_reason , + success , + evaluated_pts ); + } #endif - } - // model search #2: - if ( success != NOMAD::FULL_SUCCESS && _model_search2 ) + + // model search #1: + _model_search1->search ( *this , + nb_search_pts , + stop , + stop_reason , + success , + count_search , + new_feas_inc , + new_infeas_inc ); + + // model search #2: + if ( success != NOMAD::FULL_SUCCESS && _model_search2 ) { - + #ifdef USE_MPI - // asynchronous mode: wait for the evaluations in progress: - if ( _p.get_asynchronous() ) - { - std::list<const NOMAD::Eval_Point *> evaluated_pts; - _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , - _true_barrier , - _sgte_barrier , - _pareto_front , - stop , - stop_reason , - success , - evaluated_pts ); - } -#endif - _model_search2->search ( *this , - nb_search_pts , - stop , - stop_reason , - success , - count_search , - new_feas_inc , - new_infeas_inc ); - - // save the TGP model for the model ordering: - if ( _p.get_model_search(2) == NOMAD::TGP_MODEL ) + // asynchronous mode: wait for the evaluations in progress: + if ( _p.get_asynchronous() ) { -#ifdef USE_TGP - _ev_control.set_last_TGP_model - ( static_cast<NOMAD::TGP_Model_Search *>(_model_search2)->get_model() ); + std::list<const NOMAD::Eval_Point *> evaluated_pts; + _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , + _true_barrier , + _sgte_barrier , + _pareto_front , + stop , + stop_reason , + success , + evaluated_pts ); + } #endif - } - } - } - - // 5. VNS search: - if ( _p.get_VNS_search() && - success != NOMAD::FULL_SUCCESS && - last_it_success == NOMAD::UNSUCCESSFUL && + _model_search2->search ( *this , + nb_search_pts , + stop , + stop_reason , + success , + count_search , + new_feas_inc , + new_infeas_inc ); + } + } + + // 5. VNS search: + if ( _p.get_VNS_search() && + success != NOMAD::FULL_SUCCESS && + last_it_success == NOMAD::UNSUCCESSFUL && _mesh->is_finer_than_initial() && - _stats.get_iterations() > 0 ) + _stats.get_iterations() > 0 ) { - - // check the VNS_trigger criterion: - int bbe = _stats.get_bb_eval(); - if ( bbe==0 || - _stats.get_VNS_bb_eval() / static_cast<float>(bbe) < _p.get_VNS_trigger() ) + + // check the VNS_trigger criterion: + int bbe = _stats.get_bb_eval(); + if ( bbe==0 || + _stats.get_VNS_bb_eval() / static_cast<float>(bbe) < _p.get_VNS_trigger() ) { - + #ifdef USE_MPI - // asynchronous mode: wait for the evaluations in progress: - if ( _p.get_asynchronous() ) + // asynchronous mode: wait for the evaluations in progress: + if ( _p.get_asynchronous() ) { - std::list<const NOMAD::Eval_Point *> evaluated_pts; - _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , - _true_barrier , - _sgte_barrier , - _pareto_front , - stop , - stop_reason , - success , - evaluated_pts ); - } + std::list<const NOMAD::Eval_Point *> evaluated_pts; + _ev_control.wait_for_evaluations ( NOMAD::ASYNCHRONOUS , + _true_barrier , + _sgte_barrier , + _pareto_front , + stop , + stop_reason , + success , + evaluated_pts ); + } #endif - - _VNS_search->search ( *this , - nb_search_pts , - stop , - stop_reason , - success , - count_search , - new_feas_inc , - new_infeas_inc ); - - if ( success == NOMAD::FULL_SUCCESS ) - _stats.add_VNS_success(); - - if ( count_search ) - _stats.add_nb_VNS_searches(); - - _stats.add_VNS_pts ( nb_search_pts ); - } - } - - // 6. Latin-Hypercube (LH) search: - if ( success != NOMAD::FULL_SUCCESS && _p.get_LH_search_pi() > 0 ) - { - - // for the first iteration: do not perform the - // search if there was an initial LH search: - if ( mads_iteration > 0 || _p.get_LH_search_p0() <= 0 ) { - - LH_Search lh ( _p , false , _flag_p1_active ); - - lh.search ( *this , - nb_search_pts , - stop , - stop_reason , - success , - count_search , - new_feas_inc , - new_infeas_inc ); - - if ( success == NOMAD::FULL_SUCCESS ) - _stats.add_LH_success(); - - if ( count_search ) - _stats.add_nb_LH_searches(); - - _stats.add_LH_pts ( nb_search_pts ); - } - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << NOMAD::close_block ( "end of search" ); + + _VNS_search->search ( *this , + nb_search_pts , + stop , + stop_reason , + success , + count_search , + new_feas_inc , + new_infeas_inc ); + + if ( success == NOMAD::FULL_SUCCESS ) + _stats.add_VNS_success(); + + if ( count_search ) + _stats.add_nb_VNS_searches(); + + _stats.add_VNS_pts ( nb_search_pts ); + } + } + + // 6. Latin-Hypercube (LH) search: + if ( success != NOMAD::FULL_SUCCESS && _p.get_LH_search_pi() > 0 ) + { + + // for the first iteration: do not perform the + // search if there was an initial LH search: + if ( mads_iteration > 0 || _p.get_LH_search_p0() <= 0 ) + { + + LH_Search lh ( _p , false , _flag_p1_active ); + + lh.search ( *this , + nb_search_pts , + stop , + stop_reason , + success , + count_search , + new_feas_inc , + new_infeas_inc ); + + if ( success == NOMAD::FULL_SUCCESS ) + _stats.add_LH_success(); + + if ( count_search ) + _stats.add_nb_LH_searches(); + + _stats.add_LH_pts ( nb_search_pts ); + } + } + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << NOMAD::close_block ( "end of search" ); } /*---------------------------------------------------------*/ /* x0 eval (private) */ /*---------------------------------------------------------*/ void NOMAD::Mads::eval_x0 ( bool & stop , - NOMAD::stop_type & stop_reason ) + NOMAD::stop_type & stop_reason ) { - const std::vector<NOMAD::Point *> & x0s = _p.get_x0s(); - const std::string & x0_cache_file = _p.get_x0_cache_file(); - if ( x0s.empty() && x0_cache_file.empty() ) - return; - - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_gen_dd(); - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << NOMAD::open_block ( "starting point evaluation" ); - - NOMAD::Eval_Point * pt; - size_t k; - int m = _p.get_bb_nb_outputs(); - int n = _p.get_dimension(); - std::ostringstream err; - - // x0s from vector Parameters::_x0s: - // --------------------------------- - size_t x0s_size = x0s.size(); - for ( k = 0 ; k < x0s_size ; ++k ) - { - - // the current starting point has to be in dimension n: - if ( x0s[k]->size() != n ) - { - err << "starting point ( " << *x0s[k] << " ) is not of dimension " << n; - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , err.str() ); - } - - // creation of the Eval_Point: - pt = new NOMAD::Eval_Point; - pt->set ( *x0s[k] , m ); - pt->set_signature ( _p.get_signature() ); - - _ev_control.add_eval_point ( pt , - display_degree , - false , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() ); - } - - // x0 from a cache file: - // --------------------- - if ( !x0_cache_file.empty() ) - { - - NOMAD::Cache & cache = _ev_control.get_cache(); - const NOMAD::Eval_Point * x; - - // another cache file (this file won't be modified): - if ( x0_cache_file != _p.get_cache_file() ) - { - - NOMAD::Cache x0_cache ( out , ( _p.get_opt_only_sgte() ) ? NOMAD::SGTE : NOMAD::TRUTH ); - std::string file_name = _p.get_problem_dir() + x0_cache_file; - - if ( !x0_cache.load ( file_name , NULL , display_degree==NOMAD::FULL_DISPLAY ) ) - { - err << "could not load (or create) the cache file " << file_name; - throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , err.str() ); - } - - // we copy all the temporary cache points - // into the list of points to be evaluated: - x = x0_cache.begin(); - while ( x ) - { - - pt = new NOMAD::Eval_Point; - pt->set ( *x , m ); - - if ( x->get_signature() ) - pt->set_signature ( x->get_signature() ); - else if ( x->size() == n ) - pt->set_signature ( _p.get_signature() ); - - if ( pt->get_signature() ) - _ev_control.add_eval_point ( pt , - display_degree , - false , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() ); - else - { - if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - out << std::endl << "Warning (" << "Mads.cpp" << ", " << __LINE__ - << "): could not use the starting point " << *pt - << " (no signature)" << std::endl << std::endl; - delete pt; - } - - x = x0_cache.next(); - } - - // insertion of this temporary cache in the algorithm's cache: - cache.insert ( x0_cache ); - } - - // x0 cache file and the algorithm's cache file are the same: - else { - - x = cache.begin(); - while ( x ) { - pt = &NOMAD::Cache::get_modifiable_point ( *x ); - - if ( x->get_signature() ) - pt->set_signature ( x->get_signature() ); - else if ( x->size() == n ) - pt->set_signature ( _p.get_signature() ); - - if ( pt->get_signature() ) - _ev_control.add_eval_point ( pt , - display_degree , - false , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() ); - else { - if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - out << std::endl << "Warning (" << "Mads.cpp" << ", " << __LINE__ - << "): could not use the starting point " << *pt - << "(no signature)" << std::endl; - } - x = cache.next(); - } - } - } - - // display of all starting points: - if ( display_degree == NOMAD::FULL_DISPLAY ) { - - const std::set<NOMAD::Priority_Eval_Point> & pts = _ev_control.get_eval_lop(); - - // one starting point: - if ( pts.size() == 1 ) { - out << std::endl << "x0 eval point: ( "; - pts.begin()->get_point()->Point::display ( out , - " " , - 2 , - NOMAD::Point::get_display_limit() ); - out << " )" << std::endl; - } - - // several starting points: - else - _ev_control.display_eval_lop ( NOMAD::X0_EVAL ); - } - - NOMAD::success_type success; - const NOMAD::Eval_Point * new_feas_inc = NULL; - const NOMAD::Eval_Point * new_infeas_inc = NULL; - - // eval_list_of_points (x0): - // ------------------------- - _ev_control.eval_list_of_points ( NOMAD::X0_EVAL , - _true_barrier , - _sgte_barrier , - _pareto_front , - stop , - stop_reason , - new_feas_inc , - new_infeas_inc , - success ); - if ( !stop && - ( success == NOMAD::UNSUCCESSFUL || - (!new_feas_inc && !new_infeas_inc ) || - ( _p.get_barrier_type() == NOMAD::EB && - !get_active_barrier().get_best_feasible() ) ) ) { - stop = true; - stop_reason = NOMAD::X0_FAIL; - } - - - // displays: - display_iteration_end ( stop , - stop_reason , - success , - new_feas_inc , - new_infeas_inc ); - - // stop the algorithm if no iterations are allowed: - if ( !stop && _p.get_max_iterations() == 0 ) - { - stop = true; - stop_reason = NOMAD::MAX_ITER_REACHED; - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << NOMAD::close_block ( "end of starting point evaluation" ); + const std::vector<NOMAD::Point *> & x0s = _p.get_x0s(); + const std::string & x0_cache_file = _p.get_x0_cache_file(); + if ( x0s.empty() && x0_cache_file.empty() ) + return; + + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_gen_dd(); + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl << NOMAD::open_block ( "starting point evaluation" ); + + NOMAD::Eval_Point * pt; + size_t k; + int m = _p.get_bb_nb_outputs(); + int n = _p.get_dimension(); + std::ostringstream err; + + // x0s from vector Parameters::_x0s: + // --------------------------------- + size_t x0s_size = x0s.size(); + for ( k = 0 ; k < x0s_size ; ++k ) + { + + // the current starting point has to be in dimension n: + if ( x0s[k]->size() != n ) + { + err << "starting point ( " << *x0s[k] << " ) is not of dimension " << n; + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , err.str() ); + } + + // creation of the Eval_Point: + pt = new NOMAD::Eval_Point; + pt->set ( *x0s[k] , m ); + pt->set_signature ( _p.get_signature() ); + + _ev_control.add_eval_point ( pt , + display_degree , + false , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() ); + } + + // x0 from a cache file: + // --------------------- + if ( !x0_cache_file.empty() ) + { + + NOMAD::Cache & cache = _ev_control.get_cache(); + const NOMAD::Eval_Point * x; + + // another cache file (this file won't be modified): + if ( x0_cache_file != _p.get_cache_file() ) + { + + NOMAD::Cache x0_cache ( out , ( _p.get_opt_only_sgte() ) ? NOMAD::SGTE : NOMAD::TRUTH ); + std::string file_name = _p.get_problem_dir() + x0_cache_file; + + if ( !x0_cache.load ( file_name , NULL , display_degree==NOMAD::FULL_DISPLAY ) ) + { + err << "could not load (or create) the cache file " << file_name; + throw NOMAD::Exception ( "Mads.cpp" , __LINE__ , err.str() ); + } + + // we copy all the temporary cache points + // into the list of points to be evaluated: + x = x0_cache.begin(); + while ( x ) + { + + pt = new NOMAD::Eval_Point; + pt->set ( *x , m ); + + if ( x->get_signature() ) + pt->set_signature ( x->get_signature() ); + else if ( x->size() == n ) + pt->set_signature ( _p.get_signature() ); + + if ( pt->get_signature() ) + _ev_control.add_eval_point ( pt , + display_degree , + false , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() ); + else + { + if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + out << std::endl << "Warning (" << "Mads.cpp" << ", " << __LINE__ + << "): could not use the starting point " << *pt + << " (no signature)" << std::endl << std::endl; + delete pt; + } + + x = x0_cache.next(); + } + + // insertion of this temporary cache in the algorithm's cache: + cache.insert ( x0_cache ); + } + + // x0 cache file and the algorithm's cache file are the same: + else + { + + + x = cache.begin(); + while ( x ) + { + pt = &NOMAD::Cache::get_modifiable_point ( *x ); + + if ( x->get_signature() ) + pt->set_signature ( x->get_signature() ); + else if ( x->size() == n ) + pt->set_signature ( _p.get_signature() ); + + if ( pt->get_signature() ) + _ev_control.add_eval_point ( pt , + display_degree , + false , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() , + NOMAD::Double() ); + else + { + + if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + out << std::endl << "Warning (" << "Mads.cpp" << ", " << __LINE__ + << "): could not use the starting point " << *pt + << "(no signature)" << std::endl; + } + x = cache.next(); + } + } + } + + // display of all starting points: + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + + const std::set<NOMAD::Priority_Eval_Point> & pts = _ev_control.get_eval_lop(); + + // one starting point: + if ( pts.size() == 1 ) + { + out << std::endl << "x0 eval point: ( "; + pts.begin()->get_point()->Point::display ( out , + " " , + 2 , + NOMAD::Point::get_display_limit() ); + out << " )" << std::endl; + } + + // several starting points: + else + _ev_control.display_eval_lop ( NOMAD::X0_EVAL ); + } + + NOMAD::success_type success; + const NOMAD::Eval_Point * new_feas_inc = NULL; + const NOMAD::Eval_Point * new_infeas_inc = NULL; + + // eval_list_of_points (x0): + // ------------------------- + _ev_control.eval_list_of_points ( NOMAD::X0_EVAL , + _true_barrier , + _sgte_barrier , + _pareto_front , + stop , + stop_reason , + new_feas_inc , + new_infeas_inc , + success ); + if ( !stop && + ( success == NOMAD::UNSUCCESSFUL || + (!new_feas_inc && !new_infeas_inc ) || + ( _p.get_barrier_type() == NOMAD::EB && + !get_active_barrier().get_best_feasible() ) ) ) + { + stop = true; + stop_reason = NOMAD::X0_FAIL; + } + + + // displays: + display_iteration_end ( stop , + stop_reason , + success , + new_feas_inc , + new_infeas_inc ); + + // stop the algorithm if no iterations are allowed: + if ( !stop && _p.get_max_iterations() == 0 ) + { + stop = true; + stop_reason = NOMAD::MAX_ITER_REACHED; + } + + if ( display_degree == NOMAD::FULL_DISPLAY ) + out << std::endl << NOMAD::close_block ( "end of starting point evaluation" ); } /*---------------------------------------------------------*/ /* display the Pareto front */ /*---------------------------------------------------------*/ void NOMAD::Mads::display_pareto_front ( void ) const -{ - if ( !_pareto_front ) - return; - - const std::string & stats_file_name = _p.get_stats_file_name(); - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_gen_dd(); - - // loop on the Pareto points: - if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - out << std::endl << NOMAD::open_block ( "Pareto front" ) << std::endl; - - const NOMAD::Eval_Point * cur = _pareto_front->begin(); - while ( cur ) - { - - if ( cur->is_eval_ok() && cur->is_feasible ( _p.get_h_min() ) ) - { - - const std::list<int> & index_obj = _p.get_index_obj(); - std::list<int>::const_iterator it , end = index_obj.end(); - const NOMAD::Point & bbo = cur->get_bb_outputs(); - int i = 0; - NOMAD::Point multi_obj ( static_cast<int>(index_obj.size()) ); - - for ( it = index_obj.begin() ; it != end ; ++it ) - multi_obj[i++] = bbo[*it]; - - if ( !stats_file_name.empty() ) - _ev_control.stats_file ( stats_file_name , cur , true , &multi_obj ); - - if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY && !_p.get_display_stats().empty() ) - _ev_control.display_stats ( false , - out , - _p.get_display_stats() , - cur , - true , - &multi_obj ); - } - cur = _pareto_front->next(); - } - - if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - out << NOMAD::close_block(); - - // other stats: - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - - out << std::endl << "number of pts : " << _pareto_front->size() << std::endl; - - NOMAD::Double delta , surf; - _pareto_front->get_delta_surf ( delta , surf , - _p.get_multi_f_bounds() ); // f1_min, f1_max, - // f2_min, f2_max - out << "delta_j : " << delta << std::endl - << "surf : "; - if ( surf.is_defined() ) - out << 100*surf << "%" << std::endl; - else - out << NOMAD::Double() - << " (define valid MULTI_F_BOUNDS values to access this output)" - << std::endl; - } - else if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) - out << std::endl << "number of Pareto points: " << _pareto_front->size() - << std::endl; +{ + if ( !_pareto_front ) + return; + + const std::string & stats_file_name = _p.get_stats_file_name(); + const NOMAD::Display & out = _p.out(); + NOMAD::dd_type display_degree = out.get_gen_dd(); + + // loop on the Pareto points: + if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + out << std::endl << NOMAD::open_block ( "Pareto front" ) << std::endl; + + const NOMAD::Eval_Point * cur = _pareto_front->begin(); + while ( cur ) + { + + if ( cur->is_eval_ok() && cur->is_feasible ( _p.get_h_min() ) ) + { + + const std::list<int> & index_obj = _p.get_index_obj(); + std::list<int>::const_iterator it , end = index_obj.end(); + const NOMAD::Point & bbo = cur->get_bb_outputs(); + int i = 0; + NOMAD::Point multi_obj ( static_cast<int>(index_obj.size()) ); + + for ( it = index_obj.begin() ; it != end ; ++it ) + multi_obj[i++] = bbo[*it]; + + if ( !stats_file_name.empty() ) + _ev_control.stats_file ( stats_file_name , cur , true , &multi_obj ); + + if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY && !_p.get_display_stats().empty() ) + _ev_control.display_stats ( false , + out , + _p.get_display_stats() , + cur , + true , + &multi_obj ); + } + cur = _pareto_front->next(); + } + + if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + out << NOMAD::close_block(); + + // other stats: + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + + out << std::endl << "number of pts : " << _pareto_front->size() << std::endl; + + NOMAD::Double delta , surf; + _pareto_front->get_delta_surf ( delta , surf , + _p.get_multi_f_bounds() ); // f1_min, f1_max, + // f2_min, f2_max + out << "delta_j : " << delta << std::endl + << "surf : "; + if ( surf.is_defined() ) + out << 100*surf << "%" << std::endl; + else + out << NOMAD::Double() + << " (define valid MULTI_F_BOUNDS values to access this output)" + << std::endl; + } + else if ( display_degree != NOMAD::NO_DISPLAY && display_degree != NOMAD::MINIMAL_DISPLAY) + out << std::endl << "number of Pareto points: " << _pareto_front->size() + << std::endl; } /*---------------------------------------------------------*/ @@ -3416,168 +3517,168 @@ void NOMAD::Mads::display_pareto_front ( void ) const /*---------------------------------------------------------*/ void NOMAD::Mads::display ( const NOMAD::Display & out ) const { - NOMAD::dd_type display_degree = out.get_gen_dd(); - - if ( !NOMAD::Slave::is_master() ) - return; - - // 0. no display: - // -------------- - if ( display_degree == NOMAD::NO_DISPLAY || display_degree == NOMAD::MINIMAL_DISPLAY) - { - - // there may be a pareto front to write as a stats file: - if ( _pareto_front && - !_pareto_front->empty() && - !_p.get_stats_file_name().empty() ) - display_pareto_front(); - - return; - } - - // incumbents: - const NOMAD::Eval_Point * bf = get_best_feasible(); - const NOMAD::Eval_Point * bi = get_best_infeasible(); - const NOMAD::Eval_Point *bimv = get_best_infeasible_min_viol(); - - // save the solution file: - if ( bf ) - _ev_control.write_solution_file ( *bf , false); - else if (bimv) - _ev_control.write_solution_file ( *bimv , true ); - - - - // 1. detailed display: - // -------------------- - if ( display_degree == NOMAD::FULL_DISPLAY ) - { - - // cache: - out << std::endl - << NOMAD::open_block ( "cache" ) - << ( _p.get_opt_only_sgte() ? _ev_control.get_sgte_cache() : _ev_control.get_cache() ) - << NOMAD::close_block(); - - // constraints: - if ( _p.has_constraints() ) - out << std::endl - << NOMAD::open_block ( "constraints handling") << std::endl - << get_active_barrier() - << NOMAD::close_block(); - - // Pareto front: - if ( _pareto_front ) - { - if ( _pareto_front->empty() ) - out << std::endl << "Pareto front empty" << std::endl; - else - display_pareto_front(); - } - - // stats: - out << std::endl - << NOMAD::open_block ( "stats" ) - << _stats - << NOMAD::close_block(); - - // model stats: + NOMAD::dd_type display_degree = out.get_gen_dd(); + + if ( !NOMAD::Slave::is_master() ) + return; + + // 0. no display: + // -------------- + if ( display_degree == NOMAD::NO_DISPLAY || display_degree == NOMAD::MINIMAL_DISPLAY) + { + + // there may be a pareto front to write as a stats file: + if ( _pareto_front && + !_pareto_front->empty() && + !_p.get_stats_file_name().empty() ) + display_pareto_front(); + + return; + } + + // incumbents: + const NOMAD::Eval_Point * bf = get_best_feasible(); + const NOMAD::Eval_Point * bi = get_best_infeasible(); + const NOMAD::Eval_Point *bimv = get_best_infeasible_min_viol(); + + // save the solution file: + if ( bf ) + _ev_control.write_solution_file ( *bf , false); + else if (bimv) + _ev_control.write_solution_file ( *bimv , true ); + + + + // 1. detailed display: + // -------------------- + if ( display_degree == NOMAD::FULL_DISPLAY ) + { + + // cache: + out << std::endl + << NOMAD::open_block ( "cache" ) + << ( _p.get_opt_only_sgte() ? _ev_control.get_sgte_cache() : _ev_control.get_cache() ) + << NOMAD::close_block(); + + // constraints: + if ( _p.has_constraints() ) + out << std::endl + << NOMAD::open_block ( "constraints handling") << std::endl + << get_active_barrier() + << NOMAD::close_block(); + + // Pareto front: + if ( _pareto_front ) + { + if ( _pareto_front->empty() ) + out << std::endl << "Pareto front empty" << std::endl; + else + display_pareto_front(); + } + + // stats: + out << std::endl + << NOMAD::open_block ( "stats" ) + << _stats + << NOMAD::close_block(); + + // model stats: #ifdef DEBUG - display_model_stats ( out ); + display_model_stats ( out ); #endif - - // miscellaneous: - if ( !_pareto_front ) - { - out << std::endl - << NOMAD::open_block ( "miscellaneous" ) - << "mesh indices : min= (" - << _mesh->get_min_mesh_indices() << " ), max = (" - << _mesh->get_max_mesh_indices() << " ), last= ( " - << _mesh->get_mesh_indices() << " ) " << std::endl; - - if ( bimv ) - { - out << "best infeasible solution (min. violation): ( "; - bimv->Point::display ( out , " " , -1 , -1 ); - out << " ) h=" << bimv->get_h() - << " f=" << bimv->get_f() << std::endl; - } - - out << "best feasible solution : "; - - if ( bf ) - { - out << "( "; - bf->Point::display ( out , " " , -1 , -1 ); - out << " ) h=" << bf->get_h() - << " f=" << bf->get_f() << std::endl; - } - else - out << "no feasible solution has been found" << std::endl; - - - out.close_block(); - } - } - - // 2. normal display: - // ------------------ - else - { - - // blackbox evaluations: - out << std::endl - << "blackbox evaluations : " << _stats.get_bb_eval() << std::endl; - - // output stats: - if ( _stats.get_stat_sum().is_defined() ) - out << "stat sum : " << _stats.get_stat_sum() << std::endl; - if ( _stats.get_stat_avg().is_defined() ) - out << "stat avg : " << _stats.get_stat_avg() << std::endl; - - // Pareto front (multi-objective optimization): - if ( _pareto_front ) - { - out << "number of MADS runs : " << _stats.get_mads_runs() << std::endl; - if ( _pareto_front->empty() ) - out << "Pareto front : empty" << std::endl; - else - display_pareto_front(); - } - - // single-objective optimization (display of best solutions): - else - { - - if ( !bf && !bi ) - out << "no solution" << std::endl; - else - { - if ( bimv ) - { - out << "best infeasible solution (min. violation): ( "; - bimv->Point::display ( out , " " , -1 , -1 ); - out << " ) h=" << bimv->get_h() - << " f=" << bimv->get_f() << std::endl; - } - - out << "best feasible solution : "; - - if ( bf ) - { - out << "( "; - bf->Point::display ( out , " " , -1 , -1 ); - out << " ) h=" << bf->get_h() - << " f=" << bf->get_f() << std::endl; - } - else - out << "no feasible solution has been found" << std::endl; - - } - } - out.close_block(); - } + + // miscellaneous: + if ( !_pareto_front ) + { + out << std::endl + << NOMAD::open_block ( "miscellaneous" ) + << "mesh indices : min= (" + << _mesh->get_min_mesh_indices() << " ), max = (" + << _mesh->get_max_mesh_indices() << " ), last= ( " + << _mesh->get_mesh_indices() << " ) " << std::endl; + + if ( bimv ) + { + out << "best infeasible solution (min. violation): ( "; + bimv->Point::display ( out , " " , -1 , -1 ); + out << " ) h=" << bimv->get_h() + << " f=" << bimv->get_f() << std::endl; + } + + out << "best feasible solution : "; + + if ( bf ) + { + out << "( "; + bf->Point::display ( out , " " , -1 , -1 ); + out << " ) h=" << bf->get_h() + << " f=" << bf->get_f() << std::endl; + } + else + out << "no feasible solution has been found" << std::endl; + + + out.close_block(); + } + } + + // 2. normal display: + // ------------------ + else + { + + // blackbox evaluations: + out << std::endl + << "blackbox evaluations : " << _stats.get_bb_eval() << std::endl; + + // output stats: + if ( _stats.get_stat_sum().is_defined() ) + out << "stat sum : " << _stats.get_stat_sum() << std::endl; + if ( _stats.get_stat_avg().is_defined() ) + out << "stat avg : " << _stats.get_stat_avg() << std::endl; + + // Pareto front (multi-objective optimization): + if ( _pareto_front ) + { + out << "number of MADS runs : " << _stats.get_mads_runs() << std::endl; + if ( _pareto_front->empty() ) + out << "Pareto front : empty" << std::endl; + else + display_pareto_front(); + } + + // single-objective optimization (display of best solutions): + else + { + + if ( !bf && !bi ) + out << "no solution" << std::endl; + else + { + if ( bimv ) + { + out << "best infeasible solution (min. violation): ( "; + bimv->Point::display ( out , " " , -1 , -1 ); + out << " ) h=" << bimv->get_h() + << " f=" << bimv->get_f() << std::endl; + } + + out << "best feasible solution : "; + + if ( bf ) + { + out << "( "; + bf->Point::display ( out , " " , -1 , -1 ); + out << " ) h=" << bf->get_h() + << " f=" << bf->get_f() << std::endl; + } + else + out << "no feasible solution has been found" << std::endl; + + } + } + out.close_block(); + } } /*---------------------------------------------------------*/ @@ -3585,17 +3686,18 @@ void NOMAD::Mads::display ( const NOMAD::Display & out ) const /*---------------------------------------------------------*/ void NOMAD::Mads::display_model_stats ( const NOMAD::Display & out ) const { - if ( _model_search1 ) - out << std::endl << NOMAD::open_block ( "model search #1 stats" ) - << *_model_search1 << NOMAD::close_block(); - if ( _model_search2 ) - out << std::endl << NOMAD::open_block ( "model search #2 stats" ) - << *_model_search2 << NOMAD::close_block(); - if ( _p.get_model_eval_sort() != NOMAD::NO_MODEL ) { - out << std::endl << NOMAD::open_block ( "model ordering stats" ); - _ev_control.display_model_ordering_stats ( out ); - out << NOMAD::close_block(); - } + if ( _model_search1 ) + out << std::endl << NOMAD::open_block ( "model search #1 stats" ) + << *_model_search1 << NOMAD::close_block(); + if ( _model_search2 ) + out << std::endl << NOMAD::open_block ( "model search #2 stats" ) + << *_model_search2 << NOMAD::close_block(); + if ( _p.get_model_eval_sort() != NOMAD::NO_MODEL ) + { + out << std::endl << NOMAD::open_block ( "model ordering stats" ); + _ev_control.display_model_ordering_stats ( out ); + out << NOMAD::close_block(); + } } /*---------------------------------------------------------*/ @@ -3604,16 +3706,16 @@ void NOMAD::Mads::display_model_stats ( const NOMAD::Display & out ) const /*---------------------------------------------------------*/ void NOMAD::Mads::display_deltas ( const NOMAD::Signature & s ) const { - - NOMAD::Point delta,Delta; - - _mesh->get_delta(delta); - _mesh->get_Delta(Delta); - if (delta.is_defined() && Delta.is_defined()) - _p.out() << "mesh size : ( " << delta << " )" << std::endl - << "poll size : ( " << Delta << " )" << std::endl - << "mesh indices : ( " << _mesh->get_mesh_indices() << " )" << std::endl; - + + NOMAD::Point delta,Delta; + + _mesh->get_delta(delta); + _mesh->get_Delta(Delta); + if (delta.is_defined() && Delta.is_defined()) + _p.out() << "mesh size : ( " << delta << " )" << std::endl + << "poll size : ( " << Delta << " )" << std::endl + << "mesh indices : ( " << _mesh->get_mesh_indices() << " )" << std::endl; + } /*-------------------------------------------------------*/ @@ -3621,110 +3723,118 @@ void NOMAD::Mads::display_deltas ( const NOMAD::Signature & s ) const /*-------------------------------------------------------*/ void NOMAD::Mads::display_iteration_begin ( void ) const { - const NOMAD::Display & out = _p.out(); - if ( out.get_iter_dd() != NOMAD::FULL_DISPLAY ) - return; - - // incumbents: - const NOMAD::Eval_Point * bf = get_best_feasible(); - const NOMAD::Eval_Point * bi = get_best_infeasible(); - const NOMAD::Signature * s1 = NULL; - - out << "blackbox evaluations : " << _stats.get_bb_eval() << std::endl; + const NOMAD::Display & out = _p.out(); + if ( out.get_iter_dd() != NOMAD::FULL_DISPLAY ) + return; + + // incumbents: + const NOMAD::Eval_Point * bf = get_best_feasible(); + const NOMAD::Eval_Point * bi = get_best_infeasible(); + const NOMAD::Signature * s1 = NULL; + + out << "blackbox evaluations : " << _stats.get_bb_eval() << std::endl; #ifdef USE_MPI - if ( _p.get_asynchronous() ) - out << "eval. in progress : " << _ev_control.get_nb_eval_in_progress() - << std::endl; + if ( _p.get_asynchronous() ) + out << "eval. in progress : " << _ev_control.get_nb_eval_in_progress() + << std::endl; #endif - out << "best feas. solution : "; - if ( bf ) { - out << "( "; - bf->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); - out << " ) h=" << bf->get_h() - << " f=" << bf->get_f() - << std::endl; - } - else - out << "none" << std::endl; - out << "best infeas. solution: "; - if ( bi ) { - out << "( "; - bi->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); - out << " ) h=" << bi->get_h() - << " f=" << bi->get_f() - << std::endl; - } - else - out << "none" << std::endl; - - out << "poll center : "; - const NOMAD::Eval_Point * poll_center = get_active_barrier().get_poll_center(); - if ( poll_center ) { - out << "( "; - poll_center->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); - out << " )" << std::endl; - - s1 = poll_center->get_signature(); - if (s1) - display_deltas ( *s1 ); - } - else - out << "none" << std::endl; - - const NOMAD::Eval_Point * sec_poll_center + out << "best feas. solution : "; + if ( bf ) + { + out << "( "; + bf->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); + out << " ) h=" << bf->get_h() + << " f=" << bf->get_f() + << std::endl; + } + else + out << "none" << std::endl; + out << "best infeas. solution: "; + if ( bi ) + { + out << "( "; + bi->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); + out << " ) h=" << bi->get_h() + << " f=" << bi->get_f() + << std::endl; + } + else + out << "none" << std::endl; + + out << "poll center : "; + const NOMAD::Eval_Point * poll_center = get_active_barrier().get_poll_center(); + if ( poll_center ) + { + out << "( "; + poll_center->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); + out << " )" << std::endl; + + s1 = poll_center->get_signature(); + if (s1) + display_deltas ( *s1 ); + } + else + out << "none" << std::endl; + + const NOMAD::Eval_Point * sec_poll_center = get_active_barrier().get_sec_poll_center(); - - if ( sec_poll_center ) { - out << "sec. poll center : ( "; - sec_poll_center->Point::display ( out , - " " , - 2 , - NOMAD::Point::get_display_limit() ); - out << " )" << std::endl; - const NOMAD::Signature * s2 = sec_poll_center->get_signature(); - if ( s2 && (!s1 || s1 != s2) ) - display_deltas ( *s2 ); - } - out << "h_max : " - << get_active_barrier().get_h_max() << std::endl; + + if ( sec_poll_center ) + { + out << "sec. poll center : ( "; + sec_poll_center->Point::display ( out , + " " , + 2 , + NOMAD::Point::get_display_limit() ); + out << " )" << std::endl; + const NOMAD::Signature * s2 = sec_poll_center->get_signature(); + if ( s2 && (!s1 || s1 != s2) ) + display_deltas ( *s2 ); + } + + out << "h_max : " + << get_active_barrier().get_h_max() << std::endl; } /*---------------------------------------------------------*/ /* displays at the end of an iteration (private) */ /*---------------------------------------------------------*/ -void NOMAD::Mads::display_iteration_end -( bool stop , - NOMAD::stop_type stop_reason , - NOMAD::success_type success , - const NOMAD::Eval_Point * new_feas_inc , - const NOMAD::Eval_Point * new_infeas_inc ) const +void NOMAD::Mads::display_iteration_end ( bool stop , + NOMAD::stop_type stop_reason , + NOMAD::success_type success , + const NOMAD::Eval_Point * new_feas_inc , + const NOMAD::Eval_Point * new_infeas_inc ) const { - const NOMAD::Display & out = _p.out(); - - if ( out.get_iter_dd() != NOMAD::FULL_DISPLAY ) - return; - - out << std::endl - << "terminate MADS : "; - out.display_yes_or_no ( stop ); - out << std::endl; - if ( stop ) { - out << "termination cause : " << stop_reason; - if ( stop_reason==NOMAD::X0_FAIL && - !_flag_p1_active && - _p.has_EB_constraints() ) - out << " (phase one will be performed)"; - out << std::endl; - } - out << "iteration status : " << success << std::endl; - out << "new feas. incumbent : "; - if ( new_feas_inc ) - out << *new_feas_inc; - else - out << "none" << std::endl; - out << "new infeas. incumbent: "; - if ( new_infeas_inc ) - out << *new_infeas_inc; - else - out << "none" << std::endl; + const NOMAD::Display & out = _p.out(); + + if ( out.get_iter_dd() != NOMAD::FULL_DISPLAY ) + return; + + out << std::endl + << "terminate MADS : "; + out.display_yes_or_no ( stop ); + out << std::endl; + if ( stop ) + { + out << "termination cause : " << stop_reason; + if ( stop_reason==NOMAD::X0_FAIL && + !_flag_p1_active && + _p.has_EB_constraints() ) + out << " (phase one will be performed)"; + out << std::endl; + } + out << "iteration status : " << success << std::endl; + out << "new feas. incumbent : "; + if ( new_feas_inc ) + out << *new_feas_inc; + else + out << "none" << std::endl; + out << "new infeas. incumbent: "; + if ( new_infeas_inc ) + out << *new_infeas_inc; + else + out << "none" << std::endl; + } + + diff --git a/src/Mads.hpp b/src/Mads.hpp index c44819e34c6efc22fb22b7f4ab87aca9e8042bfa..f3b0b26357c4e98b62041bfc2a9d7e66813f7943 100644 --- a/src/Mads.hpp +++ b/src/Mads.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -55,9 +62,6 @@ #include "XMesh.hpp" #include "SMesh.hpp" -#ifdef USE_TGP -#include "TGP_Model_Search.hpp" -#endif namespace NOMAD { @@ -78,6 +82,7 @@ namespace NOMAD { NOMAD::Barrier _true_barrier; ///< Barrier for true function evaluations. NOMAD::Barrier _sgte_barrier; ///< Barrier for surrogate evaluations. + NOMAD::OrthogonalMesh * _mesh; ///< Access to the OrthogonalMesh /// Pareto front for multi-objective optimization. @@ -102,6 +107,8 @@ namespace NOMAD { static bool _flag_reset_barriers; ///< Reset or not the barriers before a MADS run. static bool _flag_p1_active; ///< Flag equal to \c true if phase one is active. + + /*-----------------------------------------------------------------------------*/ /// Initializations. @@ -153,12 +160,12 @@ namespace NOMAD { size stopping criterion has to be disabled for integer variables -- \b OUT. */ - void poll ( bool & stop, - NOMAD::stop_type & stop_reason, - NOMAD::success_type & success, - const NOMAD::Eval_Point *& new_feas_inc, + void poll ( bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + const NOMAD::Eval_Point *& new_feas_inc , const NOMAD::Eval_Point *& new_infeas_inc, - bool & forbid_poll_size_stop ); + bool & forbid_poll_size_stop ); /// Sets the poll trial points from poll direction, poll center and mesh size /** @@ -169,12 +176,12 @@ namespace NOMAD { \param offset Dir index offset for primary and sec. poll center -- \b IN. \param sorting If true than the points are for sorting -- \b IN. */ - void set_poll_trial_points ( std::list<NOMAD::Direction> & dirs, - size_t offset, - const NOMAD::Eval_Point & poll_center, - bool & stop, - NOMAD::stop_type &stop_reason, - bool sorting); + void set_poll_trial_points ( std::list<NOMAD::Direction> & dirs , + size_t offset , + const NOMAD::Eval_Point & poll_center , + bool & stop , + NOMAD::stop_type & stop_reason , + bool sorting ); /// Compute a prospect point by optimization on quadratic models. @@ -184,19 +191,19 @@ namespace NOMAD { \param prospect_point The prospect point -- \b OUT. \return A flag equal to \c true if the prospect direction has been computed. */ - bool optimize_quad_model ( const NOMAD::Eval_Point & poll_center , - const std::list<NOMAD::Direction> & dirs , - NOMAD::Point & prospect_point ) ; + bool optimize_quad_model ( const NOMAD::Eval_Point & poll_center , + const std::list<NOMAD::Direction> & dirs , + NOMAD::Point & prospect_point) ; /// Sets the poll directions from signature, poll center and mesh size /** - \param dirs List of directions for the poll -- \b OUT. - \param i_pc Poll type -- \b IN. - \param offset Dir index offset for primary and sec. poll center -- \b IN. - \param poll_center The poll center -- \b IN. - \param stop Stop flag, true if cannot get direction -- \b IN/OUT. - \param stop_reason Stop type -- \b OUT. + \param dirs List of directions for the poll -- \b OUT. + \param i_pc Poll type -- \b IN. + \param offset Dir index offset for primary and sec. poll center -- \b IN. + \param poll_center The poll center -- \b IN. + \param stop Stop flag, true if cannot get direction -- \b IN/OUT. + \param stop_reason Stop type -- \b OUT. */ void set_poll_directions ( std::list<NOMAD::Direction> & dirs , NOMAD::poll_type i_pc , @@ -205,14 +212,27 @@ namespace NOMAD { bool & stop , NOMAD::stop_type & stop_reason ); + + /// Sets the poll intensification points from signature, poll center and mesh size + /** + \param poll_center The poll center -- \b IN. + \param offset Dir index offset for intensification -- \b IN. + \param stop Stop flag, true if cannot get direction -- \b IN/OUT. + \param stop_reason Stop type -- \b OUT. + */ + void set_poll_intensification_points ( const NOMAD::Eval_Point & poll_center , + size_t & offset , + bool & stop , + NOMAD::stop_type & stop_reason ); + /// Reduce the number of poll directions -> n /** - \param dirs List of directions for the poll -- \b IN/OUT. - \param poll_center the poll center -- \b IN. + \param dirs List of directions for the poll -- \b IN/OUT. + \param poll_center The poll center -- \b IN. \return success for this step. */ - bool set_reduced_poll_to_n_directions(std::list<NOMAD::Direction> & dirs, - const NOMAD::Eval_Point & poll_center); + bool set_reduced_poll_to_n_directions(std::list<NOMAD::Direction> & dirs, + const NOMAD::Eval_Point & poll_center); /// Compute the rank of a list of directions /** @@ -299,13 +319,13 @@ namespace NOMAD { /** - The computed opposite directions already include Delta^k_m. \param dirs List of existing directions (no snap to bounds) -- \b IN. - \param newDirs New dynamic directions -- \b OUT. + \param newDirs New dynamic directions -- \b OUT. \param poll_center Poll center -- \b IN. \return true if new dynamic direction generated false otherwise */ - bool get_dynamic_directions (const std::list<NOMAD::Direction> & dirs, - std::list<NOMAD::Direction> & newDirs, - const NOMAD::Eval_Point & poll_center) ; + bool get_dynamic_directions (const std::list<NOMAD::Direction> & dirs, + std::list<NOMAD::Direction> & newDirs, + const NOMAD::Eval_Point & poll_center) ; @@ -316,7 +336,7 @@ namespace NOMAD { least one direction in the set is of type Ortho-MADS N+1. */ - bool dirs_have_orthomads_np1 ( const std::list<NOMAD::Direction> & dirs ); + bool dirs_have_orthomads_np1_dyn ( const std::list<NOMAD::Direction> & dirs ); /// Check if a dir needs to be obtained from model optimization @@ -329,12 +349,12 @@ namespace NOMAD { /// get a single direction using quad model optimization or sum of negatives /** - \param dirs Reduced poll directions (no snap to bounds) -- \b IN. - \param poll_center Poll center -- \b IN. + \param dirs Reduced poll directions (no snap to bounds) -- \b IN. + \param poll_center Poll center -- \b IN. \return new direction */ - NOMAD::Direction get_single_dynamic_direction (const std::list<NOMAD::Direction> & dirs, - const NOMAD::Eval_Point & poll_center) ; + NOMAD::Direction get_single_dynamic_direction (const std::list<NOMAD::Direction> & dirs, + const NOMAD::Eval_Point & poll_center) ; /*-----------------------------------------------------------------------------*/ @@ -355,7 +375,7 @@ namespace NOMAD { _ev_control_for_sorting( p , _stats , _ev_control.get_evaluator() , &(_ev_control.get_cache()) , &(_ev_control.get_sgte_cache()) ) , _true_barrier ( p , NOMAD::TRUTH ) , _sgte_barrier ( p , NOMAD::SGTE ) , - _mesh ( p.get_signature()->get_mesh() ) , + _mesh ( p.get_signature()->get_mesh() ) , _pareto_front ( NULL ) , _user_search ( NULL ) , _model_search1 ( NULL ) , @@ -388,7 +408,7 @@ namespace NOMAD { _ev_control_for_sorting( p , _stats , _ev_control.get_evaluator() , cache , sgte_cache ) , _true_barrier ( p , NOMAD::TRUTH ) , _sgte_barrier ( p , NOMAD::SGTE ) , - _mesh ( p.get_signature()->get_mesh() ) , + _mesh ( p.get_signature()->get_mesh() ) , _pareto_front ( NULL ) , _user_search ( NULL ) , _model_search1 ( NULL ) , @@ -406,7 +426,7 @@ namespace NOMAD { /** \return Stop reason. */ - NOMAD::stop_type run ( void ); + virtual NOMAD::stop_type run ( void ); /// Algorithm execution for multi-objective. /** diff --git a/src/Makefile.am b/src/Makefile.am index 2ffa64126077fafc59eb022c46f2530e24f38ea7..02e435d9b21c9aa765712488c03e94b627e0a80c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,9 +9,7 @@ libnomad_a_SOURCES = Barrier.cpp Cache.cpp Cache_File_Point.cpp Cache_Point.cpp\ Phase_One_Search.cpp Point.cpp Priority_Eval_Point.cpp Quad_Model.cpp\ Quad_Model_Evaluator.cpp Quad_Model_Search.cpp Random_Pickup.cpp\ RNG.cpp Signature.cpp Slave.cpp Speculative_Search.cpp Stats.cpp\ - TGP_Model.cpp TGP_Model_Evaluator.cpp TGP_Model_Search.cpp\ - TGP_Output_Model.cpp utils.cpp Variable_Group.cpp VNS_Search.cpp\ - OrthogonalMesh.cpp + utils.cpp Variable_Group.cpp VNS_Search.cpp OrthogonalMesh.cpp libnomadmpi_a_SOURCES = Barrier.cpp Cache.cpp Cache_File_Point.cpp Cache_Point.cpp\ Cache_Search.cpp Clock.cpp Direction.cpp Directions.cpp Display.cpp\ @@ -23,9 +21,7 @@ libnomadmpi_a_SOURCES = Barrier.cpp Cache.cpp Cache_File_Point.cpp Cache_Point.c Phase_One_Search.cpp Point.cpp Priority_Eval_Point.cpp Quad_Model.cpp\ Quad_Model_Evaluator.cpp Quad_Model_Search.cpp Random_Pickup.cpp\ RNG.cpp Signature.cpp Slave.cpp Speculative_Search.cpp Stats.cpp\ - TGP_Model.cpp TGP_Model_Evaluator.cpp TGP_Model_Search.cpp\ - TGP_Output_Model.cpp utils.cpp Variable_Group.cpp VNS_Search.cpp\ - OrthogonalMesh.cpp + utils.cpp Variable_Group.cpp VNS_Search.cpp OrthogonalMesh.cpp pkginclude_HEADERS = Cache_File_Point.hpp Cache.hpp Cache_Point.hpp\ Cache_Search.hpp Clock.hpp defines.hpp Direction.hpp Directions.hpp\ @@ -40,8 +36,7 @@ pkginclude_HEADERS = Cache_File_Point.hpp Cache.hpp Cache_Point.hpp\ Quad_Model_Search.hpp Random_Pickup.hpp RNG.hpp Search.hpp\ Set_Element.hpp Signature_Element.hpp Signature.hpp\ Single_Obj_Quad_Model_Evaluator.hpp Slave.hpp Speculative_Search.hpp\ - Stats.hpp TGP_Model_Evaluator.hpp TGP_Model.hpp TGP_Model_Search.hpp\ - TGP_Output_Model.hpp Uncopyable.hpp utils.hpp Variable_Group.hpp\ + Stats.hpp TGP_Model_Evaluator.hpp Uncopyable.hpp utils.hpp Variable_Group.hpp\ VNS_Search.hpp Barrier.hpp OrthogonalMesh.hpp bin_PROGRAMS = nomad diff --git a/src/Model_Sorted_Point.cpp b/src/Model_Sorted_Point.cpp index 1afbbdbb421929bbc9d8b08f172cf4afbe973b51..a37d68f9bba5fc25462c139a2db09ea4f93349e3 100644 --- a/src/Model_Sorted_Point.cpp +++ b/src/Model_Sorted_Point.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,55 +41,58 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Model_Sorted_Point.cpp - \brief Interpolation point with distance to model center (implementation) - \author Sebastien Le Digabel - \date 2010-11-15 - \see Model_Sorted_Point.hpp -*/ + \file Model_Sorted_Point.cpp + \brief Interpolation point with distance to model center (implementation) + \author Sebastien Le Digabel + \date 2010-11-15 + \see Model_Sorted_Point.hpp + */ #include "Model_Sorted_Point.hpp" /*---------------------------------------------------------*/ /* constructor */ /*---------------------------------------------------------*/ -NOMAD::Model_Sorted_Point::Model_Sorted_Point -( NOMAD::Point * x , const NOMAD::Point & center ) : _x(x) +NOMAD::Model_Sorted_Point::Model_Sorted_Point ( NOMAD::Point * x , + const NOMAD::Point & center ) : _x(x) { - int i , n = center.size(); - if ( x && x->size() == n ) { - _dist = 0.0; - for ( i = 0 ; i < n ; ++i ) - if ( (*x)[i].is_defined() && center[i].is_defined() ) { - _dist += ( (*x)[i] - center[i] ).pow2(); - } - else { - _dist.clear(); - break; - } - } + int i , n = center.size(); + if ( x && x->size() == n ) + { + _dist = 0.0; + for ( i = 0 ; i < n ; ++i ) + if ( (*x)[i].is_defined() && center[i].is_defined() ) + { + _dist += ( (*x)[i] - center[i] ).pow2(); + } + else + { + + _dist.clear(); + break; + } + } } /*---------------------------------------------------------*/ /* affectation operator */ /*---------------------------------------------------------*/ -NOMAD::Model_Sorted_Point & NOMAD::Model_Sorted_Point::operator = -( const NOMAD::Model_Sorted_Point & x ) +NOMAD::Model_Sorted_Point & NOMAD::Model_Sorted_Point::operator = ( const NOMAD::Model_Sorted_Point & x ) { - _x = x._x; - _dist = x._dist; - return *this; + _x = x._x; + _dist = x._dist; + return *this; } /*---------------------------------------------------------*/ /* comparison operator */ /*---------------------------------------------------------*/ -bool NOMAD::Model_Sorted_Point::operator < -( const Model_Sorted_Point & x ) const +bool NOMAD::Model_Sorted_Point::operator < ( const Model_Sorted_Point & x ) const { - if ( _dist.is_defined() ) { - if ( !x._dist.is_defined() ) - return true; - return _dist < x._dist; - } - return false; + if ( _dist.is_defined() ) + { + if ( !x._dist.is_defined() ) + return true; + return _dist < x._dist; + } + return false; } diff --git a/src/Model_Sorted_Point.hpp b/src/Model_Sorted_Point.hpp index c1e1a7c64d06439f014083d26ce7143e8c43d7b6..1cd2e08bc1fc298a1ff81d3c68351dbbdbab6f4b 100644 --- a/src/Model_Sorted_Point.hpp +++ b/src/Model_Sorted_Point.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,80 +41,80 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Model_Sorted_Point.hpp - \brief Interpolation point with distance to model center (headers) - \author Sebastien Le Digabel - \date 2010-11-15 - \see Model_Sorted_Point.cpp -*/ + \file Model_Sorted_Point.hpp + \brief Interpolation point with distance to model center (headers) + \author Sebastien Le Digabel + \date 2010-11-15 + \see Model_Sorted_Point.cpp + */ #ifndef __MODEL_SORTED_POINT__ #define __MODEL_SORTED_POINT__ #include "Point.hpp" namespace NOMAD { - - /// Class used to order interpolation points. - class Model_Sorted_Point { - - private: - - NOMAD::Point * _x; ///< The point. - NOMAD::Double _dist; ///< Distance to center. - - public: - - /// Constructor 1/2. - /** - \param x Interpolaton point -- \b IN. - \param center Model center -- \b IN. - */ - Model_Sorted_Point ( NOMAD::Point * x , const NOMAD::Point & center ); - - /// Constructor 2/2. - /** - \param x Interpolaton point -- \b IN. - \param dist Custom distance with center -- \b IN. - */ - Model_Sorted_Point ( NOMAD::Point * x , const NOMAD::Double & dist ) - : _x ( x ) , _dist ( dist ) {} - - /// Copy constructor. - /** - \param x The copied object -- \b IN. - */ - Model_Sorted_Point ( const Model_Sorted_Point & x ) - : _x ( x._x ) , _dist ( x._dist ) {} - - /// Affectation operator. - /** - \param x The right-hand side object -- \b IN. - \return \c *this as the result of the affectation. - */ - Model_Sorted_Point & operator = ( const Model_Sorted_Point & x ); - - /// Destructor. - virtual ~Model_Sorted_Point ( void ) {} - - /// Comparison operator. - /** - \param x The right-hand side object -- \b IN. - \return \c true if the current interpolation point is closer to the center. - */ - bool operator < ( const Model_Sorted_Point & x ) const; - - /// Access to the interpolation point. - /** - \return The interpolation point. - */ - NOMAD::Point * get_point ( void ) const { return _x; } - - /// Access to the distance. - /** - \return The distance - */ - const NOMAD::Double & get_dist ( void ) const { return _dist; } - }; + + /// Class used to order interpolation points. + class Model_Sorted_Point { + + private: + + NOMAD::Point * _x; ///< The point. + NOMAD::Double _dist; ///< Distance to center. + + public: + + /// Constructor 1/2. + /** + \param x Interpolaton point -- \b IN. + \param center Model center -- \b IN. + */ + Model_Sorted_Point ( NOMAD::Point * x , const NOMAD::Point & center ); + + /// Constructor 2/2. + /** + \param x Interpolaton point -- \b IN. + \param dist Custom distance with center -- \b IN. + */ + Model_Sorted_Point ( NOMAD::Point * x , const NOMAD::Double & dist ) + : _x ( x ) , _dist ( dist ) {} + + /// Copy constructor. + /** + \param x The copied object -- \b IN. + */ + Model_Sorted_Point ( const Model_Sorted_Point & x ) + : _x ( x._x ) , _dist ( x._dist ) {} + + /// Affectation operator. + /** + \param x The right-hand side object -- \b IN. + \return \c *this as the result of the affectation. + */ + Model_Sorted_Point & operator = ( const Model_Sorted_Point & x ); + + /// Destructor. + virtual ~Model_Sorted_Point ( void ) {} + + /// Comparison operator. + /** + \param x The right-hand side object -- \b IN. + \return \c true if the current interpolation point is closer to the center. + */ + bool operator < ( const Model_Sorted_Point & x ) const; + + /// Access to the interpolation point. + /** + \return The interpolation point. + */ + NOMAD::Point * get_point ( void ) const { return _x; } + + /// Access to the distance. + /** + \return The distance + */ + const NOMAD::Double & get_dist ( void ) const { return _dist; } + }; } #endif diff --git a/src/Model_Stats.cpp b/src/Model_Stats.cpp index bc18f4da6f89dd6b0aeef3f3f1c01d22349bf001..c71aaddb0de0e4a6f6bf398250a3a70b6eadc5c3 100644 --- a/src/Model_Stats.cpp +++ b/src/Model_Stats.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Model_Stats.cpp - \brief Model stats (implementation) - \author Sebastien Le Digabel - \date 2010-09-24 - \see Model_Stats.hpp -*/ + \file Model_Stats.cpp + \brief Model stats (implementation) + \author Sebastien Le Digabel + \date 2010-09-24 + \see Model_Stats.hpp + */ #include "Model_Stats.hpp" /*---------------------------------------------------------*/ @@ -47,38 +54,37 @@ /*---------------------------------------------------------*/ NOMAD::Model_Stats & NOMAD::Model_Stats::operator = ( const NOMAD::Model_Stats & s ) { - _nb_truth = s._nb_truth; - _nb_sgte = s._nb_sgte; - _nb_MFN = s._nb_MFN; - _nb_WP_regression = s._nb_WP_regression; - _nb_regression = s._nb_regression; - _nb_TGP = s._nb_TGP; - _not_enough_pts = s._not_enough_pts; - _nb_Y_sets = s._nb_Y_sets; - _sum_nY = s._sum_nY; - _min_nY = s._min_nY; - _max_nY = s._max_nY; - _construction_error = s._construction_error; - _construction_time = s._construction_time; - _optimization_time = s._optimization_time; - _bad_cond = s._bad_cond; - _MS_nb_searches = s._MS_nb_searches; - _MS_pts = s._MS_pts; - _MS_success = s._MS_success; - _MS_bb_eval = s._MS_bb_eval; - _MS_sgte_eval = s._MS_sgte_eval; - _MS_cache_hits = s._MS_cache_hits; - _MS_rejected = s._MS_rejected; - _MS_max_search_pts = s._MS_max_search_pts; - _MS_nb_opt = s._MS_nb_opt; - _MS_opt_error = s._MS_nb_opt; - _MS_avg_model_eval = s._MS_avg_model_eval; - _MS_max_model_eval = s._MS_max_model_eval; - _MS_max_bbe = s._MS_max_bbe; - _ES_nb_inside_radius = s._ES_nb_inside_radius; - _ES_nb_pts = s._ES_nb_pts; - - return *this; + _nb_truth = s._nb_truth; + _nb_sgte = s._nb_sgte; + _nb_MFN = s._nb_MFN; + _nb_WP_regression = s._nb_WP_regression; + _nb_regression = s._nb_regression; + _not_enough_pts = s._not_enough_pts; + _nb_Y_sets = s._nb_Y_sets; + _sum_nY = s._sum_nY; + _min_nY = s._min_nY; + _max_nY = s._max_nY; + _construction_error = s._construction_error; + _construction_time = s._construction_time; + _optimization_time = s._optimization_time; + _bad_cond = s._bad_cond; + _MS_nb_searches = s._MS_nb_searches; + _MS_pts = s._MS_pts; + _MS_success = s._MS_success; + _MS_bb_eval = s._MS_bb_eval; + _MS_sgte_eval = s._MS_sgte_eval; + _MS_cache_hits = s._MS_cache_hits; + _MS_rejected = s._MS_rejected; + _MS_max_search_pts = s._MS_max_search_pts; + _MS_nb_opt = s._MS_nb_opt; + _MS_opt_error = s._MS_nb_opt; + _MS_avg_model_eval = s._MS_avg_model_eval; + _MS_max_model_eval = s._MS_max_model_eval; + _MS_max_bbe = s._MS_max_bbe; + _ES_nb_inside_radius = s._ES_nb_inside_radius; + _ES_nb_pts = s._ES_nb_pts; + + return *this; } /*---------------------------------------------------------*/ @@ -86,12 +92,11 @@ NOMAD::Model_Stats & NOMAD::Model_Stats::operator = ( const NOMAD::Model_Stats & /*---------------------------------------------------------*/ void NOMAD::Model_Stats::reset ( void ) { - _nb_truth = + _nb_truth = _nb_sgte = _nb_MFN = _nb_WP_regression = _nb_regression = - _nb_TGP = _not_enough_pts = _construction_error = _bad_cond = @@ -103,20 +108,20 @@ void NOMAD::Model_Stats::reset ( void ) _MS_cache_hits = _MS_rejected = _MS_max_search_pts = - _MS_nb_opt = + _MS_nb_opt = _MS_opt_error = _MS_avg_model_eval = _MS_max_model_eval = _MS_max_bbe = _ES_nb_inside_radius = - _ES_nb_pts = + _ES_nb_pts = _nb_Y_sets = 0; - - _min_nY = INT_MAX; - _sum_nY = 0.0; - - _max_nY = -1; - _construction_time = + + _min_nY = INT_MAX; + _sum_nY = 0.0; + + _max_nY = -1; + _construction_time = _optimization_time = 0.0; } @@ -125,51 +130,50 @@ void NOMAD::Model_Stats::reset ( void ) /*-------------------------------------------------------*/ void NOMAD::Model_Stats::update ( const NOMAD::Model_Stats & s ) { - _nb_truth += s._nb_truth; - _nb_sgte += s._nb_sgte; - _nb_MFN += s._nb_MFN; - _nb_WP_regression += s._nb_WP_regression; - _nb_regression += s._nb_regression; - _nb_TGP += s._nb_TGP; - _not_enough_pts += s._not_enough_pts; - _construction_error += s._construction_error; - _construction_time += s._construction_time; - _optimization_time += s._optimization_time; - _bad_cond += s._bad_cond; - _MS_nb_searches += s._MS_nb_searches; - _MS_pts += s._MS_pts; - _MS_success += s._MS_success; - _MS_bb_eval += s._MS_bb_eval; - _MS_sgte_eval += s._MS_sgte_eval; - _MS_cache_hits += s._MS_cache_hits; - _MS_rejected += s._MS_rejected; - _MS_opt_error += s._MS_opt_error; - _MS_max_bbe += s._MS_max_bbe; - _ES_nb_inside_radius += s._ES_nb_inside_radius; - _ES_nb_pts += s._ES_nb_pts; - _nb_Y_sets += s._nb_Y_sets; - _sum_nY += s._sum_nY; - - _min_nY = ( _min_nY < s._min_nY ) ? + _nb_truth += s._nb_truth; + _nb_sgte += s._nb_sgte; + _nb_MFN += s._nb_MFN; + _nb_WP_regression += s._nb_WP_regression; + _nb_regression += s._nb_regression; + _not_enough_pts += s._not_enough_pts; + _construction_error += s._construction_error; + _construction_time += s._construction_time; + _optimization_time += s._optimization_time; + _bad_cond += s._bad_cond; + _MS_nb_searches += s._MS_nb_searches; + _MS_pts += s._MS_pts; + _MS_success += s._MS_success; + _MS_bb_eval += s._MS_bb_eval; + _MS_sgte_eval += s._MS_sgte_eval; + _MS_cache_hits += s._MS_cache_hits; + _MS_rejected += s._MS_rejected; + _MS_opt_error += s._MS_opt_error; + _MS_max_bbe += s._MS_max_bbe; + _ES_nb_inside_radius += s._ES_nb_inside_radius; + _ES_nb_pts += s._ES_nb_pts; + _nb_Y_sets += s._nb_Y_sets; + _sum_nY += s._sum_nY; + + _min_nY = ( _min_nY < s._min_nY ) ? _min_nY : s._min_nY; - - _max_nY = ( _max_nY > s._max_nY ) ? + + _max_nY = ( _max_nY > s._max_nY ) ? _max_nY : s._max_nY; - - _MS_max_model_eval = ( _MS_max_model_eval > s._MS_max_model_eval ) ? + + _MS_max_model_eval = ( _MS_max_model_eval > s._MS_max_model_eval ) ? _MS_max_model_eval : s._MS_max_model_eval; - - _MS_max_search_pts = ( _MS_max_search_pts > s._MS_max_search_pts ) ? + + _MS_max_search_pts = ( _MS_max_search_pts > s._MS_max_search_pts ) ? _MS_max_search_pts : s._MS_max_search_pts; - - if ( _MS_nb_opt + s._MS_nb_opt == 0 ) - _MS_avg_model_eval = 0; - else - _MS_avg_model_eval = ( _MS_avg_model_eval* _MS_nb_opt + - s._MS_avg_model_eval*s._MS_nb_opt ) / - ( _MS_nb_opt + s._MS_nb_opt ); - - _MS_nb_opt += s._MS_nb_opt; + + if ( _MS_nb_opt + s._MS_nb_opt == 0 ) + _MS_avg_model_eval = 0; + else + _MS_avg_model_eval = ( _MS_avg_model_eval* _MS_nb_opt + + s._MS_avg_model_eval*s._MS_nb_opt ) / + ( _MS_nb_opt + s._MS_nb_opt ); + + _MS_nb_opt += s._MS_nb_opt; } /*----------------------------------------------------*/ @@ -177,12 +181,12 @@ void NOMAD::Model_Stats::update ( const NOMAD::Model_Stats & s ) /*----------------------------------------------------*/ void NOMAD::Model_Stats::update_nY ( int nY ) { - ++_nb_Y_sets; - _sum_nY += nY; - if ( nY > _max_nY ) - _max_nY = nY; - if ( nY < _min_nY ) - _min_nY = nY; + ++_nb_Y_sets; + _sum_nY += nY; + if ( nY > _max_nY ) + _max_nY = nY; + if ( nY < _min_nY ) + _min_nY = nY; } /*----------------------------------------------------*/ @@ -190,8 +194,8 @@ void NOMAD::Model_Stats::update_nY ( int nY ) /*----------------------------------------------------*/ void NOMAD::Model_Stats::update_MS_max_search_pts ( int sp ) { - if ( sp > _MS_max_search_pts ) - _MS_max_search_pts = sp; + if ( sp > _MS_max_search_pts ) + _MS_max_search_pts = sp; } /*-----------------------------------------------------------------------*/ @@ -199,10 +203,10 @@ void NOMAD::Model_Stats::update_MS_max_search_pts ( int sp ) /*-----------------------------------------------------------------------*/ void NOMAD::Model_Stats::update_MS_model_opt ( int eval ) { - if ( eval > _MS_max_model_eval ) - _MS_max_model_eval = eval; - ++_MS_nb_opt; - _MS_avg_model_eval = ( (_MS_avg_model_eval*(_MS_nb_opt-1)) + eval ) / _MS_nb_opt; + if ( eval > _MS_max_model_eval ) + _MS_max_model_eval = eval; + ++_MS_nb_opt; + _MS_avg_model_eval = ( (_MS_avg_model_eval*(_MS_nb_opt-1)) + eval ) / _MS_nb_opt; } /*---------------------------------------------------------*/ @@ -210,63 +214,64 @@ void NOMAD::Model_Stats::update_MS_model_opt ( int eval ) /*---------------------------------------------------------*/ void NOMAD::Model_Stats::display ( const NOMAD::Display & out ) const { - out << "number of models built : " << get_nb_models() << std::endl; - if ( _nb_sgte > 0 ) - out << "number of truth models : " << _nb_truth << std::endl - << "number of surrogate models : " << _nb_sgte << std::endl; - out << "number of MFN interpolations : " << _nb_MFN << std::endl - << "number of WP regressions : " << _nb_WP_regression << std::endl - << "number of quadr. regressions : " << _nb_regression << std::endl - << "number of TGP models : " << _nb_TGP << std::endl - << "number of construction errors: " << _construction_error << std::endl - << "number of bad cond numbers : " << _bad_cond << std::endl - << "number of too small Y sets : " << _not_enough_pts << std::endl - << "min Y size : "; - if ( _min_nY != INT_MAX ) - out << _min_nY; - else - out << "-"; - out << std::endl - << "max Y size : "; - if ( _max_nY != -1 ) - out << _max_nY; - else - out << "-"; - out << std::endl - << "avg Y size : "; - if ( get_avg_nY() != 0.0 ) - out << get_avg_nY(); - else - out << "-"; - out << std::endl - << "construction CPU time (s) : " << _construction_time << std::endl; - if ( _MS_nb_searches > 0 ) { - out << NOMAD::open_block ( "model searches" ) - << "number of searches : " << _MS_nb_searches << std::endl - << "number of search successes : " << _MS_success << std::endl - << "number of search points : " << _MS_pts << std::endl - << "number of blackbox evaluations : " << _MS_bb_eval << std::endl; - if ( _MS_sgte_eval > 0 ) - out << "number of sgte evaluations : " << _MS_sgte_eval << std::endl; - out << "number of cache hits : " << _MS_cache_hits << std::endl - << "number of rejected candidates : " << _MS_rejected << std::endl - << "max number of trial points : " << _MS_max_search_pts << std::endl - << "number of optimizations : " << _MS_nb_opt << std::endl - << "number of optimization errors : " << _MS_opt_error << std::endl - << "number of max_bbe stops : " << _MS_max_bbe << std::endl - << "max number of model evaluations : " << _MS_max_model_eval << std::endl - << "average number of model evaluations: " << _MS_avg_model_eval << std::endl - << "optimization CPU time (s) : " << _optimization_time << std::endl - << NOMAD::close_block(); - } - - if ( _ES_nb_pts > 0 ) { - out << NOMAD::open_block ( "model ordering" ) - << "number of points considered : " << _ES_nb_pts << std::endl - << "number of points inside radius: " << _ES_nb_inside_radius - << " ("; - NOMAD::Double(_ES_nb_inside_radius*100.0/_ES_nb_pts).display ( out , "%.0f" ); - out << "%)" << std::endl - << NOMAD::close_block(); - } + out << "number of models built : " << get_nb_models() << std::endl; + if ( _nb_sgte > 0 ) + out << "number of truth models : " << _nb_truth << std::endl + << "number of surrogate models : " << _nb_sgte << std::endl; + out << "number of MFN interpolations : " << _nb_MFN << std::endl + << "number of WP regressions : " << _nb_WP_regression << std::endl + << "number of quadr. regressions : " << _nb_regression << std::endl + << "number of construction errors: " << _construction_error << std::endl + << "number of bad cond numbers : " << _bad_cond << std::endl + << "number of too small Y sets : " << _not_enough_pts << std::endl + << "min Y size : "; + if ( _min_nY != INT_MAX ) + out << _min_nY; + else + out << "-"; + out << std::endl + << "max Y size : "; + if ( _max_nY != -1 ) + out << _max_nY; + else + out << "-"; + out << std::endl + << "avg Y size : "; + if ( get_avg_nY() != 0.0 ) + out << get_avg_nY(); + else + out << "-"; + out << std::endl + << "construction CPU time (s) : " << _construction_time << std::endl; + if ( _MS_nb_searches > 0 ) + { + out << NOMAD::open_block ( "model searches" ) + << "number of searches : " << _MS_nb_searches << std::endl + << "number of search successes : " << _MS_success << std::endl + << "number of search points : " << _MS_pts << std::endl + << "number of blackbox evaluations : " << _MS_bb_eval << std::endl; + if ( _MS_sgte_eval > 0 ) + out << "number of sgte evaluations : " << _MS_sgte_eval << std::endl; + out << "number of cache hits : " << _MS_cache_hits << std::endl + << "number of rejected candidates : " << _MS_rejected << std::endl + << "max number of trial points : " << _MS_max_search_pts << std::endl + << "number of optimizations : " << _MS_nb_opt << std::endl + << "number of optimization errors : " << _MS_opt_error << std::endl + << "number of max_bbe stops : " << _MS_max_bbe << std::endl + << "max number of model evaluations : " << _MS_max_model_eval << std::endl + << "average number of model evaluations: " << _MS_avg_model_eval << std::endl + << "optimization CPU time (s) : " << _optimization_time << std::endl + << NOMAD::close_block(); + } + + if ( _ES_nb_pts > 0 ) + { + out << NOMAD::open_block ( "model ordering" ) + << "number of points considered : " << _ES_nb_pts << std::endl + << "number of points inside radius: " << _ES_nb_inside_radius + << " ("; + NOMAD::Double(_ES_nb_inside_radius*100.0/_ES_nb_pts).display ( out , "%.0f" ); + out << "%)" << std::endl + << NOMAD::close_block(); + } } diff --git a/src/Model_Stats.hpp b/src/Model_Stats.hpp index 1351a304cbf8237b2907dd1c6c0a6217fd59e590..97999693a998f47efd46d263449b3171b970d45c 100644 --- a/src/Model_Stats.hpp +++ b/src/Model_Stats.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,332 +41,322 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Model_Stats.hpp - \brief Model stats (headers) - \author Sebastien Le Digabel - \date 2010-09-24 - \see Model_Stats.cpp -*/ + \file Model_Stats.hpp + \brief Model stats (headers) + \author Sebastien Le Digabel + \date 2010-09-24 + \see Model_Stats.cpp + */ #ifndef __MODEL_STATS__ #define __MODEL_STATS__ #include "Double.hpp" namespace NOMAD { - - /// Model stats. - class Model_Stats { - - private: - - int _nb_truth; ///< Number of truth models. - int _nb_sgte; ///< Number of surrogate models. - int _nb_MFN; ///< Number of quadr. MFN models. - int _nb_WP_regression; ///< Number of quadr. well-poised regressions models. - int _nb_regression; ///< Number of quadr. regression_max_nY models. - int _nb_TGP; ///< Number of TGP models. - int _not_enough_pts; ///< Number of too small \c Y sets. - int _nb_Y_sets; ///< Number of \c Y sets. - float _sum_nY; ///< Total number of \c Y points. - int _min_nY; ///< Minimal \c Y size. - int _max_nY; ///< Maximal \c Y size. - int _construction_error; ///< Number of construction errors. - double _construction_time; ///< Models construction CPU time. - double _optimization_time; ///< Models optimization CPU time. - - /// Number of times that \c cond exceeded \c SVD_MAX_COND. - int _bad_cond; - - // model search (MS): - int _MS_nb_searches; ///< Number of searches. - int _MS_pts; ///< Number of search points. - int _MS_success; ///< Number of search successes. - int _MS_bb_eval; ///< Number of search blackbox evaluations. - int _MS_sgte_eval; ///< Number of search surrogate evaluations. - int _MS_cache_hits; ///< Number of search cache hits. - int _MS_rejected; ///< Number of rejected trial points. - int _MS_max_search_pts; ///< Max number of trial points for one search. - int _MS_nb_opt; ///< Number of optimizations. - int _MS_opt_error; ///< Number of optimization errors. - int _MS_avg_model_eval; ///< Avg number of evaluations for a model opt. - int _MS_max_model_eval; ///< Max number of evaluations for a model opt. - int _MS_max_bbe; ///< Number of times model eval. reached limit. - - // eval sort (ES): - int _ES_nb_inside_radius; ///< Total number of points inside radius. - int _ES_nb_pts; ///< Total number of points. - -public: - - /// Constructor. - explicit Model_Stats ( void ) { reset(); } - - /// Copy constructor. - /** - \param s The copied object -- \b IN. - */ - explicit Model_Stats ( const Model_Stats & s ) - : _nb_truth ( s._nb_truth ) , - _nb_sgte ( s._nb_sgte ) , - _nb_MFN ( s._nb_MFN ) , - _nb_WP_regression ( s._nb_WP_regression ) , - _nb_regression ( s._nb_regression ) , - _nb_TGP ( s._nb_TGP ) , - _not_enough_pts ( s._not_enough_pts ) , - _nb_Y_sets ( s._nb_Y_sets ) , - _sum_nY ( s._sum_nY ) , - _min_nY ( s._min_nY ) , - _max_nY ( s._max_nY ) , - _construction_error ( s._construction_error ) , - _construction_time ( s._construction_time ) , - _optimization_time ( s._optimization_time ) , - _bad_cond ( s._bad_cond ) , - _MS_nb_searches ( s._MS_nb_searches ) , - _MS_pts ( s._MS_pts ) , - _MS_success ( s._MS_success ) , - _MS_bb_eval ( s._MS_bb_eval ) , - _MS_sgte_eval ( s._MS_sgte_eval ) , - _MS_cache_hits ( s._MS_cache_hits ) , - _MS_rejected ( s._MS_rejected ) , - _MS_max_search_pts ( s._MS_max_search_pts ) , - _MS_nb_opt ( s._MS_nb_opt ) , - _MS_opt_error ( s._MS_opt_error ) , - _MS_avg_model_eval ( s._MS_avg_model_eval ) , - _MS_max_model_eval ( s._MS_max_model_eval ) , - _MS_max_bbe ( s._MS_max_bbe ) , - _ES_nb_inside_radius ( s._ES_nb_inside_radius ) , - _ES_nb_pts ( s._ES_nb_pts ) {} - - /// Affectation operator. - /** - \param s The right-hand side object -- \b IN. - */ - Model_Stats & operator = ( const Model_Stats & s ); - /// Destructor. - virtual ~Model_Stats ( void ) {} - - /// Reset the stats. - void reset ( void ); - - /// Update stats from another NOMAD::Model_Stats object. - /** - \param s The other NOMAD::Model_Stats object -- \b IN. - */ - void update ( const Model_Stats & s ); - - /// Update stats on the size of interpolation set \c Y. - /** - \param nY Size of an interpolation set \c Y -- \b IN. - */ - void update_nY ( int nY ); - - /// Update stat \c _MS_max_search_pts. - /** - \param sp Number of trial points for a model search -- \b IN. - */ - void update_MS_max_search_pts ( int sp ); - - /// Update stats \c _MS_nb_opt, \c _MS_max_model_eval, and \c _MS_avg_model_eval. - /** - \param eval Number of model evaluations during one model optimization -- \b IN. - */ - void update_MS_model_opt ( int eval ); - - /// Update model ordering stats. - /** - \param nb_inside_radius Number of points inside radius -- \b IN. - \param nb_pts Number of points -- \b IN. - */ - void update_ES_stats ( int nb_inside_radius , int nb_pts ) - { - _ES_nb_inside_radius += nb_inside_radius; - _ES_nb_pts += nb_pts; - } - - /// Add a real to stat \c _construction_time. - /** - \param t Time -- \b IN. - */ - void add_construction_time ( double t ) { _construction_time += t; } - - /// Add a real to stat \c _optimization_time. - /** - \param t Time -- \b IN. - */ - void add_optimization_time ( double t ) { _optimization_time += t; } - - /// Add \c 1 to stat \c _nb_truth. - void add_nb_truth ( void ) { ++_nb_truth; } - - /// Add \c 1 to stat \c _nb_sgte. - void add_nb_sgte ( void ) { ++_nb_sgte; } - - /// Add \c 1 to stat \c _nb_MFN. - void add_nb_MFN ( void ) { ++_nb_MFN; } - - /// Add \c 1 to stat \c _nb_WP_regression. - void add_nb_WP_regression ( void ) { ++_nb_WP_regression; } - - /// Add \c 1 to stat \c _nb_regression. - void add_nb_regression ( void ) { ++_nb_regression; } - - /// Add \c 1 to stat \c _nb_TGP. - void add_nb_TGP ( void ) { ++_nb_TGP; } - - /// Add \c 1 to stat \c _not_enough_pts. - void add_not_enough_pts ( void ) { ++_not_enough_pts; } - - /// Add \c 1 to stat \c _construction_error. - void add_construction_error ( void ) { ++_construction_error; } - - /// Add \c 1 to stat \c _bad_cond. - void add_bad_cond ( void ) { ++_bad_cond; } - - /// Add \c 1 to stat \c _MS_nb_searches. - void add_MS_nb_searches ( void ) { ++_MS_nb_searches; } - - /// Add \c 1 to stat \c _MS_success. - void add_MS_success ( void ) { ++_MS_success; } - - /// Add \c 1 to stat \c _MS_opt_error. - void add_MS_opt_error ( void ) { ++_MS_opt_error; } - - /// Add \c 1 to stat \c _MS_max_bbe. - void add_MS_max_bbe ( void ) { ++_MS_max_bbe; } - - /// Add \c 1 to stat \c _MS_rejected. - void add_MS_rejected ( void ) { ++_MS_rejected; } - - /// Add an integer to stat \c _MS_pts. - /** - \param i The integer -- \b IN. - */ - void add_MS_pts ( int i ) { _MS_pts += i; } - - /// Add an integer to stat \c _MS_bb_eval. - /** - \param i The integer -- \b IN. - */ - void add_MS_bb_eval ( int i ) { _MS_bb_eval += i; } - - /// Add an integer to stat \c _MS_sgte_eval. - /** - \param i The integer -- \b IN. - */ - void add_MS_sgte_eval ( int i ) { _MS_sgte_eval += i; } - - /// Add an integer to stat \c _MS_cache_hits. - /** - \param i The integer -- \b IN. - */ - void add_MS_cache_hits ( int i ) { _MS_cache_hits += i; } - - /// Access to the number of model searches. - /* - \return The number of model searches. - **/ - int get_MS_nb_searches ( void ) const { return _MS_nb_searches; } - - /// Access to the number of model optimizations. - /* - \return The number of model optimizations. - **/ - int get_MS_nb_opt ( void ) const { return _MS_nb_opt; } - - /// Access to the number of model search points. - /* - \return The number of model search points. - **/ - int get_MS_pts ( void ) const { return _MS_pts; } - - /// Access to the number of model blackbox evaluations. - /* - \return The number of model blackbox evaluations. - **/ - int get_MS_bb_eval ( void ) const { return _MS_bb_eval; } - - /// Access to the number of model search surrogate evaluations. - /* - \return The number of model search surrogate evaluations. - **/ - int get_MS_sgte_eval ( void ) const { return _MS_sgte_eval; } - - /// Access to the number of model search successes. - /* - \return The number of model search successes. - **/ - int get_MS_success ( void ) const { return _MS_success; } - - /// Access to the number of models. - /* - \return The number of models. - **/ - int get_nb_models ( void ) const { return _nb_truth + _nb_sgte; } - - /// Access to stat \c _min_nY. - /** - \return The stat \c _min_nY. - */ - int get_min_nY ( void ) const { return _min_nY; } - - /// Access to stat \c _max_nY. - /** - \return The stat \c _max_nY. - */ - int get_max_nY ( void ) const { return _max_nY; } - - /// Access to the average size of interpolation sets. - /** - \return The average size of interpolation sets. - */ - float get_avg_nY ( void ) const - { - return ( _nb_Y_sets == 0 ) ? 0 : _sum_nY / _nb_Y_sets; - } - - /// Access to stat \c _nb_MFN. - /** - \return \c The stat _nb_MFN. - */ - int get_nb_MFN ( void ) const { return _nb_MFN; } + /// Model stats. + class Model_Stats { + + private: + + int _nb_truth; ///< Number of truth models. + int _nb_sgte; ///< Number of surrogate models. + int _nb_MFN; ///< Number of quadr. MFN models. + int _nb_WP_regression; ///< Number of quadr. well-poised regressions models. + int _nb_regression; ///< Number of quadr. regression_max_nY models. + int _not_enough_pts; ///< Number of too small \c Y sets. + int _nb_Y_sets; ///< Number of \c Y sets. + float _sum_nY; ///< Total number of \c Y points. + int _min_nY; ///< Minimal \c Y size. + int _max_nY; ///< Maximal \c Y size. + int _construction_error; ///< Number of construction errors. + double _construction_time; ///< Models construction CPU time. + double _optimization_time; ///< Models optimization CPU time. + + /// Number of times that \c cond exceeded \c SVD_MAX_COND. + int _bad_cond; + + // model search (MS): + int _MS_nb_searches; ///< Number of searches. + int _MS_pts; ///< Number of search points. + int _MS_success; ///< Number of search successes. + int _MS_bb_eval; ///< Number of search blackbox evaluations. + int _MS_sgte_eval; ///< Number of search surrogate evaluations. + int _MS_cache_hits; ///< Number of search cache hits. + int _MS_rejected; ///< Number of rejected trial points. + int _MS_max_search_pts; ///< Max number of trial points for one search. + int _MS_nb_opt; ///< Number of optimizations. + int _MS_opt_error; ///< Number of optimization errors. + int _MS_avg_model_eval; ///< Avg number of evaluations for a model opt. + int _MS_max_model_eval; ///< Max number of evaluations for a model opt. + int _MS_max_bbe; ///< Number of times model eval. reached limit. + + // eval sort (ES): + int _ES_nb_inside_radius; ///< Total number of points inside radius. + int _ES_nb_pts; ///< Total number of points. + + public: + + /// Constructor. + explicit Model_Stats ( void ) { reset(); } + + /// Copy constructor. + /** + \param s The copied object -- \b IN. + */ + explicit Model_Stats ( const Model_Stats & s ) + : _nb_truth ( s._nb_truth ) , + _nb_sgte ( s._nb_sgte ) , + _nb_MFN ( s._nb_MFN ) , + _nb_WP_regression ( s._nb_WP_regression ) , + _nb_regression ( s._nb_regression ) , + _not_enough_pts ( s._not_enough_pts ) , + _nb_Y_sets ( s._nb_Y_sets ) , + _sum_nY ( s._sum_nY ) , + _min_nY ( s._min_nY ) , + _max_nY ( s._max_nY ) , + _construction_error ( s._construction_error ) , + _construction_time ( s._construction_time ) , + _optimization_time ( s._optimization_time ) , + _bad_cond ( s._bad_cond ) , + _MS_nb_searches ( s._MS_nb_searches ) , + _MS_pts ( s._MS_pts ) , + _MS_success ( s._MS_success ) , + _MS_bb_eval ( s._MS_bb_eval ) , + _MS_sgte_eval ( s._MS_sgte_eval ) , + _MS_cache_hits ( s._MS_cache_hits ) , + _MS_rejected ( s._MS_rejected ) , + _MS_max_search_pts ( s._MS_max_search_pts ) , + _MS_nb_opt ( s._MS_nb_opt ) , + _MS_opt_error ( s._MS_opt_error ) , + _MS_avg_model_eval ( s._MS_avg_model_eval ) , + _MS_max_model_eval ( s._MS_max_model_eval ) , + _MS_max_bbe ( s._MS_max_bbe ) , + _ES_nb_inside_radius ( s._ES_nb_inside_radius ) , + _ES_nb_pts ( s._ES_nb_pts ) {} + + /// Affectation operator. + /** + \param s The right-hand side object -- \b IN. + */ + Model_Stats & operator = ( const Model_Stats & s ); + + /// Destructor. + virtual ~Model_Stats ( void ) {} + + /// Reset the stats. + void reset ( void ); + + /// Update stats from another NOMAD::Model_Stats object. + /** + \param s The other NOMAD::Model_Stats object -- \b IN. + */ + void update ( const Model_Stats & s ); + + /// Update stats on the size of interpolation set \c Y. + /** + \param nY Size of an interpolation set \c Y -- \b IN. + */ + void update_nY ( int nY ); + + /// Update stat \c _MS_max_search_pts. + /** + \param sp Number of trial points for a model search -- \b IN. + */ + void update_MS_max_search_pts ( int sp ); + + /// Update stats \c _MS_nb_opt, \c _MS_max_model_eval, and \c _MS_avg_model_eval. + /** + \param eval Number of model evaluations during one model optimization -- \b IN. + */ + void update_MS_model_opt ( int eval ); + + /// Update model ordering stats. + /** + \param nb_inside_radius Number of points inside radius -- \b IN. + \param nb_pts Number of points -- \b IN. + */ + void update_ES_stats ( int nb_inside_radius , int nb_pts ) + { + _ES_nb_inside_radius += nb_inside_radius; + _ES_nb_pts += nb_pts; + } + + /// Add a real to stat \c _construction_time. + /** + \param t Time -- \b IN. + */ + void add_construction_time ( double t ) { _construction_time += t; } + + /// Add a real to stat \c _optimization_time. + /** + \param t Time -- \b IN. + */ + void add_optimization_time ( double t ) { _optimization_time += t; } + + /// Add \c 1 to stat \c _nb_truth. + void add_nb_truth ( void ) { ++_nb_truth; } + + /// Add \c 1 to stat \c _nb_sgte. + void add_nb_sgte ( void ) { ++_nb_sgte; } + + /// Add \c 1 to stat \c _nb_MFN. + void add_nb_MFN ( void ) { ++_nb_MFN; } + + /// Add \c 1 to stat \c _nb_WP_regression. + void add_nb_WP_regression ( void ) { ++_nb_WP_regression; } + + /// Add \c 1 to stat \c _nb_regression. + void add_nb_regression ( void ) { ++_nb_regression; } + + /// Add \c 1 to stat \c _not_enough_pts. + void add_not_enough_pts ( void ) { ++_not_enough_pts; } + + /// Add \c 1 to stat \c _construction_error. + void add_construction_error ( void ) { ++_construction_error; } + + /// Add \c 1 to stat \c _bad_cond. + void add_bad_cond ( void ) { ++_bad_cond; } + + /// Add \c 1 to stat \c _MS_nb_searches. + void add_MS_nb_searches ( void ) { ++_MS_nb_searches; } + + /// Add \c 1 to stat \c _MS_success. + void add_MS_success ( void ) { ++_MS_success; } + + /// Add \c 1 to stat \c _MS_opt_error. + void add_MS_opt_error ( void ) { ++_MS_opt_error; } + + /// Add \c 1 to stat \c _MS_max_bbe. + void add_MS_max_bbe ( void ) { ++_MS_max_bbe; } + + /// Add \c 1 to stat \c _MS_rejected. + void add_MS_rejected ( void ) { ++_MS_rejected; } + + /// Add an integer to stat \c _MS_pts. + /** + \param i The integer -- \b IN. + */ + void add_MS_pts ( int i ) { _MS_pts += i; } + + /// Add an integer to stat \c _MS_bb_eval. + /** + \param i The integer -- \b IN. + */ + void add_MS_bb_eval ( int i ) { _MS_bb_eval += i; } + + /// Add an integer to stat \c _MS_sgte_eval. + /** + \param i The integer -- \b IN. + */ + void add_MS_sgte_eval ( int i ) { _MS_sgte_eval += i; } + + /// Add an integer to stat \c _MS_cache_hits. + /** + \param i The integer -- \b IN. + */ + void add_MS_cache_hits ( int i ) { _MS_cache_hits += i; } + + /// Access to the number of model searches. + /* + \return The number of model searches. + **/ + int get_MS_nb_searches ( void ) const { return _MS_nb_searches; } + + /// Access to the number of model optimizations. + /* + \return The number of model optimizations. + **/ + int get_MS_nb_opt ( void ) const { return _MS_nb_opt; } + + /// Access to the number of model search points. + /* + \return The number of model search points. + **/ + int get_MS_pts ( void ) const { return _MS_pts; } + + /// Access to the number of model blackbox evaluations. + /* + \return The number of model blackbox evaluations. + **/ + int get_MS_bb_eval ( void ) const { return _MS_bb_eval; } + + /// Access to the number of model search surrogate evaluations. + /* + \return The number of model search surrogate evaluations. + **/ + int get_MS_sgte_eval ( void ) const { return _MS_sgte_eval; } + + /// Access to the number of model search successes. + /* + \return The number of model search successes. + **/ + int get_MS_success ( void ) const { return _MS_success; } + + /// Access to the number of models. + /* + \return The number of models. + **/ + int get_nb_models ( void ) const { return _nb_truth + _nb_sgte; } + + /// Access to stat \c _min_nY. + /** + \return The stat \c _min_nY. + */ + int get_min_nY ( void ) const { return _min_nY; } + + /// Access to stat \c _max_nY. + /** + \return The stat \c _max_nY. + */ + int get_max_nY ( void ) const { return _max_nY; } + + /// Access to the average size of interpolation sets. + /** + \return The average size of interpolation sets. + */ + float get_avg_nY ( void ) const + { + return ( _nb_Y_sets == 0 ) ? 0 : _sum_nY / _nb_Y_sets; + } + + /// Access to stat \c _nb_MFN. + /** + \return \c The stat _nb_MFN. + */ + int get_nb_MFN ( void ) const { return _nb_MFN; } + + /// Access to stat \c _nb_WP_regression. + /** + \return \c The stat _nb_WP_regression. + */ + int get_nb_WP_regression ( void ) const { return _nb_WP_regression; } + + /// Access to stat \c _nb_regression. + /** + \return \c The stat _nb_regression. + */ + int get_nb_regression ( void ) const { return _nb_regression; } + + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display ( const NOMAD::Display & out ) const; + }; - /// Access to stat \c _nb_WP_regression. - /** - \return \c The stat _nb_WP_regression. - */ - int get_nb_WP_regression ( void ) const { return _nb_WP_regression; } - - /// Access to stat \c _nb_regression. - /** - \return \c The stat _nb_regression. - */ - int get_nb_regression ( void ) const { return _nb_regression; } - - /// Access to stat \c _nb_TGP. + /// Display a NOMAD::Model_Stats object. /** - \return \c The stat _nb_TGP. - */ - int get_nb_TGP ( void ) const { return _nb_TGP; } - - /// Display. - /** - \param out The NOMAD::Display object -- \b IN. - */ - void display ( const NOMAD::Display & out ) const; - }; - - /// Display a NOMAD::Model_Stats object. - /** \param out The NOMAD::Display object -- \b IN. \param s The NOMAD::Model_Stats object to be displayed -- \b IN. \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Model_Stats & s ) { - s.display ( out ); - return out; - } + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::Model_Stats & s ) + { + s.display ( out ); + return out; + } } #endif diff --git a/src/Multi_Obj_Evaluator.cpp b/src/Multi_Obj_Evaluator.cpp index 89c5bfe23b45ebcbbb4dcfb081e1ef0b365e19fd..9fdcf133a682c61f493eb66e584357924612015f 100644 --- a/src/Multi_Obj_Evaluator.cpp +++ b/src/Multi_Obj_Evaluator.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Multi_Obj_Evaluator.cpp - \brief NOMAD::Evaluator subclass for multiobjective optimization (implementation) - \author Sebastien Le Digabel - \date 2010-04-09 - \see Multi_Obj_Evaluator.hpp -*/ + \file Multi_Obj_Evaluator.cpp + \brief NOMAD::Evaluator subclass for multiobjective optimization (implementation) + \author Sebastien Le Digabel + \date 2010-04-09 + \see Multi_Obj_Evaluator.hpp + */ #include "Multi_Obj_Evaluator.hpp" /*-----------------------------------*/ @@ -54,15 +61,15 @@ int NOMAD::Multi_Obj_Evaluator::_i2 = -1; /*---------------------------------------*/ void NOMAD::Multi_Obj_Evaluator::set_obj_indexes ( const std::list<int> & index_obj ) { - if ( index_obj.size() != 2 ) - throw NOMAD::Exception ( "Multi_Obj_Evaluator.cpp" , __LINE__ , - "Multi_Obj_Evaluator defined with a number of indexes different than two" ); - - std::list<int>::const_iterator it = index_obj.begin(); - - NOMAD::Multi_Obj_Evaluator::_i1 = *it; - it++; - NOMAD::Multi_Obj_Evaluator::_i2 = *it; + if ( index_obj.size() != 2 ) + throw NOMAD::Exception ( "Multi_Obj_Evaluator.cpp" , __LINE__ , + "Multi_Obj_Evaluator defined with a number of indexes different than two" ); + + std::list<int>::const_iterator it = index_obj.begin(); + + NOMAD::Multi_Obj_Evaluator::_i1 = *it; + it++; + NOMAD::Multi_Obj_Evaluator::_i2 = *it; } /*-------------------------------------------------------------*/ @@ -71,98 +78,106 @@ void NOMAD::Multi_Obj_Evaluator::set_obj_indexes ( const std::list<int> & index_ /*-------------------------------------------------------------*/ void NOMAD::Multi_Obj_Evaluator::compute_f ( NOMAD::Eval_Point & x ) const { - if ( _i1 < 0 || _i2 < 0 ) - throw NOMAD::Exception ( "Multi_Obj_Evaluator.cpp" , __LINE__ , - "Multi_Obj_Evaluator::compute_f(): no objective indexes defined" ); - - int obj_index [2]; - obj_index[0] = _i1; - obj_index[1] = _i2; - - const NOMAD::Point & bbo = x.get_bb_outputs(); - - // a reference is available: - if ( _ref ) - { - - NOMAD::multi_formulation_type mft = _p.get_multi_formulation(); - - if ( mft == NOMAD::UNDEFINED_FORMULATION ) - throw NOMAD::Exception ( "Multi_Obj_Evaluator.cpp" , __LINE__ , - "Multi_Obj_Evaluator::compute_f(): no formulation type is defined" ); - - // normalized formulation: - if ( mft == NOMAD::NORMALIZED || mft == NOMAD::DIST_LINF ) { - - // f1 - r1: - NOMAD::Double d = bbo[obj_index[0]] - (*_ref)[0]; - - // f2 - r2: - NOMAD::Double f2mr2 = bbo[obj_index[1]] - (*_ref)[1]; - - // we take the max: - if ( f2mr2 > d ) - d = f2mr2; - - x.set_f ( d ); - } - - // product formulation: - else if ( mft == NOMAD::PRODUCT ) { - - NOMAD::Double prod = 1.0 , ri , fi; - - for ( int i = 0 ; i < 2 ; ++i ) { - - ri = (*_ref)[i]; - fi = bbo[obj_index[i]]; - - if ( fi > ri ) { - prod = 0.0; - break; - } - prod = prod * (ri-fi).pow2(); - } - - x.set_f ( -prod ); - } - - // distance formulation: - else { - - NOMAD::Double d; - NOMAD::Double r1mf1 = (*_ref)[0] - bbo[obj_index[0]]; - NOMAD::Double r2mf2 = (*_ref)[1] - bbo[obj_index[1]]; - - if ( r1mf1 >= 0.0 && r2mf2 >= 0.0 ) { - d = r1mf1.pow2(); - NOMAD::Double tmp = r2mf2.pow2(); - if ( tmp < d ) - d = tmp; - d = -d; - } - else if ( r1mf1 <= 0.0 && r2mf2 <= 0.0 ) { - - // with L2 norm: - if ( mft == NOMAD::DIST_L2 ) - d = r1mf1.pow2() + r2mf2.pow2(); - - // with L1 norm: - else - d = (r1mf1.abs() + r2mf2.abs()).pow2(); - - // Linf norm: treated as NORMALIZED - } - else if ( r1mf1 > 0.0 ) - d = r2mf2.pow2(); - else - d = r1mf1.pow2(); - - x.set_f ( d ); - } - } + if ( _i1 < 0 || _i2 < 0 ) + throw NOMAD::Exception ( "Multi_Obj_Evaluator.cpp" , __LINE__ , + "Multi_Obj_Evaluator::compute_f(): no objective indexes defined" ); + + int obj_index [2]; + obj_index[0] = _i1; + obj_index[1] = _i2; + + const NOMAD::Point & bbo = x.get_bb_outputs(); + + // a reference is available: + if ( _ref ) + { + + NOMAD::multi_formulation_type mft = _p.get_multi_formulation(); + + if ( mft == NOMAD::UNDEFINED_FORMULATION ) + throw NOMAD::Exception ( "Multi_Obj_Evaluator.cpp" , __LINE__ , + "Multi_Obj_Evaluator::compute_f(): no formulation type is defined" ); + + // normalized formulation: + if ( mft == NOMAD::NORMALIZED || mft == NOMAD::DIST_LINF ) + { + + // f1 - r1: + NOMAD::Double d = bbo[obj_index[0]] - (*_ref)[0]; + + // f2 - r2: + NOMAD::Double f2mr2 = bbo[obj_index[1]] - (*_ref)[1]; + + // we take the max: + if ( f2mr2 > d ) + d = f2mr2; + + x.set_f ( d ); + } + + // product formulation: + else if ( mft == NOMAD::PRODUCT ) + { + + NOMAD::Double prod = 1.0 , ri , fi; + + for ( int i = 0 ; i < 2 ; ++i ) + { + + ri = (*_ref)[i]; + fi = bbo[obj_index[i]]; + + if ( fi > ri ) + { + prod = 0.0; + break; + } + prod = prod * (ri-fi).pow2(); + } + + x.set_f ( -prod ); + } + + // distance formulation: + else + { + + + NOMAD::Double d; + NOMAD::Double r1mf1 = (*_ref)[0] - bbo[obj_index[0]]; + NOMAD::Double r2mf2 = (*_ref)[1] - bbo[obj_index[1]]; + + if ( r1mf1 >= 0.0 && r2mf2 >= 0.0 ) + { + d = r1mf1.pow2(); + NOMAD::Double tmp = r2mf2.pow2(); + if ( tmp < d ) + d = tmp; + d = -d; + } + else if ( r1mf1 <= 0.0 && r2mf2 <= 0.0 ) + { + + // with L2 norm: + if ( mft == NOMAD::DIST_L2 ) + d = r1mf1.pow2() + r2mf2.pow2(); + + // with L1 norm: + else + d = (r1mf1.abs() + r2mf2.abs()).pow2(); + + // Linf norm: treated as NORMALIZED + } + else if ( r1mf1 > 0.0 ) + d = r2mf2.pow2(); + else + d = r1mf1.pow2(); + + x.set_f ( d ); + } + } - // no reference is available (use weights): - else - x.set_f ( _w1 * bbo[obj_index[0]] + _w2 * bbo[obj_index[1]] ); + // no reference is available (use weights): + else + x.set_f ( _w1 * bbo[obj_index[0]] + _w2 * bbo[obj_index[1]] ); } diff --git a/src/Multi_Obj_Evaluator.hpp b/src/Multi_Obj_Evaluator.hpp index 522cb4f8780707249730e230cc6ddc4ed27decfc..155be5e7f28a199f93c88a6ac4d049d21f97dd9b 100644 --- a/src/Multi_Obj_Evaluator.hpp +++ b/src/Multi_Obj_Evaluator.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,107 +41,113 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Multi_Obj_Evaluator.hpp - \brief NOMAD::Evaluator subclass for multiobjective optimization (headers) - \author Sebastien Le Digabel - \date 2010-04-20 - \see Multi_Obj_Evaluator.cpp -*/ + \file Multi_Obj_Evaluator.hpp + \brief NOMAD::Evaluator subclass for multiobjective optimization (headers) + \author Sebastien Le Digabel + \date 2010-04-20 + \see Multi_Obj_Evaluator.cpp + */ #ifndef __MULTI_OBJ_EVALUATOR__ #define __MULTI_OBJ_EVALUATOR__ #include "Phase_One_Evaluator.hpp" namespace NOMAD { - - /// NOMAD::Evaluator subclass for multiobjective optimization. - /** - Version for two objective functions. - */ - class Multi_Obj_Evaluator : public NOMAD::Evaluator { - - private: - - static int _i1; ///< Index of the first objective. - static int _i2; ///< Index of the second objective. - - NOMAD::Double _w1; ///< Weight on the first objective function. - NOMAD::Double _w2; ///< Weight on the second objective function. - - const NOMAD::Point * _ref; ///< Reference point. - - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - */ - Multi_Obj_Evaluator ( const NOMAD::Parameters & p ) - : NOMAD::Evaluator ( p ) , - _w1 ( 1.0 ) , - _w2 ( 0.0 ) , - _ref ( NULL ) { _is_multi_obj = true; } - - /// Destructor. - virtual ~Multi_Obj_Evaluator ( void ) {} - - /// Initialization of objective indexes. - /** - \param index_obj List of objective indexes -- \b IN. - */ - static void set_obj_indexes ( const std::list<int> & index_obj ); - - /// Updates after a MADS run. - /** - This virtual method is called every time a MADS run is terminated. - \param stats Stats -- \b IN. - \param ev_control Evaluator control -- \b IN. - \param true_barrier Barrier for true functions -- \b IN. - \param sgte_barrier Barrier for surrogate functions -- \b IN. - \param pareto_front Pareto front -- \b IN. - */ - virtual void update_mads_run ( const NOMAD::Stats & stats , - const NOMAD::Evaluator_Control & ev_control , - const NOMAD::Barrier & true_barrier , - const NOMAD::Barrier & sgte_barrier , - const NOMAD::Pareto_Front & pareto_front ) {} - - /// Compute \c f(x) from the blackbox outputs of a point. + + /// NOMAD::Evaluator subclass for multiobjective optimization. /** - - Bi-objective version. - - Computation of \c f taking into account the two objectives + Version for two objective functions. + */ + class Multi_Obj_Evaluator : public NOMAD::Evaluator { + + private: + + static int _i1; ///< Index of the first objective. + static int _i2; ///< Index of the second objective. + + NOMAD::Double _w1; ///< Weight on the first objective function. + NOMAD::Double _w2; ///< Weight on the second objective function. + + const NOMAD::Point * _ref; ///< Reference point. + + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + */ + Multi_Obj_Evaluator ( const NOMAD::Parameters & p ) + : NOMAD::Evaluator ( p ) , + _w1 ( 1.0 ) , + _w2 ( 0.0 ) , + _ref ( NULL ) { _is_multi_obj = true; } + + /// Destructor. + virtual ~Multi_Obj_Evaluator ( void ) {} + + /// Initialization of objective indexes. + /** + \param index_obj List of objective indexes -- \b IN. + */ + static void set_obj_indexes ( const std::list<int> & index_obj ); + + /// Updates after a MADS run. + /** + This virtual method is called every time a MADS run is terminated. + \param stats Stats -- \b IN. + \param ev_control Evaluator control -- \b IN. + \param true_barrier Barrier for true functions -- \b IN. + \param sgte_barrier Barrier for surrogate functions -- \b IN. + \param pareto_front Pareto front -- \b IN. + */ + virtual void update_mads_run ( const NOMAD::Stats & stats , + const NOMAD::Evaluator_Control & ev_control , + const NOMAD::Barrier & true_barrier , + const NOMAD::Barrier & sgte_barrier , + const NOMAD::Pareto_Front & pareto_front ) {} + + /// Compute \c f(x) from the blackbox outputs of a point. + /** + - Bi-objective version. + - Computation of \c f taking into account the two objectives with a reformulation based on a reference point, or with weights when no reference is available. - \param x The evaluation point -- \b IN/OUT. - */ - virtual void compute_f ( NOMAD::Eval_Point & x ) const; - - /// Get the index of the first objective function. - /** - \return The index of the first objective function. - */ - static int get_i1 ( void ) { return _i1; } - - /// Get the index of the second objective function. - /** - \return The index of the second objective function. - */ - static int get_i2 ( void ) { return _i2; } - - /// Set the weights. - /** - \param w1 Weight on the first objective function -- \b IN. - \param w2 Weight on the second objective function -- \b IN. - */ - void set_weights ( const NOMAD::Double & w1 , - const NOMAD::Double & w2 ) { _w1 = w1; _w2 = w2; } - - /// Set the reference point. - /** - \param ref A pointer to the reference point -- \b IN. - */ - void set_ref ( const NOMAD::Point * ref ) { _ref = ref; } - }; + \param x The evaluation point -- \b IN/OUT. + */ + virtual void compute_f ( NOMAD::Eval_Point & x ) const; + + /// Get the index of the first objective function. + /** + \return The index of the first objective function. + */ + static int get_i1 ( void ) { return _i1; } + + /// Get the index of the second objective function. + /** + \return The index of the second objective function. + */ + static int get_i2 ( void ) { return _i2; } + + /// Set the weights. + /** + \param w1 Weight on the first objective function -- \b IN. + \param w2 Weight on the second objective function -- \b IN. + */ + void set_weights ( const NOMAD::Double & w1 , + const NOMAD::Double & w2 ) + { + _w1 = w1; + _w2 = w2; + } + + /// Set the reference point. + /** + \param ref A pointer to the reference point -- \b IN. + */ + void set_ref ( const NOMAD::Point * ref ) { _ref = ref; } + + + }; } #endif diff --git a/src/Multi_Obj_Quad_Model_Evaluator.hpp b/src/Multi_Obj_Quad_Model_Evaluator.hpp index 932fa5abe6a3905c4b4737eca156e805978b23d9..c59b5f4e36e05246295adf9c00d66d99b7d9f521 100644 --- a/src/Multi_Obj_Quad_Model_Evaluator.hpp +++ b/src/Multi_Obj_Quad_Model_Evaluator.hpp @@ -1,7 +1,8 @@ + /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ +/* Copyright (C) 2001-2015 Mark Abramson - Brigham Young University, Provo */ /* Charles Audet - Ecole Polytechnique, Montreal */ /* Gilles Couture - Ecole Polytechnique, Montreal */ /* John Dennis - Rice University, Houston */ @@ -36,7 +37,7 @@ /** \file Multi_Obj_Quad_Model_Evaluator.hpp \brief NOMAD::Mulit_Obj_Evaluator subclass for quadratic model optimization (headers) - \author Christophe Tribes + \author Christophe Tribes \date 2014-06-19 \see Multi_Obj_Quad_Model_Evaluator.cpp */ @@ -47,36 +48,36 @@ #include "Multi_Obj_Evaluator.hpp" namespace NOMAD { - - /// Bi-objective NOMAD::Evaluator subclass for quadratic model. - class Multi_Obj_Quad_Model_Evaluator : public NOMAD::Quad_Model_Evaluator, public NOMAD::Multi_Obj_Evaluator { - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - \param model Model -- \b IN. - */ - Multi_Obj_Quad_Model_Evaluator ( const NOMAD::Parameters & p , - const NOMAD::Quad_Model & model ) : NOMAD::Quad_Model_Evaluator(p,model),NOMAD::Multi_Obj_Evaluator(p) {_is_model_evaluator=true;} - - /// Destructor. - virtual ~Multi_Obj_Quad_Model_Evaluator ( void ){;} - - - /// Evaluate the blackboxes quad model at a given trial point - /** - \param x point to evaluate -- \b IN/OUT. - \param h_max h_max for barrier -- \b IN. - \param count_eval Count eval if true -- \b IN. - \return A boolean equal to \c false if the evaluation failed. - */ - virtual bool eval_x ( NOMAD::Eval_Point & x , - const NOMAD::Double & h_max , - bool & count_eval ) const {return Quad_Model_Evaluator::eval_x(x,h_max,count_eval);} - - - }; + + /// Bi-objective NOMAD::Evaluator subclass for quadratic model. + class Multi_Obj_Quad_Model_Evaluator : public NOMAD::Quad_Model_Evaluator, public NOMAD::Multi_Obj_Evaluator { + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + \param model Model -- \b IN. + */ + Multi_Obj_Quad_Model_Evaluator ( const NOMAD::Parameters & p , + const NOMAD::Quad_Model & model ) : NOMAD::Quad_Model_Evaluator(p,model),NOMAD::Multi_Obj_Evaluator(p) {_is_model_evaluator=true;} + + /// Destructor. + virtual ~Multi_Obj_Quad_Model_Evaluator ( void ){;} + + + /// Evaluate the blackboxes quad model at a given trial point + /** + \param x point to evaluate -- \b IN/OUT. + \param h_max h_max for barrier -- \b IN. + \param count_eval Count eval if true -- \b IN. + \return A boolean equal to \c false if the evaluation failed. + */ + virtual bool eval_x ( NOMAD::Eval_Point & x , + const NOMAD::Double & h_max , + bool & count_eval ) const {return Quad_Model_Evaluator::eval_x(x,h_max,count_eval);} + + + }; } #endif diff --git a/src/OrthogonalMesh.cpp b/src/OrthogonalMesh.cpp index 1c7331aea1444bbe891c17b523d05cb7967acc3d..d0a0e60a4dbcc79b32b7299fd84515f209cebfd2 100644 --- a/src/OrthogonalMesh.cpp +++ b/src/OrthogonalMesh.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -44,69 +51,80 @@ #include "OrthogonalMesh.hpp" /// Constructor (called only by derived objects). -NOMAD::OrthogonalMesh::OrthogonalMesh (const NOMAD::Point & Delta_0 , - const NOMAD::Point & Delta_min , - const NOMAD::Point & delta_min , - const NOMAD::Point & fixed_variables , - NOMAD::Double update_basis, - int coarsening_step, - int refining_step, - int limit_mesh_index ) : -_delta_0 ( Delta_0 ), -_Delta_0 ( Delta_0 ), -_Delta_min ( Delta_min ), -_delta_min ( delta_min ), -_update_basis ( update_basis ), -_coarsening_step ( coarsening_step ), -_refining_step ( refining_step ), +NOMAD::OrthogonalMesh::OrthogonalMesh (bool anisotropic_mesh , + const NOMAD::Point & Delta_0 , + const NOMAD::Point & Delta_min , + const NOMAD::Point & delta_min , + const NOMAD::Point & fixed_variables , + const NOMAD::Point & granularity , + NOMAD::Double update_basis , + int coarsening_step , + int refining_step , + int limit_mesh_index ) : +_delta_0 ( Delta_0 ), +_Delta_0 ( Delta_0 ), +_Delta_min ( Delta_min ), +_delta_min ( delta_min ), +_fixed_variables ( fixed_variables ), +_granularity ( granularity ), +_anisotropic_mesh ( anisotropic_mesh ), +_update_basis ( update_basis ), +_coarsening_step ( coarsening_step ), +_refining_step ( refining_step ), _limit_mesh_index ( limit_mesh_index ) { - - _Delta_min_is_defined=_Delta_min.is_defined(); - _Delta_min_is_complete=_Delta_min.is_complete(); - bool chkMesh = delta_min.is_defined(); - bool chkPoll = _Delta_min_is_defined; - _n = Delta_0.size(); + _Delta_min_is_defined = _Delta_min.is_defined(); + _Delta_min_is_complete = _Delta_min.is_complete(); - _n_free_variables = _n - fixed_variables.nb_defined(); + _delta_min_is_defined = _delta_min.is_defined(); + _delta_min_is_complete = _delta_min.is_complete(); - // The delta_0 are decreased - _delta_0*=pow(_n_free_variables,-0.5); + _n = Delta_0.size(); + + _n_free_variables = _n - _fixed_variables.nb_defined(); + + if ( _granularity.is_defined() && ( ! _granularity.is_complete() || _granularity.size() != _n ) ) + throw NOMAD::Exception ( "OrthogonalMesh.hpp" , __LINE__ , + "NOMAD::OrthogonalMesh::OrthogonalMesh(): granularity has undefined values" ); if ( !_Delta_0.is_complete() ) throw NOMAD::Exception ( "OrthogonalMesh.hpp" , __LINE__ , "NOMAD::OrthogonalMesh::OrthogonalMesh(): delta_0 has undefined values" ); - if ( chkMesh && delta_min.size() != _n ) + if ( _delta_min_is_defined && delta_min.size() != _n ) throw NOMAD::Exception ( "OrthogonalMesh.hpp" , __LINE__ , "NOMAD::OrthogonalMesh::OrthogonalMesh(): delta_0 and delta_min have different sizes" ); - if ( chkPoll && Delta_min.size() != _n ) + if ( _Delta_min_is_defined && Delta_min.size() != _n ) throw NOMAD::Exception ( "OrthogonalMesh.hpp" , __LINE__ , "NOMAD::OrthogonalMesh::OrthogonalMesh(): Delta_0 and Delta_min have different sizes" ); std::string error; + _all_granular = ( _granularity.is_defined() && _granularity.is_complete() ) ? true:false ; for ( int k = 0 ; k < _n ; ++k ) { // we check that Delta_min <= Delta_0 and that delta_min <= delta_0: - if ( chkMesh && - _delta_min[k].is_defined() && - _delta_0[k] < _delta_min[k] ) + if ( _delta_min_is_defined && + _delta_min[k].is_defined() && + _delta_0[k] < _delta_min[k] ) { error = "NOMAD::OrthogonalMesh::OrthogonalMesh(): delta_0 < delta_min"; break; } - if ( chkPoll && - _Delta_min[k].is_defined() && + if ( _Delta_min_is_defined && + _Delta_min[k].is_defined() && _Delta_0[k] < _Delta_min[k] ) { error = "NOMAD::OrthogonalMesh::OrthogonalMesh(): Delta_0 < Delta_min"; break; } + if ( _all_granular && _granularity[k] == 0 ) + _all_granular = false; + } if ( !error.empty() ) @@ -137,42 +155,88 @@ void NOMAD::OrthogonalMesh::set_min_mesh_sizes ( const NOMAD::Point & delta_min if ( ! delta_min.is_defined() ) { _delta_min.clear(); + _delta_min_is_defined = false; + _delta_min_is_complete = false; return; } - // If delta_min defined test that everything is consistent + // Test that given delta_min is valid if ( delta_min.size() != _n ) - throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , - "NOMAD::OrthogonalMesh::set_min_mesh_sizes() delta_min has dimension different than mesh dimension" ); + throw NOMAD::Exception ( "OrthogonalMesh.cpp" , __LINE__ , + "set_min_mesh_sizes() delta_min has dimension different than mesh dimension" ); - if ( !delta_min.is_complete() ) + if ( ! delta_min.is_complete() ) throw NOMAD::Exception ( "OrthogonalMesh.hpp" , __LINE__ , - "NOMAD::OrthogonalMesh::set_min_mesh_sizes(): delta_min has some defined and undefined values" ); + "set_min_mesh_sizes(): delta_min has some defined and undefined values" ); + + _delta_min.reset(_n); + _delta_min_is_defined = true; + _delta_min_is_complete = true; + _delta_min=delta_min; std::string error; for ( int k = 0 ; k < _n ; ++k ) { // we check that Delta_min <= Delta_0 and that delta_min <= delta_0: - if ( delta_min[k].is_defined() && - _delta_0[k] < delta_min[k] ) + if ( delta_min[k].is_defined() && + _delta_0[k] < delta_min[k] ) { - error = "NOMAD::OrthogonalMesh::set_delta_min(): delta_0 < delta_min"; - break; + _delta_min[k]=_delta_0[k]; } - if ( delta_min[k].is_defined() && + if ( delta_min[k].is_defined() && _Delta_0[k] < delta_min[k] ) { - error = "NOMAD::OrthogonalMesh::set_delta_min(): Delta_0 < delta_min"; - break; + _delta_min[k]=_Delta_0[k]; } } if ( !error.empty() ) - throw NOMAD::Exception ( "OrthogonalMesh.hpp" , __LINE__ , error ); + throw NOMAD::Exception ( "OrthogonalMesh.cpp" , __LINE__ , error ); - _delta_min=delta_min; + +} + + +/// Manually set the min poll size per coordinate. +void NOMAD::OrthogonalMesh::set_min_poll_sizes ( const NOMAD::Point & Delta_min ) +{ + + // If Delta_min undefined than _Delta_min->undefined + if ( ! Delta_min.is_defined() ) + { + _Delta_min.clear(); + _Delta_min_is_defined = false; + _Delta_min_is_complete = false; + return; + } + + // Test that given Delta_min is valid + if ( Delta_min.size() != _n ) + throw NOMAD::Exception ( "OrthogonalMesh.cpp" , __LINE__ , + "set_min_poll_sizes() Delta_min has dimension different than mesh dimension" ); + + // Test that the given Delta_min is complete + if ( ! Delta_min.is_complete() ) + throw NOMAD::Exception ( "OrthogonalMesh.hpp" , __LINE__ , + "set_min_poll_sizes(): Delta_min has some defined and undefined values" ); + + _Delta_min.reset( _n ); + _Delta_min = Delta_min; + _Delta_min_is_defined = true; + _Delta_min_is_complete = true; + + std::string error; + for ( int k = 0 ; k < _n ; ++k ) + { + // we check that Delta_min <= Delta_0 : + if ( Delta_min[k].is_defined() && _Delta_0[k] < Delta_min[k] ) + _Delta_min[k]=_Delta_0[k]; + } + + if ( !error.empty() ) + throw NOMAD::Exception ( "OrthogonalMesh.cpp" , __LINE__ , error ); } diff --git a/src/OrthogonalMesh.hpp b/src/OrthogonalMesh.hpp index 5971ae5ea03e931d42fce8e58c5f1cbda63e8943..92887d90b59310f1590abdc1a8368b32828a1d93 100644 --- a/src/OrthogonalMesh.hpp +++ b/src/OrthogonalMesh.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file OrthogonalMesh.hpp - \brief Virtual class for the MADS orthogonal meshes (headers) - \author Christophe Tribes - \date 2010-04-06 - \see Mesh.cpp XMesh.cpp -*/ + \file OrthogonalMesh.hpp + \brief Virtual class for the MADS orthogonal meshes (headers) + \author Christophe Tribes + \date 2010-04-06 + \see Mesh.cpp XMesh.cpp + */ #ifndef __ORTHOGONALMESH__ #define __ORTHOGONALMESH__ @@ -47,338 +54,366 @@ #include "Direction.hpp" namespace NOMAD { - - /// Virtual class for the MADS orthogonal meshes. - /** + + /// Virtual class for the MADS orthogonal meshes. + /** - An orthogonal mesh in NOMAD is defined with the basic orthogonal directions the - mesh size parameter delta^k. + mesh size parameter delta^k. - The poll size parameter Delta^k is not used to define the mesh but - to define the poll trial points. + to define the poll trial points. - At each MADS iteration the mesh is updated. - Mesh and poll size parameters are stored as NOMAD::Point objects. - */ - class OrthogonalMesh { - - /*--------------------------------------------------------------*/ - private: - - - /*--------------------------------------------------------------*/ - - /// Private affectation operator. - /** - \param m The right-hand side object -- \b IN. - */ - const OrthogonalMesh & operator = ( const OrthogonalMesh & m ); - - - /*--------------------------------------------------------------*/ - protected: - - - NOMAD::Point _delta_0; - NOMAD::Point _Delta_0; - NOMAD::Point _Delta_min; - NOMAD::Point _delta_min; - - - NOMAD::Double _update_basis; - int _coarsening_step; - int _refining_step ; - - int _n; + - A mesh index is mapped to the mesh and poll sizes. + */ + class OrthogonalMesh { + + /*--------------------------------------------------------------*/ + private: + + + /*--------------------------------------------------------------*/ + + /// Private affectation operator. + /** + \param m The right-hand side object -- \b IN. + */ + const OrthogonalMesh & operator = ( const OrthogonalMesh & m ); + + + /*--------------------------------------------------------------*/ + protected: + + + NOMAD::Point _delta_0; + NOMAD::Point _Delta_0; + NOMAD::Point _Delta_min; + NOMAD::Point _delta_min; + NOMAD::Point _fixed_variables; + NOMAD::Point _granularity; + + bool _anisotropic_mesh; + bool _all_granular; bool _Delta_min_is_defined; bool _Delta_min_is_complete; + bool _delta_min_is_defined; + bool _delta_min_is_complete; + + NOMAD::Double _update_basis; + int _coarsening_step; + int _refining_step ; + + int _n; int _n_free_variables; int _limit_mesh_index; // Limit max or min of the mesh index for fine mesh (SMesh->max, XMesh->min) - - /// Constructor (called only by derived objects). - /** - \param Delta_0 Initial poll size Delta_0 -- \b IN. - \param Delta_min Minimal poll size Delta_min (may be undefined) -- \b IN. - \param delta_min Minimal mesh size delta_min (may be undefined) -- \b IN. - \param fixed_variables Fixed variables -- \b IN. - \param update_basis Mesh/poll update basis (tau) -- \b IN. - \param coarsening_step Mesh/poll coarsening exponent (w+) -- \b IN. - \param refining_step Mesh/poll refining exponent (w-) -- \b IN. - \param limit_mesh_index Limit mesh index to trigger stopping criterion -- \b IN. - */ - OrthogonalMesh (const NOMAD::Point & Delta_0 , - const NOMAD::Point & Delta_min , - const NOMAD::Point & delta_min , - const NOMAD::Point & fixed_variables , - NOMAD::Double update_basis, - int coarsening_step, - int refining_step, - int limit_mesh_index ) ; - - - /// Copy constructor (called only by derived objects). - /** - \param m The copied object -- \b IN. - */ - OrthogonalMesh ( const OrthogonalMesh & m ) - : _delta_0 ( m._delta_0 ), - _Delta_0 ( m._Delta_0 ), - _Delta_min ( m._Delta_min ), - _delta_min ( m._delta_min ), - _update_basis ( m._update_basis ), - _coarsening_step ( m._coarsening_step ), - _refining_step ( m._refining_step ), - _n ( m._n ), - _Delta_min_is_defined ( m._Delta_min_is_defined ), - _Delta_min_is_complete ( m._Delta_min_is_complete ), - _n_free_variables ( m._n_free_variables ), - _limit_mesh_index ( m._limit_mesh_index){} - - - /*--------------------------------------------------------------*/ - public: - - - /// Destructor. - virtual ~OrthogonalMesh ( void ){;} - - - /// Update the Mesh (poll and mesh sizes). - /** - \param success Type of success of the iteration -- \b IN. - \param dir Direction of the iteration (optional) -- \b IN. - */ - virtual void update ( NOMAD::success_type success, const NOMAD::Direction * dir=NULL) = 0; - - - /// Update the provided mesh indices (the Mesh is unchanged). - /** - \param success Type of success of the iteration -- \b IN. - \param mesh_indices Provided mesh indices for update -- \b IN/OUT. - \param dir Direction of the iteration (optional) -- \b IN. - */ - virtual void update ( NOMAD::success_type success, NOMAD::Point & mesh_indices, const NOMAD::Direction * dir=NULL ) const = 0; - - - - /// Reset the Mesh to its original sizes (poll and mesh sizes). - virtual void reset ( void ) = 0; - - - /// Access to the initial mesh size. - /** - \return A NOMAD::Point for the initial mesh size. - */ - const NOMAD::Point & get_initial_mesh_size ( void ) const { return _delta_0; } + + /// Constructor (called only by derived objects). + /** + \param anisotropic_mesh Anisotropy of the mesh (true or false) -- \b IN. + \param Delta_0 Initial poll size Delta_0 -- \b IN. + \param Delta_min Minimal poll size Delta_min (may be undefined) -- \b IN. + \param delta_min Minimal mesh size delta_min (may be undefined) -- \b IN. + \param fixed_variables Fixed variables -- \b IN. + \param granularity Granularity of variables -- \b IN. + \param update_basis Mesh/poll update basis (tau) -- \b IN. + \param coarsening_step Mesh/poll coarsening exponent (w+) -- \b IN. + \param refining_step Mesh/poll refining exponent (w-) -- \b IN. + \param limit_mesh_index Limit mesh index to trigger stopping criterion -- \b IN. + */ + OrthogonalMesh (bool anisotropic_mesh , + const NOMAD::Point & Delta_0 , + const NOMAD::Point & Delta_min , + const NOMAD::Point & delta_min , + const NOMAD::Point & fixed_variables , + const NOMAD::Point & granularity , + NOMAD::Double update_basis, + int coarsening_step, + int refining_step, + int limit_mesh_index ) ; + + + /// Copy constructor (called only by derived objects). + /** + \param m The copied object -- \b IN. + */ + OrthogonalMesh ( const OrthogonalMesh & m ) + : + _delta_0 ( m._delta_0 ), + _Delta_0 ( m._Delta_0 ), + _Delta_min ( m._Delta_min ), + _delta_min ( m._delta_min ), + _fixed_variables ( m._fixed_variables ), + _granularity ( m._granularity ), + _anisotropic_mesh ( m._anisotropic_mesh ), + _Delta_min_is_defined ( m._Delta_min_is_defined ), + _Delta_min_is_complete ( m._Delta_min_is_complete ), + _delta_min_is_defined ( m._delta_min_is_defined ), + _delta_min_is_complete ( m._delta_min_is_complete ), + _update_basis ( m._update_basis ), + _coarsening_step ( m._coarsening_step ), + _refining_step ( m._refining_step ), + _n ( m._n ), + _n_free_variables ( m._n_free_variables ), + _limit_mesh_index ( m._limit_mesh_index ){} + + + /*--------------------------------------------------------------*/ + public: + + + /// Destructor. + virtual ~OrthogonalMesh ( void ){;} + + + /// Update the Mesh (poll and mesh sizes). + /** + \param success Type of success of the iteration -- \b IN. + \param dir Direction of the iteration (optional) -- \b IN. + */ + virtual void update ( NOMAD::success_type success, const NOMAD::Direction * dir=NULL) = 0; + + + /// Update the provided mesh indices (the Mesh is unchanged). + /** + \param success Type of success of the iteration -- \b IN. + \param mesh_indices Provided mesh indices for update -- \b IN/OUT. + \param dir Direction of the iteration (optional) -- \b IN. + */ + virtual void update ( NOMAD::success_type success, NOMAD::Point & mesh_indices, + const NOMAD::Direction * dir=NULL ) const = 0; + + + + /// Reset the Mesh to its original sizes (poll and mesh sizes). + virtual void reset ( void ) = 0; + + + /// Access to the initial mesh size. + /** + \return A NOMAD::Point for the initial mesh size. + */ + const NOMAD::Point & get_initial_mesh_size ( void ) const { return _delta_0; } /// Access to the initial poll size. /** \return A NOMAD::Point for the initial poll size. */ const NOMAD::Point & get_initial_poll_size ( void ) const { return _Delta_0; } - - - /// Access to the minimal mesh size. - /** - \return A NOMAD::Point for the minimal mesh size. - */ - const NOMAD::Point & get_min_mesh_size ( void ) const { return _delta_min; } - - - /// Access to the minimal poll size. - /** - \return A NOMAD::Point for the minimal poll size. - */ - const NOMAD::Point & get_min_poll_size ( void ) const { return _Delta_min; } - - - /// Test if mesh is finest so far. - /** - \return True if mesh is the finest so far, False otherwise. - */ - virtual bool is_finest(void) const = 0; - + + /// Access to the minimal mesh size. + /** + \return A NOMAD::Point for the minimal mesh size. + */ + const NOMAD::Point & get_min_mesh_size ( void ) const { return _delta_min; } + + + /// Access to the minimal poll size. + /** + \return A NOMAD::Point for the minimal poll size. + */ + const NOMAD::Point & get_min_poll_size ( void ) const { return _Delta_min; } + + + /// Test if mesh is finest so far. + /** + \return True if mesh is the finest so far, False otherwise. + */ + virtual bool is_finest(void) const = 0; + + /// Test if current mesh is finer than initial mesh (used by VNS search). - /** - \return True if mesh size is smaller than initial mesh size for all components. - */ - bool is_finer_than_initial (void) const; - + /** + \return True if mesh size is smaller than initial mesh size for all components. + */ + virtual bool is_finer_than_initial (void) const; + + + /// Access to the mesh/poll update basis tau. + /** + \return A double with the update basis tau. + */ + double get_update_basis ( void ) const { return _update_basis.value(); } + + + /// Access to the mesh ratio after a success + /** + \return A point with the ratio for each coordinate + */ + virtual NOMAD::Point get_mesh_ratio_if_success( void ) const = 0; + + + /// Access to the number of variables. + /** + \return An integer with the number of variables. + */ + int get_n ( void ) const { return _n; } - /// Access to the mesh/poll update basis tau. - /** - \return A double with the update basis tau. - */ - double get_update_basis ( void ) const { return _update_basis.value(); } - - - /// Access to the mesh ratio after a success - /** - \return A point with the ratio for each coordinate - */ - virtual NOMAD::Point get_mesh_ratio_if_success( void ) const = 0; - - - /// Access to the number of variables. - /** - \return An integer with the number of variables. - */ - int get_n ( void ) const { return _n; } - /// Access to the number of free variables. - /** - \return An integer with the number of free variables. - */ - int get_n_free_variables ( void ) const { return _n_free_variables; } - + /** + \return An integer with the number of free variables. + */ + int get_n_free_variables ( void ) const { return _n_free_variables; } + /// Access to the mesh size parameter delta^k. - /** - \return delta The mesh size parameter delta^k -- \b OUT. - */ - NOMAD::Point get_delta ( void ) const + /** + \return delta The mesh size parameter delta^k -- \b OUT. + */ + NOMAD::Point get_delta ( void ) const { NOMAD::Point delta; get_delta(delta); return delta; } - - /// Access to the mesh size parameter delta^k. - /** - \param delta The mesh size parameter delta^k -- \b OUT. - \return A boolean equal to \c true if all values are - strictly inferior than the associated minimal - mesh size delta_min - (stopping criterion MIN_MESH_SIZE). - */ - virtual bool get_delta ( NOMAD::Point & delta ) const = 0; - - /// Access to the largest mesh size. - /** - \return The largest mesh size -- \b OUT. - */ - virtual NOMAD::Point get_delta_max ( void ) const = 0; - + + /// Access to the mesh size parameter delta^k. + /** + \param delta The mesh size parameter delta^k -- \b OUT. + \return A boolean equal to \c true if all values are + strictly inferior than the associated minimal + mesh size delta_min + (stopping criterion MIN_MESH_SIZE). + */ + virtual bool get_delta ( NOMAD::Point & delta ) const = 0; + + /// Access to the largest mesh size. + /** + \return The largest mesh size -- \b OUT. + */ + virtual NOMAD::Point get_delta_max ( void ) const = 0; + /// Access to the poll size parameter Delta^k. - /** - \return Delta The poll size parameter Delta^k -- \b OUT. - */ - NOMAD::Point get_Delta ( void ) + /** + \return Delta The poll size parameter Delta^k -- \b OUT. + */ + NOMAD::Point get_Delta ( void ) { NOMAD::Point Delta; get_Delta(Delta); return Delta; } - /// Access to the poll size parameter Delta^k. - /** - \param Delta The poll size parameter Delta^k -- \b OUT. - \return A boolean equal to \c true if all values are - strictly inferior than the associated minimal - mesh size delta_min - (stopping criterion MIN_POLL_SIZE). - */ - virtual bool get_Delta ( NOMAD::Point & Delta ) const = 0 ; - - - /// Display. - /** - \param out The NOMAD::Display object -- \b IN. - */ - virtual void display ( const NOMAD::Display & out ) const = 0; - - /// Check the stopping conditions on the minimal poll and mesh sizes. - /** - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - */ - virtual void check_min_mesh_sizes ( bool & stop , - NOMAD::stop_type & stop_reason ) const = 0; - - /// Access to the mesh indices per coordinate. - /** - \return A point with the mesh index for each coordinate. - */ - virtual const NOMAD::Point get_mesh_indices ( void ) const = 0; - - /// Manually set the mesh indices per coordinate (virtual). - /** - \param r The mesh index per coordinate -- \b IN. - */ - virtual void set_mesh_indices ( const NOMAD::Point & r ) =0 ; - - /// Manually set the min mesh size per coordinate. - /** - \param delta_min The min mesh sizes per coordinate (can be undefined) -- \b IN. - */ - void set_min_mesh_sizes ( const NOMAD::Point & delta_min ); - - /// Manually set intial mesh size per coordinate. - /** - \param d The initial mesh sizes per coordinate -- \b IN. - */ + /// Access to the poll size parameter Delta^k. + /** + \param Delta The poll size parameter Delta^k -- \b OUT. + \return A boolean equal to \c true if all values are + strictly inferior than the associated minimal + mesh size delta_min + (stopping criterion MIN_POLL_SIZE). + */ + virtual bool get_Delta ( NOMAD::Point & Delta ) const = 0 ; + + + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + */ + virtual void display ( const NOMAD::Display & out ) const = 0; + + /// Check the stopping conditions on the minimal poll and mesh sizes. + /** + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + */ + virtual void check_min_mesh_sizes ( bool & stop , + NOMAD::stop_type & stop_reason ) const = 0; + + /// Access to the mesh indices per coordinate. + /** + \return A point with the mesh index for each coordinate. + */ + virtual const NOMAD::Point get_mesh_indices ( void ) const = 0; + + /// Manually set the mesh indices per coordinate (virtual). + /** + \param r The mesh index per coordinate -- \b IN. + */ + virtual void set_mesh_indices ( const NOMAD::Point & r ) =0 ; + + /// Manually set the min mesh size per coordinate. + /** + \param delta_min The min mesh sizes per coordinate (can be undefined) -- \b IN. + */ + void set_min_mesh_sizes ( const NOMAD::Point & delta_min ); + + /// Manually set the min poll size per coordinate. + /** + \param Delta_min The min poll sizes per coordinate (can be undefined) -- \b IN. + */ + void set_min_poll_sizes ( const NOMAD::Point & Delta_min ); + + + /// Manually set intial mesh size per coordinate. + /** + \param d The initial mesh sizes per coordinate -- \b IN. + */ void set_delta_0 ( const NOMAD::Point & d ); - /// Manually set intial poll size per coordinate. - /** - \param d The initial poll sizes per coordinate -- \b IN. - */ + /// Manually set intial poll size per coordinate. + /** + \param d The initial poll sizes per coordinate -- \b IN. + */ void set_Delta_0 ( const NOMAD::Point & d ); - - - /// Access to the min mesh indices reached so far. - /** - \return A point with the mesh index for each coordinate. - */ - virtual const NOMAD::Point get_min_mesh_indices ( void ) const = 0; - - /// Access to the max mesh indices reached so far. - /** - \return A point with the mesh index for each coordinate. - */ - virtual const NOMAD::Point get_max_mesh_indices ( void ) const = 0; - - + + + /// Access to the min mesh indices reached so far. + /** + \return A point with the mesh index for each coordinate. + */ + virtual const NOMAD::Point get_min_mesh_indices ( void ) const = 0; + + /// Access to the max mesh indices reached so far. + /** + \return A point with the mesh index for each coordinate. + */ + virtual const NOMAD::Point get_max_mesh_indices ( void ) const = 0; + + /// Access to the limit mesh index. - /** - \return An integer with the limit mesh index. - */ - int get_limit_mesh_index ( void ) const { return _limit_mesh_index;} + /** + \return An integer with the limit mesh index. + */ + int get_limit_mesh_index ( void ) const { return _limit_mesh_index;} /// Manually set the limit mesh index. - /** - \param limit_mesh_index The limit mesh index. - */ - virtual void set_limit_mesh_index ( int limit_mesh_index ) = 0; - + /** + \param limit_mesh_index The limit mesh index. + */ + virtual void set_limit_mesh_index ( int limit_mesh_index ) = 0; + + + /// Scale and project the ith component of a vector on the mesh + /** + \param i The vector component number -- \b IN. + \param l The vector component value -- \b IN. + \param round_up The flag to perform or not rounding up (optional) -- \b IN. + \return The ith component of a vector after mesh scaling and projection + */ + virtual NOMAD::Double scale_and_project(int i, + const NOMAD::Double & l, + bool round_up=false ) const = 0 ; + - /// Scale and project the ith component of a vector on the mesh - /** - \param i The vector component number -- \b IN. - \param l The vector component value -- \b IN. - \return The ith component of a vector after mesh scaling and projection - */ - virtual NOMAD::Double scale_and_project(int i, const NOMAD::Double & l) const = 0 ; - - - }; - - /// Display a NOMAD::OrthogonalMesh object. - /** + }; + + /// Display a NOMAD::OrthogonalMesh object. + /** \param out The NOMAD::Display object -- \b IN. \param m The NOMAD::OrthogonalMesh object to be displayed -- \b IN. \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::OrthogonalMesh & m ) - { - m.display ( out ); - return out; - } + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::OrthogonalMesh & m ) + { + m.display ( out ); + return out; + } } #endif diff --git a/src/Parameter_Entries.cpp b/src/Parameter_Entries.cpp index 6a7392c8cb4fa578d24065d9029ae0460b62d7c4..d2ef0d3d8716e55d8d743d4a8f66b7098025239c 100644 --- a/src/Parameter_Entries.cpp +++ b/src/Parameter_Entries.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Parameter_Entries.cpp - \brief Parameter entries (implementation) - \author Sebastien Le Digabel - \date 2010-04-05 - \see Parameter_Entries.hpp -*/ + \file Parameter_Entries.cpp + \brief Parameter entries (implementation) + \author Sebastien Le Digabel + \date 2010-04-05 + \see Parameter_Entries.hpp + */ #include "Parameter_Entries.hpp" /*--------------------------------------------*/ @@ -47,10 +54,10 @@ /*--------------------------------------------*/ NOMAD::Parameter_Entries::~Parameter_Entries ( void ) { - std::multiset<NOMAD::Parameter_Entry*, NOMAD::Parameter_Entry_Comp>::iterator + std::multiset<NOMAD::Parameter_Entry*, NOMAD::Parameter_Entry_Comp>::iterator end = _entries.end() , it; - for ( it = _entries.begin() ; it != end ; ++it) - delete *it; + for ( it = _entries.begin() ; it != end ; ++it) + delete *it; } /*--------------------------------------------*/ @@ -58,12 +65,12 @@ NOMAD::Parameter_Entries::~Parameter_Entries ( void ) /*--------------------------------------------*/ NOMAD::Parameter_Entry * NOMAD::Parameter_Entries::find ( const std::string & name ) const { - NOMAD::Parameter_Entry p (name); - std::multiset<NOMAD::Parameter_Entry*, NOMAD::Parameter_Entry_Comp>::const_iterator + NOMAD::Parameter_Entry p (name); + std::multiset<NOMAD::Parameter_Entry*, NOMAD::Parameter_Entry_Comp>::const_iterator it = _entries.find ( &p ); - if ( it != _entries.end() ) - return (*it); - return NULL; + if ( it != _entries.end() ) + return (*it); + return NULL; } /*----------------------------------------*/ @@ -71,15 +78,16 @@ NOMAD::Parameter_Entry * NOMAD::Parameter_Entries::find ( const std::string & na /*----------------------------------------*/ void NOMAD::Parameter_Entries::insert ( NOMAD::Parameter_Entry * entry ) { - NOMAD::Parameter_Entry * cur = find ( entry->get_name() ); - if ( cur ) { - entry->set_unique ( false ); - cur->set_unique ( false ); - while ( cur->get_next() ) - cur = cur->get_next(); - cur->set_next ( entry ); - } - _entries.insert ( entry ); + NOMAD::Parameter_Entry * cur = find ( entry->get_name() ); + if ( cur ) + { + entry->set_unique ( false ); + cur->set_unique ( false ); + while ( cur->get_next() ) + cur = cur->get_next(); + cur->set_next ( entry ); + } + _entries.insert ( entry ); } /*----------------------------------------*/ @@ -87,12 +95,12 @@ void NOMAD::Parameter_Entries::insert ( NOMAD::Parameter_Entry * entry ) /*----------------------------------------*/ NOMAD::Parameter_Entry * NOMAD::Parameter_Entries::find_non_interpreted ( void ) const { - std::multiset<NOMAD::Parameter_Entry*, NOMAD::Parameter_Entry_Comp>::const_iterator + std::multiset<NOMAD::Parameter_Entry*, NOMAD::Parameter_Entry_Comp>::const_iterator end = _entries.end() , it; - for ( it = _entries.begin() ; it != end ; ++it ) - if ( !(*it)->has_been_interpreted() ) - return *it; - return NULL; + for ( it = _entries.begin() ; it != end ; ++it ) + if ( !(*it)->has_been_interpreted() ) + return *it; + return NULL; } /*--------------------------------------------*/ @@ -100,8 +108,8 @@ NOMAD::Parameter_Entry * NOMAD::Parameter_Entries::find_non_interpreted ( void ) /*--------------------------------------------*/ void NOMAD::Parameter_Entries::display ( const NOMAD::Display & out ) const { - std::multiset<NOMAD::Parameter_Entry*,NOMAD::Parameter_Entry_Comp>::const_iterator + std::multiset<NOMAD::Parameter_Entry*,NOMAD::Parameter_Entry_Comp>::const_iterator end = _entries.end() , it; - for ( it = _entries.begin() ; it != end ; ++it ) - out << **it << std::endl; + for ( it = _entries.begin() ; it != end ; ++it ) + out << **it << std::endl; } diff --git a/src/Parameter_Entries.hpp b/src/Parameter_Entries.hpp index aff4d011b277bc8e987de16c2dc924bc7af28671..d2682bf0323fca1e4a8099f3dc04326abfd78e95 100644 --- a/src/Parameter_Entries.hpp +++ b/src/Parameter_Entries.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,80 +41,81 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Parameter_Entries.hpp - \brief Parameter entries (headers) - \author Sebastien Le Digabel - \date 2010-04-05 - \see Parameter_Entries.cpp -*/ + \file Parameter_Entries.hpp + \brief Parameter entries (headers) + \author Sebastien Le Digabel + \date 2010-04-05 + \see Parameter_Entries.cpp + */ #ifndef __PARAMETER_ENTRIES__ #define __PARAMETER_ENTRIES__ #include "Parameter_Entry.hpp" namespace NOMAD { - - /// Parameter entries. - /** + + /// Parameter entries. + /** - Objects of this class store NOMAD::Parameter_Entry objects. - One NOMAD::Parameter_Entries object summarizes an entire parameters file. - */ - class Parameter_Entries : private NOMAD::Uncopyable { - - private: - - /// List of NOMAD::Parameter_Entry objects (the entries). - std::multiset<NOMAD::Parameter_Entry *, NOMAD::Parameter_Entry_Comp> _entries; - - public: - - /// Constructor. - explicit Parameter_Entries ( void ) {} - - /// Destructor. - virtual ~Parameter_Entries ( void ); - - /// Find a specific entry in a set. - /** - \param name The name of the wanted NOMAD::Parameter_Entry object -- \b IN. - \return A pointer to the NOMAD::Parameter_Entry object if it - has been found in the list of entries, - or \c NULL otherwise. - */ - NOMAD::Parameter_Entry * find ( const std::string & name ) const; - - /// Insert a new entry in the list of entries. - /** - \param entry A pointer to the new NOMAD::Parameter_Entry object -- \b IN. - */ - void insert ( NOMAD::Parameter_Entry * entry ); - - /// Find a non-interpreted entry. - /** - \return A pointer to the first NOMAD::Parameter_Entry that has not been - interpreted so far, - or \c NULL if all entries have already been interpreted. - */ - NOMAD::Parameter_Entry * find_non_interpreted ( void ) const; - - /// Display. + */ + class Parameter_Entries : private NOMAD::Uncopyable { + + private: + + /// List of NOMAD::Parameter_Entry objects (the entries). + std::multiset<NOMAD::Parameter_Entry *, NOMAD::Parameter_Entry_Comp> _entries; + + public: + + /// Constructor. + explicit Parameter_Entries ( void ) {} + + /// Destructor. + virtual ~Parameter_Entries ( void ); + + /// Find a specific entry in a set. + /** + \param name The name of the wanted NOMAD::Parameter_Entry object -- \b IN. + \return A pointer to the NOMAD::Parameter_Entry object if it + has been found in the list of entries, + or \c NULL otherwise. + */ + NOMAD::Parameter_Entry * find ( const std::string & name ) const; + + /// Insert a new entry in the list of entries. + /** + \param entry A pointer to the new NOMAD::Parameter_Entry object -- \b IN. + */ + void insert ( NOMAD::Parameter_Entry * entry ); + + /// Find a non-interpreted entry. + /** + \return A pointer to the first NOMAD::Parameter_Entry that has not been + interpreted so far, + or \c NULL if all entries have already been interpreted. + */ + NOMAD::Parameter_Entry * find_non_interpreted ( void ) const; + + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display ( const NOMAD::Display & out ) const; + }; + + /// Display a NOMAD::Parameter_Entries object. /** - \param out The NOMAD::Display object -- \b IN. - */ void display ( const NOMAD::Display & out ) const; - }; - - /// Display a NOMAD::Parameter_Entries object. - /** \param out The NOMAD::Display object -- \b IN. \param e The NOMAD::Parameter_Entries object to be displayed -- \b IN. \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Parameter_Entries & e ) - { - e.display ( out ); - return out; - } + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::Parameter_Entries & e ) + { + e.display ( out ); + return out; + } } #endif diff --git a/src/Parameter_Entry.cpp b/src/Parameter_Entry.cpp index de60272d0c1a7822d0901232fab6ef8840bf77d2..198d80b6d83e18a1b7e7fbae7e6005355bffba05 100644 --- a/src/Parameter_Entry.cpp +++ b/src/Parameter_Entry.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Parameter_Entry.cpp - \brief Parameter entry (implementation) - \author Sebastien Le Digabel - \date 2010-04-05 - \see Parameter_Entry.hpp -*/ + \file Parameter_Entry.cpp + \brief Parameter entry (implementation) + \author Sebastien Le Digabel + \date 2010-04-05 + \see Parameter_Entry.hpp + */ #include "Parameter_Entry.hpp" /*-----------------------------------*/ @@ -47,133 +54,147 @@ /* . ignores all entries after '#' */ /*-----------------------------------*/ NOMAD::Parameter_Entry::Parameter_Entry ( const std::string & entry , - bool remove_comments ) - : _ok ( false ) , - _unique ( true ) , - _next ( NULL ) , - _has_been_interpreted ( false ) + bool remove_comments ) +: _ok ( false ) , +_unique ( true ) , +_next ( NULL ) , +_has_been_interpreted ( false ) { - int i , idst; - std::string s; - std::istringstream in ( entry ); - in >> _name; - - if (_name.size()==0) - return; - - if ( remove_comments && _name[0] == '#' ) - _name.clear(); - else { - - NOMAD::toupper ( _name ); - - bool stats_file_name_read = false; - - while ( true ) { - in >> s; - - if ( in.fail() ) - break; - - // comment: - if ( remove_comments && s[0]=='#' ) - break; - - // string with quotes: - bool had_quotes = false; - if ( s[0] == '\"' || s[0] == '\'' ) { - - had_quotes = true; - char quote = s[0]; - - s.erase ( s.begin() ); - - if ( s[s.size()-1] == quote ) - s.resize ( s.size() - 1 ); - - else { - std::string ss; - getline ( in , ss , quote ); - - if ( in.fail() || !in.good()) { - _ok = false; - return; - } - - s = s + ss; - } - } - - // DISPLAY_STATS or STATS_FILE: - if ( _name == "STATS_FILE" && !stats_file_name_read ) - stats_file_name_read = true; - - else if ( _name == "DISPLAY_STATS" || _name == "STATS_FILE" ) { - - if ( had_quotes ) { - _ok = false; - return; - } - - std::string keyword , ss = s; - bool interpreted = false; - NOMAD::toupper ( ss ); - - NOMAD::display_stats_type dst = NOMAD::DS_OBJ; - while ( dst < NOMAD::DS_UNDEFINED ) { - - keyword = NOMAD::Display::get_display_stats_keyword (dst); - - i = static_cast<int> ( ss.rfind ( keyword , ss.size()-1 ) ); - - if ( i >= 0 ) { - std::string s1 = s.substr ( 0 , i ); - std::string s2 = s.substr ( i+keyword.size() ); - if ( !s1.empty() ) - _values.push_back ( s1 ); - _values.push_back ( keyword ); - if ( !s2.empty() ) - _values.push_back ( s2 ); - _values.push_back ( std::string() ); - interpreted = true; - break; - } - - // loop increment: - idst = dst; - ++idst; - dst = static_cast<NOMAD::display_stats_type> ( idst ); - } - - if ( !interpreted ) { - _values.push_back ( s ); - _values.push_back ( std::string() ); - } - - continue; - } - - // vector: - if ( s.size() > 1 && ( s[0] == '[' || s[0] == '(' ) ) { - _values.push_back ( s[0]=='[' ? "[" : "(" ); - s.erase(s.begin()); - } - int sm1 = static_cast<int>(s.size()) - 1; - char c = s[sm1]; - if ( s.size() > 1 && ( c == ']' || c == ')' ) ) { - s.resize(sm1); - _values.push_back (s); - _values.push_back ( c==']' ? "]" : ")" ); - continue; - } - - // other values: - _values.push_back ( s ); + int i , idst; + std::string s; + std::istringstream in ( entry ); + in >> _name; + + if (_name.size()==0) + return; + + if ( remove_comments && _name[0] == '#' ) + _name.clear(); + else + { + + + NOMAD::toupper ( _name ); + + bool stats_file_name_read = false; + + while ( true ) + { + in >> s; + + if ( in.fail() ) + break; + + // comment: + if ( remove_comments && s[0]=='#' ) + break; + + // string with quotes: + bool had_quotes = false; + if ( s[0] == '\"' || s[0] == '\'' ) + { + + had_quotes = true; + char quote = s[0]; + + s.erase ( s.begin() ); + + if ( s[s.size()-1] == quote ) + s.resize ( s.size() - 1 ); + + else + { + + std::string ss; + getline ( in , ss , quote ); + + if ( in.fail() || !in.good()) + { + _ok = false; + return; + } + + s = s + ss; + } + } + + // DISPLAY_STATS or STATS_FILE: + if ( _name == "STATS_FILE" && !stats_file_name_read ) + stats_file_name_read = true; + + else if ( _name == "DISPLAY_STATS" || _name == "STATS_FILE" ) + { + + if ( had_quotes ) + { + _ok = false; + return; + } + + std::string keyword , ss = s; + bool interpreted = false; + NOMAD::toupper ( ss ); + + NOMAD::display_stats_type dst = NOMAD::DS_OBJ; + while ( dst < NOMAD::DS_UNDEFINED ) + { + + keyword = NOMAD::Display::get_display_stats_keyword (dst); + + i = static_cast<int> ( ss.rfind ( keyword , ss.size()-1 ) ); + + if ( i >= 0 ) + { + std::string s1 = s.substr ( 0 , i ); + std::string s2 = s.substr ( i+keyword.size() ); + if ( !s1.empty() ) + _values.push_back ( s1 ); + _values.push_back ( keyword ); + if ( !s2.empty() ) + _values.push_back ( s2 ); + _values.push_back ( std::string() ); + interpreted = true; + break; + } + + // loop increment: + idst = dst; + ++idst; + dst = static_cast<NOMAD::display_stats_type> ( idst ); + } + + if ( !interpreted ) + { + _values.push_back ( s ); + _values.push_back ( std::string() ); + } + + continue; + } + + // vector: + if ( s.size() > 1 && ( s[0] == '[' || s[0] == '(' ) ) + { + _values.push_back ( s[0]=='[' ? "[" : "(" ); + s.erase(s.begin()); + } + int sm1 = static_cast<int>(s.size()) - 1; + char c = s[sm1]; + if ( s.size() > 1 && ( c == ']' || c == ')' ) ) + { + s.resize(sm1); + _values.push_back (s); + _values.push_back ( c==']' ? "]" : ")" ); + continue; + } + + // other values: + _values.push_back ( s ); + } + + if ( !_values.empty() ) + _ok = true; } - - if ( !_values.empty() ) - _ok = true; - } } /*------------------------------*/ @@ -181,10 +202,11 @@ NOMAD::Parameter_Entry::Parameter_Entry ( const std::string & entry , /*------------------------------*/ void NOMAD::Parameter_Entry::display ( const NOMAD::Display & out ) const { - if ( _ok ) { - out << _name << ": "; - std::list<std::string>::const_iterator end = _values.end(); - for ( std::list<std::string>::const_iterator it = _values.begin() ; it != end ; ++it ) - out << "[" << *it << "] "; - } + if ( _ok ) + { + out << _name << ": "; + std::list<std::string>::const_iterator end = _values.end(); + for ( std::list<std::string>::const_iterator it = _values.begin() ; it != end ; ++it ) + out << "[" << *it << "] "; + } } diff --git a/src/Parameter_Entry.hpp b/src/Parameter_Entry.hpp index 7c1e0b96bd7b491f38d6381aceba961f6a324911..85bfe40ca940363d3f1a40d593ef880eaba7cb8f 100644 --- a/src/Parameter_Entry.hpp +++ b/src/Parameter_Entry.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -74,7 +81,7 @@ namespace NOMAD { \param entry A string describing the parameter entry -- \b IN. \param remove_comments A boolean equal to \c true if entries after \c '#' are ignored -- \b IN - -- \b optional (default = \c true). + -- \b optional (default = \c true). */ Parameter_Entry ( const std::string & entry , bool remove_comments = true ); @@ -189,7 +196,7 @@ namespace NOMAD { \return The NOMAD::Display object. */ inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Parameter_Entry & e ) + const NOMAD::Parameter_Entry & e ) { e.display ( out ); return out; diff --git a/src/Parameters.cpp b/src/Parameters.cpp index cf218fe94a114a0ed88a836aac507b71f7678e29..5e89b82f83b273164dbdf10f8c3e5fd18527a875 100644 --- a/src/Parameters.cpp +++ b/src/Parameters.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -47,6 +54,7 @@ bool NOMAD::Parameters::_warning_has_been_displayed=false; + /*----------------------------------------*/ /* destructor */ /*----------------------------------------*/ @@ -65,7 +73,6 @@ void NOMAD::Parameters::init ( void ) // miscellaneous and algorithm parameters: _to_be_checked = true; _seed = 0; - // _seed = NOMAD::get_pid(); _max_eval = -1; _max_sim_bb_eval = -1; _max_bb_eval = -1; @@ -99,18 +106,21 @@ void NOMAD::Parameters::init ( void ) set_INF_STR ( NOMAD::DEFAULT_INF_STR ); // Mesh: - _anisotropic_mesh = true; - _use_smesh = false; - _mesh_update_basis = 4; - _poll_update_basis = 2; - _mesh_coarsening_exponent = 1; - _mesh_refining_exponent =-1; - _initial_mesh_index = 0; - _min_poll_size_defined = false; + _anisotropic_mesh = true; + _mesh_type = NOMAD::XMESH; + + _mesh_update_basis = 4; + _poll_update_basis = 2; + _mesh_coarsening_exponent = 1; + _mesh_refining_exponent =-1; + _initial_mesh_index = 0; + _limit_mesh_index = NOMAD::XL_LIMITS; + _min_poll_size_defined = false; _initial_mesh_size.clear(); _initial_poll_size.clear(); _min_mesh_size.clear(); _min_poll_size.clear(); + _granularity.clear(); // Directions: reset_directions ( ); @@ -149,6 +159,10 @@ void NOMAD::Parameters::init ( void ) _has_filter_constraints = false; _barrier_type = NOMAD::EB; + // Intensification: + _max_eval_intensification = -1; + _intensification_type = NOMAD::NO_INTENSIFICATION; + // outputs: _index_obj.clear(); _bb_exe.clear(); @@ -199,10 +213,6 @@ void NOMAD::Parameters::init ( void ) _model_params.quad_max_Y_size = 500; _model_params.model_np1_quad_epsilon =0.01; - // TGP model parameters: - _model_params.tgp_mode = NOMAD::TGP_FAST; - _model_params.tgp_reuse_model = true; - // other searches: _VNS_trigger.clear(); _speculative_search = true; @@ -216,12 +226,12 @@ void NOMAD::Parameters::init ( void ) _opp_CS_is_defined = false; // opportunistic strategy: - _bb_max_block_size = 1; + _bb_max_block_size = 1; _eval_points_as_block = false; - _opportunistic_eval = true; - _opportunistic_min_nb_success = -1; - _opportunistic_min_eval = -1; - _opportunistic_lucky_eval = false; + _opportunistic_eval = true; + _opportunistic_min_nb_success = -1; + _opportunistic_min_eval = -1; + _opportunistic_lucky_eval = false; _opportunistic_min_f_imprvmt.clear(); // display: @@ -239,6 +249,7 @@ void NOMAD::Parameters::init ( void ) reset_stats_file(); _display_all_eval = false; + } /*------------------------------------------------------------------*/ @@ -281,13 +292,16 @@ bool NOMAD::Parameters::check_display_stats { int var_index; std::list<std::string>::const_iterator it , end = stats.end(); - for ( it = stats.begin() ; it != end ; ++it ) { + for ( it = stats.begin() ; it != end ; ++it ) + { if ( !it->empty() && - NOMAD::Display::get_display_stats_type(*it) == NOMAD::DS_VAR ) { + NOMAD::Display::get_display_stats_type(*it) == NOMAD::DS_VAR ) + { ++it; if ( !NOMAD::atoi ( *it , var_index ) || var_index < 0 || - var_index >= _dimension ) { + var_index >= _dimension ) + { return false; } } @@ -314,19 +328,24 @@ bool NOMAD::Parameters::check_directory ( std::string & s ) // step 2: replace '/' or '\' with DIR_SEP: i = 0; ns = s.size(); - while ( i < ns ) { + while ( i < ns ) + { if ( s[i] == '/' || s[i] == '\\' ) s[i] = NOMAD::DIR_SEP; ++i; } // step 3: add DIR_SEP at the end: - if ( i >= 1 ) { - if (s[i-1] != NOMAD::DIR_SEP) { + if ( i >= 1 ) + { + if (s[i-1] != NOMAD::DIR_SEP) + { s += NOMAD::DIR_SEP; } } - else { + else + { + s = "."; s.push_back ( NOMAD::DIR_SEP ); } @@ -338,17 +357,18 @@ bool NOMAD::Parameters::check_directory ( std::string & s ) /* interpretation of the Parameter_Entry for PERIODIC_VARIABLE */ /* (private) */ /*---------------------------------------------------------------*/ -void NOMAD::Parameters::interpret_periodic_var -( const NOMAD::Parameter_Entries & entries ) +void NOMAD::Parameters::interpret_periodic_var ( const NOMAD::Parameter_Entries & entries ) { int i , j , k; std::list<std::string>::const_iterator it , end; NOMAD::Parameter_Entry * pe = entries.find ( "PERIODIC_VARIABLE" ); - while ( pe ) { + while ( pe ) + { // just one variable index (can be '*' or a range of indexes 'i-j'): - if ( pe->get_nb_values() == 1 ) { + if ( pe->get_nb_values() == 1 ) + { it = pe->get_values().begin(); if ( !NOMAD::string_to_index_range ( *it , i , j , &_dimension ) ) @@ -360,9 +380,12 @@ void NOMAD::Parameters::interpret_periodic_var } // list of variable indexes: - else { + else + { + end = pe->get_values().end(); - for ( it = pe->get_values().begin() ; it != end ; ++it ) { + for ( it = pe->get_values().begin() ; it != end ; ++it ) + { if ( !NOMAD::atoi ( *it , i ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: PERIODIC_VARIABLE" ); @@ -386,10 +409,12 @@ void NOMAD::Parameters::interpret_var_groups ( const NOMAD::Parameter_Entries & std::list<std::string>::const_iterator it , end; NOMAD::Parameter_Entry * pe = entries.find ( "VARIABLE_GROUP" ); - while ( pe ) { + while ( pe ) + { // just one variable index (can be '*' or a range of indexes 'i-j'): - if ( pe->get_nb_values() == 1 ) { + if ( pe->get_nb_values() == 1 ) + { it = pe->get_values().begin(); if ( !NOMAD::string_to_index_range ( *it , i , j , &_dimension ) ) @@ -401,9 +426,12 @@ void NOMAD::Parameters::interpret_var_groups ( const NOMAD::Parameter_Entries & } // list of variable indexes: - else { + else + { + end = pe->get_values().end(); - for ( it = pe->get_values().begin() ; it != end ; ++it ) { + for ( it = pe->get_values().begin() ; it != end ; ++it ) + { if ( !NOMAD::atoi ( *it , i ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: VARIABLE_GROUP" ); @@ -485,7 +513,9 @@ void NOMAD::Parameters::interpret_BFVS ( const NOMAD::Parameter_Entries & entrie // file name: - else { + else + { + file_name = _problem_dir + *pe->get_values().begin(); @@ -499,7 +529,8 @@ void NOMAD::Parameters::interpret_BFVS ( const NOMAD::Parameter_Entries & entrie } try { - switch ( param_name[0] ) { + switch ( param_name[0] ) + { case 'L': _lb.reset ( _dimension ); fin >> _lb; @@ -517,7 +548,8 @@ void NOMAD::Parameters::interpret_BFVS ( const NOMAD::Parameter_Entries & entrie fin >> _scaling; } } - catch ( NOMAD::Point::Bad_Input & ) { + catch ( NOMAD::Point::Bad_Input & ) + { err = "invalid parameter: " + param_name + " - could not read file \'" + file_name + "\'"; throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); @@ -528,9 +560,11 @@ void NOMAD::Parameters::interpret_BFVS ( const NOMAD::Parameter_Entries & entrie } // vector form: all values on one row: - else if ( pe->get_nb_values() == _dimension + 2 ) { + else if ( pe->get_nb_values() == _dimension + 2 ) + { - if ( !pe->is_unique() ) { + if ( !pe->is_unique() ) + { err = "invalid parameter: " + param_name + " - has been given in vector form with [] or () and is not unique"; throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); @@ -538,21 +572,25 @@ void NOMAD::Parameters::interpret_BFVS ( const NOMAD::Parameter_Entries & entrie it = pe->get_values().begin(); - if ( *it != "[" && *it != "(" ) { + if ( *it != "[" && *it != "(" ) + { err = "invalid parameter: " + param_name + " - error in vector form with () or []"; throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); } ++it; - for ( k = 0 ; k < _dimension ; ++k ) { - if ( !v.atof(*it) ) { + for ( k = 0 ; k < _dimension ; ++k ) + { + if ( !v.atof(*it) ) + { err = "invalid parameter: " + param_name; throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); } ++it; - switch ( param_name[0] ) { + switch ( param_name[0] ) + { case 'L': set_LOWER_BOUND ( k , v ); break; case 'U': set_UPPER_BOUND ( k , v ); @@ -563,7 +601,8 @@ void NOMAD::Parameters::interpret_BFVS ( const NOMAD::Parameter_Entries & entrie } } - if ( *it != "]" && *it != ")" ) { + if ( *it != "]" && *it != ")" ) + { err = "invalid parameter: " + param_name + " - error in vector form with () or []"; throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); @@ -572,34 +611,40 @@ void NOMAD::Parameters::interpret_BFVS ( const NOMAD::Parameter_Entries & entrie } // indexed values: - else { + else + { + - if ( pe->get_nb_values() != 2 ) { + if ( pe->get_nb_values() != 2 ) + { err = "invalid parameter: " + param_name; throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); } it = pe->get_values().begin(); - if ( !NOMAD::string_to_index_range ( *it , i , j , &_dimension ) ) { + if ( !NOMAD::string_to_index_range ( *it , i , j , &_dimension ) ) + { err = "invalid parameter: " + param_name; throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); } ++it; - if ( !v.atof(*it) ) { + if ( !v.atof(*it) ) + { err = "invalid parameter: " + param_name; throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); } for ( k = j ; k >= i ; --k ) - switch (param_name[0]) { - case 'L': set_LOWER_BOUND ( k, v ); - break; - case 'U': set_UPPER_BOUND ( k, v ); - break; - case 'F': set_FIXED_VARIABLE ( k, v ); - break; - case 'S': set_SCALING ( k, v ); - } + switch (param_name[0]) + { + case 'L': set_LOWER_BOUND ( k, v ); + break; + case 'U': set_UPPER_BOUND ( k, v ); + break; + case 'F': set_FIXED_VARIABLE ( k, v ); + break; + case 'S': set_SCALING ( k, v ); + } } pe->set_has_been_interpreted(); pe = pe->get_next(); @@ -675,11 +720,9 @@ void NOMAD::Parameters::interpret_f_target ( const NOMAD::Parameter_Entries & en /* interpretation of the Parameter_Entry for mesh/poll sizes */ /* (private) */ /*-------------------------------------------------------------*/ -void NOMAD::Parameters::interpret_mesh_sizes -( const NOMAD::Parameter_Entries & entries , - const std::string & param_name ) +void NOMAD::Parameters::interpret_mesh_sizes ( const NOMAD::Parameter_Entries & entries , + const std::string & param_name ) { - // param_name == "INITIAL_MESH_SIZE" or "INITIAL_MESH_SIZE" or "MIN_MESH_SIZE" or "MIN_POLL_SIZE": if ( param_name != "INITIAL_POLL_SIZE" && param_name != "INITIAL_MESH_SIZE" && param_name != "MIN_MESH_SIZE" && @@ -759,7 +802,8 @@ void NOMAD::Parameters::interpret_mesh_sizes else if ( pe->get_nb_values() == _dimension + 2 ) { - if ( !pe->is_unique() ) { + if ( !pe->is_unique() ) + { err = "invalid parameter: " + param_name + " - has been given in vector form with [] or () and is not unique"; throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); @@ -812,6 +856,123 @@ void NOMAD::Parameters::interpret_mesh_sizes } } + +/*----------------------------------------------------------------*/ +/* interpretation of the Parameter_Entry for granular variables */ +/* (private) */ +/*----------------------------------------------------------------*/ +void NOMAD::Parameters::interpret_granularity ( const NOMAD::Parameter_Entries & entries , + const std::string & param_name ) +{ + if ( param_name != "GRANULARITY" ) + throw Bad_Access ( "Parameters.cpp" , __LINE__ , + "wrong use of Parameters::interpret_granularity()" ); + + int i , j , k; + NOMAD::Double v; + std::string err; + std::list<std::string>::const_iterator it; + NOMAD::Parameter_Entry * pe = entries.find ( param_name ); + + while ( pe ) + { + + // just one value: + if ( pe->get_nb_values() == 1 ) + { + + if ( !pe->is_unique() ) + { + err = "invalid parameter: " + param_name + + " - has been given with just one value and is not unique"; + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); + } + + if ( !v.atof ( *pe->get_values().begin() ) ) + { + err = "invalid parameter: " + param_name; + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); + } + + set_GRANULARITY( v ); + + } + + // indexed form: + else if ( pe->get_nb_values() == 2 ) + { + + it = pe->get_values().begin(); + if ( !NOMAD::string_to_index_range ( *it , i , j , &_dimension ) ) + { + err = "invalid parameter: " + param_name; + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); + } + ++it; + + if ( !v.atof( *it ) ) + { + err = "invalid parameter: " + param_name; + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); + } + + for ( k = i ; k <= j ; ++k ) + set_GRANULARITY( k , v ); + } + + // vector form: all values on one row: + else if ( pe->get_nb_values() == _dimension + 2 ) + { + + if ( !pe->is_unique() ) + { + err = "invalid parameter: " + param_name + + " - has been given in vector form with [] or () and is not unique"; + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); + } + + it = pe->get_values().begin(); + + if ( *it != "[" && *it != "(" ) + { + err = "invalid parameter: " + param_name + + " - error in vector form with () or []"; + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); + } + + ++it; + for ( k = 0 ; k < _dimension ; ++k ) + { + if ( !v.atof ( *it ) ) + { + err = "invalid parameter: " + param_name; + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); + } + ++it; + set_GRANULARITY( k , v ); + } + + if ( *it != "]" && *it != ")" ) + { + err = "invalid parameter: " + param_name + + " - error in vector form with () or []"; + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); + } + } + + else + { + err = "invalid parameter: " + param_name; + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); + } + + pe->set_has_been_interpreted(); + pe = pe->get_next(); + } +} + + + /*---------------------------------------------------------------------------------*/ /* interpretation of the Parameter_Entry for BB_INPUT_TYPE (private) */ /*---------------------------------------------------------------------------------*/ @@ -820,18 +981,19 @@ void NOMAD::Parameters::interpret_mesh_sizes /* # or { Real , Cat , Bin , Int } */ /* or BB_INPUT_TYPE i-j t */ /*---------------------------------------------------------------------------------*/ -void NOMAD::Parameters::interpret_bb_input_type -( const NOMAD::Parameter_Entries & entries ) +void NOMAD::Parameters::interpret_bb_input_type ( const NOMAD::Parameter_Entries & entries ) { int i , j , k; NOMAD::bb_input_type bbit; std::list<std::string>::const_iterator it; NOMAD::Parameter_Entry * pe = entries.find ( "BB_INPUT_TYPE" ); - while ( pe ) { + while ( pe ) + { // indexed form: - if ( pe->get_nb_values() == 2 ) { + if ( pe->get_nb_values() == 2 ) + { it = pe->get_values().begin(); if ( !NOMAD::string_to_index_range ( *it , i , j , &_dimension ) ) @@ -847,7 +1009,8 @@ void NOMAD::Parameters::interpret_bb_input_type } // vector form: all values on one row: - else if ( pe->get_nb_values() == _dimension + 2 ) { + else if ( pe->get_nb_values() == _dimension + 2 ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -861,7 +1024,8 @@ void NOMAD::Parameters::interpret_bb_input_type "invalid parameter: BB_INPUT_TYPE - error in vector form with () or []" ); ++it; - for ( k = 0 ; k < _dimension ; ++k ) { + for ( k = 0 ; k < _dimension ; ++k ) + { if ( !NOMAD::string_to_bb_input_type ( *it , bbit ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: BB_INPUT_TYPE" ); @@ -896,7 +1060,8 @@ void NOMAD::Parameters::interpret_x0 ( const NOMAD::Parameter_Entries & entries NOMAD::Point tmp_x0; std::vector<int> indexes; - while ( pe ) { + while ( pe ) + { tmp_x0.reset ( _dimension ); @@ -905,15 +1070,18 @@ void NOMAD::Parameters::interpret_x0 ( const NOMAD::Parameter_Entries & entries set_X0 ( *pe->get_values().begin() ); // Vector form: all values on one row: - else if ( pe->get_nb_values() == _dimension + 2 ) { + else if ( pe->get_nb_values() == _dimension + 2 ) + { it = pe->get_values().begin(); - if ( *it != "[" && *it != "(" ) { + if ( *it != "[" && *it != "(" ) + { // particular case with n=1 and 3 entry values: // example: X0 1 0 4.0 (first coordinate of the 2nd x0 point put to 4.0) - if ( _dimension == 1 ) { + if ( _dimension == 1 ) + { it = pe->get_values().begin(); @@ -925,7 +1093,8 @@ void NOMAD::Parameters::interpret_x0 ( const NOMAD::Parameter_Entries & entries if ( l > i ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: X0" ); - else if ( l == i ) { + else if ( l == i ) + { l = static_cast<int> ( _x0s.size() ); indexes.push_back ( l ); set_X0 ( tmp_x0 ); @@ -955,10 +1124,13 @@ void NOMAD::Parameters::interpret_x0 ( const NOMAD::Parameter_Entries & entries "invalid parameter: X0 - error in vector form with () or []" ); } - else { + else + { + ++it; - for ( k = 0 ; k < _dimension ; ++k ) { + for ( k = 0 ; k < _dimension ; ++k ) + { if ( !v.atof(*it) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: X0" ); @@ -976,7 +1148,8 @@ void NOMAD::Parameters::interpret_x0 ( const NOMAD::Parameter_Entries & entries // indexed values without x0 index (must be unique) // (example: X0 0-5 1.0): - else if ( pe->get_nb_values() == 2 ) { + else if ( pe->get_nb_values() == 2 ) + { it = pe->get_values().begin(); if ( !NOMAD::string_to_index_range ( *it , i , j , &_dimension ) ) @@ -985,7 +1158,8 @@ void NOMAD::Parameters::interpret_x0 ( const NOMAD::Parameter_Entries & entries if ( !v.atof(*it) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: X0" ); - if ( indexes.empty() ) { + if ( indexes.empty() ) + { l = static_cast<int> ( _x0s.size() ); indexes.push_back ( l ); set_X0 ( tmp_x0 ); @@ -1000,7 +1174,9 @@ void NOMAD::Parameters::interpret_x0 ( const NOMAD::Parameter_Entries & entries // indexed values with x0 index // example: X0 0 0-5 1.0 --> first x0 point // X0 1 0-5 2.0 --> 2nd x0 point - else { + else + { + if ( pe->get_nb_values() != 3 ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: X0" ); @@ -1013,7 +1189,8 @@ void NOMAD::Parameters::interpret_x0 ( const NOMAD::Parameter_Entries & entries i = static_cast<int> ( indexes.size() ); if ( l > i ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: X0" ); - else if ( l == i ) { + else if ( l == i ) + { l = static_cast<int> ( _x0s.size() ); indexes.push_back ( l ); set_X0 ( tmp_x0 ); @@ -1050,6 +1227,7 @@ void NOMAD::Parameters::read ( const std::string & param_file ) // ------------ _problem_dir.clear(); size_t k = param_file.find_last_of ( NOMAD::DIR_SEP ); + if ( k < param_file.size() ) _problem_dir = param_file.substr (0,k) + NOMAD::DIR_SEP; else @@ -1058,12 +1236,14 @@ void NOMAD::Parameters::read ( const std::string & param_file ) // open the parameters file: std::string err = "could not open parameters file \'" + param_file + "\'"; std::ifstream fin; - if ( NOMAD::check_read_file ( param_file ) ) { + if ( NOMAD::check_read_file ( param_file ) ) + { fin.open ( param_file.c_str() ); if ( !fin.fail() ) err.clear(); } - if ( !err.empty() ) { + if ( !err.empty() ) + { fin.close(); throw NOMAD::Exception ( "Parameters.cpp" , __LINE__ , err ); } @@ -1280,20 +1460,24 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) } } - // USE_SMESH: + // MESH_TYPE: // --------------- { - pe = entries.find ( "USE_SMESH" ); + pe = entries.find ( "MESH_TYPE" ); if ( pe ) { - if ( !pe->is_unique() ) + if ( ! pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameter: USE_SMESH not unique" ); - i = NOMAD::string_to_bool ( *(pe->get_values().begin() ) ); - if ( pe->get_nb_values() != 1 || i == -1 ) + "invalid parameter: MESH_TYPE not unique" ); + + NOMAD::mesh_type mt; + std::string smt = *(pe->get_values().begin()); + + if ( ! NOMAD::string_to_mesh_type ( smt , mt ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameter: USE_SMESH" ); - set_USE_SMESH ( i == 1 ); + "invalid parameter: MESH_TYPE" ); + + set_MESH_TYPE ( mt ); pe->set_has_been_interpreted(); } } @@ -1303,7 +1487,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // -------------------- { pe = entries.find ( "POINT_DISPLAY_LIMIT" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: POINT_DISPLAY_LIMIT not unique" ); @@ -1320,12 +1505,15 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) { pe = entries.find ( "DIMENSION" ); - if ( !pe ) { + if ( !pe ) + { if ( !pe && _dimension <= 0 ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: DIMENSION not defined" ); } - else { + else + { + if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: DIMENSION not unique" ); @@ -1345,7 +1533,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // --------------- { pe = entries.find ( "SNAP_TO_BOUNDS" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: SNAP_TO_BOUNDS not unique" ); @@ -1363,7 +1552,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) { // MULTI_OVERALL_BB_EVAL: pe = entries.find ( "MULTI_OVERALL_BB_EVAL" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MULTI_OVERALL_BB_EVAL not unique" ); @@ -1376,7 +1566,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // MULTI_NB_MADS_RUNS: pe = entries.find ( "MULTI_NB_MADS_RUNS" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MULTI_NB_MADS_RUNS not unique" ); @@ -1389,7 +1580,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // MULTI_USE_DELTA_CRIT: pe = entries.find ( "MULTI_USE_DELTA_CRIT" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MULTI_USE_DELTA_CRIT not unique" ); @@ -1403,7 +1595,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // MULTI_F_BOUNDS (f1_min, f2_min, f2_min, f2_max): pe = entries.find ( "MULTI_F_BOUNDS" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MULTI_F_BOUNDS not unique" ); @@ -1412,7 +1605,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) "invalid parameter: MULTI_F_BOUNDS" ); NOMAD::Point mfb ( 4 ); it = pe->get_values().begin(); - for ( i = 0 ; i < 4 ; ++i ) { + for ( i = 0 ; i < 4 ; ++i ) + { if ( !d.atof ( *it ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MULTI_F_BOUNDS" ); @@ -1427,7 +1621,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ------------------ { pe = entries.find ( "MULTI_FORMULATION" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MULTI_FORMULATION not unique" ); @@ -1479,7 +1674,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) bool b_model_search = false; pe = entries.find ( "MODEL_SEARCH" ); - while ( pe ) { + while ( pe ) + { if ( pe->get_nb_values() != 1 ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -1493,7 +1689,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) int imt = NOMAD::string_to_bool ( smt ); // entered as a boolean: - if ( imt == 0 || imt == 1 ) { + if ( imt == 0 || imt == 1 ) + { if ( b_model_search || i_model_search == 2 ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MODEL_SEARCH (boolean argument can only be used once)" ); @@ -1502,7 +1699,9 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) } // entered as a model type: - else { + else + { + if ( !NOMAD::string_to_model_type ( smt , mt ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -1519,7 +1718,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // MODEL_SEARCH_OPTIMISTIC: { pe = entries.find ( "MODEL_SEARCH_OPTIMISTIC" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MODEL_SEARCH_OPTIMISTIC not unique" ); @@ -1535,7 +1735,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // MODEL_SEARCH_PROJ_TO_MESH: { pe = entries.find ( "MODEL_SEARCH_PROJ_TO_MESH" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MODEL_SEARCH_PROJ_TO_MESH not unique" ); @@ -1551,7 +1752,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // MODEL_QUAD_RADIUS_FACTOR: { pe = entries.find ( "MODEL_QUAD_RADIUS_FACTOR" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MODEL_QUAD_RADIUS_FACTOR not unique" ); @@ -1566,7 +1768,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // MODEL_QUAD_USE_WP: { pe = entries.find ( "MODEL_QUAD_USE_WP" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MODEL_QUAD_USE_WP not unique" ); @@ -1582,7 +1785,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // MODEL_QUAD_MAX_Y_SIZE: { pe = entries.find ( "MODEL_QUAD_MAX_Y_SIZE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MODEL_QUAD_MAX_Y_SIZE not unique" ); @@ -1597,7 +1801,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // MODEL_QUAD_MIN_Y_SIZE: { pe = entries.find ( "MODEL_QUAD_MIN_Y_SIZE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -1625,7 +1830,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // MODEL_QUAD_HYPERCUBE_LOWER_LIM: { pe = entries.find ( "MODEL_NP1_QUAD_EPSILON" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -1647,44 +1853,48 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) } } - // MODEL_TGP_MODE: - { - pe = entries.find ( "MODEL_TGP_MODE" ); - if ( pe ) { - if ( !pe->is_unique() ) - throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameter: MODEL_TGP_MODE not unique" ); - - NOMAD::TGP_mode_type m; - if ( pe->get_nb_values() != 1 || - !NOMAD::string_to_TGP_mode_type ( *(pe->get_values().begin()) , m ) ) - throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "Invalid parameter: MODEL_TGP_MODE" ); - pe->set_has_been_interpreted(); - set_MODEL_TGP_MODE ( m ); - } - } - // MODEL_TGP_REUSE_MODEL: - { - pe = entries.find ( "MODEL_TGP_REUSE_MODEL" ); - if ( pe ) { - if ( !pe->is_unique() ) - throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameter: MODEL_TGP_REUSE_MODEL not unique" ); - i = NOMAD::string_to_bool ( *(pe->get_values().begin() ) ); - if ( pe->get_nb_values() != 1 || i == -1 ) - throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameter: MODEL_TGP_REUSE_MODEL" ); - set_MODEL_TGP_REUSE_MODEL ( i == 1 ); - pe->set_has_been_interpreted(); - } - } + // // MODEL_TGP_MODE: + // { + // pe = entries.find ( "MODEL_TGP_MODE" ); + // if ( pe ) + // { + // if ( !pe->is_unique() ) + // throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + // "invalid parameter: MODEL_TGP_MODE not unique" ); + // + // NOMAD::TGP_mode_type m; + // if ( pe->get_nb_values() != 1 || + // !NOMAD::string_to_TGP_mode_type ( *(pe->get_values().begin()) , m ) ) + // throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + // "Invalid parameter: MODEL_TGP_MODE" ); + // pe->set_has_been_interpreted(); + // set_MODEL_TGP_MODE ( m ); + // } + // } + // + // // MODEL_TGP_REUSE_MODEL: + // { + // pe = entries.find ( "MODEL_TGP_REUSE_MODEL" ); + // if ( pe ) + // { + // if ( !pe->is_unique() ) + // throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + // "invalid parameter: MODEL_TGP_REUSE_MODEL not unique" ); + // i = NOMAD::string_to_bool ( *(pe->get_values().begin() ) ); + // if ( pe->get_nb_values() != 1 || i == -1 ) + // throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + // "invalid parameter: MODEL_TGP_REUSE_MODEL" ); + // set_MODEL_TGP_REUSE_MODEL ( i == 1 ); + // pe->set_has_been_interpreted(); + // } + // } // MODEL_SEARCH_MAX_TRIAL_PTS: { pe = entries.find ( "MODEL_SEARCH_MAX_TRIAL_PTS" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MODEL_SEARCH_MAX_TRIAL_PTS not unique" ); @@ -1699,7 +1909,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // MODEL_EVAL_SORT: { pe = entries.find ( "MODEL_EVAL_SORT" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MODEL_EVAL_SORT not unique" ); @@ -1716,7 +1927,9 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) set_MODEL_EVAL_SORT ( imt == 1 ); // entered as a model type: - else { + else + { + if ( !NOMAD::string_to_model_type ( smt , mt ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -1731,7 +1944,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // MODEL_EVAL_SORT_CAUTIOUS: { pe = entries.find ( "MODEL_EVAL_SORT_CAUTIOUS" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MODEL_EVAL_SORT_CAUTIOUS not unique" ); @@ -1749,7 +1963,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ------------------- { pe = entries.find ( "SPECULATIVE_SEARCH" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: SPECULATIVE_SEARCH not unique" ); @@ -1766,7 +1981,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ----------- { pe = entries.find ( "VNS_SEARCH" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: VNS_SEARCH not unique" ); @@ -1778,7 +1994,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) i = NOMAD::string_to_bool ( s ); // entered as a real: - if ( i == -1 || s == "1" ) { + if ( i == -1 || s == "1" ) + { if ( !d.atof ( s ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: VNS_SEARCH" ); @@ -1796,7 +2013,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ------------- { pe = entries.find ( "CACHE_SEARCH" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: CACHE_SEARCH not unique" ); @@ -1813,7 +2031,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ---------- { pe = entries.find ( "LH_SEARCH" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: LH_SEARCH not unique" ); @@ -1838,7 +2057,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ----------------- { pe = entries.find ( "OPPORTUNISTIC_LH" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: OPPORTUNISTIC_LH not unique" ); @@ -1856,7 +2076,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // --------------------------- { pe = entries.find ( "OPPORTUNISTIC_CACHE_SEARCH" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: OPPORTUNISTIC_CACHE_SEARCH not unique" ); @@ -1875,7 +2096,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // BB_MAX_BLOCK_SIZE pe = entries.find ( "BB_MAX_BLOCK_SIZE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: BB_MAX_BLOCK_SIZE not unique" ); @@ -1893,7 +2115,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // OPPORTUNISTIC_EVAL: pe = entries.find ( "OPPORTUNISTIC_EVAL" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: OPPORTUNISTIC_EVAL not unique" ); @@ -1907,7 +2130,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // OPPORTUNISTIC_MIN_NB_SUCCESS: pe = entries.find ( "OPPORTUNISTIC_MIN_NB_SUCCESS" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: OPPORTUNISTIC_MIN_NB_SUCCESS not unique" ); @@ -1920,7 +2144,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // OPPORTUNISTIC_MIN_EVAL: pe = entries.find ( "OPPORTUNISTIC_MIN_EVAL" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: OPPORTUNISTIC_MIN_EVAL not unique" ); @@ -1933,7 +2158,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // OPPORTUNISTIC_MIN_F_IMPRVMT: pe = entries.find ( "OPPORTUNISTIC_MIN_F_IMPRVMT" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: OPPORTUNISTIC_MIN_F_IMPRVMT not unique" ); @@ -1946,7 +2172,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // OPPORTUNISTIC_LUCKY_EVAL: pe = entries.find ( "OPPORTUNISTIC_LUCKY_EVAL" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: OPPORTUNISTIC_LUCKY_EVAL not unique" ); @@ -1966,7 +2193,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) pe = entries.find ( "DIRECTION_TYPE" ); - while ( pe ) { + while ( pe ) + { if ( !NOMAD::strings_to_direction_type ( pe->get_values() , dt ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -1979,7 +2207,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) } pe = entries.find ( "SEC_POLL_DIR_TYPE" ); - while ( pe ) { + while ( pe ) + { if ( !NOMAD::strings_to_direction_type ( pe->get_values() , dt ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: SEC_POLL_DIR_TYPE" ); @@ -1990,12 +2219,30 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) } } + // INTENSIFICATION: + { + pe = entries.find( "MAX_EVAL_INTENSIFICATION"); + if ( pe ) + { + if ( !pe->is_unique() ) + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + "invalid parameter: MAX_EVAL_INTENSIFICATION not unique" ); + if ( !NOMAD::atoi (*(pe->get_values().begin()) , i) ) + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + "invalid parameter: MAX_EVAL_INTENSIFICATION" ); + pe->set_has_been_interpreted(); + set_MAX_EVAL_INTENSIFICATION (i); + + } + } + // MAX_ITERATIONS: // --------------- { pe = entries.find ( "MAX_ITERATIONS" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MAX_ITERATIONS not unique" ); @@ -2011,7 +2258,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ---------------------------------- { pe = entries.find ( "MAX_CONSECUTIVE_FAILED_ITERATIONS" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MAX_CONSECUTIVE_FAILED_ITERATIONS not unique" ); @@ -2027,7 +2275,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ----------------- { pe = entries.find ( "MAX_CACHE_MEMORY" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MAX_CACHE_MEMORY not unique" ); @@ -2043,7 +2292,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // --------- { pe = entries.find ( "MAX_EVAL" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MAX_EVAL not unique" ); @@ -2059,7 +2309,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ------------ { pe = entries.find ( "MAX_BB_EVAL" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MAX_BB_EVAL not unique" ); @@ -2075,7 +2326,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ---------------- { pe = entries.find ( "MAX_SIM_BB_EVAL" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MAX_SIM_BB_EVAL not unique" ); @@ -2091,7 +2343,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // -------------- { pe = entries.find ( "MAX_SGTE_EVAL" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MAX_SGTE_EVAL not unique" ); @@ -2107,7 +2360,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // --------- { pe = entries.find ( "MAX_TIME" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MAX_TIME not unique" ); @@ -2124,7 +2378,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ---------------- { pe = entries.find ( "STAT_SUM_TARGET" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: STAT_SUM_TARGET not unique" ); @@ -2140,7 +2395,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // --------------- { pe = entries.find ( "L_CURVE_TARGET" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: L_CURVE_TARGET not unique" ); @@ -2156,7 +2412,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ---------------------- { pe = entries.find ( "EXTENDED_POLL_TRIGGER" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: EXTENDED_POLL_TRIGGER not unique" ); @@ -2177,7 +2434,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ---------------------- { pe = entries.find ( "EXTENDED_POLL_ENABLED" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: EXTENDED_POLL_ENABLED not unique" ); @@ -2194,7 +2452,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ------------------- { pe = entries.find ( "USER_CALLS_ENABLED" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: USER_CALLS_ENABLED not unique" ); @@ -2211,7 +2470,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ------------- { pe = entries.find ( "ASYNCHRONOUS" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: ASYNCHRONOUS not unique" ); @@ -2228,7 +2488,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ---- { pe = entries.find ( "RHO" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: RHO not unique" ); @@ -2244,7 +2505,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ------ { pe = entries.find ( "H_MIN" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: H_MIN not unique" ); @@ -2260,7 +2522,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // -------- { pe = entries.find ( "H_MAX_0" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: H_MAX_0 not unique" ); @@ -2276,7 +2539,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ------- { pe = entries.find ( "H_NORM" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: H_NORM not unique" ); @@ -2295,7 +2559,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) { _tmp_dir.clear(); pe = entries.find ( "TMP_DIR" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: TMP_DIR not unique" ); @@ -2314,7 +2579,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ----------------------- { pe = entries.find ( "ADD_SEED_TO_FILE_NAMES" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: ADD_SEED_TO_FILE_NAMES not unique" ); @@ -2337,7 +2603,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) { _solution_file.clear(); pe = entries.find ( "SOLUTION_FILE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: SOLUTION_FILE not unique" ); @@ -2355,7 +2622,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) { _history_file.clear(); pe = entries.find ( "HISTORY_FILE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: HISTORY_FILE not unique" ); @@ -2372,7 +2640,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ----------- { pe = entries.find ( "STATS_FILE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -2386,7 +2655,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) std::list<std::string> ls; if (it!=end) { - while ( it != end ) { + while ( it != end ) + { ls.push_back(*it); ++it; } @@ -2403,7 +2673,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) { _cache_file.clear(); pe = entries.find ( "CACHE_FILE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: CACHE_FILE not unique" ); @@ -2420,7 +2691,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) { _sgte_cache_file.clear(); pe = entries.find ( "SGTE_CACHE_FILE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: SGTE_CACHE_FILE not unique" ); @@ -2437,7 +2709,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ------------------ { pe = entries.find ( "CACHE_SAVE_PERIOD" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: CACHE_SAVE_PERIOD not unique" ); @@ -2453,7 +2726,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ---------- { pe = entries.find ( "SGTE_COST" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: SGTE_COST not unique" ); @@ -2497,7 +2771,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // STOP_IF_FEASIBLE: // ----------------- pe = entries.find ( "STOP_IF_FEASIBLE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: STOP_IF_FEASIBLE not unique" ); @@ -2513,7 +2788,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // --------------------- { pe = entries.find ( "BB_INPUT_INCLUDE_TAG" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: BB_INPUT_INCLUDE_TAG not unique" ); @@ -2530,7 +2806,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ---------------------- { pe = entries.find ( "BB_INPUT_INCLUDE_SEED" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: BB_INPUT_INCLUDE_SEED not unique" ); @@ -2546,7 +2823,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // --------------- { pe = entries.find ( "BB_REDIRECTION" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: BB_REDIRECTION not unique" ); @@ -2566,17 +2844,26 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) interpret_mesh_sizes ( entries , "MIN_MESH_SIZE" ); interpret_mesh_sizes ( entries , "MIN_POLL_SIZE" ); + + // GRANULARITY ---> for the next release! + //-------------------- + // interpret_granularity( entries , "GRANULARITY"); + + // BB_OUTPUT_TYPE: // --------------- { pe = entries.find ( "BB_OUTPUT_TYPE" ); - if ( !pe ) { + if ( !pe ) + { if ( _bb_output_type.empty() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: BB_OUTPUT_TYPE not defined" ); } - else { + else + { + if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -2592,8 +2879,10 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) std::list<NOMAD::bb_output_type> bbot; i = 0; end = pe->get_values().end(); - for ( it = pe->get_values().begin() ; it != end ; ++it ) { - if ( !NOMAD::string_to_bb_output_type ( *it , cur ) ) { + for ( it = pe->get_values().begin() ; it != end ; ++it ) + { + if ( !NOMAD::string_to_bb_output_type ( *it , cur ) ) + { err = "invalid parameter: BB_OUTPUT_TYPE (" + pe->get_name(); throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); } @@ -2611,7 +2900,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) { _neighbors_exe.clear(); pe = entries.find ( "NEIGHBORS_EXE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: NEIGHBORS_EXE not unique" ); @@ -2628,7 +2918,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ------- { pe = entries.find ( "BB_EXE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -2639,7 +2930,9 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) if ( m == 1 ) set_BB_EXE ( *pe->get_values().begin() ); - else { + else + { + if ( m != static_cast<int>(_bb_output_type.size()) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -2661,18 +2954,21 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // --------- { pe = entries.find ( "SGTE_EXE" ); - if ( pe ) { + if ( pe ) + { std::string bb_exe_name , sgte_name; - if ( pe->get_nb_values() == 1 ) { + if ( pe->get_nb_values() == 1 ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: SGTE_EXE (with one arguement) not unique" ); sgte_name = *pe->get_values().begin(); } - else if ( pe->get_nb_values() == 2 ) { + else if ( pe->get_nb_values() == 2 ) + { bb_exe_name = *pe->get_values().begin(); sgte_name = *(++pe->get_values().begin()); } @@ -2690,7 +2986,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // --------------- { pe = entries.find ( "SGTE_EVAL_SORT" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: SGTE_EVAL_SORT not unique" ); @@ -2707,7 +3004,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // --------- { pe = entries.find ( "HAS_SGTE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: HAS_SGTE not unique" ); @@ -2724,7 +3022,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // -------------- { pe = entries.find ( "OPT_ONLY_SGTE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: OPT_ONLY_SGTE not unique" ); @@ -2741,7 +3040,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // --------------- { pe = entries.find ( "DISPLAY_DEGREE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: DISPLAY_DEGREE not unique" ); @@ -2757,7 +3057,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ----------- { pe = entries.find ( "OPEN_BRACE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: OPEN_BRACE not unique" ); @@ -2776,7 +3077,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ------------- { pe = entries.find ( "CLOSED_BRACE" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: CLOSED_BRACE not unique" ); @@ -2794,7 +3096,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // DISPLAY_STATS: { pe = entries.find ( "DISPLAY_STATS" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: DISPLAY_STATS not unique" ); @@ -2812,7 +3115,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // ----------------- { pe = entries.find ( "DISPLAY_ALL_EVAL" ); - if ( pe ) { + if ( pe ) + { if ( !pe->is_unique() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: DISPLAY_ALL_EVAL not unique" ); @@ -2844,7 +3148,6 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) s = *(pe->get_values().begin()); NOMAD::toupper(s); - if ( s == "DIFF" ) i = -1; else if ( !NOMAD::atoi ( s , i ) ) @@ -2853,10 +3156,10 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) set_SEED(i); pe->set_has_been_interpreted(); - } } + // VARIABLE_GROUP: // --------------- interpret_var_groups ( entries ); @@ -2869,7 +3172,8 @@ void NOMAD::Parameters::read ( const NOMAD::Parameter_Entries & entries ) // check the non-interpreted parameters: pe = entries.find_non_interpreted(); - if ( pe ) { + if ( pe ) + { err = "invalid parameter: " + pe->get_name() + " - unknown"; throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , err ); } @@ -2884,13 +3188,15 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const { std::list<std::string>::const_iterator it; - if ( _to_be_checked ) { + if ( _to_be_checked ) + { out << "parameters not checked" << std::endl; return; } // problem directory: - if ( !_problem_dir.empty() ) { + if ( !_problem_dir.empty() ) + { out << "problem directory : " << _problem_dir << std::endl; if ( _tmp_dir != _problem_dir ) out << "tmp directory : " << _tmp_dir << std::endl; @@ -2900,26 +3206,30 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const out << "dimension : n=" << _dimension << std::endl; // bounds: - if ( _lb.is_defined() ) { + if ( _lb.is_defined() ) + { out << "lower bounds : ( "; _lb.display ( out , " " , 4 , NOMAD::Point::get_display_limit() ); out << " )" << std::endl; } - if ( _ub.is_defined() ) { + if ( _ub.is_defined() ) + { out << "upper bounds : ( "; _ub.display ( out , " " , 4 , NOMAD::Point::get_display_limit() ); out << " )" << std::endl; } // scaling: - if ( _scaling.is_defined() ) { + if ( _scaling.is_defined() ) + { out << "scaling : ( "; _scaling.display ( out , " " , 4 , NOMAD::Point::get_display_limit() ); out << " )" << std::endl; } // fixed variables: - if ( _fixed_variables.is_defined() ) { + if ( _fixed_variables.is_defined() ) + { out << "fixed variables : ( "; _fixed_variables.display ( out , " " , 4 , NOMAD::Point::get_display_limit() ); out << " )" << std::endl; @@ -2938,8 +3248,10 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const out << "( " << _bb_input_type << " )" << std::endl; // extended poll trigger: - if ( get_signature()->has_categorical() ) { - if ( _extended_poll_enabled ) { + if ( get_signature()->has_categorical() ) + { + if ( _extended_poll_enabled ) + { out << "extended poll trigger: " << _extended_poll_trigger; if ( _relative_ept ) out << " (relative)"; @@ -2952,7 +3264,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const } // periodic variables: - if ( !_periodic_variables.empty() ) { + if ( !_periodic_variables.empty() ) + { out << "periodic variables : { "; for ( size_t k = 0 ; k < _periodic_variables.size() ; ++k ) if ( _periodic_variables[k] ) @@ -2961,7 +3274,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const } // variable groups: - if ( _var_groups.size() > 1 ) { + if ( _var_groups.size() > 1 ) + { int i = 0; out.open_block ( "variable groups" ); std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp>::const_iterator @@ -2981,9 +3295,11 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const it = _bb_exe.begin(); out.open_block ( "blackbox outputs (m=" + NOMAD::itos ( m ) + ")" ); - for ( int i = 0 ; i < m ; ++i ) { + for ( int i = 0 ; i < m ; ++i ) + { out << "#" << std::setw(w) << i << " " << std::setw(12) << _bb_output_type[i]; - if ( display_bb_exe ) { + if ( display_bb_exe ) + { out << "\t" << *it; if ( display_sgte_exe ) out << "\t" << get_sgte_exe(*it); @@ -2999,7 +3315,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const << ( (_std_signature) ? "standard" : "extern" ) << std::endl; // BB_REDIRECTION: - if ( !_bb_redirection ) { + if ( !_bb_redirection ) + { out << "blackbox output redirection : "; out.display_yes_or_no ( _bb_redirection ); out << std::endl; @@ -3010,10 +3327,12 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const out << "has surrogate : "; out.display_yes_or_no ( _has_sgte ); out << std::endl; - if ( _has_sgte ) { + if ( _has_sgte ) + { // OPT_ONLY_SGTE: - if ( _opt_only_sgte ) { + if ( _opt_only_sgte ) + { out << "minimize only with surrogate : "; out.display_yes_or_no ( _opt_only_sgte ); out << std::endl; @@ -3035,7 +3354,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const } // MULTI-MADS: - if ( get_nb_obj() > 1 ) { + if ( get_nb_obj() > 1 ) + { out << "multi-MADS : [overall bb eval="; if ( _multi_overall_bb_eval >= 0 ) out << _multi_overall_bb_eval; @@ -3051,7 +3371,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const out << "]" << std::endl << " [formulation=" << _multi_formulation << "]"; - if ( _multi_f_bounds.is_defined() ) { + if ( _multi_f_bounds.is_defined() ) + { out << " [f_bounds="; _multi_f_bounds.display ( out , "," , -1 , -1 ); out << "]"; @@ -3060,10 +3381,12 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const } // barrier: - if ( _has_constraints ) { + if ( _has_constraints ) + { out << "barrier type : "; - switch ( _barrier_type ) { + switch ( _barrier_type ) + { case NOMAD::EB: out << "extreme" << std::endl; break; @@ -3102,10 +3425,12 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const // STATS_FILE: out << "stats file : "; - if ( !_stats_file_name.empty() ) { + if ( !_stats_file_name.empty() ) + { out << "(" << _stats_file_name << ") "; std::list<std::string>::const_iterator end = _stats_file.end(); - for ( it = _stats_file.begin() ; it != end ; ++it ) { + for ( it = _stats_file.begin() ; it != end ; ++it ) + { if ( it->empty() ) out << " "; else @@ -3118,7 +3443,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const // CACHE_FILE: out << "cache file : "; - if ( !_cache_file.empty() ) { + if ( !_cache_file.empty() ) + { out << _cache_file << std::endl; out << "cache save period : "; if ( _cache_save_period <= 0 ) @@ -3141,10 +3467,14 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const if ( _x0s.empty() && _x0_cache_file.empty() ) out << "x0 : points in \'" << _cache_file << "\'" << std::endl; - else { + else + { + bool first = true; - if ( !_x0_cache_file.empty() ) { - if ( first ) { + if ( !_x0_cache_file.empty() ) + { + if ( first ) + { out << "x0 : "; first = false; } @@ -3155,10 +3485,13 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const out << " (read only)"; out << std::endl; } - if ( !_x0s.empty() ) { + if ( !_x0s.empty() ) + { size_t x0n = _x0s.size(); - for ( size_t k = 0 ; k < x0n ; ++k ) { - if ( first ) { + for ( size_t k = 0 ; k < x0n ; ++k ) + { + if ( first ) + { out << "x0 : "; first = false; } @@ -3177,20 +3510,27 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const if ( _direction_types.size() == 1 ) out << "directions : " << *_direction_types.begin() << std::endl; - else { + else + { + out << NOMAD::open_block ( "directions" ); for ( it = _direction_types.begin() ; it != end ; ++it ) out << *it << std::endl; out.close_block(); } - if ( _barrier_type == NOMAD::PB || _barrier_type == NOMAD::PEB_P ) { + if ( _barrier_type == NOMAD::PB || _barrier_type == NOMAD::PEB_P ) + { if ( _sec_poll_dir_types.empty() ) out << "sec. poll dir. type: no secondary poll" << std::endl; - else { + else + { + if ( _sec_poll_dir_types.size() == 1 ) out << "sec. poll dir. type: " << *_sec_poll_dir_types.begin() << std::endl; - else { + else + { + end = _sec_poll_dir_types.end(); out << NOMAD::open_block ( "sec. poll dir. types" ); for ( it = _sec_poll_dir_types.begin() ; it != end ; ++it ) @@ -3199,17 +3539,16 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const } } } - } // mesh: { - if ( get_use_smesh() ) + if ( _mesh_type == NOMAD::SMESH ) { out << NOMAD::open_block ( "smesh (isotropic)" ); out << "mesh update basis : " << std::setw(3) << _mesh_update_basis << std::endl; } - else + else if ( _mesh_type == NOMAD::XMESH ) { if ( get_anisotropic_mesh() ) out << NOMAD::open_block ( "xmesh (anisotropic)" ); @@ -3217,6 +3556,7 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const out << NOMAD::open_block ( "xmesh (isotropic)" ); out << "poll update basis : " << std::setw(3) << _poll_update_basis << std::endl; } + out << "coarsening exponent : " << std::setw(3) << _mesh_coarsening_exponent << std::endl << "refining exponent : " << std::setw(3) << _mesh_refining_exponent @@ -3228,12 +3568,14 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const out << "initial poll size : ( "; _initial_poll_size.display ( out , " " , 4 , NOMAD::Point::get_display_limit() ); out << " )" << std::endl; - if ( _min_mesh_size.is_defined() ) { + if ( _min_mesh_size.is_defined() ) + { out << "min mesh size : ( "; _min_mesh_size.display ( out , " " , 4 , NOMAD::Point::get_display_limit() ); out << " )" << std::endl; } - if ( _min_poll_size.is_defined() ) { + if ( _min_poll_size.is_defined() ) + { out << "min poll size : ( "; _min_poll_size.display ( out , " " , 4 , NOMAD::Point::get_display_limit() ); out << " )" << std::endl; @@ -3262,7 +3604,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const out << "opportunistic evaluations : "; out.display_yes_or_no ( _opportunistic_eval ); out << std::endl; - if ( _opportunistic_eval ) { + if ( _opportunistic_eval ) + { if ( _opportunistic_min_nb_success > 0 ) out << "opportunistic min nb success : " << _opportunistic_min_nb_success << std::endl; @@ -3314,8 +3657,10 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const out << "no model search" << std::endl; // model ordering: - if ( _model_params.eval_sort != NOMAD::NO_MODEL ) { - if ( _model_params.eval_sort == NOMAD::QUADRATIC_MODEL ) { + if ( _model_params.eval_sort != NOMAD::NO_MODEL ) + { + if ( _model_params.eval_sort == NOMAD::QUADRATIC_MODEL ) + { out << NOMAD::open_block ( "model ordering" ) << "models type : " << _model_params.eval_sort << std::endl << "cautious model ordering: "; @@ -3343,12 +3688,13 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const // quadratic model parameters: if ( _model_params.eval_sort == NOMAD::QUADRATIC_MODEL || _model_params.search1 == NOMAD::QUADRATIC_MODEL || - _model_params.search2 == NOMAD::QUADRATIC_MODEL ) { + _model_params.search2 == NOMAD::QUADRATIC_MODEL ) + { out << NOMAD::open_block ( "quadratic model parameters" ) << "radius factor: " << _model_params.quad_radius_factor << std::endl << "use WP : "; out.display_yes_or_no ( _model_params.quad_use_WP ); - out << std::endl << "min Y size : "; + out << std::endl << "min Y size : "; if ( _model_params.quad_min_Y_size < 0 ) out << "n+1"; else @@ -3357,19 +3703,11 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const << "max Y size : " << _model_params.quad_max_Y_size << std::endl << NOMAD::close_block(); } - - // TGP model parameters: - if ( _model_params.eval_sort == NOMAD::TGP_MODEL || - _model_params.search1 == NOMAD::TGP_MODEL || - _model_params.search2 == NOMAD::TGP_MODEL ) { - out << NOMAD::open_block ( "TGP model parameters" ) - << "mode : " << _model_params.tgp_mode << std::endl - << "reuse model: " << _model_params.tgp_reuse_model << std::endl - << NOMAD::close_block(); - } out.close_block(); } - else { + else + { + out << "use models : "; out.display_yes_or_no ( false ); out << std::endl; @@ -3390,7 +3728,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const // LH_SEARCH: out << "Latin-Hypercube (LH) search : "; - if ( _LH_search_p0 > 0 || _LH_search_pi > 0 ) { + if ( _LH_search_p0 > 0 || _LH_search_pi > 0 ) + { out << "#init:" << _LH_search_p0 << ", #iter:" << _LH_search_pi << ", opport:"; @@ -3402,7 +3741,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const // CACHE_SEARCH: out << "cache search : "; - if ( _cache_search ) { + if ( _cache_search ) + { out.display_yes_or_no ( true ); out << ", opport:"; out.display_yes_or_no ( _opportunistic_cache_search ); @@ -3437,7 +3777,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const // DISPLAY_STATS: out << "display stats : "; std::list<std::string>::const_iterator end = _display_stats.end(); - for ( it = _display_stats.begin() ; it != end ; ++it ) { + for ( it = _display_stats.begin() ; it != end ; ++it ) + { if ( it->empty() ) out << " "; else @@ -3462,7 +3803,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const out << "max eval. (bb+cache) : " << _max_eval << std::endl; // MAX_BB_EVAL: - if ( _max_bb_eval >= 0 ) { + if ( _max_bb_eval >= 0 ) + { out << "max number of blackbox eval. : " << _max_bb_eval; if ( _max_bb_eval == 0 ) out << " (no blackbox eval. allowed)"; @@ -3474,7 +3816,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const out << "max simulated blackbox eval. : " << _max_sim_bb_eval << std::endl; // MAX_SGTE_EVAL: - if ( _sgte_max_eval >= 0 ) { + if ( _sgte_max_eval >= 0 ) + { out << "max surrogate eval. : " << _sgte_max_eval; if ( _sgte_max_eval == 0 ) out << " (no surrogate eval. allowed)"; @@ -3482,7 +3825,8 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const } // MAX_ITERATIONS: - if ( _max_iterations >= 0 ) { + if ( _max_iterations >= 0 ) + { out << "max iterations : " << _max_iterations; if ( _max_iterations == 0 ) out << " (no iterations allowed)"; @@ -3503,9 +3847,11 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const out << "max wall-clock time : " << _max_time << "s" << std::endl; // F_TARGET: - if ( _f_target.is_defined() ) { + if ( _f_target.is_defined() ) + { out << "objective target : "; - if ( _f_target.size() > 1 ) { + if ( _f_target.size() > 1 ) + { out << "( "; _f_target.display ( out , " " , 4 , -1 ); out << " )" << std::endl; @@ -3525,11 +3871,13 @@ void NOMAD::Parameters::display ( const NOMAD::Display & out ) const << _L_curve_target << std::endl; // STOP_IF_FEASIBLE: - if ( _stop_if_feasible ) { + if ( _stop_if_feasible ) + { out << "stop if feasible : "; out.display_yes_or_no ( _stop_if_feasible ); out << std::endl; } + } /*---------------------------------------*/ @@ -3764,7 +4112,7 @@ void NOMAD::Parameters::check ( bool remove_history_file , /*----------------------------*/ { - if ( _use_smesh && _anisotropic_mesh ) + if ( _mesh_type == NOMAD::SMESH && _anisotropic_mesh ) { _anisotropic_mesh=false; if ( !_warning_has_been_displayed ) @@ -3795,6 +4143,36 @@ void NOMAD::Parameters::check ( bool remove_history_file , } + // limit mesh index: + // -------------------------------- + { + if ( _mesh_type == NOMAD::SMESH && _limit_mesh_index > NOMAD::L_LIMITS ) + if ( !_warning_has_been_displayed ) + _out << NOMAD::open_block("Warning:") + << "A limit mesh index that is greater than the defaut limit of " << NOMAD::L_LIMITS << " is provided. This convergence criterion can be difficult to meet due to nomad precision" << std::endl + << NOMAD::close_block(); + + if ( _mesh_type == NOMAD::SMESH && _limit_mesh_index == NOMAD::XL_LIMITS ) + _limit_mesh_index = NOMAD::L_LIMITS; + + if ( ( _mesh_type == NOMAD::XMESH ) && _limit_mesh_index < NOMAD::XL_LIMITS ) + if ( !_warning_has_been_displayed ) + _out << NOMAD::open_block("Warning:") + << "A limit mesh index that is smaller than the defaut limit of " << NOMAD::L_LIMITS << " is provided. This convergence criterion can be difficult to meet due to nomad precision" << std::endl + << NOMAD::close_block(); + + if ( _mesh_type == NOMAD::SMESH && _limit_mesh_index <= _initial_mesh_index ) + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + "invalid parameter: LIMIT_MESH_INDEX must be larger than INITIAL_MESH_INDEX (SMESH)" ); + + if ( ( _mesh_type == NOMAD::XMESH ) && _limit_mesh_index >= _initial_mesh_index ) + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + "invalid parameter: LIMIT_MESH_INDEX must be smaller than INITIAL_MESH_INDEX (XMESH)" ); + + + } + + // initial mesh size or poll size: // -------------------------------- bool use_x0 = !_x0s.empty() && _x0s[0]->size() == _dimension; @@ -3806,10 +4184,10 @@ void NOMAD::Parameters::check ( bool remove_history_file , if ( _bb_input_type[i] == NOMAD::CONTINUOUS ) { - // Determine _initial_mesh_size from _initial_poll_size (this will disappear in future version) if ( _initial_mesh_size[i].is_defined() ) _initial_poll_size[i]=_initial_mesh_size[i]*pow(_dimension,0.5); + // default value for initial mesh size if ( !_initial_poll_size[i].is_defined() ) { @@ -3846,12 +4224,19 @@ void NOMAD::Parameters::check ( bool remove_history_file , } } } + else if ( !_fixed_variables[i].is_defined() && ( _initial_poll_size[i].value() < NOMAD::Double::get_epsilon() || _initial_poll_size[i].value() <= 0.0 ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: INITIAL_MESH_SIZE" ); + + // Determine _initial_mesh_size from _initial_poll_size (this will disappear in future version) + if ( !_initial_mesh_size[i].is_defined() ) + _initial_mesh_size[i]=_initial_poll_size[i]*pow(_dimension,-0.5); + } + // binary/categorical variables: // ----------------------------- else if ( _bb_input_type[i] == NOMAD::BINARY || @@ -3862,6 +4247,7 @@ void NOMAD::Parameters::check ( bool remove_history_file , _initial_mesh_size[i] = 1.0; _initial_poll_size[i] = 1.0; } + // integer variables: // ------------------ else @@ -3877,31 +4263,27 @@ void NOMAD::Parameters::check ( bool remove_history_file , if ( _initial_mesh_size[i] < 1.0 ) _initial_mesh_size[i] = 1.0; + } else // that is no initial_mesh_size and no initial_poll_size { - - // default value for initial mesh size // (r0.1 if there are bounds + rounding to nearest integer not zero, 1.0 otherwise): if ( !_lb[i].is_defined() || !_ub[i].is_defined() ) _initial_mesh_size[i] = 1.0; else { set_INITIAL_POLL_SIZE ( i , 0.1 , true ); - _initial_mesh_size[i]=_initial_poll_size[i]*pow(_dimension,-0.5); - _initial_mesh_size[i]=_initial_mesh_size[i].round(); + _initial_mesh_size[i] = _initial_poll_size[i] * pow(_dimension,-0.5); + _initial_mesh_size[i] = _initial_mesh_size[i].round(); if ( _initial_mesh_size[i] < 1.0 ) _initial_mesh_size[i] = 1.0; } } - _initial_poll_size[i]=_initial_mesh_size[i]*pow(_dimension,0.5); + // Determine the initial poll size from mesh size + _initial_poll_size[i] = _initial_mesh_size[i] * pow(_dimension,0.5); } - // Determine _initial_mesh_size from _initial_poll_size (this will disappear in future version) - if ( !_initial_mesh_size[i].is_defined() ) - _initial_mesh_size[i]=_initial_poll_size[i]*pow(_dimension,-0.5); - } // min mesh size \delta_min: @@ -3910,14 +4292,14 @@ void NOMAD::Parameters::check ( bool remove_history_file , if ( _min_mesh_size.size() != _dimension ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameter: MIN_MESH_SIZE" ); + "invalid parameter: MIN_MESH_SIZE must have the same dimension as the problem" ); for ( i = 0 ; i < _dimension ; ++i ) if ( _min_mesh_size[i].is_defined() && - (_min_mesh_size[i].value() < NOMAD::Double::get_epsilon() || + ( _min_mesh_size[i].value() < NOMAD::Double::get_epsilon() || _min_mesh_size[i].value() <= 0.0 ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameters: MIN_MESH_SIZE" ); + "invalid parameters: MIN_MESH_SIZE must be greater than zero" ); } // min poll size \Delta^p_min: @@ -3928,8 +4310,8 @@ void NOMAD::Parameters::check ( bool remove_history_file , if ( _min_poll_size.size() != _dimension ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameter: MIN_POLL_SIZE" ); - + "invalid parameter: MIN_POLL_SIZE must have the same dimension as the problem." ); + // test validity of min poll size for ( i = 0 ; i < _dimension ; ++i ) { // continuous variables: @@ -3939,36 +4321,20 @@ void NOMAD::Parameters::check ( bool remove_history_file , (_min_poll_size[i].value() < NOMAD::Double::get_epsilon() || _min_poll_size[i].value() <= 0.0 ) ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameters: MIN_POLL_SIZE" ); + "invalid parameters: MIN_POLL_SIZE must be consistent with continuous variable" ); } - // integer and binary variables: else if ( _bb_input_type[i] != NOMAD::CATEGORICAL ) { - if ( _min_poll_size[i].is_defined() ) - { - if ( _min_poll_size[i] < 1.0 ) - _min_poll_size[i] = 1.0; - } - else - _min_poll_size[i] = 1.0; + if ( _min_poll_size[i].is_defined() && _min_poll_size[i] < 1.0 ) + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + "invalid parameters: MIN_POLL_SIZE must be consistent with integer/binary variable" ); } } } - - // default min poll size for non-continuous variables: else - { - _min_poll_size_defined = false; - - _min_poll_size = NOMAD::Point ( _dimension ); - for ( i = 0 ; i < _dimension ; ++i ) - if ( _bb_input_type[i] == NOMAD::INTEGER ) - _min_poll_size[i] = 1.0; - } - // default value for _mesh_update_basis (tau): if ( _mesh_update_basis <= 1.0 ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameters: MESH_UPDATE_BASIS (must be >1)" ); @@ -3979,6 +4345,66 @@ void NOMAD::Parameters::check ( bool remove_history_file , } + { + // Granularity --> this will be used in the next version in which granular variabtesles will be handled + //------------------- + if ( _granularity.is_defined () && _granularity.size () != _dimension ) + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + "invalid parameters: granularity (size must be equal to dimension)" ); + + if ( ! _granularity.is_defined() ) + _granularity = NOMAD::Point ( _dimension ,0 ); + else + { + double inpart; + for ( i = 0 ; i < _dimension ; ++i ) + { + + if ( _granularity[i].is_defined() && _granularity[i] < 0 ) + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + "invalid parameters: granularity (negative values)" ); + + if ( _granularity[i].is_defined() && _granularity[i] !=0 && _mesh_type == NOMAD::SMESH ) + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + "invalid parameters: granular variables are not supported when mesh_type = smesh " ); + + // Exception if a granularity is not supported by xmesh is given + if ( _granularity[i].is_defined() && _granularity[i] != 0.0 && _granularity[i] != 1.0 ) + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + "invalid parameters: granularity must be 0 (continuous) or 1 (integer). " ); + + //from bb_input_type --> _granularity. No granularity is required for categorical variables (different variable group + no mesh ) + if ( _bb_input_type[i] == NOMAD::CONTINUOUS ) + { + if ( _granularity[i].is_defined() && _granularity[i] != 0.0 && _out.get_gen_dd()>=NOMAD::NORMAL_DISPLAY && !_warning_has_been_displayed ) + _out << NOMAD::open_block("Warning:") + << " The granularity of the continuous variable " << i << " is changed to 0." << std::endl + << NOMAD::close_block(); + _granularity[i] = 0.0; + } + + if ( _bb_input_type[i] == NOMAD::INTEGER || _bb_input_type[i] == NOMAD::BINARY ) + { + + if ( _granularity[i].is_defined() && _granularity[i] != 1.0 && _out.get_gen_dd() >= NOMAD::NORMAL_DISPLAY && !_warning_has_been_displayed ) + _out << NOMAD::open_block("Warning:") + << " The granularity of the integer/binary variable " << i << " is changed to 1." << std::endl + << NOMAD::close_block(); + _granularity[i] = 1.0; + } + + if ( !_x0s.empty() && _granularity[i].is_defined() && _granularity[i] > 0.0 + && std::modf ( (*_x0s[0])[i].value() / _granularity[i].value() , &inpart ) != 0 ) + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + "NOMAD::Parameters::check : invalid granularity of variables vs initial value" ); + } + + } + + + } + + int nb_obj = static_cast<int>(_index_obj.size()); /*----------------------------*/ @@ -4068,14 +4494,16 @@ void NOMAD::Parameters::check ( bool remove_history_file , // blackbox with the associated surrogate // (SGTE_EXE parameter with only one argument): it = _sgte_exe.find(""); - if ( it != end ) { + if ( it != end ) + { if ( _sgte_exe.size() != 1 ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: SGTE_EXE - impossible to interpret with one argument" ); std::string bb_exe_name = *bb_exe_begin; std::list<std::string>::const_iterator it2 = ++bb_exe_begin; - while ( it2 != bb_exe_end ) { + while ( it2 != bb_exe_end ) + { if ( *it2 != bb_exe_name ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: unique SGTE_EXE without unique blackbox executable" ); @@ -4244,10 +4672,20 @@ void NOMAD::Parameters::check ( bool remove_history_file , _speculative_search = false; } + + /*----------------------------*/ + /* intensification */ + /*----------------------------*/ + if ( _max_eval_intensification > 0 ) + _intensification_type = NOMAD::POLL_AND_SEARCH; + else + _intensification_type = NOMAD::NO_INTENSIFICATION; + /*----------------------------*/ /* periodic variables */ /*----------------------------*/ - if ( !_periodic_variables.empty() ) { + if ( !_periodic_variables.empty() ) + { // check the size: if ( _dimension != static_cast<int>(_periodic_variables.size()) ) @@ -4256,7 +4694,8 @@ void NOMAD::Parameters::check ( bool remove_history_file , // check the bounds: for ( int k = 0 ; k < _dimension ; ++k ) - if ( _periodic_variables[k] ) { + if ( _periodic_variables[k] ) + { if ( !_lb[k].is_defined() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: PERIODIC_VARIABLE - lower bound not defined" ); @@ -4275,7 +4714,7 @@ void NOMAD::Parameters::check ( bool remove_history_file , // disable models upon request if ( _disable_models) { - _model_params.search1 = _model_params.search2 = _model_params.eval_sort = NOMAD::NO_MODEL; + _model_params.search1 = _model_params.search2 = _model_params.eval_sort = NOMAD::NO_MODEL; if (_out.get_gen_dd()>NOMAD::MINIMAL_DISPLAY && !_warning_has_been_displayed) { _out << NOMAD::open_block("Warning:") @@ -4311,25 +4750,36 @@ void NOMAD::Parameters::check ( bool remove_history_file , if ( _nb_free_variables >= 50 || has_categorical || _opt_only_sgte ) { - _model_params.search1 = _model_params.search2 = _model_params.eval_sort = NOMAD::NO_MODEL; + _model_params.search1 = _model_params.search2 = _model_params.eval_sort = NOMAD::NO_MODEL; set_DIRECTION_TYPE_NO_MODEL(); - if (_out.get_gen_dd()>NOMAD::MINIMAL_DISPLAY && !_warning_has_been_displayed) + if ( _out.get_gen_dd() > NOMAD::MINIMAL_DISPLAY && !_warning_has_been_displayed) { - if ( _opt_only_sgte) + if ( _opt_only_sgte ) _out << NOMAD::open_block("Warning:") << "Model use is disabled when setting the option OPT_ONLY_SGTE to yes." << std::endl; - if ( has_categorical) + if ( has_categorical ) _out << NOMAD::open_block("Warning:") << "Model use is disabled for problem with categorical variables." << std::endl << NOMAD::close_block(); - if ( _nb_free_variables >= 50) + if ( _nb_free_variables >= 50 ) _out << NOMAD::open_block("Warning:") << "Model use is disabled for problem with dimension greater than 50." << std::endl << NOMAD::close_block(); } } + // disable minimal granularity when categorical variables are present + if ( has_categorical && get_number_granular_variables() > 0 ) + { + _granularity.reset( _dimension , 0.0 ); + + if (_out.get_gen_dd()>NOMAD::MINIMAL_DISPLAY && !_warning_has_been_displayed) + _out << NOMAD::open_block("Warning:") + << "Setting granularity different than 0 is disabled for problem with categorical variables." << std::endl + << NOMAD::close_block(); + + } // disable PEB constraints when categorical variables are present if ( has_categorical && _barrier_type == NOMAD::PEB_P) @@ -4402,12 +4852,14 @@ void NOMAD::Parameters::check ( bool remove_history_file , if ( _model_params.search_max_trial_pts < 1 ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MODEL_SEARCH_MAX_TRIAL_PTS (must be >= 1)" ); + + } /*----------------------------*/ /* EVAL SORT */ /*----------------------------*/ - if (_disable_eval_sort) + if ( _disable_eval_sort ) { _model_params.eval_sort = NOMAD::NO_MODEL; @@ -4474,7 +4926,8 @@ void NOMAD::Parameters::check ( bool remove_history_file , for ( i = 0 ; i < _dimension ; ++i ) { - if ( !in_group[i] && !_fixed_variables[i].is_defined() ) { + if ( !in_group[i] && !_fixed_variables[i].is_defined() ) + { if ( _bb_input_type[i] != NOMAD::CATEGORICAL ) vi_cbi.insert(i); else @@ -4485,6 +4938,7 @@ void NOMAD::Parameters::check ( bool remove_history_file , // creation of a group for cont./bin./int. variables: if ( !vi_cbi.empty() ) { + vg = new NOMAD::Variable_Group ( vi_cbi , _direction_types , _sec_poll_dir_types , @@ -4640,16 +5094,18 @@ void NOMAD::Parameters::check ( bool remove_history_file , _bb_input_type , _lb , _ub , - _use_smesh , - _anisotropic_mesh , - _initial_poll_size, - _min_poll_size, - _min_mesh_size, - _mesh_update_basis, - _poll_update_basis, + _mesh_type , + _anisotropic_mesh , + _granularity , + _initial_poll_size , + _min_poll_size , + _min_mesh_size , + _mesh_update_basis , + _poll_update_basis , _mesh_coarsening_exponent, _mesh_refining_exponent, - _initial_mesh_index, + _initial_mesh_index , + _limit_mesh_index , _scaling , _fixed_variables , _periodic_variables , @@ -4679,6 +5135,7 @@ void NOMAD::Parameters::check ( bool remove_history_file , _ub , _scaling , _fixed_variables , + _granularity , _periodic_variables , _var_groups ); } @@ -4697,7 +5154,8 @@ void NOMAD::Parameters::check ( bool remove_history_file , /* X0 */ /*----------------------------*/ { - if ( _x0s.empty() && _x0_cache_file.empty() ) { + if ( _x0s.empty() && _x0_cache_file.empty() ) + { if ( _LH_search_p0 <= 0 ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "Parameters::check(): no starting point" ); @@ -4713,13 +5171,12 @@ void NOMAD::Parameters::check ( bool remove_history_file , throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: x0 with missing coordinates" ); - // check that x0 is consistent with input type for ( i = 0 ; i < _dimension ; ++i ) { const NOMAD::Double xi = (*_x0s[k])[i]; if ( _bb_input_type[i] != NOMAD::CONTINUOUS && ! xi.is_integer() ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameter: x0 with variables values inconistent with their type (integer, binary, categorical." ); + "invalid parameter: x0 with variables values inconsistent with their type (integer, binary, categorical)." ); } @@ -4759,7 +5216,8 @@ void NOMAD::Parameters::add_seed_to_file_name ( int n_seed , std::string ext = ""; std::string fic = file_name; - if ( k >= 0 && k < n_pn ) { + if ( k >= 0 && k < n_pn ) + { fic = file_name.substr ( 0 , k ); ext = file_name.substr ( k , n_pn-k ); n_pn = k; @@ -4936,24 +5394,6 @@ int NOMAD::Parameters::get_model_quad_min_Y_size ( void ) const return _model_params.quad_min_Y_size; } -// get_model_tgp_mode: -NOMAD::TGP_mode_type NOMAD::Parameters::get_model_tgp_mode ( void ) const -{ - if ( _to_be_checked ) - throw Bad_Access ( "Parameters.cpp" , __LINE__ , - "Parameters::get_model_tgp_mode(), Parameters::check() must be invoked" ); - return _model_params.tgp_mode; -} - -// get_model_tgp_reuse_model: -bool NOMAD::Parameters::get_model_tgp_reuse_model ( void ) const -{ - if ( _to_be_checked ) - throw Bad_Access ( "Parameters.cpp" , __LINE__ , - "Parameters::get_model_tgp_reuse_model(), Parameters::check() must be invoked" ); - return _model_params.tgp_reuse_model; -} - // get_model_search_max_trial_pts: int NOMAD::Parameters::get_model_search_max_trial_pts ( void ) const { @@ -5082,17 +5522,18 @@ bool NOMAD::Parameters::get_anisotropic_mesh ( void ) const return _anisotropic_mesh; } - -// smesh: -bool NOMAD::Parameters::get_use_smesh ( void ) const +// mesh_type: +const NOMAD::mesh_type & NOMAD::Parameters::get_mesh_type ( void ) const { if ( _to_be_checked ) throw Bad_Access ( "Parameters.cpp" , __LINE__ , - "Parameters::get_use_smesh, Parameters::check() must be invoked" ); - return _use_smesh; + "Parameters::get_mesh_type, Parameters::check() must be invoked" ); + return _mesh_type; + } + // get_mesh_update_basis: const NOMAD::Double & NOMAD::Parameters::get_mesh_update_basis ( void ) const { @@ -5963,7 +6404,8 @@ void NOMAD::Parameters::set_POINT_DISPLAY_LIMIT ( int dl ) // set_DIMENSION: bool NOMAD::Parameters::set_DIMENSION ( int dim ) { - if ( _dimension > 0 ) { + if ( _dimension > 0 ) + { _dimension = -1; throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: DIMENSION - defined twice" ); @@ -5972,7 +6414,8 @@ bool NOMAD::Parameters::set_DIMENSION ( int dim ) _to_be_checked = true; _dimension = dim; - if ( _dimension <= 0 ) { + if ( _dimension <= 0 ) + { _dimension = -1; throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: DIMENSION" ); @@ -6020,6 +6463,9 @@ void NOMAD::Parameters::set_EXTERN_SIGNATURE ( NOMAD::Signature * s ) // fixed variables: set_FIXED_VARIABLE ( s->get_fixed_variables() ); + // granularity: + set_GRANULARITY( s->get_granularity() ); + // periodic variables: set_PERIODIC_VARIABLE ( s->get_periodic_variables() ); @@ -6027,9 +6473,12 @@ void NOMAD::Parameters::set_EXTERN_SIGNATURE ( NOMAD::Signature * s ) reset_variable_groups(); set_VARIABLE_GROUP ( s->get_var_groups() ); + // mesh: the mesh is set during check + _to_be_checked = true; } + // set_SNAP_TO_BOUNDS: void NOMAD::Parameters::set_SNAP_TO_BOUNDS ( bool stb ) { @@ -6078,8 +6527,6 @@ void NOMAD::Parameters::set_model_parameters ( const NOMAD::model_params_type & set_MODEL_QUAD_USE_WP ( mp.quad_use_WP ); set_MODEL_QUAD_MIN_Y_SIZE ( mp.quad_min_Y_size ); set_MODEL_QUAD_MAX_Y_SIZE ( mp.quad_max_Y_size ); - set_MODEL_TGP_MODE ( mp.tgp_mode ); - set_MODEL_TGP_REUSE_MODEL ( mp.tgp_reuse_model ); } // set_MODEL_SEARCH (1/3): @@ -6087,24 +6534,21 @@ void NOMAD::Parameters::set_MODEL_SEARCH ( int i , NOMAD::model_type ms ) { _to_be_checked = true; -#ifndef USE_TGP - if ( ms == NOMAD::TGP_MODEL ) - throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameter: MODEL_SEARCH: this version has not been compiled for TGP" ); -#endif - if ( i != 1 && i != 2 ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "NOMAD::Parameters::set_MODEL_SEARCH(i,m): bad value for argument i (must be 1 or 2)" ); - if ( i == 1 ) { + if ( i == 1 ) + { if ( _model_params.search2 != NOMAD::NO_MODEL ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "NOMAD::Parameters::set_MODEL_SEARCH(1,m): already a second model search" ); _model_params.search1 = ms; } - else { + else + { + if ( _model_params.search1 == NOMAD::NO_MODEL && ms != NOMAD::NO_MODEL ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -6121,11 +6565,14 @@ void NOMAD::Parameters::set_MODEL_SEARCH ( int i , NOMAD::model_type ms ) // set_MODEL_SEARCH (2/3): void NOMAD::Parameters::set_MODEL_SEARCH ( bool ms ) { - if ( ms ) { + if ( ms ) + { set_MODEL_SEARCH ( 1 , NOMAD::QUADRATIC_MODEL ); set_MODEL_SEARCH ( 2 , NOMAD::NO_MODEL ); } - else { + else + { + set_MODEL_SEARCH ( 1 , NOMAD::NO_MODEL ); set_MODEL_SEARCH ( 2 , NOMAD::NO_MODEL ); } @@ -6142,11 +6589,6 @@ void NOMAD::Parameters::set_MODEL_SEARCH ( NOMAD::model_type ms ) // set_MODEL_EVAL_SORT (1/2): void NOMAD::Parameters::set_MODEL_EVAL_SORT ( NOMAD::model_type mes ) { -#ifndef USE_TGP - if ( mes == NOMAD::TGP_MODEL ) - throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameter: MODEL_EVAL_SORT: this version has not been compiled for TGP" ); -#endif _to_be_checked = true; _model_params.eval_sort = mes; } @@ -6210,27 +6652,6 @@ void NOMAD::Parameters::set_MODEL_NP1_QUAD_EPSILON ( const NOMAD::Double & d ) _model_params.model_np1_quad_epsilon = d; } - - -// set_MODEL_TGP_MODE: -void NOMAD::Parameters::set_MODEL_TGP_MODE ( NOMAD::TGP_mode_type m ) -{ - if ( m == NOMAD::TGP_USER ) { - throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , - "invalid parameter: MODEL_TGP_MODE: the TGP user mode is only a debugging option" ); - } - - _to_be_checked = true; - _model_params.tgp_mode = m; -} - -// set_MODEL_TGP_REUSE_MODEL: -void NOMAD::Parameters::set_MODEL_TGP_REUSE_MODEL ( bool rm ) -{ - _to_be_checked = true; - _model_params.tgp_reuse_model = rm; -} - // set_MODEL_SEARCH_MAX_TRIAL_PTS: void NOMAD::Parameters::set_MODEL_SEARCH_MAX_TRIAL_PTS ( int s ) { @@ -6257,7 +6678,8 @@ void NOMAD::Parameters::set_VNS_SEARCH ( bool s ) void NOMAD::Parameters::set_VNS_SEARCH ( const NOMAD::Double & trigger ) { _to_be_checked = true; - if ( !trigger.is_defined() ) { + if ( !trigger.is_defined() ) + { _VNS_search = false; return; } @@ -6323,7 +6745,8 @@ void NOMAD::Parameters::set_SEC_POLL_DIR_TYPE ( NOMAD::direction_type dt ) // set_SEC_POLL_DIR_TYPE (2/2): void NOMAD::Parameters::set_SEC_POLL_DIR_TYPE -( const std::set<NOMAD::direction_type> & dt ) { +( const std::set<NOMAD::direction_type> & dt ) +{ std::set<NOMAD::direction_type>::const_iterator it , end = dt.end(); for ( it = dt.begin() ; it != end ; ++it ) set_SEC_POLL_DIR_TYPE ( *it ); @@ -6796,7 +7219,8 @@ void NOMAD::Parameters::set_SGTE_CACHE_FILE ( const std::string & cf ) _sgte_cache_file = cf; if ( cf.empty() ) return; - if ( !NOMAD::Parameters::check_directory ( _sgte_cache_file ) ) { + if ( !NOMAD::Parameters::check_directory ( _sgte_cache_file ) ) + { throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: SGTE_CACHE_FILE"); } @@ -6828,7 +7252,8 @@ void NOMAD::Parameters::set_X0 ( const std::string & file_name ) std::string complete_file_name = _problem_dir + file_name; std::ifstream fin ( complete_file_name.c_str() ); - if ( fin.fail() ) { + if ( fin.fail() ) + { std::string err = "invalid parameter: X0 - could not open file \'" + complete_file_name + "\'"; fin.close(); @@ -6839,14 +7264,16 @@ void NOMAD::Parameters::set_X0 ( const std::string & file_name ) try { fin >> tmp_x0; } - catch ( NOMAD::Point::Bad_Input & ) { + catch ( NOMAD::Point::Bad_Input & ) + { flag = false; // we suppose that the file name corresponds to a cache file: _x0_cache_file = file_name; } - while ( flag ) { + while ( flag ) + { set_X0 ( tmp_x0 ); @@ -6855,7 +7282,8 @@ void NOMAD::Parameters::set_X0 ( const std::string & file_name ) try { fin >> tmp_x0; } - catch ( NOMAD::Point::Bad_Input & ) { + catch ( NOMAD::Point::Bad_Input & ) + { flag = false; } } @@ -6880,7 +7308,8 @@ void NOMAD::Parameters::set_DISPLAY_STATS ( const std::list<std::string> & ls ) // set_DISPLAY_STATS (2/2): void NOMAD::Parameters::set_DISPLAY_STATS ( const std::string & stats ) { - if ( stats.empty() ) { + if ( stats.empty() ) + { _display_stats.clear(); return; } @@ -6891,7 +7320,8 @@ void NOMAD::Parameters::set_DISPLAY_STATS ( const std::string & stats ) it = pe.get_values().begin(); std::list<std::string> ls; - while ( it != end ) { + while ( it != end ) + { ls.push_back ( *it ); ++it; } @@ -6905,7 +7335,8 @@ void NOMAD::Parameters::set_DISPLAY_STATS ( const std::string & stats ) void NOMAD::Parameters::set_STATS_FILE ( const std::string & file_name , const std::list<std::string> & ls ) { - if ( file_name.empty() ) { + if ( file_name.empty() ) + { reset_stats_file(); return; } @@ -6930,7 +7361,8 @@ void NOMAD::Parameters::set_STATS_FILE ( const std::string & file_name , it = pe.get_values().begin(); std::list<std::string> ls; ++it; - while ( it != end ) { + while ( it != end ) + { ls.push_back(*it); ++it; } @@ -6957,27 +7389,32 @@ bool NOMAD::Parameters::set_DISPLAY_DEGREE ( const std::string & dd ) std::string ddu = dd; NOMAD::toupper ( ddu ); - if ( ddu == "NO" || ddu == "NO_DISPLAY" ) { + if ( ddu == "NO" || ddu == "NO_DISPLAY" ) + { set_DISPLAY_DEGREE ( 0 , 0 , 0 , 0 ); return true; } - else if ( ddu == "MIN" || ddu == "MINIMAL" || ddu == "MINIMAL_DISPLAY" ) { + else if ( ddu == "MIN" || ddu == "MINIMAL" || ddu == "MINIMAL_DISPLAY" ) + { set_DISPLAY_DEGREE ( 1 , 1 , 1 , 1 ); return true; } - else if ( ddu == "NORMAL" || ddu == "NORMAL_DISPLAY" ) { + else if ( ddu == "NORMAL" || ddu == "NORMAL_DISPLAY" ) + { set_DISPLAY_DEGREE ( 2 , 2 , 2 , 2 ); return true; } - else if ( ddu == "FULL" || ddu == "FULL_DISPLAY" ) { + else if ( ddu == "FULL" || ddu == "FULL_DISPLAY" ) + { set_DISPLAY_DEGREE ( 3 , 3 , 3 , 3 ); return true; } } - if ( dd.size() == 1 ) { + if ( dd.size() == 1 ) + { int i; if ( !NOMAD::atoi ( dd[0] , i ) ) return false; @@ -7073,6 +7510,15 @@ void NOMAD::Parameters::set_MAX_BB_EVAL ( int bbe ) _max_bb_eval = ( bbe < 0 ) ? -1 : bbe; } + +// set_MAX_BB_EVAL: +void NOMAD::Parameters::set_MAX_EVAL_INTENSIFICATION ( int bbe ) +{ + _to_be_checked = true; + _max_eval_intensification = ( bbe <= 0 ) ? -1 : bbe; +} + + // set_MAX_SIM_BB_EVAL: void NOMAD::Parameters::set_MAX_SIM_BB_EVAL ( int bbe ) { @@ -7160,20 +7606,20 @@ void NOMAD::Parameters::set_L_CURVE_TARGET ( const NOMAD::Double & lct ) // set_ANISOTROPIC_MESH: void NOMAD::Parameters::set_ANISOTROPIC_MESH ( bool anis ) { - _to_be_checked = true; - _anisotropic_mesh = anis; + _to_be_checked = true; + _anisotropic_mesh = anis; } - -// set_USE_SMESH: -void NOMAD::Parameters::set_USE_SMESH ( bool use_smesh ) +// set_MESH_TYPE: +void NOMAD::Parameters::set_MESH_TYPE ( NOMAD::mesh_type mt ) { - _to_be_checked = true; - _use_smesh = use_smesh; + _to_be_checked = true; + _mesh_type = mt; } + // set_MESH_UPDATE_BASIS: void NOMAD::Parameters::set_MESH_UPDATE_BASIS ( const NOMAD::Double & mub ) { @@ -7426,7 +7872,8 @@ void NOMAD::Parameters::set_MIN_POLL_SIZE ( int index , throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , "invalid parameter: MIN_POLL_SIZE" ); _to_be_checked = true; - if ( relative ) { + if ( relative ) + { if ( !_lb[index].is_defined() || !_ub[index].is_defined() || !d.is_defined() || d <= 0.0 || d > 1.0 ) throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , @@ -7442,7 +7889,8 @@ void NOMAD::Parameters::set_MIN_POLL_SIZE ( const NOMAD::Point & delta_p_min , bool relative ) { _to_be_checked = true; - if ( relative ) { + if ( relative ) + { int nd = delta_p_min.size(); for ( int i = 0 ; i < nd ; ++i ) set_MIN_POLL_SIZE ( i , delta_p_min[i] , true ); @@ -7465,6 +7913,12 @@ void NOMAD::Parameters::set_MIN_POLL_SIZE ( const NOMAD::Double & d , bool relat _min_poll_size = NOMAD::Point ( _dimension , d ); } +void NOMAD::Parameters::set_LIMIT_MESH_INDEX ( const int & lmi ) +{ + _to_be_checked = true; + _limit_mesh_index = lmi; +} + // set_NEIGHBORS_EXE: void NOMAD::Parameters::set_NEIGHBORS_EXE ( const std::string & ne ) { @@ -7560,7 +8014,6 @@ void NOMAD::Parameters::set_BB_MAX_BLOCK_SIZE ( int max_block_size ) if ( _bb_max_block_size > 1 ) _eval_points_as_block=true; - } @@ -7708,11 +8161,83 @@ void NOMAD::Parameters::set_VARIABLE_GROUP for ( it = vg.begin() ; it != end ; ++it ) set_VARIABLE_GROUP ( (*it)->get_var_indexes () , (*it)->get_direction_types () , - (*it)->get_sec_poll_dir_types() - ); + (*it)->get_sec_poll_dir_types() ); + +} + + +void NOMAD::Parameters::reset_granulary ( void ) +{ + _to_be_checked = true; + _granularity.clear(); +} + + +const NOMAD::Point & NOMAD::Parameters::get_granularity ( void ) const +{ + if ( _to_be_checked ) + throw Bad_Access ( "Parameters.cpp" , __LINE__ , + "Parameters::get_granularity(), Parameters::check() must be invoked" ); + + return _granularity; +} + +int NOMAD::Parameters::get_number_granular_variables ( void ) const +{ + + if ( ! _granularity.is_defined() ) + return -1; + + int k=0; + for ( int i=0 ; i < _dimension ; i++ ) + { + if ( _granularity[i] > 0 ) + k++; + + } + return k; +} + + +// set_GRANULAR_VARIABLE +void NOMAD::Parameters::set_GRANULARITY ( int index , const NOMAD::Double & value ) +{ + + _to_be_checked = true; + + if ( index < 0 || index >= _dimension ) + throw Invalid_Parameter ( "Parameters.cpp" , __LINE__ , + "invalid parameter: GRANULARITY - index must be in [0;dimension-1] " ); + + if ( ! _granularity.is_defined() || _granularity.size() != _dimension ) + _granularity.reset( _dimension, 0.0 ); + _granularity[index] = value; } + +// set_GRANULARITY +void NOMAD::Parameters::set_GRANULARITY ( const NOMAD::Point & v ) +{ + _to_be_checked = true; + _granularity = v; + +} + + +// set_GRANULARITY +void NOMAD::Parameters::set_GRANULARITY ( const NOMAD::Double & v ) +{ + _to_be_checked = true; + + _granularity.clear(); + + set_GRANULARITY ( NOMAD::Point( _dimension , v ) ); + +} + + + /*-----------------------------------------------*/ /* help (display parameter descriptions) - 1/3 */ /*-----------------------------------------------*/ @@ -7765,8 +8290,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo const char registered_key_basic[]="2N ANGLES AVG BARRIER BASIC BASIC BB_EXE BB_INPUT_TYPE BB_OUTPUT_TYPE BI-MADS BI-OBJECTIVES BIMADS \ - BINARY BIOBJECTIVES BLACK-BOXES BLACKBOXES BOUNDS CACHE BBEVAL CACHE_FILE CNT_EVAL CONSTRAINTS CONTINUOUS COUNT DEBUG DELTA_0 DIMENSION \ - DIRECTION_TYPE DIRECTION_TYPES DIRECTIONS DIRECTIONS_TYPES DIRECTORY DISPLAY_ALL_EVAL DISPLAY_DEGREES DISPLAY_STATS EVALUATIONS \ + BINARY BIOBJECTIVES BLACK-BOXES BLACKBOXES BOUNDS CACHE BBEVAL CACHE_FILE CNT_EVAL CONSTRAINTS CONTINUOUS COUNT DEBUG DELTA_0 DIMENSION \ + DIRECTION_TYPE DIRECTION_TYPES DIRECTIONS DIRECTIONS_TYPES DIRECTORY DISPLAY_ALL_EVAL DISPLAY_DEGREES DISPLAY_STATS EVALUATIONS \ EXECUTABLE F_TARGET FILES FILTER FORMAT GPS h(x) HISTORY_FILE INITIAL_MESH_SIZE INTEGER LATEX LATIN-HYPERCUBE LB LH_SEARCH LOWER_BOUND \ LT LT-MADS LTMADS MADS MAX_BB_EVAL MAX_TIME MAXIMUM MINIMIZE MODEL MODELS MULTI-OBJECTIVE MULTIOBJECTIVES N+1 NUMBER OPTIMIZE ORTHO \ ORTHO-MADS ORTHOMADS OUTPUTS PATH PB PEB POINT POLL PROGRESSIVE-BARRIER RANDOM SAMPLING SCREEN SCREEN SOLUTION_FILE STARTING STATIC \ @@ -7786,16 +8311,17 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo OPTIMISTIC ORTHO ORTHO-MADS ORTHOGONAL ORTHOMADS OUTPUT OUTPUTS PARALLELISM PARETO PB PEB PERIODIC_VARIABLE PMADS POINT_DISPLAY_LIMIT \ POLL POLL_UPDATE_BASIS PRECISION PROGRESSIVE-BARRIER PROJECTION PSD-MADS PSDMADS QUAD QUADRATIC RAM RANDOM REALS REGRESSION RHO SAMPLING SCALE SCALING \ SEARCH SEED SGTE_CACHE_FILE SGTE_COST SGTE_EVAL_SORT SGTE_EXE SGTE_ORDERING SGTES SIMULATED SNAP_TO_BOUNDS SPECULATIVE_SEARCH \ - STAT_SUM_TARGET STATS STOP_IF_FEASIBLE SUCCESSES SURF SURROGATES TABULATIONS TAU TERMINATES TERMINATION TGP TGPMODEL_SEARCH TRIGGER \ - UB UNDEF_STR UNDEFINED USER_CALLS_DISABLED USER_CALLS_ENABLED VARIABLE_GROUP VARIABLES VNS_SEARCH W- W+"; + STAT_SUM_TARGET STATS STOP_IF_FEASIBLE SUCCESSES SURF SURROGATES TABULATIONS TAU TERMINATES TERMINATION TRIGGER \ + UB UNDEF_STR UNDEFINED USER_CALLS_DISABLED USER_CALLS_ENABLED VARIABLE_GROUP VARIABLES VNS_SEARCH W- W+ "; const char registered_key_developer[]="BI-MADS BI-OBJECTIVES BIMADS BIOBJECTIVES BLACK-BOXES BLACK-BOXES COMPARISONS DEVELOPER \ DIRECTIONS EPSILON EVALUATIONS FROBENIUS INITIAL_MESH_INDEX IMPROVEMENT INTERPOLATION L_CURVE_TARGET MADS MFN MODEL MODEL_EVAL_SORT_CAUTIOUS MODEL_ORDERING \ MODEL_QUAD_MAX_Y_SIZE MODEL_QUAD_MIN_Y_SIZE MODEL_QUAD_RADIUS_FACTOR MODEL_QUAD_USE_WP MODEL_SEARCH MODEL_SEARCH_MAX_TRIAL_PTS \ - MODEL_SEARCH_PROJ_TO_MESH MODEL_TGP_MODE MODEL_TGP_REUSE_MODEL MODELS MULTI_FORMULATION MULTI_USE_DELTA_CRITERION MULTI-OBJECTIVES \ + MODEL_SEARCH_PROJ_TO_MESH MODELS MULTI_FORMULATION MULTI_USE_DELTA_CRITERION MULTI-OBJECTIVES \ MULTIOBJECTIVES N+1 NP1 OBJECTIVE OPPORTUNISTIC_LUCKY_EVAL OPPORTUNISTIC_MIN_F_IMPRVMT OPPORTUNISTIC_MIN_NB_SUCCESSES OPT_ONLY_SGTES \ ORTHO PARETO PB PEB POLL PRECISION PROGRESSIVE-BARRIER PROJECTION QUAD QUADRATIC REALS REGRESSION SEC_POLL_DIR_TYPES SGTES STOPPING \ - SUCCESSES SURROGATES TERMINATES TERMINATION TGP USE_SMESH WELL-POISEDNESS"; + SUCCESSES SURROGATES TERMINATES TERMINATION MESH_TYPE WELL-POISEDNESS " ; + if ( display_all || NOMAD::string_find ( registered_key_basic, param_names ) ) @@ -7812,7 +8338,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo EXECUTABLE FILES BI-OBJECTIVES \ BIOBJECTIVES MULTIOBJECTIVES \ BIMADS BI-MADS \ - MULTI-OBJECTIVES" , param_names ) ) { + MULTI-OBJECTIVES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "BB_EXE (basic)" ) << std::endl << ". blackbox executable names" << std::endl @@ -7839,7 +8366,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // -------------- if ( display_all || NOMAD::string_find ( "BB_INPUT_TYPE BLACK-BOXES BLACKBOXES \ BASIC VARIABLES CONTINUOUS \ - INTEGER BINARY" , param_names ) ) { + INTEGER BINARY" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "BB_INPUT_TYPE (basic)" ) << std::endl << ". blackbox input types" << std::endl @@ -7869,7 +8397,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo MULTI-OBJECTIVE MINIMIZE \ BIOBJECTIVES MULTIOBJECTIVES \ BI-MADS BIMADS \ - OPTIMIZE" , param_names ) ) { + OPTIMIZE" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "BB_OUTPUT_TYPE (basic)" ) << std::endl << ". blackbox output types" << std::endl @@ -7915,7 +8444,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // CACHE_FILE: // ----------- if ( display_all || NOMAD::string_find ( "CACHE_FILE BASIC \ - FILES OUTPUTS" , param_names ) ) { + FILES OUTPUTS" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "CACHE_FILE (basic)" ) << std::endl << ". cache file; if the specified file" << std::endl @@ -7952,7 +8482,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo MADS DIRECTIONS 2N N+1 POLL MODEL MODELS \ ORTHOMADS ORTHO-MADS LTMADS LT-MADS \ RANDOM STATIC UNIFORM ANGLES" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "DIRECTION_TYPE (basic)" ) << std::endl << ". types of directions used in the poll step" << std::endl @@ -7975,6 +8506,10 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo << " # ((n+1)th dir = " << std::endl << " # negative sum of" << std::endl << " # n first dirs)" << std::endl + << "DIRECTION_TYPE ORTHO N+1 UNI # OrthoMADS, n+1" << std::endl + << " # uniform " << std::endl + << " # distribution of" << std::endl + << " # dirs)" << std::endl << "DIRECTION_TYPE ORTHO # OrthoMADS, n+1 QUAD " << std::endl << "DIRECTION_TYPE ORTHO 2N # OrthoMADS, 2n" << std::endl << "DIRECTION_TYPE LT 1 # LT-MADS, 1" << std::endl @@ -8028,12 +8563,13 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // DISPLAY_DEGREE: // --------------- if ( display_all || NOMAD::string_find ( "DISPLAY_DEGREES OUTPUTS \ - SCREEN DEBUG BASIC" , param_names ) ) { + SCREEN DEBUG BASIC" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "DISPLAY_DEGREE (basic)" ) << std::endl << ". " << NOMAD::open_block ( "display degree" ) << "0: no display" << std::endl - << "1: minimal display" << std::endl + << "1: minimal display" << std::endl << "2: normal display" << std::endl << "3: full display" << std::endl << NOMAD::close_block() @@ -8066,7 +8602,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // DISPLAY_STATS: // --------------- if ( display_all || NOMAD::string_find ( "DISPLAY_STATS OUTPUTS LATEX FORMAT \ - SCREEN DEBUG BASIC" , param_names ) ) { + SCREEN DEBUG BASIC" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "DISPLAY_STATS (basic)" ) << std::endl << ". format of the outputs displayed at each success" << std::endl @@ -8119,7 +8656,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo MULTI-OBJECTIVES \ BIOBJECTIVES MULTIOBJECTIVES \ BI-MADS BIMADS \ - TERMINATES TERMINATION" , param_names ) ) { + TERMINATES TERMINATION" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "F_TARGET (basic)" ) << std::endl << ". NOMAD terminates if fi <= F_TARGET[i] for" << std::endl @@ -8137,7 +8675,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // HISTORY_FILE: // ------------- if ( display_all || NOMAD::string_find ( "HISTORY_FILE BASIC \ - FILES OUTPUTS" , param_names ) ) { + FILES OUTPUTS" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "HISTORY_FILE (basic)" ) << std::endl << ". history file: contains all trial points" << std::endl @@ -8155,7 +8694,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // INITIAL_MESH_SIZE: // ------------------ if ( display_all || NOMAD::string_find ( "INITIAL_MESH_SIZE BASIC MADS \ - DELTA_0 " , param_names ) ) { + DELTA_0 " , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "INITIAL_MESH_SIZE (basic)" ) << std::endl << ". initial mesh size" << std::endl @@ -8183,7 +8723,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // INITIAL_POLL_SIZE: // ------------------ if ( display_all || NOMAD::string_find ( "INITIAL_POLL_SIZE BASIC MADS \ - DELTA_0 " , param_names ) ) { + DELTA_0 " , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "INITIAL_POLL_SIZE (basic)" ) << std::endl << ". initial poll size" << std::endl @@ -8212,7 +8753,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // LH_SEARCH: // ---------- if ( display_all || NOMAD::string_find ( "LH_SEARCH LATIN-HYPERCUBE \ - SAMPLING BASIC" , param_names ) ) { + SAMPLING BASIC" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "LH_SEARCH (basic)" ) << std::endl << ". Latin-Hypercube sampling (search)" << std::endl @@ -8234,7 +8776,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // LOWER_BOUND: // ------------ if ( display_all || NOMAD::string_find ( "LOWER_BOUND BASIC LB BOUNDS FILES" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "LOWER_BOUND (basic)" ) << std::endl << ". lower bounds for each variable" << std::endl @@ -8258,7 +8801,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo BI-0BJECTIVE MULTI-OBJECTIVE \ BIOBJECTIVES MULTIOBJECTIVES \ BI-MADS BIMADS \ - TERMINATES TERMINATION" , param_names ) ) { + TERMINATES TERMINATION" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MAX_BB_EVAL (basic)" ) << std::endl << ". maximum number of blackbox evaluations" << std::endl @@ -8278,7 +8822,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo if ( display_all || NOMAD::string_find ( "MAX_TIME BASIC BLACK-BOXES BLACKBOXES \ MAXIMUM WALL-CLOCK REAL \ STOPPING TERMINATION \ - TERMINATES" , param_names ) ) { + TERMINATES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MAX_TIME (basic)" ) << std::endl << ". maximum wall-clock time in seconds" << std::endl @@ -8293,7 +8838,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // SOLUTION_FILE: // -------------- if ( display_all || NOMAD::string_find ( "SOLUTION_FILE BASIC \ - FILES OUTPUTS" , param_names ) ) { + FILES OUTPUTS" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "SOLUTION_FILE (basic)" ) << std::endl << ". file containing the solution" << std::endl @@ -8312,7 +8858,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ----------- if ( display_all || NOMAD::string_find ( "STATS_FILE BASIC \ FILES OUTPUTS DISPLAY_STATS" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "STATS_FILE (basic)" ) << std::endl << ". file containing all successes with the same format" << std::endl @@ -8332,7 +8879,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // -------- if ( display_all || NOMAD::string_find ( "TMP_DIR BASIC PATH TEMPORARY \ DIRECTORY FILES \ - BLACK-BOXES BLACKBOXES" , param_names ) ) { + BLACK-BOXES BLACKBOXES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "TMP_DIR (basic)" ) << std::endl << ". temporary directory for blackbox input/output files" << std::endl @@ -8349,7 +8897,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // UPPER_BOUND: // ------------ if ( display_all || NOMAD::string_find ( "UPPER_BOUND BASIC UB BOUNDS" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "UPPER_BOUND (basic)" ) << std::endl << ". upper bounds for each variable" << std::endl @@ -8365,7 +8914,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo if ( display_all || NOMAD::string_find ( "X0 STARTING POINT BASIC \ VARIABLES \ LH LATIN-HYPERCUBE \ - CACHE FILES" , param_names ) ) { + CACHE FILES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "X0 (basic)" ) << std::endl << ". starting point(s)" << std::endl @@ -8407,7 +8957,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ADD_SEED_TO_FILE_NAMES: // ----------------------- if ( display_all || NOMAD::string_find ( "ADD_SEED_TO_FILE_NAMES OUTPUTS \ - ADVANCED FILES" , param_names ) ) { + ADVANCED FILES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "ADD_SEED_TO_FILE_NAMES (advanced)" ) << std::endl << ". if \'yes\', the seed is added to the name of" << std::endl @@ -8422,12 +8973,13 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ANISOTROPIC_MESH: // ------------- - if ( display_all || NOMAD::string_find ( "ANISOTROPIC MESH SCALING" , param_names ) ) { + if ( display_all || NOMAD::string_find ( "ANISOTROPIC MESH SCALING" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "ANISOTROPIC_MESH (advanced)" ) << std::endl << ". use anisotropic mesh for generating directions" << std::endl - << ". if \'yes\', the mesh size is scaled dynamically" << std::endl - << ". based on direction of success." << std::endl + << ". if \'yes\', the mesh size is scaled dynamically" << std::endl + << ". based on direction of success." << std::endl << ". This option is compatible with Ortho Mads " << std::endl << ". directions only " << std::endl << ". default: \'yes\'" << std::endl @@ -8440,7 +8992,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ASYNCHRONOUS: // ------------- if ( display_all || NOMAD::string_find ( "ASYNCHRONOUS PARALLELISM MPI \ - ADVANCED PMADS" , param_names ) ) { + ADVANCED PMADS" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "ASYNCHRONOUS (advanced)" ) << std::endl << ". asynchronous strategy for the parallel version" << std::endl @@ -8458,7 +9011,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ---------------------- if ( display_all || NOMAD::string_find ( "BB_INPUT_INCLUDE_SEED BLACK-BOXES \ BLACKBOXES \ - ADVANCED FILES" , param_names ) ) { + ADVANCED FILES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "BB_INPUT_INCLUDE_SEED (advanced)" ) << std::endl << ". if \'yes\', the seed (\'SEED\') of the current" << std::endl @@ -8475,7 +9029,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // --------------------- if ( display_all || NOMAD::string_find ( "BB_INPUT_INCLUDE_TAG \ BLACK-BOXES BLACKBOXES \ - ADVANCED FILES" , param_names ) ) { + ADVANCED FILES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "BB_INPUT_INCLUDE_TAG (advanced)" ) << std::endl << ". if \'yes\', the tag of a point is put as the first" << std::endl @@ -8492,7 +9047,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // BB_REDIRECTION: // --------------- if ( display_all || NOMAD::string_find ( "BB_REDIRECTION BLACK-BOXES BLACKBOXES \ - ADVANCED OUTPUT FILES" , param_names ) ) { + ADVANCED OUTPUT FILES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "BB_REDIRECTION (advanced)" ) << std::endl << ". if NOMAD uses a redirection (\'>\') to" << std::endl @@ -8564,8 +9120,9 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo if ( display_all || NOMAD::string_find ( "MODEL DISABLE MODELS DISABLE_MODELS \ MODEL_EVAL_SORT ADVANCED \ EVAL_SORT \ - ORTHO N+1 QUAD QUADRATIC MODEL_SEARCH TGP " , - param_names ) ) { + ORTHO N+1 QUAD QUADRATIC MODEL_SEARCH" , + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "DISABLE (advanced)" ) << std::endl << ". this parameter is used to forcefully disable a feature." << std::endl @@ -8578,35 +9135,37 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo << " MODEL_SEARCH and DIRECTION_TYPE ORTHO N+1 QUAD" << std::endl << " will be ignored " << std::endl << ". # DISABLE EVAL_SORT: ordering by lexicographic order only. " << std::endl - << " # WARNING: setting of MODEL_EVAL_SORT," << std::endl - << " SURROGATE_EVAL_SORT and user priority " << std::endl - << " will be ignored" << std::endl + << " # WARNING: setting of MODEL_EVAL_SORT," << std::endl + << " SURROGATE_EVAL_SORT and user priority " << std::endl + << " will be ignored" << std::endl << ". default: no default" << std::endl << NOMAD::close_block(); chk = true; } + // BB_MAX_BLOCK_SIZE //----------- if ( display_all || NOMAD::string_find ( "EVAL LIST MAX BLOCK SIZE BB BLACKBOX \ BLACK-BOX OPPORTUNIST OPPORTUNISTIC PARALLEL", - param_names ) ) { + param_names ) ) + { _out << std::endl - << NOMAD::open_block ( "BB_MAX_BLOCK_SIZE (advanced)" ) << std::endl - << ". maximum size of a block of evaluations send to the blackbox" << std::endl - << " executable at once. Blackbox executable can manage parallel" << std::endl - << " evaluations on its own. Opportunistic strategies may apply after" << std::endl - << " each block of evaluations." << std::endl - << " Depending on the algorithm phase, the blackbox executable will" << std::endl - << " receive at most BB_MAX_BLOCK_SIZE points to evaluate." << std::endl + << NOMAD::open_block ( "BB_MAX_BLOCK_SIZE (advanced)" ) << std::endl + << ". maximum size of a block of evaluations send to the blackbox" << std::endl + << " executable at once. Blackbox executable can manage parallel" << std::endl + << " evaluations on its own. Opportunistic strategies may apply after" << std::endl + << " each block of evaluations." << std::endl + << " Depending on the algorithm phase, the blackbox executable will" << std::endl + << " receive at most BB_MAX_BLOCK_SIZE points to evaluate." << std::endl << " When this parameter is greater than one, the number of evaluations"<< std::endl - << " may exceed the MAX_BB_EVAL stopping criterion." << std::endl - << ". argument: integer > 0" << std::endl - << ". example: BB_MAX_BLOCK_SIZE 3," << std::endl - << " The blackbox executable receives blocks of" << std::endl - << " at most 3 points for evaluation." << std::endl - << ". default: 1" << std::endl + << " may exceed the MAX_BB_EVAL stopping criterion." << std::endl + << ". argument: integer > 0" << std::endl + << ". example: BB_MAX_BLOCK_SIZE 3," << std::endl + << " The blackbox executable receives blocks of" << std::endl + << " at most 3 points for evaluation." << std::endl + << ". default: 1" << std::endl << NOMAD::close_block(); chk = true; } @@ -8618,7 +9177,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo EXTENDED_POLL_DISABLED \ MIXED MVP CATEGORICAL \ ADVANCED" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "EXTENDED_POLL_ENABLED (advanced)" ) << std::endl << ". if \'no\', the extended poll for categorical" << std::endl @@ -8635,7 +9195,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // EXTENDED_POLL_TRIGGER: // ---------------------- if ( display_all || NOMAD::string_find ( "EXTENDED_POLL_TRIGGER ADVANCED \ - MIXED MVP CATEGORICAL" , param_names ) ) { + MIXED MVP CATEGORICAL" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "EXTENDED_POLL_TRIGGER (advanced)" ) << std::endl << ". extended poll trigger for categorical variables" << std::endl @@ -8657,7 +9218,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // FIXED_VARIABLE: // --------------- if ( display_all || NOMAD::string_find ( "FIXED_VARIABLE VARIABLES ADVANCED \ - FILES" , param_names ) ) { + FILES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "FIXED_VARIABLE (advanced)" ) << std::endl << ". fix some variables to some specific values" << std::endl @@ -8686,7 +9248,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo CONSTRAINTS PB FILTER PEB \ L1 L2 LINF L_INF \ FEASIBILITY \ - PROGRESSIVE-BARRIER" , param_names ) ) { + PROGRESSIVE-BARRIER" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "H_MAX_0 (advanced)" ) << std::endl << ". initial value of h_max (for PB and" << std::endl @@ -8706,7 +9269,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo CONSTRAINTS PB FILTER PEB \ L1 L2 LINF L_INF \ FEASIBILITY \ - PROGRESSIVE-BARRIER" , param_names ) ) { + PROGRESSIVE-BARRIER" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "H_MIN (advanced)" ) << std::endl << ". value of h_min; x is feasible if h(x) <= h_min" << std::endl @@ -8724,7 +9288,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo CONSTRAINTS PB FILTER PEB \ L1 L2 LINF L_INF \ FEASIBILITY \ - PROGRESSIVE-BARRIER" , param_names ) ) { + PROGRESSIVE-BARRIER" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "H_NORM (advanced)" ) << std::endl << ". norm used by the F and PB constraints handling" << std::endl @@ -8741,8 +9306,9 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // HAS_SGTE: // --------- if ( display_all || NOMAD::string_find ( "HAS_SGTE SGTE_EXE ADVANCED SURROGATES \ - BLACK-BOXES BLACKBOXES \ - SGTES" , param_names ) ) { + BLACK-BOXES BLACKBOXES \ + SGTES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "HAS_SGTE (advanced)" ) << std::endl << ". to indicate that the problem has a surrogate" << std::endl @@ -8762,7 +9328,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // -------- if ( display_all || NOMAD::string_find ( "INF_STR ADVANCED \ INFINITY DISPLAY REALS" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "INF_STR (advanced)" ) << std::endl << ". string used to display infinity" << std::endl @@ -8778,7 +9345,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo if ( display_all || NOMAD::string_find ( "MAX_CACHE_MEMORY ADVANCED \ MAXIMUM RAM STOPPING \ MB MEGA-BYTES MEGABYTES \ - TERMINATES TERMINATION" , param_names ) ) { + TERMINATES TERMINATION" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MAX_CACHE_MEMORY (advanced)" ) << std::endl << ". the program terminates as soon as the cache" << std::endl @@ -8794,7 +9362,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // MAX_CONSECUTIVE_FAILED_ITERATIONS: // ---------------------------------- if ( display_all || NOMAD::string_find ( "MAX_CONSECUTIVE_FAILED_ITERATIONS ADVANCED \ - TERMINATION STOPPING TERMINATES" , param_names ) ) { + TERMINATION STOPPING TERMINATES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MAX_CONSECUTIVE_FAILED_ITERATIONS (advanced)" ) << std::endl << ". maximum number of consecutive failed iterations" << std::endl @@ -8810,7 +9379,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo if ( display_all || NOMAD::string_find ( "MAX_EVAL ADVANCED BLACK-BOXES BLACKBOXES \ MAXIMUM CACHE BBEVAL \ NUMBER EVALUATIONS STOPPING \ - TERMINATES TERMINATION" , param_names ) ) { + TERMINATES TERMINATION" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MAX_EVAL (advanced)" ) << std::endl << ". maximum number of evaluations" << std::endl @@ -8828,7 +9398,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo if ( display_all || NOMAD::string_find ( "MAX_ITERATIONS ADVANCED \ MAXIMUM MADS \ NUMBER STOPPING \ - TERMINATES TERMINATION" , param_names ) ) { + TERMINATES TERMINATION" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MAX_ITERATIONS (advanced)" ) << std::endl << ". maximum number of MADS iterations" << std::endl @@ -8839,14 +9410,14 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo chk = true; } - // MAX_SGTE_EVAL: // -------------- if ( display_all || NOMAD::string_find ( "MAX_SGTE_EVAL ADVANCED BLACK-BOXES \ BLACKBOXES \ MAXIMUM SURROGATES BBEVAL SGTES \ NUMBER EVALUATIONS STOPPING \ - TERMINATES TERMINATION" , param_names ) ) { + TERMINATES TERMINATION" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MAX_SGTE_EVAL (advanced)" ) << std::endl << ". maximum number of surrogate evaluations" << std::endl @@ -8863,7 +9434,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo BLACK-BOXES BLACKBOXES BBEVAL \ MAXIMUM CACHE SIMULATED \ NUMBER EVALUATIONS STOPPING \ - TERMINATES TERMINATION" , param_names ) ) { + TERMINATES TERMINATION" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MAX_SIM_BB_EVAL (advanced)" ) << std::endl << ". maximum number of simulated blackbox evaluations" << std::endl @@ -8883,7 +9455,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // MESH_COARSENING_EXPONENT: // ------------------------- if ( display_all || NOMAD::string_find ( "MESH_COARSENING_EXPONENT ADVANCED \ - MADS W+ \\DELTA" , param_names ) ) { + MADS W+ \\DELTA" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MESH_COARSENING_EXPONENT (advanced)" ) << std::endl << ". mesh coarsening exponent w^+ used to update the mesh" << std::endl @@ -8900,7 +9473,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // MESH_REFINING_EXPONENT: // ----------------------- if ( display_all || NOMAD::string_find ( "MESH_REFINING_EXPONENT ADVANCED \ - MADS W- \\DELTA" , param_names ) ) { + MADS W- \\DELTA" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MESH_REFINING_EXPONENT (advanced)" ) << std::endl << ". mesh refining exponent w^- used to update the mesh" << std::endl @@ -8915,7 +9489,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // MESH_UPDATE_BASIS: // ------------------ if ( display_all || NOMAD::string_find ( "MESH_UPDATE_BASIS ADVANCED \ - MADS \\TAU \\DELTA" , param_names ) ) { + MADS \\TAU \\DELTA" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MESH_UPDATE_BASIS (advanced)" ) << std::endl << ". mesh update basis \\tau used to update the" << std::endl @@ -8931,7 +9506,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // -------------- if ( display_all || NOMAD::string_find ( "MIN_MESH_SIZE ADVANCED \ \\DELTA MINIMUM TERMINATION \ - STOPPING TERMINATES" , param_names ) ) { + STOPPING TERMINATES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MIN_MESH_SIZE (advanced)" ) << std::endl << ". minimum mesh size" << std::endl @@ -8947,7 +9523,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // -------------- if ( display_all || NOMAD::string_find ( "MIN_POLL_SIZE MESH ADVANCED \ \\DELTA^P MINIMUM TERMINATION \ - STOPPING TERMINATES" , param_names ) ) { + STOPPING TERMINATES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MIN_POLL_SIZE (advanced)" ) << std::endl << ". minimum poll size" << std::endl @@ -8965,18 +9542,18 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ---------------- if ( display_all || NOMAD::string_find ( "MODEL_ORDERING MODEL_EVAL_SORT ADVANCED \ MODELS INTERPOLATION REGRESSION \ - MFN FROBENIUS QUADRATIC \ - TGP" , param_names ) ) { + MFN FROBENIUS QUADRATIC" , param_names ) ) + { _out << std::endl - << NOMAD::open_block ( "MODEL_EVAL_SORT (advanced)" ) << std::endl + << NOMAD::open_block ( "MODEL_EVAL_SORT (advanced)" ) << std::endl << ". if models are used to sort the trial points" << std::endl << ". disabled for more than 50 variables" << std::endl << ". disabled with categorical variables" << std::endl << ". argument: one boolean (\'yes\' or \'no\')" << std::endl - << " or one string in {\'QUADRATIC\', \'TGP\'}" << std::endl + << " or one string in {\'QUADRATIC\'}" << std::endl << ". default: \'QUADRATIC\'" << std::endl << ". examples: MODEL_EVAL_SORT quadratic" << std::endl - << " MODEL_EVAL_SORT yes # quadratic is used" << std::endl + << " MODEL_EVAL_SORT yes # quadratic is used" << std::endl << " MODEL_EVAL_SORT no # no MES" << std::endl << NOMAD::close_block(); chk = true; @@ -8987,8 +9564,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ------------- if ( display_all || NOMAD::string_find ( "MODEL_SEARCH ADVANCED CATEGORICAL \ MODELS INTERPOLATION REGRESSION \ - MFN FROBENIUS QUADRATIC PARALLEL \ - TGP" , param_names ) ) { + MFN FROBENIUS QUADRATIC PARALLEL" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MODEL_SEARCH (advanced)" ) << std::endl << ". model search (MS)" << std::endl @@ -8997,10 +9574,9 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo << ". disabled with categorical variables" << std::endl << ". disabled in parallel mode" << std::endl << ". argument: one boolean (\'yes\' or \'no\')" << std::endl - << " or one string in {\'QUADRATIC\', \'TGP\'}" << std::endl + << " or one string in {\'QUADRATIC\'}" << std::endl << ". default: \'QUADRATIC\'" << std::endl << ". example: MODEL_SEARCH QUADRATIC" << std::endl - << " MODEL_SEARCH TGP" << std::endl << NOMAD::close_block(); chk = true; } @@ -9011,8 +9587,9 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ------------------------ if ( display_all || NOMAD::string_find ( "MODEL_SEARCH_OPTIMISTIC ADVANCED \ MODELS INTERPOLATION REGRESSION \ - MFN FROBENIUS QUADRATIC \ - TGP" , param_names ) ) { + MFN FROBENIUS QUADRATIC " + , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MODEL_SEARCH_OPTIMISTIC (advanced)" ) << std::endl << ". model search (MS) is optimistic or not" << std::endl @@ -9030,7 +9607,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo BI-OBJECTIVES MULTI-OBJECTIVES \ BIOBJECTIVES MULTIOBJECTIVES \ BI-MADS BIMADS SURF" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MULTI_F_BOUNDS (advanced)" ) << std::endl << ". multi-objective optimization: bounds on the two" << std::endl @@ -9055,7 +9633,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo BI-OBJECTIVES MULTI-OBJECTIVES \ BIOBJECTIVES MULTIOBJECTIVES \ BI-MADS BIMADS \ - NUMBER" , param_names ) ) { + NUMBER" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MULTI_NB_MADS_RUNS (advanced)" ) << std::endl << ". multi-objective optimization:" << std::endl @@ -9075,7 +9654,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo BI-MADS BIMADS \ NUMBER BLACK-BOXES BLACKBOXES BBEVAL \ EVALUATIONS TERMINATION \ - STOPPING TERMINATES" , param_names ) ) { + STOPPING TERMINATES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "MULTI_OVERALL_BB_EVAL (advanced)" ) << std::endl << ". multi-objective optimization: maximum" << std::endl @@ -9096,7 +9676,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo EXTENDED_POLL \ MIXED MVP CATEGORICAL \ ADVANCED" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "NEIGHBORS_EXE (advanced)" ) << std::endl << ". to indicate a neighborhood executable for categorical" << std::endl @@ -9135,7 +9716,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo if ( display_all || NOMAD::string_find ( "OPPORTUNISTIC_CACHE_SEARCH ADVANCED \ BLACK-BOXES BLACKBOXES EVALUATIONS \ SUCCESSES CACHE SEARCH" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "OPPORTUNISTIC_CACHE_SEARCH (advanced)" ) << std::endl << ". opportunistic strategy for cache search" << std::endl @@ -9150,7 +9732,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ------------------- if ( display_all || NOMAD::string_find ( "OPPORTUNISTIC_EVAL ADVANCED \ BLACK-BOXES BLACKBOXES EVALUATIONS \ - SUCCESSES" , param_names ) ) { + SUCCESSES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "OPPORTUNISTIC_EVAL (advanced)" ) << std::endl << ". opportunistic strategy (terminate a list of" << std::endl @@ -9169,7 +9752,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo if ( display_all || NOMAD::string_find ( "OPPORTUNISTIC_LH ADVANCED \ BLACK-BOXES BLACKBOXES EVALUATIONS \ SUCCESSES LATIN-HYPERCUBE SEARCH" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "OPPORTUNISTIC_LH (advanced)" ) << std::endl << ". opportunistic strategy for Latin-Hypercube search" << std::endl @@ -9186,7 +9770,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ----------------------- if ( display_all || NOMAD::string_find ( "OPPORTUNISTIC_MIN_EVAL ADVANCED \ BLACK-BOXES BLACKBOXES EVALUATIONS \ - SUCCESSES" , param_names ) ) { + SUCCESSES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "OPPORTUNISTIC_MIN_EVAL (advanced)" ) << std::endl << ". advanced parameter for the opportunistic" << std::endl @@ -9220,7 +9805,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // POINT_DISPLAY_LIMIT: // -------------------- if ( display_all || NOMAD::string_find ( "POINT_DISPLAY_LIMIT OUTPUTS \ - ADVANCED PRECISION" , param_names ) ) { + ADVANCED PRECISION" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "POINT_DISPLAY_LIMIT (advanced)" ) << std::endl << ". maximum number of point coordinates" << std::endl @@ -9235,7 +9821,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // POLL_UPDATE_BASIS: // ------------------ if ( display_all || NOMAD::string_find ( "POLL_UPDATE_BASIS ADVANCED \ - MADS ANISOTROPIC MESH \\TAU \\DELTA" , param_names ) ) { + MADS ANISOTROPIC MESH \\TAU \\DELTA" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "POLL_UPDATE_BASIS (advanced)" ) << std::endl << ". poll update basis \\tau used to update the" << std::endl @@ -9250,8 +9837,9 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // RHO: // ---- if ( display_all || NOMAD::string_find ( "RHO ADVANCED MADS CONSTRAINTS \ - PROGRESSIVE-BARRIER PB PEB \ - FILTER TRIGGER" , param_names ) ) { + PROGRESSIVE-BARRIER PB PEB \ + FILTER TRIGGER" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "RHO (advanced)" ) << std::endl << ". rho parameter of the progressive barrier" << std::endl @@ -9265,7 +9853,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // SCALING: // -------- if ( display_all || NOMAD::string_find ( "SCALING SCALE ADVANCED \ - FILES" , param_names ) ) { + FILES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "SCALING (advanced)" ) << std::endl << ". variable scaling" << std::endl @@ -9293,8 +9882,9 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ----- if ( display_all || NOMAD::string_find ( "SEED ADVANCED \ RANDOM FILES ORTHOMADS LT-MADS LTMADS \ - LATIN-HYPERCUBE LH TGP \ - SAMPLING SEARCH" , param_names ) ) { + LATIN-HYPERCUBE LH \ + SAMPLING SEARCH" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "SEED (advanced)" ) << std::endl << ". random seed" << std::endl @@ -9307,7 +9897,7 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo << ". the seed is used in the output file names" << std::endl << ". the seed affects the randomness of " << std::endl << " Ortho-MADS and LT-MADS directions," << std::endl - << " Latin-Hypercube search, and TGP search." << std::endl + << " Latin-Hypercube search." << std::endl << ". example: SEED 123456" << std::endl << NOMAD::close_block(); chk = true; @@ -9319,7 +9909,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ---------------- if ( display_all || NOMAD::string_find ( "SGTE_CACHE_FILE ADVANCED \ SURROGATES SGTES \ - FILES OUTPUTS" , param_names ) ) { + FILES OUTPUTS" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "SGTE_CACHE_FILE (advanced)" ) << std::endl << ". surrogate cache file; cannot be the same" << std::endl @@ -9358,7 +9949,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // --------------- if ( display_all || NOMAD::string_find ( "SGTE_EVAL_SORT ADVANCED SURROGATES \ SGTE_ORDERING SGTES BLACK-BOXES \ - BLACKBOXES" , param_names ) ) { + BLACKBOXES" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "SGTE_EVAL_SORT (advanced)" ) << std::endl << ". if surrogate is used to sort the trial points" << std::endl @@ -9373,7 +9965,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ---------- if ( display_all || NOMAD::string_find ( "SGTE_EXE HAS_SGTE ADVANCED SURROGATES \ SGTES BLACK-BOXES BLACKBOXES \ - FILES EXECUTABLE" , param_names ) ) { + FILES EXECUTABLE" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "SGTE_EXE (advanced)" ) << std::endl << ". to indicate a surrogate executable" << std::endl @@ -9389,7 +9982,7 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo << "SGTE_EXE b1.exe s1.exe # \'s1.exe\' is a surrogate" << std::endl << " # for \'b1.exe\'" << std::endl << std::endl << "SGTE_EXE sgte.exe # only if one blackbox" << std::endl - << " # executable is used" << std::endl + << " # executable is used" << std::endl << NOMAD::close_block() << NOMAD::close_block(); chk = true; } @@ -9414,7 +10007,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // SPECULATIVE_SEARCH: // ------------------- if ( display_all || NOMAD::string_find ( "SPECULATIVE_SEARCH MADS OPTIMISTIC \ - ADVANCED" , param_names ) ) { + ADVANCED" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "SPECULATIVE_SEARCH (advanced)" ) << std::endl << ". MADS speculative_search (optimistic strategy)" << std::endl @@ -9447,7 +10041,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ----------------- if ( display_all || NOMAD::string_find ( "STOP_IF_FEASIBLE ADVANCED \ TERMINATES TERMINATION STOPPING" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "STOP_IF_FEASIBLE (advanced)" ) << std::endl << ". the algorithm terminates if it generates" << std::endl @@ -9464,7 +10059,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ---------- if ( display_all || NOMAD::string_find ( "UNDEF_STR ADVANCED \ UNDEFINED DISPLAY REALS" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "UNDEF_STR (advanced)" ) << std::endl << ". string used to display undefined real values" << std::endl @@ -9480,7 +10076,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ------------------- if ( display_all || NOMAD::string_find ( "USER_CALLS_ENABLED USER_CALLS_DISABLED \ ADVANCED LIBRARY" , - param_names ) ) { + param_names ) ) + { _out << std::endl << NOMAD::open_block ( "USER_CALLS_ENABLED (advanced)" ) << std::endl << ". if \'no\', the automatic calls to user" << std::endl @@ -9495,7 +10092,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // VARIABLE_GROUP: // -------------- if ( display_all || NOMAD::string_find ( "VARIABLE_GROUP GROUPS PSD-MADS PSDMADS \ - VARIABLES ADVANCED" , param_names ) ) { + VARIABLES ADVANCED" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "VARIABLE_GROUP (advanced)" ) << std::endl << ". defines groups of variables" << std::endl @@ -9522,9 +10120,11 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo METAHEURISTICS META-HEURISTICS \ GLOBAL ADVANCED \ TRIGGER" , - param_names ) ) { + param_names ) ) + { - if ( !NOMAD::string_find ( "RHO" , param_names ) ) { + if ( !NOMAD::string_find ( "RHO" , param_names ) ) + { _out << std::endl << NOMAD::open_block ( "VNS_SEARCH (advanced)" ) << std::endl @@ -9553,7 +10153,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // last display: - if ( !chk && !developer) { + if ( !chk && !developer) + { std::string pname = ( pnames.size() == 1 ) ? ("\'" + *pnames.begin() + "\'") : @@ -9575,7 +10176,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // -------- if ( developer && (display_all || NOMAD::string_find ( "EPSILON DEVELOPPER \ PRECISION REALS COMPARISONS" , - param_names ) ) ) { + param_names ) ) ) + { _out << std::endl << NOMAD::open_block ( "EPSILON (developer)" ) << std::endl << ". precision on reals" << std::endl @@ -9590,7 +10192,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // INITIAL_MESH_INDEX: // ------------------- if ( developer && ( display_all || NOMAD::string_find ( "INITIAL_MESH_INDEX DEVELOPER SMESH \ - \\DELTA MADS L0 L_0 \\ELL_0" , param_names ) ) ) { + \\DELTA MADS L0 L_0 \\ELL_0" , param_names ) ) ) + { _out << std::endl << NOMAD::open_block ( "INITIAL_MESH_INDEX (developer)" ) << std::endl << ". initial mesh index for SMesh \\ell_0" << std::endl @@ -9606,7 +10209,9 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // L_CURVE_TARGET: // --------------- if ( developer && ( display_all || NOMAD::string_find ( "L_CURVE_TARGET DEVELOPER TERMINATION \ - STOPPING TERMINATES" , param_names ) ) ){ + STOPPING TERMINATES" , param_names ) ) ) + { + _out << std::endl << NOMAD::open_block ( "L_CURVE_TARGET (developer)" ) << std::endl << ". MADS terminates if it detects that the objective will" << std::endl @@ -9620,13 +10225,13 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo } - // MODEL_EVAL_SORT_CAUTIOUS: // ------------------------- if ( developer && ( display_all || NOMAD::string_find ( "MODEL_ORDERING MODEL_EVAL_SORT_CAUTIOUS \ MODELS INTERPOLATION REGRESSION \ MFN FROBENIUS DEVELOPER \ - QUADRATIC TGP" , param_names ) ) ) { + QUADRATIC" , param_names ) ) ) + { _out << std::endl << NOMAD::open_block ( "MODEL_EVAL_SORT_CAUTIOUS (developer)" ) << std::endl << ". if the model ordering strategy is cautious, meaning" << std::endl @@ -9642,7 +10247,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ---------------------- if ( developer && ( display_all || NOMAD::string_find ( "MODEL_QUAD_MAX_Y_SIZE MODEL_SEARCH DEVELOPER \ MODELS INTERPOLATION REGRESSION \ - MFN FROBENIUS QUADRATIC" , param_names ) ) ) { + MFN FROBENIUS QUADRATIC" , param_names ) ) ) + { _out << std::endl << NOMAD::open_block ( "MODEL_QUAD_MAX_Y_SIZE (developer)" ) << std::endl << ". Sup. limit on the size of interp. set Y for quadr. models" << std::endl @@ -9657,7 +10263,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ---------------------- if ( developer && (display_all || NOMAD::string_find ( "MODEL_QUAD_MIN_Y_SIZE MODEL_SEARCH DEVELOPER \ MODELS INTERPOLATION REGRESSION \ - MFN FROBENIUS QUADRATIC" , param_names ) ) ) { + MFN FROBENIUS QUADRATIC" , param_names ) ) ) + { _out << std::endl << NOMAD::open_block ( "MODEL_QUAD_MIN_Y_SIZE (developer)" ) << std::endl << ". Inf. limit on the size of interp. set Y for quadr. models" << std::endl @@ -9674,7 +10281,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ------------------------- if ( developer && ( display_all || NOMAD::string_find ( "MODEL_QUAD_RADIUS_FACTOR MODEL_SEARCH \ DEVELOPER MODELS INTERPOLATION REGRESSION \ - MFN FROBENIUS QUADRATIC" , param_names ) ) ) { + MFN FROBENIUS QUADRATIC" , param_names ) ) ) + { _out << std::endl << NOMAD::open_block ( "MODEL_QUAD_RADIUS_FACTOR (developer)" ) << std::endl << ". quadratic model search radius factor (see user guide)" << std::endl @@ -9690,7 +10298,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo if ( developer && ( display_all || NOMAD::string_find ( "MODEL_SEARCH_MAX_TRIAL_PTS \ DEVELOPER MODELS INTERPOLATION REGRESSION \ MFN FROBENIUS QUADRATIC \ - TGP" , param_names ) ) ) { + " , param_names ) ) ) + { _out << std::endl << NOMAD::open_block ( "MODEL_SEARCH_MAX_TRIAL_PTS (developer)" ) << std::endl << ". limit on the number of trial points for one model search" << std::endl @@ -9706,8 +10315,9 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // -------------------------- if ( developer && ( display_all || NOMAD::string_find ( "MODEL_SEARCH_PROJ_TO_MESH DEVELOPER \ MODELS INTERPOLATION REGRESSION \ - MFN FROBENIUS QUADRATIC PROJECTION \ - TGP" , param_names ) ) ) { + MFN FROBENIUS QUADRATIC PROJECTION " , + param_names ) ) ) + { _out << std::endl << NOMAD::open_block ( "MODEL_SEARCH_PROJ_TO_MESH (developer)" ) << std::endl << ". if model search trial points are projected to the mesh" << std::endl @@ -9723,7 +10333,9 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo if ( developer && ( display_all || NOMAD::string_find ( "MODEL_QUAD_USE_WP DEVELOPER \ WELL-POISEDNESS \ MODELS INTERPOLATION REGRESSION \ - MFN FROBENIUS QUADRATIC" , param_names ) ) ){ + MFN FROBENIUS QUADRATIC" , param_names ) ) ) + { + _out << std::endl << NOMAD::open_block ( "MODEL_QUAD_USE_WP (developer)" ) << std::endl << ". enable the strategy to maintain WP with quadr. models" << std::endl @@ -9739,50 +10351,20 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // --------------- if ( developer && (display_all || NOMAD::string_find ( "MODEL MODELS NP1 QUAD EPSILON \ ORTHO N+1 QUAD DEVELOPER" , - param_names ) ) ){ + param_names ) ) ) + { + _out << std::endl << NOMAD::open_block ( "MODEL_NP1_QUAD_EPSILON (developer)" ) << std::endl << ". with the direction type ORTHO N+1 QUAD selected the" << std::endl << " (n+1)-th direction is determined within a truncated " << std::endl << " unit hypercube ]epsilon;1[^n defined by the first " << std::endl << " n-th directions. The truncation is on lower limit " << std::endl - << " and is defined with a single argument (epsilon)." << std::endl + << " and is defined with a single argument (epsilon)." << std::endl << ". argument: real in ]0;1[" << std::endl << ". default: 0.01" << std::endl << NOMAD::close_block(); chk = true; - } - - - // MODEL_TGP_MODE: - // --------------- - if ( developer && (display_all || NOMAD::string_find ( "MODEL_TGP_MODE MODEL_SEARCH DEVELOPER \ - MODELS INTERPOLATION REGRESSION \ - TGP" , param_names ) ) ) { - _out << std::endl - << NOMAD::open_block ( "MODEL_TGP_MODE (developer)" ) << std::endl - << ". TGP mode (fast or precise)" << std::endl - << ". arguments: one string in {\'FAST\', \'PRECISE\'}" << std::endl - << ". default: \'FAST\'" << std::endl - << ". example: MODEL_TGP_MODE PRECISE" << std::endl - << NOMAD::close_block(); - chk = true; - } - - // MODEL_TGP_REUSE_MODEL: - // ---------------------- - if (developer && ( display_all || NOMAD::string_find ( "MODEL_TGP_REUSE_MODEL DEVELOPER \ - MODELS INTERPOLATION REGRESSION \ - TGP" , param_names ) ) ){ - _out << std::endl - << NOMAD::open_block ( "MODEL_TGP_REUSE_MODEL (developer)" ) << std::endl - << ". enable to use the last model from the TGP search for" << std::endl - << " the TGP model eval sort strategy." << std::endl - << ". argument: one boolean (\'yes\' or \'no\')" << std::endl - << ". default: \'yes\'" << std::endl - << ". example: MODEL_TGP_REUSE_MODEL no" << std::endl - << NOMAD::close_block(); - chk = true; } // MULTI_FORMULATION: @@ -9791,7 +10373,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo BI-OBJECTIVES MULTI-OBJECTIVES\ BIOBJECTIVES MULTIOBJECTIVES \ BI-MADS BIMADS" , - param_names ) ) ) { + param_names ) ) ) + { _out << std::endl << NOMAD::open_block ( "MULTI_FORMULATION (developer)" ) << std::endl << ". multi-objective optimization: single-objective reformulation" @@ -9814,7 +10397,9 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo BIOBJECTIVES MULTIOBJECTIVES \ BI-MADS BIMADS \ BI-OBJECTIVES MULTI-OBJECTIVES" , - param_names ) ) ){ + param_names ) ) ) + { + _out << std::endl << NOMAD::open_block ( "MULTI_USE_DELTA_CRIT (developer)" ) << std::endl << ". multi-objective optimization: use the delta criterion" << std::endl @@ -9830,7 +10415,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ------------------------- if ( developer && ( display_all || NOMAD::string_find ( "OPPORTUNISTIC_LUCKY_EVAL DEVELOPER \ BLACK-BOXES BLACKBOXES EVALUATIONS \ - SUCCESSES" , param_names ) ) ) { + SUCCESSES" , param_names ) ) ) + { _out << std::endl << NOMAD::open_block ( "OPPORTUNISTIC_LUCKY_EVAL (developer)" ) << std::endl << ". developer parameter for the opportunistic" << std::endl @@ -9847,7 +10433,8 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo if ( developer && ( display_all || NOMAD::string_find ( "OPPORTUNISTIC_MIN_F_IMPRVMT DEVELOPER \ OBJECTIVE \ BLACK-BOXES BLACKBOXES EVALUATIONS \ - SUCCESSES IMPROVEMENT" , param_names ) ) ) { + SUCCESSES IMPROVEMENT" , param_names ) ) ) + { _out << std::endl << NOMAD::open_block ( "OPPORTUNISTIC_MIN_F_IMPRVMT (developer)" ) << std::endl << ". advanced parameter for the opportunistic" << std::endl @@ -9863,7 +10450,9 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ----------------------------- if ( developer && ( display_all || NOMAD::string_find ( "OPPORTUNISTIC_MIN_NB_SUCCESSES DEVELOPER \ BLACK-BOXES BLACKBOXES \ - EVALUATIONS" , param_names ) ) ){ + EVALUATIONS" , param_names ) ) ) + { + _out << std::endl << NOMAD::open_block ( "OPPORTUNISTIC_MIN_NB_SUCCESS (developer)" ) << std::endl << ". advanced parameter for the opportunistic" << std::endl @@ -9878,8 +10467,10 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // OPT_ONLY_SGTE: // -------------- if (developer && ( display_all || NOMAD::string_find ( "OPT_ONLY_SGTES DEVELOPER SURROGATES \ - BLACK-BOXES BLACKBOXES \ - SGTES" , param_names ) ) ){ + BLACK-BOXES BLACKBOXES \ + SGTES" , param_names ) ) ) + { + _out << std::endl << NOMAD::open_block ( "OPT_ONLY_SGTE (developer)" ) << std::endl << ". NOMAD will only minimize the surrogate" << std::endl @@ -9895,7 +10486,9 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo // ------------------- if ( developer && ( display_all || NOMAD::string_find ( "SEC_POLL_DIR_TYPES DEVELOPER MADS \ POLL DIRECTIONS PB PEB \ - PROGRESSIVE-BARRIER" , param_names ) ) ){ + PROGRESSIVE-BARRIER" , param_names ) ) ) + { + _out << std::endl << NOMAD::open_block ( "SEC_POLL_DIR_TYPES (developer)" ) << std::endl << ". types of directions for the secondary poll" << std::endl @@ -9906,22 +10499,26 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo chk = true; } - // USE_SMESH: + // MESH_TYPE: // ------------------- - if ( developer && ( display_all || NOMAD::string_find ( "USE_SMESH SMESH MESH \ - ANISO" , param_names ) ) ){ + if ( developer && ( display_all || NOMAD::string_find ( "MESH_TYPE XMESH SMESH MESH \ + ANISO" , param_names ) ) ) + { + _out << std::endl - << NOMAD::open_block ( "USE_SMESH (developer)" ) << std::endl - << ". forces the use of the standard mesh (older version of mesh)" << std::endl - << ". default: no" << std::endl - << ". example: USE_SMESH 1" << std::endl + << NOMAD::open_block ( "MESH_TYPE (developer)" ) << std::endl + << ". forces the use of a specific type of mesh (xmesh, smesh))" << std::endl + << ". arguments: X or S" << std::endl + << ". default: X" << std::endl + << ". example: MESH_TYPE X " << std::endl << NOMAD::close_block(); chk = true; } // last display: - if ( !chk && developer) { + if ( !chk && developer) + { std::string pname = ( pnames.size() == 1 ) ? ("\'" + *pnames.begin() + "\'") : @@ -9933,6 +10530,7 @@ void NOMAD::Parameters::help ( const std::list<std::string> & pnames,bool develo << std::endl; } - _out.close_block(); } + + diff --git a/src/Parameters.hpp b/src/Parameters.hpp index 5a8d6c8e701ebd7c4f3234a55db81a080f1848dc..cf8e370c71e6a7435f0cac3e20946abed01b2f29 100644 --- a/src/Parameters.hpp +++ b/src/Parameters.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -71,8 +78,6 @@ namespace NOMAD { int quad_max_Y_size; ///< Limit sup on the size of \c Y. NOMAD::Double model_np1_quad_epsilon;///< Ortho n+1 quadratic model epsilon (scaling used for (n+1)th dynamic direction with Ortho n+1) - NOMAD::TGP_mode_type tgp_mode; ///< TGP mode (fast or precise). - bool tgp_reuse_model; ///< Use the model from MS for the MES. }; /// Class for the NOMAD parameters. @@ -103,6 +108,15 @@ namespace NOMAD { void interpret_mesh_sizes ( const NOMAD::Parameter_Entries & entries , const std::string & param_name ); + /// Interpretation of the entries for granular variables. + /** + \param entries Parameter entries -- \b IN. + \param param_name Parameter name -- \b IN. + */ + void interpret_granularity ( const NOMAD::Parameter_Entries & entries , + const std::string & param_name ); + + /// Interpretation of the entries for bounds and fixed variables. /** \c BFVS stands for "Bounds and Fixed VariableS". @@ -238,8 +252,8 @@ namespace NOMAD { /// Display parameter help. /** For a list of parameters. - \param param_names_list List of parameter names -- \b IN. - \param developer Bool to request developer help (defaut=false) -- \b IN. + \param param_names_list List of parameter names -- \b IN. + \param developer Bool to request developer help (defaut=false) -- \b IN. */ void help ( const std::list<std::string> & param_names_list , bool developer=false) const; @@ -315,6 +329,12 @@ namespace NOMAD { /// Maximum number of simulated evaluations. int _max_sim_bb_eval; + + /// Maximum number of evaluation during intensification of poll and/or search + int _max_eval_intensification; + + int _intensification_type; + int _max_time; ///< Maximum time. int _max_iterations; ///< Maximum number of iterations. int _max_cons_failed_it; ///< Maximum number of consecutive failed iterations. @@ -399,6 +419,19 @@ namespace NOMAD { */ int get_max_bb_eval ( void ) const; + /// Access to the \c INTENSITIFICATION_TYPE parameter. + /** + \return The \c INTENSIFICATION_TYPE parameter. + */ + int get_intensification_type ( void ) const { return _intensification_type ; } + + /// Access to the \c MAX_EVAL_INTENSIFICATION parameter. + /** + \return The \c MAX_EVAL_INTENSIFICATION parameter. + */ + int get_max_eval_intensification ( void ) const { return _max_eval_intensification ; } + + /// Access to the \c MAX_TIME parameter. /** \return The \c MAX_TIME parameter. @@ -567,6 +600,12 @@ namespace NOMAD { */ void set_MAX_BB_EVAL ( int bbe ); + /// Set the \c MAX_EVAL_INTENSIFICATION parameter. + /** + \param bbe The \c MAX_EVAL_INTENSIFICATION parameter -- \b IN. + */ + void set_MAX_EVAL_INTENSIFICATION ( int bbe ); + /// Set the \c MAX_TIME parameter. /** \param mt The \c MAX_TIME parameter -- \b IN. @@ -912,18 +951,6 @@ namespace NOMAD { */ int get_model_quad_min_Y_size ( void ) const; - /// Access to the \c MODEL_TGP_MODE parameter. - /** - \return The \c MODEL_TGP_MODE parameter. - */ - NOMAD::TGP_mode_type get_model_tgp_mode ( void ) const; - - /// Access to the \c MODEL_TGP_REUSE_MODEL parameter. - /** - \return The \c MODEL_TGP_REUSE_MODEL parameter. - */ - bool get_model_tgp_reuse_model ( void ) const; - /// Access to the \c MODEL_SEARCH_MAX_TRIAL_PTS parameter. /** \return The \c MODEL_SEARCH_MAX_TRIAL_PTS parameter. @@ -1074,18 +1101,6 @@ namespace NOMAD { */ void set_MODEL_NP1_QUAD_EPSILON ( const NOMAD::Double & r ); - /// Set the \c MODEL_TGP_MODE parameter. - /** - \param m The \c MODEL_TGP_MODE parameter -- \b IN. - */ - void set_MODEL_TGP_MODE ( NOMAD::TGP_mode_type m ); - - /// Set the \c MODEL_TGP_REUSE_MODEL parameter. - /** - \param rm The \c MODEL_TGP_REUSE_MODEL parameter -- \b IN. - */ - void set_MODEL_TGP_REUSE_MODEL ( bool rm ); - /// Set the \c MODEL_SEARCH_MAX_TRIAL_PTS parameter. /** \param s The \c MODEL_SEARCH_MAX_TRIAL_PTS parameter -- \b IN. @@ -1152,13 +1167,14 @@ namespace NOMAD { // ----- private: - bool _use_smesh; ///< Use smesh (default xmesh) - bool _anisotropic_mesh; ///< Anisotropic mesh (xmesh only, i.e. _use_smesh=false) + NOMAD::mesh_type _mesh_type; ///< The type of mesh used (xmesh [D], smesh [old] ) + bool _anisotropic_mesh; ///< Anisotropic mesh (xmesh only) NOMAD::Double _mesh_update_basis; ///< Mesh update basis (tau). NOMAD::Double _poll_update_basis; ///< Poll update basis (beta). int _mesh_coarsening_exponent; ///< Mesh coarsening exponent. int _mesh_refining_exponent; ///< Mesh refining exponent. int _initial_mesh_index; ///< Initial mesh index (ell_0). + int _limit_mesh_index; ///< Limit value of mesh index. NOMAD::Point _initial_mesh_size; ///< Initial (absolute) mesh size (delta^0). NOMAD::Point _min_mesh_size; ///< Minimal (absolute) mesh size (delta_min). NOMAD::Point _initial_poll_size; ///< Initial (absolute) poll size (delta^0). @@ -1174,12 +1190,12 @@ namespace NOMAD { */ bool get_anisotropic_mesh ( void ) const; - /// Access to the \c USE_SMESH parameter. + + /// Access to the \c MESH_TYPE parameter. /** - \return The \c USE_SMESH parameter -- \b IN. + \return The \c MESH_TYPE parameter -- \b IN. */ - bool get_use_smesh ( void ) const; - + const NOMAD::mesh_type & get_mesh_type ( void ) const; /// Access to the \c POLL_UPDATE_BASIS parameter. @@ -1213,7 +1229,6 @@ namespace NOMAD { */ int get_initial_mesh_index ( void ) const; - /// Access to the \c INITIAL_MESH_SIZE parameter. /** \return The \c INITIAL_MESH_SIZE parameter. @@ -1251,12 +1266,11 @@ namespace NOMAD { */ void set_ANISOTROPIC_MESH ( bool anis ); - /// Set the \c USE_SMESH parameter. + /// Set the \c MESH_TYPE parameter. /** - \param use_smesh The \c USE_SMESH parameter -- \b IN. + \param mt The \c MESH_TYPE parameter -- \b IN. */ - void set_USE_SMESH ( bool use_smesh ); - + void set_MESH_TYPE ( NOMAD::mesh_type mt ); /// Set the \c MESH_UPDATE_BASIS parameter. /** @@ -1270,7 +1284,6 @@ namespace NOMAD { */ void set_POLL_UPDATE_BASIS ( const NOMAD::Double & r ); - /// Set the \c INITIAL_MESH_INDEX parameter. /** \param ell_0 The \c INITIAL_MESH_INDEX parameter -- \b IN. @@ -1295,7 +1308,8 @@ namespace NOMAD { \param relative Indicated as a relative value -- \b IN -- \b optional (default = \c false). */ - void set_MIN_MESH_SIZE ( const NOMAD::Double & mms , bool relative = false ); + void set_MIN_MESH_SIZE ( const NOMAD::Double & mms , + bool relative = false ); /// Set the \c MIN_MESH_SIZE parameter. /** @@ -1314,7 +1328,8 @@ namespace NOMAD { \param relative Indicated as relative values -- \b IN -- \b optional (default = \c false). */ - void set_MIN_MESH_SIZE ( const NOMAD::Point & mms , bool relative = false ); + void set_MIN_MESH_SIZE ( const NOMAD::Point & mms , + bool relative = false ); /// Set the \c MIN_POLL_SIZE parameter. /** @@ -1322,7 +1337,8 @@ namespace NOMAD { \param relative Indicated as a relative value -- \b IN -- \b optional (default = \c false). */ - void set_MIN_POLL_SIZE ( const NOMAD::Double & mps , bool relative = false ); + void set_MIN_POLL_SIZE ( const NOMAD::Double & mps , + bool relative = false ); /// Set the \c MIN_POLL_SIZE parameter. /** @@ -1341,7 +1357,8 @@ namespace NOMAD { \param relative Indicated as relative values -- \b IN -- \b optional (default = \c false). */ - void set_MIN_POLL_SIZE ( const NOMAD::Point & mps , bool relative = false ); + void set_MIN_POLL_SIZE ( const NOMAD::Point & mps , + bool relative = false ); /// Set the \c INITIAL_MESH_SIZE parameter. /** @@ -1349,7 +1366,8 @@ namespace NOMAD { \param relative Indicated as a relative value -- \b IN -- \b optional (default = \c false). */ - void set_INITIAL_MESH_SIZE ( const NOMAD::Double & ims , bool relative = false ); + void set_INITIAL_MESH_SIZE ( const NOMAD::Double & ims , + bool relative = false ); /// Set the \c INITIAL_MESH_SIZE parameter. /** @@ -1368,7 +1386,8 @@ namespace NOMAD { \param relative Indicated as relative values -- \b IN -- \b optional (default = \c false). */ - void set_INITIAL_MESH_SIZE ( const NOMAD::Point & ims , bool relative = false ); + void set_INITIAL_MESH_SIZE ( const NOMAD::Point & ims , + bool relative = false ); /// Set the \c INITIAL_POLL_SIZE parameter. @@ -1377,7 +1396,8 @@ namespace NOMAD { \param relative Indicated as a relative value -- \b IN -- \b optional (default = \c false). */ - void set_INITIAL_POLL_SIZE ( const NOMAD::Double & ims , bool relative = false ); + void set_INITIAL_POLL_SIZE ( const NOMAD::Double & ims , + bool relative = false ); /// Set the \c INITIAL_POLL_SIZE parameter. /** @@ -1399,6 +1419,63 @@ namespace NOMAD { void set_INITIAL_POLL_SIZE ( const NOMAD::Point & ims , bool relative = false ); + /// Set the \c LIMIT_MESH_INDEX parameter. + /** + \param lmi Limit mesh index -- \b IN. + */ + void set_LIMIT_MESH_INDEX ( const int & lmi ); + + + + // Granular variables: + // ------------------- + private: + + NOMAD::Point _granularity; ///< Granularity. + + public: + + /// Access to the granular variables. + /** + \return The granular variables. + */ + const NOMAD::Point & get_granularity ( void ) const ; + + /// Access to the number of granular variables (granularity !=0). + /** + \return The number of real granular variables. + */ + int get_number_granular_variables ( void ) const; + + + /// Reset the granular variables. + /** + This sets all variables with a granularity of zero. + */ + void reset_granulary ( void ); + + /// Set the granularity for one variable. + /** + \param i Index of the variable -- \b IN. + \param value Granularity of the variable -- \b IN. + */ + void set_GRANULARITY ( int i , const NOMAD::Double & value ); + + /// Set the granularity of a series of variables. + /** + \param fv The granular variables; This point is of dimension \c n; + regular variables have a granularity of zero -- \b IN. + */ + void set_GRANULARITY ( const NOMAD::Point & fv ); + + + /// Set the granularity of all variables. + /** + \param v The granularity of all variables -- \b IN. + */ + void set_GRANULARITY ( const NOMAD::Double & v ); + + // Directions: // ----------- @@ -1445,8 +1522,9 @@ namespace NOMAD { */ bool has_dynamic_direction(void) const; - /// Reset the directions. + /** + */ void reset_directions ( void ); @@ -1475,6 +1553,7 @@ namespace NOMAD { */ void set_SEC_POLL_DIR_TYPE ( const std::set<NOMAD::direction_type> & dt ); + /// Enables use of quad model to determine prospect direction /// for Ortho n+1 direction type /** @@ -1784,8 +1863,7 @@ namespace NOMAD { \param g Group to reset; may be \c _var_groups or \c _user_var_groups -- \b IN/OUT. */ - void reset_variable_groups - ( std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & g ) const; + void reset_variable_groups ( std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & g ) const; public: @@ -1813,10 +1891,9 @@ namespace NOMAD { \param prim_poll_dir_types Types of the poll directions -- \b IN. \param sec_poll_dir_types Types of the secondary poll directions -- \b IN. */ - void set_VARIABLE_GROUP - ( const std::set<int> & var_indexes , - const std::set<NOMAD::direction_type> & prim_poll_dir_types , - const std::set<NOMAD::direction_type> & sec_poll_dir_types ); + void set_VARIABLE_GROUP ( const std::set<int> & var_indexes , + const std::set<NOMAD::direction_type> & prim_poll_dir_types , + const std::set<NOMAD::direction_type> & sec_poll_dir_types ); /// Set several groups of variables. /** @@ -2151,7 +2228,7 @@ namespace NOMAD { */ std::map<std::string,std::string> _sgte_exe; - bool _disable_eval_sort; ///< Sort disablement + bool _disable_eval_sort; ///< Sort disablement /// Flag equal to \c true if surrogates are used to sort evaluation points. bool _sgte_eval_sort; @@ -2168,7 +2245,7 @@ namespace NOMAD { */ int _sgte_cost; - /// Maximum number of surrogate evaluations. + /// Maximum number of surrogate evaluations. int _sgte_max_eval; /// Surrogate cache file. @@ -2467,7 +2544,7 @@ namespace NOMAD { /// Minimum number of evaluations. /** - Parameter \c OPPORTUNISTIC_MIN_EVAL. + Parameter \c OPPORTUNISTIC_MIN_EVAL. */ int _opportunistic_min_eval; @@ -2488,7 +2565,7 @@ namespace NOMAD { /** Parameter \c BB_MAX_BLOCK_SIZE. */ - int _bb_max_block_size; + int _bb_max_block_size; /// Block of points evaluation /** @@ -2579,7 +2656,6 @@ namespace NOMAD { - }; /*----------------------------------------------------------------------*/ diff --git a/src/Pareto_Front.cpp b/src/Pareto_Front.cpp index 0abcee593ad4602007a667adc201f9ee3823fd81..c6dc902a628f9805ba12431abd4d616b958d5e8c 100644 --- a/src/Pareto_Front.cpp +++ b/src/Pareto_Front.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Pareto_Front.cpp - \brief Pareto front (implementation) - \author Sebastien Le Digabel - \date 2010-04-09 - \see Pareto_Front.hpp -*/ + \file Pareto_Front.cpp + \brief Pareto front (implementation) + \author Sebastien Le Digabel + \date 2010-04-09 + \see Pareto_Front.hpp + */ #include "Pareto_Front.hpp" /*------------------------------------------------------*/ @@ -48,43 +55,50 @@ /*------------------------------------------------------*/ bool NOMAD::Pareto_Front::insert ( const NOMAD::Eval_Point & x ) { - - NOMAD::Pareto_Point pp ( &x ); - if ( _pareto_pts.empty() ) { - _pareto_pts.insert (pp); - return true; - } - - bool insert = false; - - std::set<NOMAD::Pareto_Point>::iterator it = _pareto_pts.begin(); - while ( it != _pareto_pts.end() ) { - if ( pp.dominates (*it) ) { - _pareto_pts.erase(it++); - insert = true; - - continue; + NOMAD::Pareto_Point pp ( &x ); + + if ( _pareto_pts.empty() ) + { + _pareto_pts.insert (pp); + return true; } - ++it; - } - - if ( !insert ) { - insert = true; - std::set<NOMAD::Pareto_Point>::iterator end = _pareto_pts.end(); - for ( it = _pareto_pts.begin() ; it != end ; ++it ) { - if ( it->dominates (pp) ) { - insert = false; - break; - } + + bool insert = false; + + std::set<NOMAD::Pareto_Point>::iterator it = _pareto_pts.begin(); + while ( it != _pareto_pts.end() ) + { + if ( pp.dominates (*it) ) + { + _pareto_pts.erase(it++); + insert = true; + + continue; + } + ++it; + } + + if ( !insert ) + { + insert = true; + std::set<NOMAD::Pareto_Point>::iterator end = _pareto_pts.end(); + for ( it = _pareto_pts.begin() ; it != end ; ++it ) + { + if ( it->dominates (pp) ) + { + insert = false; + break; + } + } + } + + if ( insert ) + { + _pareto_pts.insert ( pp ); + return true; } - } - - if ( insert ) { - _pareto_pts.insert ( pp ); - return true; - } - return false; + return false; } /*-------------------------------------------------------*/ @@ -93,298 +107,310 @@ bool NOMAD::Pareto_Front::insert ( const NOMAD::Eval_Point & x ) /*-------------------------------------------------------*/ const NOMAD::Eval_Point * NOMAD::Pareto_Front::get_best_f2 ( void ) const { - if ( _pareto_pts.empty() ) - return NULL; - - std::set<NOMAD::Pareto_Point>::const_iterator it = _pareto_pts.end(); - --it; - - return it->get_element(); + if ( _pareto_pts.empty() ) + return NULL; + + std::set<NOMAD::Pareto_Point>::const_iterator it = _pareto_pts.end(); + --it; + + return it->get_element(); } /*------------------------------------------------------*/ /* get the reference point */ /*------------------------------------------------------*/ NOMAD::Point * NOMAD::Pareto_Front::get_ref ( const NOMAD::Pareto_Point *& xj , - NOMAD::Double & delta_j ) const + NOMAD::Double & delta_j ) const { - xj = NULL; - delta_j.clear(); - - int p = static_cast<int>(_pareto_pts.size()); + xj = NULL; + delta_j.clear(); - // no points in the front: - if ( p == 0 ) - return NULL; - - // just one point in the front: - if ( p == 1 ) { - xj = &(*_pareto_pts.begin()); - delta_j = 1.0 / ( xj->get_w() + 1 ); // delta=1.0 - return NULL; - } - - std::set<NOMAD::Pareto_Point>::const_iterator it = _pareto_pts.begin(); - NOMAD::Point * ref = new NOMAD::Point ( 2 ); - - NOMAD::Double f1xm1; // f_1 ( x_{j-1} ) - NOMAD::Double f1x; // f_1 ( x_j ) - NOMAD::Double f1xp1; // f_1 ( x_{j+1} ) - - NOMAD::Double f2xm1; // f_2 ( x_{j-1} ) - NOMAD::Double f2x; // f_2 ( x_j ) - NOMAD::Double f2xp1; // f_2 ( x_{j+1} ) + int p = static_cast<int>(_pareto_pts.size()); - // two points in the front: - if ( p == 2 ) { - - f1xm1 = it->get_f1(); - f2xm1 = it->get_f2(); - - ++it; - xj = &(*it); + // no points in the front: + if ( p == 0 ) + return NULL; - f1x = xj->get_f1(); - f2x = xj->get_f2(); - - delta_j = ( (f1x-f1xm1).pow2() + (f2x-f2xm1).pow2() ) / ( xj->get_w() + 1.0 ); + // just one point in the front: + if ( p == 1 ) + { + xj = &(*_pareto_pts.begin()); + delta_j = 1.0 / ( xj->get_w() + 1 ); // delta=1.0 + return NULL; + } - const_cast<NOMAD::Pareto_Point *>(xj)->update_w(); + std::set<NOMAD::Pareto_Point>::const_iterator it = _pareto_pts.begin(); + NOMAD::Point * ref = new NOMAD::Point ( 2 ); - (*ref)[0] = f1x; - (*ref)[1] = f2xm1; - - return ref; - } - - // more than two points in the front: - std::set<NOMAD::Pareto_Point>::const_iterator end = _pareto_pts.end(); + NOMAD::Double f1xm1; // f_1 ( x_{j-1} ) + NOMAD::Double f1x; // f_1 ( x_j ) + NOMAD::Double f1xp1; // f_1 ( x_{j+1} ) - const NOMAD::Pareto_Point * prev , * cur , * next; - - NOMAD::Double delta; - - prev = &(*it); - ++it; + NOMAD::Double f2xm1; // f_2 ( x_{j-1} ) + NOMAD::Double f2x; // f_2 ( x_j ) + NOMAD::Double f2xp1; // f_2 ( x_{j+1} ) - while ( true ) { - - cur = &(*it); - - ++it; - if ( it == end ) - break; + // two points in the front: + if ( p == 2 ) + { + + f1xm1 = it->get_f1(); + f2xm1 = it->get_f2(); + + ++it; + xj = &(*it); + + f1x = xj->get_f1(); + f2x = xj->get_f2(); + + delta_j = ( (f1x-f1xm1).pow2() + (f2x-f2xm1).pow2() ) / ( xj->get_w() + 1.0 ); + + const_cast<NOMAD::Pareto_Point *>(xj)->update_w(); + + (*ref)[0] = f1x; + (*ref)[1] = f2xm1; + + return ref; + } - next = &(*it); - - f1xm1 = prev->get_f1(); - f2xm1 = prev->get_f2(); + // more than two points in the front: + std::set<NOMAD::Pareto_Point>::const_iterator end = _pareto_pts.end(); - f1x = cur->get_f1(); - f2x = cur->get_f2(); - - f1xp1 = next->get_f1(); - f2xp1 = next->get_f2(); - - delta = ( (f1x-f1xm1).pow2() + (f2x-f2xm1).pow2() + - (f1x-f1xp1).pow2() + (f2x-f2xp1).pow2() ) / ( cur->get_w() + 1.0 ); - - if ( !delta_j.is_defined() || delta > delta_j ) { - xj = cur; - delta_j = delta; - (*ref)[0] = f1xp1; - (*ref)[1] = f2xm1; + const NOMAD::Pareto_Point * prev , * cur , * next; + + NOMAD::Double delta; + + prev = &(*it); + ++it; + + while ( true ) + { + + cur = &(*it); + + ++it; + if ( it == end ) + break; + + next = &(*it); + + f1xm1 = prev->get_f1(); + f2xm1 = prev->get_f2(); + + f1x = cur->get_f1(); + f2x = cur->get_f2(); + + f1xp1 = next->get_f1(); + f2xp1 = next->get_f2(); + + delta = ( (f1x-f1xm1).pow2() + (f2x-f2xm1).pow2() + + (f1x-f1xp1).pow2() + (f2x-f2xp1).pow2() ) / ( cur->get_w() + 1.0 ); + + if ( !delta_j.is_defined() || delta > delta_j ) + { + xj = cur; + delta_j = delta; + (*ref)[0] = f1xp1; + (*ref)[1] = f2xm1; + } + + prev = cur; } - prev = cur; - } - - const_cast<Pareto_Point *>(xj)->update_w(); - - return ref; + const_cast<Pareto_Point *>(xj)->update_w(); + + return ref; } /*------------------------------------------------------*/ /* compute delta and surf */ /*------------------------------------------------------*/ void NOMAD::Pareto_Front::get_delta_surf ( NOMAD::Double & delta_j , - NOMAD::Double & surf , - const NOMAD::Point & f_bounds ) const + NOMAD::Double & surf , + const NOMAD::Point & f_bounds ) const { - bool def = f_bounds.is_complete(); - NOMAD::Double f1_min , f1_max , f2_min , f2_max; - - if ( def ) { - - if ( f_bounds.size() == 4 ) { - - f1_min = f_bounds[0]; - f1_max = f_bounds[1]; - f2_min = f_bounds[2]; - f2_max = f_bounds[3]; - - if ( f1_min >= f1_max || f2_min >= f2_max ) { - f1_min.clear(); - f1_max.clear(); - f2_min.clear(); - f2_max.clear(); - def = false; - } - } - else - def = false; - } - - delta_j.clear(); - surf.clear(); - - int p = static_cast<int> ( _pareto_pts.size() ); - - // no point in the front: - if ( p == 0 ) { + bool def = f_bounds.is_complete(); + NOMAD::Double f1_min , f1_max , f2_min , f2_max; + if ( def ) - surf = 1.0; - return; - } - - const NOMAD::Pareto_Point * xj; - NOMAD::Double f1x; // f_1 ( x_j ) - NOMAD::Double f2x; // f_2 ( x_j ) - - NOMAD::Double surf_frame = (def) ? + { + + if ( f_bounds.size() == 4 ) + { + + f1_min = f_bounds[0]; + f1_max = f_bounds[1]; + f2_min = f_bounds[2]; + f2_max = f_bounds[3]; + + if ( f1_min >= f1_max || f2_min >= f2_max ) + { + f1_min.clear(); + f1_max.clear(); + f2_min.clear(); + f2_max.clear(); + def = false; + } + } + else + def = false; + } + + delta_j.clear(); + surf.clear(); + + int p = static_cast<int> ( _pareto_pts.size() ); + + // no point in the front: + if ( p == 0 ) + { + if ( def ) + surf = 1.0; + return; + } + + const NOMAD::Pareto_Point * xj; + NOMAD::Double f1x; // f_1 ( x_j ) + NOMAD::Double f2x; // f_2 ( x_j ) + + NOMAD::Double surf_frame = (def) ? ( f2_max - f2_min ) * ( f1_max - f1_min ) : NOMAD::Double(); - - // just one point in the front: - if ( p == 1 ) { - xj = &(*_pareto_pts.begin()); - delta_j = 1.0 / ( xj->get_w() + 1 ); // delta=1.0 - f1x = xj->get_f1(); - f2x = xj->get_f2(); - - if ( !def || f1x > f1_max || f1x < f1_min || f2x > f2_max || f2x < f2_min ) - return; - - surf = ( ( f2_max - f2_min ) * ( f1x - f1_min ) - + ( f2x - f2_min ) * ( f1_max - f1x ) ) / surf_frame; - - return; - } - - std::set<NOMAD::Pareto_Point>::const_iterator it = _pareto_pts.begin(); - - NOMAD::Double f1xm1; // f_1 ( x_{j-1} ) - NOMAD::Double f1xp1; // f_1 ( x_{j+1} ) - - NOMAD::Double f2xm1; // f_2 ( x_{j-1} ) - NOMAD::Double f2xp1; // f_2 ( x_{j+1} ) - // two points in the front: - if ( p == 2 ) { - - f1xm1 = it->get_f1(); - f2xm1 = it->get_f2(); - - if ( def && ( f1xm1 < f1_min || - f1xm1 > f1_max || - f2xm1 < f2_min || - f2xm1 > f2_max ) ) - def = false; - - ++it; - xj = &(*it); + // just one point in the front: + if ( p == 1 ) + { + xj = &(*_pareto_pts.begin()); + delta_j = 1.0 / ( xj->get_w() + 1 ); // delta=1.0 + f1x = xj->get_f1(); + f2x = xj->get_f2(); + + if ( !def || f1x > f1_max || f1x < f1_min || f2x > f2_max || f2x < f2_min ) + return; + + surf = ( ( f2_max - f2_min ) * ( f1x - f1_min ) + + ( f2x - f2_min ) * ( f1_max - f1x ) ) / surf_frame; + + return; + } - f1x = xj->get_f1(); - f2x = xj->get_f2(); - - if ( def && ( f1x < f1_min || - f1x > f1_max || - f2x < f2_min || - f2x > f2_max ) ) - def = false; + std::set<NOMAD::Pareto_Point>::const_iterator it = _pareto_pts.begin(); - delta_j = ( (f1x-f1xm1).pow2() + (f2x-f2xm1).pow2() ) / ( xj->get_w() + 1.0 ); - - if ( def ) - surf = ( ( f2xm1 - f2_min ) * ( f1x - f1xm1 ) - + ( f2_max - f2_min ) * ( f1xm1 - f1_min ) - + ( f2x - f2_min ) * ( f1_max - f1x ) ) / surf_frame; - - return; - } - - // more than two points in the front: - std::set<NOMAD::Pareto_Point>::const_iterator end = _pareto_pts.end(); + NOMAD::Double f1xm1; // f_1 ( x_{j-1} ) + NOMAD::Double f1xp1; // f_1 ( x_{j+1} ) - const NOMAD::Pareto_Point * prev , * cur , * next; - - NOMAD::Double delta; - - prev = &(*it); - f1xm1 = prev->get_f1(); - f2xm1 = prev->get_f2(); - - ++it; - - cur = &(*it); - f1x = cur->get_f1(); - - if ( def && ( f1xm1 < f1_min || - f1xm1 > f1_max || - f2xm1 < f2_min || - f2xm1 > f2_max || - f1x < f1_min || - f1x > f1_max ) ) - def = false; - - if ( def ) - surf = ( f2xm1 - f2_min ) * ( f1x - f1xm1 ) - + ( f2_max - f2_min ) * ( f1xm1 - f1_min ); - - while ( true ) { - - cur = &(*it); - - ++it; - if ( it == end ) - break; + NOMAD::Double f2xm1; // f_2 ( x_{j-1} ) + NOMAD::Double f2xp1; // f_2 ( x_{j+1} ) + + // two points in the front: + if ( p == 2 ) + { + + f1xm1 = it->get_f1(); + f2xm1 = it->get_f2(); + + if ( def && ( f1xm1 < f1_min || + f1xm1 > f1_max || + f2xm1 < f2_min || + f2xm1 > f2_max ) ) + def = false; + + ++it; + xj = &(*it); + + f1x = xj->get_f1(); + f2x = xj->get_f2(); + + if ( def && ( f1x < f1_min || + f1x > f1_max || + f2x < f2_min || + f2x > f2_max ) ) + def = false; + + delta_j = ( (f1x-f1xm1).pow2() + (f2x-f2xm1).pow2() ) / ( xj->get_w() + 1.0 ); + + if ( def ) + surf = ( ( f2xm1 - f2_min ) * ( f1x - f1xm1 ) + + ( f2_max - f2_min ) * ( f1xm1 - f1_min ) + + ( f2x - f2_min ) * ( f1_max - f1x ) ) / surf_frame; + + return; + } - next = &(*it); - + // more than two points in the front: + std::set<NOMAD::Pareto_Point>::const_iterator end = _pareto_pts.end(); + + const NOMAD::Pareto_Point * prev , * cur , * next; + + NOMAD::Double delta; + + prev = &(*it); f1xm1 = prev->get_f1(); f2xm1 = prev->get_f2(); - f1x = cur->get_f1(); - f2x = cur->get_f2(); - - f1xp1 = next->get_f1(); - f2xp1 = next->get_f2(); - - - if ( def && - ( f1xm1 < f1_min || f1xm1 > f1_max || f2xm1 < f2_min || f2xm1 > f2_max || - f1x < f1_min || f1x > f1_max || f2x < f2_min || f2x > f2_max || - f1xp1 < f1_min || f1xp1 > f1_max || f2xp1 < f2_min || f2xp1 > f2_max ) ) - def = false; - - delta = ( (f1x-f1xm1).pow2() + (f2x-f2xm1).pow2() + - (f1x-f1xp1).pow2() + (f2x-f2xp1).pow2() ) / ( cur->get_w() + 1.0 ); - - if ( !delta_j.is_defined() || delta > delta_j ) - delta_j = delta; - + ++it; + + cur = &(*it); + f1x = cur->get_f1(); + + if ( def && ( f1xm1 < f1_min || + f1xm1 > f1_max || + f2xm1 < f2_min || + f2xm1 > f2_max || + f1x < f1_min || + f1x > f1_max ) ) + def = false; + if ( def ) - surf += ( f2x - f2_min ) * ( f1xp1 - f1x ); + surf = ( f2xm1 - f2_min ) * ( f1x - f1xm1 ) + + ( f2_max - f2_min ) * ( f1xm1 - f1_min ); - prev = cur; - } - - if ( def ) { - surf += ( f2xp1 - f2_min ) * ( f1_max - f1xp1 ); - surf = surf / surf_frame; - } - else - surf.clear(); + while ( true ) + { + + cur = &(*it); + + ++it; + if ( it == end ) + break; + + next = &(*it); + + f1xm1 = prev->get_f1(); + f2xm1 = prev->get_f2(); + + f1x = cur->get_f1(); + f2x = cur->get_f2(); + + f1xp1 = next->get_f1(); + f2xp1 = next->get_f2(); + + + if ( def && + ( f1xm1 < f1_min || f1xm1 > f1_max || f2xm1 < f2_min || f2xm1 > f2_max || + f1x < f1_min || f1x > f1_max || f2x < f2_min || f2x > f2_max || + f1xp1 < f1_min || f1xp1 > f1_max || f2xp1 < f2_min || f2xp1 > f2_max ) ) + def = false; + + delta = ( (f1x-f1xm1).pow2() + (f2x-f2xm1).pow2() + + (f1x-f1xp1).pow2() + (f2x-f2xp1).pow2() ) / ( cur->get_w() + 1.0 ); + + if ( !delta_j.is_defined() || delta > delta_j ) + delta_j = delta; + + if ( def ) + surf += ( f2x - f2_min ) * ( f1xp1 - f1x ); + + prev = cur; + } + + if ( def ) + { + surf += ( f2xp1 - f2_min ) * ( f1_max - f1xp1 ); + surf = surf / surf_frame; + } + else + surf.clear(); } /*------------------------------------------------------*/ @@ -392,16 +418,17 @@ void NOMAD::Pareto_Front::get_delta_surf ( NOMAD::Double & delta_j , /*------------------------------------------------------*/ void NOMAD::Pareto_Front::display ( const NOMAD::Display & out ) const { - size_t nb = _pareto_pts.size(); - int cnt = 0; - std::set<NOMAD::Pareto_Point>::const_iterator it , end = _pareto_pts.end(); - for ( it = _pareto_pts.begin() ; it != end ; ++it ) { - out << "#"; - out.display_int_w ( cnt++ , static_cast<int>(nb) ); - out << " "; - it->display ( out ); - out << std::endl; - } + size_t nb = _pareto_pts.size(); + int cnt = 0; + std::set<NOMAD::Pareto_Point>::const_iterator it , end = _pareto_pts.end(); + for ( it = _pareto_pts.begin() ; it != end ; ++it ) + { + out << "#"; + out.display_int_w ( cnt++ , static_cast<int>(nb) ); + out << " "; + it->display ( out ); + out << std::endl; + } } /*------------------------------------------------------------------*/ @@ -410,7 +437,8 @@ void NOMAD::Pareto_Front::display ( const NOMAD::Display & out ) const /* . example: */ /* */ /* const Eval_Point * cur = pareto_front.begin(); */ -/* while (cur) { */ +/* while (cur) + { */ /* ... */ /* cur = pareto_front.next(); */ /* } */ @@ -420,20 +448,20 @@ void NOMAD::Pareto_Front::display ( const NOMAD::Display & out ) const // -------- const NOMAD::Eval_Point * NOMAD::Pareto_Front::begin ( void ) const { - if ( _pareto_pts.empty() ) - return NULL; - _it = _pareto_pts.begin(); - return _it->get_element(); + if ( _pareto_pts.empty() ) + return NULL; + _it = _pareto_pts.begin(); + return _it->get_element(); } // next(): (supposes that begin() has been called) // ------- const NOMAD::Eval_Point * NOMAD::Pareto_Front::next ( void ) const { - if ( _pareto_pts.empty() ) - return NULL; - ++_it; - if ( _it == _pareto_pts.end() ) - return NULL; - return _it->get_element(); + if ( _pareto_pts.empty() ) + return NULL; + ++_it; + if ( _it == _pareto_pts.end() ) + return NULL; + return _it->get_element(); } diff --git a/src/Pareto_Front.hpp b/src/Pareto_Front.hpp index c7d251f5a2c9f0543d2ddc7d5460b9c5a27935c5..2c332630cd910d38bd05f9b74e8bb7dbda04e9be 100644 --- a/src/Pareto_Front.hpp +++ b/src/Pareto_Front.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,133 +41,134 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Pareto_Front.hpp - \brief Pareto front (headers) - \author Sebastien Le Digabel - \date 2010-04-09 - \see Pareto_Front.cpp -*/ + \file Pareto_Front.hpp + \brief Pareto front (headers) + \author Sebastien Le Digabel + \date 2010-04-09 + \see Pareto_Front.cpp + */ #ifndef __PARETO_FRONT__ #define __PARETO_FRONT__ #include "Pareto_Point.hpp" namespace NOMAD { - - /// Pareto front for two objective functions. - /** + + /// Pareto front for two objective functions. + /** Browse the front with the following instructions: \code const Eval_Point * cur = pareto_front.begin(); while ( cur ) { - ... - cur = pareto_front.next(); + ... + cur = pareto_front.next(); } \endcode - */ - class Pareto_Front : private NOMAD::Uncopyable { - - private: - - /// The set of Pareto points. - std::set<NOMAD::Pareto_Point> _pareto_pts; - - /// Iterator to browse the front with begin() and next(). - mutable std::set<NOMAD::Pareto_Point>::const_iterator _it; - - public: - - /// Constructor. - Pareto_Front ( void ) {} - - /// Destructor. - virtual ~Pareto_Front ( void ) {} - - /// Access to the first Pareto point. - /** - Used to initialize a loop on the Pareto points. - \return A pointer to the first Pareto point and \c NULL if the front - is empty. - */ - const NOMAD::Eval_Point * begin ( void ) const; - - /// Access to the next Pareto point. - /** - Used to increment a loop on the Pareto points. - \return A pointer to the next Pareto point and \c NULL if - the current point is the last point in the front. - */ - const NOMAD::Eval_Point * next ( void ) const; - - /// Access to the number of Pareto points. - /** - \return The number of Pareto points. - */ - int size ( void ) const { return static_cast<int>(_pareto_pts.size()); } - - /// Check if the front is empty. - /** - \return A boolean equal to \c true if the front is empty. - */ - bool empty ( void ) const { return _pareto_pts.empty(); } - - /// Computation and access to the reference point. - /** - \param xj A pointer to the reference point; Is equal to \c NULL if - no reference exists -- \b OUT. - \param delta_j The \c delta stats measuring the front repartition -- \b OUT. - \return A pointer to the reference point and - \c NULL if there is no reference point. - */ - NOMAD::Point * get_ref ( const NOMAD::Pareto_Point *& xj , - NOMAD::Double & delta_j ) const; - - /// Access to the Pareto point minimizing f2(x). - /** - \return A pointer to the Pareto point minimizing f2 and - \c NULL if such a point does not exist. - */ - const NOMAD::Eval_Point * get_best_f2 ( void ) const; - - /// Compute the stats \c delta and \c surf. - /** - - \c delta measures the front repartition (lower is best). - - \c surf measures the front quality (lower is best). - \param delta_j The \c delta stat -- \b OUT. - \param surf The \c surf stat -- \b OUT. - \param f_bounds NOMAD::Point with 4 values (f1_min, f1_max, f2_min, and f2_max) - defining bounds for f1 and f2 for the computation - of the \c surf stat -- \b IN. - */ - void get_delta_surf ( NOMAD::Double & delta_j , - NOMAD::Double & surf , - const NOMAD::Point & f_bounds ) const; + */ + class Pareto_Front : private NOMAD::Uncopyable { + + private: + + /// The set of Pareto points. + std::set<NOMAD::Pareto_Point> _pareto_pts; + + /// Iterator to browse the front with begin() and next(). + mutable std::set<NOMAD::Pareto_Point>::const_iterator _it; + + public: + + /// Constructor. + Pareto_Front ( void ) {} + + /// Destructor. + virtual ~Pareto_Front ( void ) {} + + /// Access to the first Pareto point. + /** + Used to initialize a loop on the Pareto points. + \return A pointer to the first Pareto point and \c NULL if the front + is empty. + */ + const NOMAD::Eval_Point * begin ( void ) const; + + /// Access to the next Pareto point. + /** + Used to increment a loop on the Pareto points. + \return A pointer to the next Pareto point and \c NULL if + the current point is the last point in the front. + */ + const NOMAD::Eval_Point * next ( void ) const; + + /// Access to the number of Pareto points. + /** + \return The number of Pareto points. + */ + int size ( void ) const { return static_cast<int>(_pareto_pts.size()); } + + /// Check if the front is empty. + /** + \return A boolean equal to \c true if the front is empty. + */ + bool empty ( void ) const { return _pareto_pts.empty(); } + + /// Computation and access to the reference point. + /** + \param xj A pointer to the reference point; Is equal to \c NULL if + no reference exists -- \b OUT. + \param delta_j The \c delta stats measuring the front repartition -- \b OUT. + \return A pointer to the reference point and + \c NULL if there is no reference point. + */ + NOMAD::Point * get_ref ( const NOMAD::Pareto_Point *& xj , + NOMAD::Double & delta_j ) const; + + /// Access to the Pareto point minimizing f2(x). + /** + \return A pointer to the Pareto point minimizing f2 and + \c NULL if such a point does not exist. + */ + const NOMAD::Eval_Point * get_best_f2 ( void ) const; + + /// Compute the stats \c delta and \c surf. + /** + - \c delta measures the front repartition (lower is best). + - \c surf measures the front quality (lower is best). + \param delta_j The \c delta stat -- \b OUT. + \param surf The \c surf stat -- \b OUT. + \param f_bounds NOMAD::Point with 4 values (f1_min, f1_max, f2_min, and f2_max) + defining bounds for f1 and f2 for the computation + of the \c surf stat -- \b IN. + */ + void get_delta_surf ( NOMAD::Double & delta_j , + NOMAD::Double & surf , + const NOMAD::Point & f_bounds ) const; + + /// Insertion of a point in the Pareto front. + /** + \param x The point to be inserted -- \b IN. + \return A boolean equal to \c true if the point is a new Pareto point. + */ + bool insert ( const NOMAD::Eval_Point & x ); + + /// Display the Pareto points. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display ( const NOMAD::Display & out ) const; + }; - /// Insertion of a point in the Pareto front. + /// Display a NOMAD::Pareto_Front object. /** - \param x The point to be inserted -- \b IN. - \return A boolean equal to \c true if the point is a new Pareto point. - */ - bool insert ( const NOMAD::Eval_Point & x ); - - /// Display the Pareto points. - /** - \param out The NOMAD::Display object -- \b IN. - */ - void display ( const NOMAD::Display & out ) const; - }; - - /// Display a NOMAD::Pareto_Front object. - /** \param out The NOMAD::Display object -- \b IN. \param pf The NOMAD::Pareto_Front object to be displayed -- \b IN. \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Pareto_Front & pf ) { - pf.display ( out ); - return out; - } + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::Pareto_Front & pf ) + { + pf.display ( out ); + return out; + } } #endif diff --git a/src/Pareto_Point.cpp b/src/Pareto_Point.cpp index 75ad0ae1cb7dcf608c9e4d66369d973bea23e1b8..985d3670124b4cc0a9112c7f855e16877b407e62 100644 --- a/src/Pareto_Point.cpp +++ b/src/Pareto_Point.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Pareto_Point.cpp - \brief Pareto point (implementation) - \author Sebastien Le Digabel - \date 2010-04-09 - \see Pareto_Point.hpp -*/ + \file Pareto_Point.cpp + \brief Pareto point (implementation) + \author Sebastien Le Digabel + \date 2010-04-09 + \see Pareto_Point.hpp + */ #include "Pareto_Point.hpp" /*--------------------------------------------------------*/ @@ -51,13 +58,13 @@ bool NOMAD::Pareto_Point::operator < ( const NOMAD::Set_Element<NOMAD::Eval_Point> & fp ) const { - if ( this == &fp || get_element() == fp.get_element() ) - return false; - - int i1 = NOMAD::Multi_Obj_Evaluator::get_i1(); - - return get_element()->get_bb_outputs()[i1].value() < - fp.get_element()->get_bb_outputs()[i1].value(); + if ( this == &fp || get_element() == fp.get_element() ) + return false; + + int i1 = NOMAD::Multi_Obj_Evaluator::get_i1(); + + return get_element()->get_bb_outputs()[i1].value() < + fp.get_element()->get_bb_outputs()[i1].value(); } /*---------------------------------------------------------------*/ @@ -67,25 +74,25 @@ bool NOMAD::Pareto_Point::operator < /*---------------------------------------------------------------*/ bool NOMAD::Pareto_Point::dominates ( const NOMAD::Pareto_Point & pp ) const { - if ( this == &pp || get_element() == pp.get_element() ) + if ( this == &pp || get_element() == pp.get_element() ) + return false; + + int i1 = NOMAD::Multi_Obj_Evaluator::get_i1(); + int i2 = NOMAD::Multi_Obj_Evaluator::get_i2(); + + // we compare F(x)=[f1(x),f2(x)] and F(y)=[f1(y),f2(y)]: + double f1x = get_element()->get_bb_outputs ()[i1].value(); + double f2x = get_element()->get_bb_outputs ()[i2].value(); + double f1y = pp.get_element()->get_bb_outputs()[i1].value(); + double f2y = pp.get_element()->get_bb_outputs()[i2].value(); + + if ( f1x < f1y ) + return f2x <= f2y; + + if ( f1x == f1y ) + return ( f2x < f2y ); + return false; - - int i1 = NOMAD::Multi_Obj_Evaluator::get_i1(); - int i2 = NOMAD::Multi_Obj_Evaluator::get_i2(); - - // we compare F(x)=[f1(x),f2(x)] and F(y)=[f1(y),f2(y)]: - double f1x = get_element()->get_bb_outputs ()[i1].value(); - double f2x = get_element()->get_bb_outputs ()[i2].value(); - double f1y = pp.get_element()->get_bb_outputs()[i1].value(); - double f2y = pp.get_element()->get_bb_outputs()[i2].value(); - - if ( f1x < f1y ) - return f2x <= f2y; - - if ( f1x == f1y ) - return ( f2x < f2y ); - - return false; } /*---------------------------------------------------------------*/ @@ -93,14 +100,14 @@ bool NOMAD::Pareto_Point::dominates ( const NOMAD::Pareto_Point & pp ) const /*---------------------------------------------------------------*/ void NOMAD::Pareto_Point::display ( const NOMAD::Display & out ) const { - const NOMAD::Point & bbo = get_element()->get_bb_outputs(); - int w = 13; - - out << "x=( "; - get_element()->NOMAD::Point::display ( out , " " , w , -1 ); - out << " ) F(x)=[ "; - bbo.Point::display ( out , " " , w , -1 ); - out << " ] [ f1(x) f2(x) ]=[ " - << std::setw(w) << bbo[NOMAD::Multi_Obj_Evaluator::get_i1()] << " " - << std::setw(w) << bbo[NOMAD::Multi_Obj_Evaluator::get_i2()] << " ]"; + const NOMAD::Point & bbo = get_element()->get_bb_outputs(); + int w = 13; + + out << "x=( "; + get_element()->NOMAD::Point::display ( out , " " , w , -1 ); + out << " ) F(x)=[ "; + bbo.Point::display ( out , " " , w , -1 ); + out << " ] [ f1(x) f2(x) ]=[ " + << std::setw(w) << bbo[NOMAD::Multi_Obj_Evaluator::get_i1()] << " " + << std::setw(w) << bbo[NOMAD::Multi_Obj_Evaluator::get_i2()] << " ]"; } diff --git a/src/Pareto_Point.hpp b/src/Pareto_Point.hpp index 1d981f646c51333094190b8c99e886a850136a6c..9503fbb5dcd657a37129ff04086333b1ae49f4d6 100644 --- a/src/Pareto_Point.hpp +++ b/src/Pareto_Point.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,122 +41,122 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Pareto_Point.hpp - \brief Pareto point (headers) - \author Sebastien Le Digabel - \date 2010-04-22 - \see Pareto_Point.cpp -*/ + \file Pareto_Point.hpp + \brief Pareto point (headers) + \author Sebastien Le Digabel + \date 2010-04-22 + \see Pareto_Point.cpp + */ #ifndef __PARETO_POINT__ #define __PARETO_POINT__ #include "Multi_Obj_Evaluator.hpp" namespace NOMAD { - - /// Pareto point for two objective functions. - class Pareto_Point : public NOMAD::Set_Element<NOMAD::Eval_Point> { - - private: - - int _w; ///< Weight. - - /// Affectation operator. - /** - \param p The right-hand side object -- \b IN. - */ - Pareto_Point & operator = ( const Pareto_Point & p ); - - public: - - /// Constructor. - /** - \param ep A pointer to an evaluation point -- \b IN. - */ - Pareto_Point ( const NOMAD::Eval_Point * ep ) - : NOMAD::Set_Element<NOMAD::Eval_Point> ( ep ) , - _w ( 0 ) {} - - /// Copy constructor. - /** - \param pp The copied object -- \b IN. - */ - explicit Pareto_Point ( const Pareto_Point & pp ) - : NOMAD::Set_Element<NOMAD::Eval_Point> ( pp.get_element() ) , - _w ( 0 ) {} - - /// Destructor. - virtual ~Pareto_Point ( void ) {} - - /// Update the weight. - /** - A more evolved formula than \c ++w is used in order - to avoid stagnation with large number of evaluations. - */ - void update_w ( void ) { _w = 2 * _w + 2; } - - /// Access to the weight. - /** - \return The weight. - */ - int get_w ( void ) const { return _w; } - - /// Access to the value of the first objective function. - /** - \return The value of the first objective function. - */ - const NOMAD::Double & get_f1 ( void ) const - { - return get_element()->get_bb_outputs()[NOMAD::Multi_Obj_Evaluator::get_i1()]; - } - - /// Access to the value of the second objective function. - /** - \return The value of the second objective function. - */ - const NOMAD::Double & get_f2 ( void ) const - { - return get_element()->get_bb_outputs()[NOMAD::Multi_Obj_Evaluator::get_i2()]; - } - - /// Comparison operator. - /** - - Supposes that \c y is a Pareto point. - - Used for the insertion in a set (the Pareto front). - - \c f1(*this) and \c f1(y) are compared. - \param y The right-hand side of the comparison -- \b IN. - \return A boolean equal to \c true if \c *this \c < \c y. - */ - virtual bool operator < ( const NOMAD::Set_Element<NOMAD::Eval_Point> & y ) const; - - /// Dominance operator. - /** - Used for the comparison (dominance) of two Pareto points - before they are inserted into the Pareto front. - \param y The right-hand side of the comparison -- \b IN. - \return A boolean equal to \c true if \c *this dominates \c y. - */ - bool dominates ( const Pareto_Point & y ) const; - /// Display the Pareto point. + /// Pareto point for two objective functions. + class Pareto_Point : public NOMAD::Set_Element<NOMAD::Eval_Point> { + + private: + + int _w; ///< Weight. + + /// Affectation operator. + /** + \param p The right-hand side object -- \b IN. + */ + Pareto_Point & operator = ( const Pareto_Point & p ); + + public: + + /// Constructor. + /** + \param ep A pointer to an evaluation point -- \b IN. + */ + Pareto_Point ( const NOMAD::Eval_Point * ep ) + : NOMAD::Set_Element<NOMAD::Eval_Point> ( ep ) , + _w ( 0 ) {} + + /// Copy constructor. + /** + \param pp The copied object -- \b IN. + */ + explicit Pareto_Point ( const Pareto_Point & pp ) + : NOMAD::Set_Element<NOMAD::Eval_Point> ( pp.get_element() ) , + _w ( 0 ) {} + + /// Destructor. + virtual ~Pareto_Point ( void ) {} + + /// Update the weight. + /** + A more evolved formula than \c ++w is used in order + to avoid stagnation with large number of evaluations. + */ + void update_w ( void ) { _w = 2 * _w + 2; } + + /// Access to the weight. + /** + \return The weight. + */ + int get_w ( void ) const { return _w; } + + /// Access to the value of the first objective function. + /** + \return The value of the first objective function. + */ + const NOMAD::Double & get_f1 ( void ) const + { + return get_element()->get_bb_outputs()[NOMAD::Multi_Obj_Evaluator::get_i1()]; + } + + /// Access to the value of the second objective function. + /** + \return The value of the second objective function. + */ + const NOMAD::Double & get_f2 ( void ) const + { + return get_element()->get_bb_outputs()[NOMAD::Multi_Obj_Evaluator::get_i2()]; + } + + /// Comparison operator. + /** + - Supposes that \c y is a Pareto point. + - Used for the insertion in a set (the Pareto front). + - \c f1(*this) and \c f1(y) are compared. + \param y The right-hand side of the comparison -- \b IN. + \return A boolean equal to \c true if \c *this \c < \c y. + */ + virtual bool operator < ( const NOMAD::Set_Element<NOMAD::Eval_Point> & y ) const; + + /// Dominance operator. + /** + Used for the comparison (dominance) of two Pareto points + before they are inserted into the Pareto front. + \param y The right-hand side of the comparison -- \b IN. + \return A boolean equal to \c true if \c *this dominates \c y. + */ + bool dominates ( const Pareto_Point & y ) const; + + /// Display the Pareto point. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display ( const NOMAD::Display & out ) const; + }; + + /// Display a NOMAD::Pareto_Point object. /** - \param out The NOMAD::Display object -- \b IN. - */ - void display ( const NOMAD::Display & out ) const; - }; - - /// Display a NOMAD::Pareto_Point object. - /** \param out The NOMAD::Display object -- \b IN. \param pp The NOMAD::Pareto_Point object to be displayed -- \b IN. \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Pareto_Point & pp ) - { - pp.display ( out ); - return out; - } + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::Pareto_Point & pp ) + { + pp.display ( out ); + return out; + } } #endif diff --git a/src/Phase_One_Evaluator.cpp b/src/Phase_One_Evaluator.cpp index 27d57ef89f42ad2b4f2220cdf9c9ca31ea516d76..ba014d5e3bc740602f96695580ece42be32ada2e 100644 --- a/src/Phase_One_Evaluator.cpp +++ b/src/Phase_One_Evaluator.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -48,30 +55,30 @@ /*------------------------------------------------------------------*/ void NOMAD::Phase_One_Evaluator::compute_f ( NOMAD::Eval_Point & x ) const { - if ( x.get_bb_outputs().size() != _p.get_bb_nb_outputs() ) - { - std::ostringstream err; - err << "Phase_One_Evaluator::compute_f(x): " - << "x has a wrong number of blackbox outputs (" - << x.get_bb_outputs().size() << " != " << _p.get_bb_nb_outputs() << ")"; - throw NOMAD::Exception ( "Phase_One_Evaluator.cpp" , __LINE__ , err.str() ); - } - - // objective value for MADS phase 1: the squared sum of all EB constraint violations - // (each EB constraint has been previously transformed into OBJ values): - const std::list<int> & index_obj = _p.get_index_obj(); - const std::list<int>::const_iterator end = index_obj.end(); - const NOMAD::Point & bbo = x.get_bb_outputs(); - NOMAD::Double h_min = _p.get_h_min(); - NOMAD::Double sum = 0.0; - NOMAD::Double v; - - for ( std::list<int>::const_iterator it = index_obj.begin() ; it != end ; ++it ) - { - v = bbo[*it]; - if ( v > h_min ) - sum += v.pow2(); - } - - x.set_f ( sum ); + if ( x.get_bb_outputs().size() != _p.get_bb_nb_outputs() ) + { + std::ostringstream err; + err << "Phase_One_Evaluator::compute_f(x): " + << "x has a wrong number of blackbox outputs (" + << x.get_bb_outputs().size() << " != " << _p.get_bb_nb_outputs() << ")"; + throw NOMAD::Exception ( "Phase_One_Evaluator.cpp" , __LINE__ , err.str() ); + } + + // objective value for MADS phase 1: the squared sum of all EB constraint violations + // (each EB constraint has been previously transformed into OBJ values): + const std::list<int> & index_obj = _p.get_index_obj(); + const std::list<int>::const_iterator end = index_obj.end(); + const NOMAD::Point & bbo = x.get_bb_outputs(); + NOMAD::Double h_min = _p.get_h_min(); + NOMAD::Double sum = 0.0; + NOMAD::Double v; + + for ( std::list<int>::const_iterator it = index_obj.begin() ; it != end ; ++it ) + { + v = bbo[*it]; + if ( v > h_min ) + sum += v.pow2(); + } + + x.set_f ( sum ); } diff --git a/src/Phase_One_Evaluator.hpp b/src/Phase_One_Evaluator.hpp index a22ca4e274ee10f58f813677512889f362d33aea..0446b24cce9ca05183efd45d220c449e34024753 100644 --- a/src/Phase_One_Evaluator.hpp +++ b/src/Phase_One_Evaluator.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -74,7 +81,8 @@ namespace NOMAD { \param s Stats -- \b IN. \param x Successful point -- \b IN. */ - virtual void update_success ( const NOMAD::Stats & s , const NOMAD::Eval_Point & x ) + virtual void update_success ( const NOMAD::Stats & s , + const NOMAD::Eval_Point & x ) { _basic_ev.update_success ( s , x ); } @@ -116,8 +124,7 @@ namespace NOMAD { This method is called before the evaluation of a list of points. \param pts List of points to preprocess -- \b IN/OUT. */ - virtual void list_of_points_preprocessing - ( std::set<NOMAD::Priority_Eval_Point> & pts ) const + virtual void list_of_points_preprocessing ( std::set<NOMAD::Priority_Eval_Point> & pts ) const { _basic_ev.list_of_points_preprocessing ( pts ); } @@ -132,6 +139,7 @@ namespace NOMAD { return _basic_ev.is_model_evaluator(); } + /// User updates after an iteration. /** This virtual method is called every time a MADS iteration is terminated. diff --git a/src/Phase_One_Search.cpp b/src/Phase_One_Search.cpp index d058fe2288534de79f11985d9945efc631c5d192..19b3fd6b1c7037c232c596862bff4051b8f63684 100644 --- a/src/Phase_One_Search.cpp +++ b/src/Phase_One_Search.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -85,17 +92,19 @@ void NOMAD::Phase_One_Search::search ( NOMAD::Mads & mads // save and modify parameters: std::string old_display_degree; _p.out().get_display_degree ( old_display_degree ); - const std::list<std::string> old_ds = _p.get_display_stats(); - NOMAD::Double old_VNS_trigger = _p.get_VNS_trigger(); - const std::string old_stats_file_name = _p.get_stats_file_name(); - const std::string old_sol_file = _p.get_solution_file(); - const std::list<std::string> old_stats_file = _p.get_stats_file(); - const NOMAD::Point old_f_target = _p.get_f_target(); - NOMAD::Double old_lct = _p.get_L_curve_target(); - bool old_sif = _p.get_stop_if_feasible(); + const std::list<std::string> old_ds = _p.get_display_stats(); + const std::string old_stats_file_name = _p.get_stats_file_name(); + const std::string old_sol_file = _p.get_solution_file(); + const std::list<std::string> old_stats_file = _p.get_stats_file(); + const NOMAD::Point old_f_target = _p.get_f_target(); + NOMAD::Double old_lct = _p.get_L_curve_target(); + bool old_sif = _p.get_stop_if_feasible(); const std::vector<NOMAD::bb_output_type> old_bbot = _p.get_bb_output_type(); std::vector<NOMAD::bb_output_type> p1_bbot = old_bbot; + NOMAD::multi_formulation_type old_multi_formulation = _p.get_multi_formulation() ; + int old_multi_nb_mads_runs = _p.get_multi_nb_mads_runs(); + if ( display_degree == NOMAD::NORMAL_DISPLAY) // Normal display -> minimal display for Phase one _p.set_DISPLAY_DEGREE( NOMAD::MINIMAL_DISPLAY); @@ -117,16 +126,24 @@ void NOMAD::Phase_One_Search::search ( NOMAD::Mads & mads p1_bbot[i] = NOMAD::UNDEFINED_BBO; } - if ( cnt == 0 ) { + if ( cnt == 0 ) + { stop = true; stop_reason = NOMAD::P1_FAIL; return; } + + if ( cnt > 1 ) + { + // _p.set_LH_SEARCH(100, 0); + _p.set_MULTI_FORMULATION( NOMAD::DIST_LINF ); + _p.set_MULTI_NB_MADS_RUNS( 1 ); + } + _p.set_F_TARGET ( NOMAD::Point ( cnt , 0.0 ) ); _p.set_L_CURVE_TARGET ( NOMAD::Double() ); _p.set_STOP_IF_FEASIBLE ( false ); - _p.set_VNS_SEARCH ( false ); _p.set_BB_OUTPUT_TYPE ( p1_bbot ); _p.set_SOLUTION_FILE ( "" ); _p.reset_stats_file(); @@ -160,7 +177,6 @@ void NOMAD::Phase_One_Search::search ( NOMAD::Mads & mads // run MADS with modified parameters: // ---------------------------------- - // C. Tribes march 2014 ---- these flags are mads static and must be put back to their original value after running mads (see below) // get flags: bool flag_check_bimads , flag_reset_mesh , flag_reset_barriers , flag_p1_active; NOMAD::Mads::get_flags ( flag_check_bimads , @@ -174,7 +190,7 @@ void NOMAD::Phase_One_Search::search ( NOMAD::Mads & mads NOMAD::Mads::set_flag_reset_mesh ( false ); NOMAD::Mads::set_flag_p1_active ( true ); NOMAD::Mads::set_flag_reset_barriers ( true ); - + // run: stop_reason = mads.run(); @@ -190,7 +206,9 @@ void NOMAD::Phase_One_Search::search ( NOMAD::Mads & mads } // continue: - else { + else + { + stop = false; stop_reason = NOMAD::NO_STOP; } @@ -199,15 +217,11 @@ void NOMAD::Phase_One_Search::search ( NOMAD::Mads & mads stop = true; // reset flags to there previous state : - // C. Tribes march 2014 ---- these flags are mads static and must be put back to their original value after running mads NOMAD::Mads::set_flag_check_bimads ( flag_check_bimads ); NOMAD::Mads::set_flag_reset_mesh ( flag_reset_mesh ); NOMAD::Mads::set_flag_p1_active ( flag_p1_active ); NOMAD::Mads::set_flag_reset_barriers ( flag_reset_barriers ); - // NOMAD::Mads::set_flag_check_bimads ( true ); - // NOMAD::Mads::set_flag_reset_mesh ( true ); - // NOMAD::Mads::set_flag_p1_active ( false ); // number of search points: nb_search_pts = stats.get_eval() - old_eval; @@ -220,7 +234,6 @@ void NOMAD::Phase_One_Search::search ( NOMAD::Mads & mads mads.set_pareto_front ( old_pareto_front ); // restore parameters: - _p.set_VNS_SEARCH ( old_VNS_trigger ); _p.set_F_TARGET ( old_f_target ); _p.set_L_CURVE_TARGET ( old_lct ); _p.set_BB_OUTPUT_TYPE ( old_bbot ); @@ -230,11 +243,13 @@ void NOMAD::Phase_One_Search::search ( NOMAD::Mads & mads _p.set_STATS_FILE ( old_stats_file_name , old_stats_file ); _p.set_DISPLAY_STATS (old_ds); + _p.set_MULTI_NB_MADS_RUNS( old_multi_nb_mads_runs ); + _p.set_MULTI_FORMULATION( old_multi_formulation ); + _p.check ( false , // remove_history_file = false true , // remove_solution_file = true false ); // remove_stats_file = true - // counters: stats.add_p1_iterations ( stats.get_iterations() - old_it ); stats.add_p1_bbe ( stats.get_bb_eval () - old_bbe ); @@ -316,7 +331,7 @@ void NOMAD::Phase_One_Search::search ( NOMAD::Mads & mads // stats_file: const std::string & stats_file_name = _p.get_stats_file_name(); - if ( !stats_file_name.empty() && display_degree > NOMAD::NO_DISPLAY) + if ( !stats_file_name.empty() && display_degree > NOMAD::NO_DISPLAY) ev_control.stats_file ( stats_file_name , bf , true , NULL ); // display_stats diff --git a/src/Phase_One_Search.hpp b/src/Phase_One_Search.hpp index 46b57d6b2357ab10ad6795352ac2c87270cafeba..f82c450a90d1734add06db7815c302cd835ddb41 100644 --- a/src/Phase_One_Search.hpp +++ b/src/Phase_One_Search.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Phase_One_Search.hpp - \brief NOMAD::Search subclass for the phase one (headers) - \author Sebastien Le Digabel - \date 2010-04-09 - \see Phase_One_Search.cpp -*/ + \file Phase_One_Search.hpp + \brief NOMAD::Search subclass for the phase one (headers) + \author Sebastien Le Digabel + \date 2010-04-09 + \see Phase_One_Search.cpp + */ #ifndef __PHASE_ONE_SEARCH__ #define __PHASE_ONE_SEARCH__ @@ -47,47 +54,47 @@ #include "Mads.hpp" namespace NOMAD { - - /// NOMAD::Search subclass for the phase one. - /** + + /// NOMAD::Search subclass for the phase one. + /** - The phase one occurs when no feasible starting point has been given. - It consists in minimizing the constraint violations and it stops - as soon as a feasible point is found. - */ - class Phase_One_Search : public NOMAD::Search , private NOMAD::Uncopyable { - - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - */ - Phase_One_Search ( NOMAD::Parameters & p ) - : NOMAD::Search ( p , NOMAD::P1_SEARCH ) {} - - /// Destructor. - virtual ~Phase_One_Search ( void ) {} - - /// The phase one search. - /** - \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. - \param nb_search_pts Number of generated search points -- \b OUT. - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - \param success Type of success -- \b OUT. - \param count_search Count or not the search -- \b OUT. - \param new_feas_inc New feasible incumbent -- \b IN/OUT. - \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. - */ - virtual void search ( NOMAD::Mads & mads , - int & nb_search_pts , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - bool & count_search , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ); - }; + as soon as a feasible point is found. + */ + class Phase_One_Search : public NOMAD::Search , private NOMAD::Uncopyable { + + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + */ + Phase_One_Search ( NOMAD::Parameters & p ) + : NOMAD::Search ( p , NOMAD::P1_SEARCH ) {} + + /// Destructor. + virtual ~Phase_One_Search ( void ) {} + + /// The phase one search. + /** + \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. + \param nb_search_pts Number of generated search points -- \b OUT. + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + \param success Type of success -- \b OUT. + \param count_search Count or not the search -- \b OUT. + \param new_feas_inc New feasible incumbent -- \b IN/OUT. + \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. + */ + virtual void search ( NOMAD::Mads & mads , + int & nb_search_pts , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + bool & count_search , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ); + }; } #endif diff --git a/src/Point.cpp b/src/Point.cpp index fe27123b57e9ce9aee2cee6661edad621ecc890d..fd2ac1350089a2136bc664d9dc3a1e8b8e8d350a 100644 --- a/src/Point.cpp +++ b/src/Point.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -58,18 +65,18 @@ int NOMAD::Point::_display_limit = NOMAD::DEFAULT_POINT_DISPLAY_LIMIT; NOMAD::Point::Point ( int n , const NOMAD::Double & d ) : _n (n) , _coords (NULL) { #ifdef MEMORY_DEBUG - ++NOMAD::Point::_cardinality; - if ( NOMAD::Point::_cardinality > NOMAD::Point::_max_cardinality ) - ++NOMAD::Point::_max_cardinality; + ++NOMAD::Point::_cardinality; + if ( NOMAD::Point::_cardinality > NOMAD::Point::_max_cardinality ) + ++NOMAD::Point::_max_cardinality; #endif - if (_n > 0) + if (_n > 0) { - _coords = new NOMAD::Double [_n]; - if ( d.is_defined() ) - std::fill ( _coords , _coords+_n , d ); - } - else - _n = 0; + _coords = new NOMAD::Double [_n]; + if ( d.is_defined() ) + std::fill ( _coords , _coords+_n , d ); + } + else + _n = 0; } /*-----------------------------------------------------------*/ @@ -78,17 +85,17 @@ NOMAD::Point::Point ( int n , const NOMAD::Double & d ) : _n (n) , _coords (NULL NOMAD::Point::Point ( const NOMAD::Point & p ) : _n (p._n) , _coords (NULL) { #ifdef MEMORY_DEBUG - ++NOMAD::Point::_cardinality; - if ( NOMAD::Point::_cardinality >= NOMAD::Point::_max_cardinality ) - ++NOMAD::Point::_max_cardinality; + ++NOMAD::Point::_cardinality; + if ( NOMAD::Point::_cardinality >= NOMAD::Point::_max_cardinality ) + ++NOMAD::Point::_max_cardinality; #endif - if ( _n > 0 ) + if ( _n > 0 ) { - NOMAD::Double * p1 = _coords = new NOMAD::Double [_n]; - const NOMAD::Double * p2 = p._coords; - for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 ) - *p1 = *p2; - } + NOMAD::Double * p1 = _coords = new NOMAD::Double [_n]; + const NOMAD::Double * p2 = p._coords; + for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 ) + *p1 = *p2; + } } /*-----------------------------------------------*/ @@ -97,9 +104,9 @@ NOMAD::Point::Point ( const NOMAD::Point & p ) : _n (p._n) , _coords (NULL) NOMAD::Point::~Point ( void ) { #ifdef MEMORY_DEBUG - --NOMAD::Point::_cardinality; + --NOMAD::Point::_cardinality; #endif - delete [] _coords; + delete [] _coords; } /*-----------------------------------------------*/ @@ -108,23 +115,23 @@ NOMAD::Point::~Point ( void ) /*-----------------------------------------------*/ void NOMAD::Point::reset ( int n , const NOMAD::Double & d ) { - if ( n <= 0 ) + if ( n <= 0 ) { - _n = 0; - delete [] _coords; - _coords = NULL; - } - else + _n = 0; + delete [] _coords; + _coords = NULL; + } + else { - if ( _n != n ) + if ( _n != n ) { - delete [] _coords; - _n = n; - _coords = new NOMAD::Double [_n]; - } - if ( d.is_defined() ) - std::fill ( _coords , _coords+_n , d ); - } + delete [] _coords; + _n = n; + _coords = new NOMAD::Double [_n]; + } + if ( d.is_defined() ) + std::fill ( _coords , _coords+_n , d ); + } } /*----------------------------------------------------------------*/ @@ -132,31 +139,31 @@ void NOMAD::Point::reset ( int n , const NOMAD::Double & d ) /*----------------------------------------------------------------*/ void NOMAD::Point::resize ( int n ) { - if ( n == _n ) - return; + if ( n == _n ) + return; - if ( n <= 0 ) + if ( n <= 0 ) { - _n = 0; - delete [] _coords; - _coords = NULL; - return; - } - NOMAD::Double * new_coords = new NOMAD::Double [n]; - if ( _coords ) + _n = 0; + delete [] _coords; + _coords = NULL; + return; + } + NOMAD::Double * new_coords = new NOMAD::Double [n]; + if ( _coords ) { - int min = ( n < _n ) ? n : _n; - - NOMAD::Double * p1 = new_coords; - const NOMAD::Double * p2 = _coords; - - for ( int i = 0 ; i < min ; ++i , ++p1 , ++p2 ) - *p1 = *p2; - - delete [] _coords; - } - _coords = new_coords; - _n = n; + int min = ( n < _n ) ? n : _n; + + NOMAD::Double * p1 = new_coords; + const NOMAD::Double * p2 = _coords; + + for ( int i = 0 ; i < min ; ++i , ++p1 , ++p2 ) + *p1 = *p2; + + delete [] _coords; + } + _coords = new_coords; + _n = n; } /*-----------------------------------------------------------*/ @@ -166,25 +173,25 @@ void NOMAD::Point::resize ( int n ) // const version: const NOMAD::Double & NOMAD::Point::operator [] ( int i ) const { - if ( !_coords ) - throw NOMAD::Point::Not_Defined ( "Point.cpp" , __LINE__ , - "operator x[i] (const): 'x' not defined" ); - if ( i < 0 || i >= _n ) - throw NOMAD::Point::Bad_Access ( "Point.cpp" , __LINE__ , - "operator x[i] (const): 'i' outside the array's bounds." ); - return _coords[i]; + if ( !_coords ) + throw NOMAD::Point::Not_Defined ( "Point.cpp" , __LINE__ , + "operator x[i] (const): 'x' not defined" ); + if ( i < 0 || i >= _n ) + throw NOMAD::Point::Bad_Access ( "Point.cpp" , __LINE__ , + "operator x[i] (const): 'i' outside the array's bounds." ); + return _coords[i]; } // non-const version: NOMAD::Double & NOMAD::Point::operator [] ( int i ) { - if ( !_coords ) - throw NOMAD::Point::Not_Defined ( "Point.cpp" , __LINE__ , - "operator x[i]: 'x' not defined" ); - if ( i < 0 || i >= _n ) - throw NOMAD::Point::Bad_Access ( "Point.cpp" , __LINE__ , - "operator x[i] (const): 'i' outside the array's bounds." ); - return _coords[i]; + if ( !_coords ) + throw NOMAD::Point::Not_Defined ( "Point.cpp" , __LINE__ , + "operator x[i]: 'x' not defined" ); + if ( i < 0 || i >= _n ) + throw NOMAD::Point::Bad_Access ( "Point.cpp" , __LINE__ , + "operator x[i] (const): 'i' outside the array's bounds." ); + return _coords[i]; } /*-----------------------------------------------------------*/ @@ -192,25 +199,25 @@ NOMAD::Double & NOMAD::Point::operator [] ( int i ) /*-----------------------------------------------------------*/ const NOMAD::Point & NOMAD::Point::operator = ( const NOMAD::Point & p ) { - if ( this == &p ) - return *this; - - if ( _n != p._n ) + if ( this == &p ) + return *this; + + if ( _n != p._n ) { - delete [] _coords; - _n = p._n; - if (_n > 0) - _coords = new NOMAD::Double [_n]; - else - _coords = NULL; - } - - NOMAD::Double * p1 = _coords; - const NOMAD::Double * p2 = p._coords; - for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 ) - *p1 = *p2; - - return *this; + delete [] _coords; + _n = p._n; + if (_n > 0) + _coords = new NOMAD::Double [_n]; + else + _coords = NULL; + } + + NOMAD::Double * p1 = _coords; + const NOMAD::Double * p2 = p._coords; + for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 ) + *p1 = *p2; + + return *this; } /*------------------------------------*/ @@ -218,36 +225,36 @@ const NOMAD::Point & NOMAD::Point::operator = ( const NOMAD::Point & p ) /* (*this = ref + k * delta) */ /*------------------------------------*/ void NOMAD::Point::project_to_mesh ( const NOMAD::Point & ref , - const NOMAD::Point & delta , - const NOMAD::Point & lb , - const NOMAD::Point & ub ) + const NOMAD::Point & delta , + const NOMAD::Point & lb , + const NOMAD::Point & ub ) { - if ( delta._n != _n || - ref._n != _n || - ( lb._n > 0 && lb._n != _n ) || - ( ub._n > 0 && ub._n != _n ) ) - throw NOMAD::Point::Bad_Operation ( "Point.cpp" , __LINE__ , - "Point::project_to_mesh(): invalid Point sizes" ); - - NOMAD::Double * p = _coords , - * pr = ref._coords , - * pd = delta._coords , - * pl = lb._coords , - * pu = ub._coords; - int k; - - if ( lb._n == 0 && ub._n == 0 ) - for ( k = 0 ; k < _n ; ++k , ++pr , ++p , ++pd ) - p->project_to_mesh ( *pr , *pd ); - else if ( lb._n == 0 ) - for ( k = 0 ; k < _n ; ++k , ++pr , ++p , ++pd , ++pu ) - p->project_to_mesh ( *pr , *pd , NOMAD::Double() , *pu ); - else if ( ub._n == 0 ) - for ( k = 0 ; k < _n ; ++k , ++pr , ++p , ++pd , ++pl ) - p->project_to_mesh ( *pr , *pd , *pl ); - else - for ( k = 0 ; k < _n ; ++k , ++pr , ++p , ++pd , ++pl , ++pu ) - p->project_to_mesh ( *pr , *pd , *pl , *pu ); + if ( delta._n != _n || + ref._n != _n || + ( lb._n > 0 && lb._n != _n ) || + ( ub._n > 0 && ub._n != _n ) ) + throw NOMAD::Point::Bad_Operation ( "Point.cpp" , __LINE__ , + "Point::project_to_mesh(): invalid Point sizes" ); + + NOMAD::Double * p = _coords , + * pr = ref._coords , + * pd = delta._coords , + * pl = lb._coords , + * pu = ub._coords; + int k; + + if ( lb._n == 0 && ub._n == 0 ) + for ( k = 0 ; k < _n ; ++k , ++pr , ++p , ++pd ) + p->project_to_mesh ( *pr , *pd ); + else if ( lb._n == 0 ) + for ( k = 0 ; k < _n ; ++k , ++pr , ++p , ++pd , ++pu ) + p->project_to_mesh ( *pr , *pd , NOMAD::Double() , *pu ); + else if ( ub._n == 0 ) + for ( k = 0 ; k < _n ; ++k , ++pr , ++p , ++pd , ++pl ) + p->project_to_mesh ( *pr , *pd , *pl ); + else + for ( k = 0 ; k < _n ; ++k , ++pr , ++p , ++pd , ++pl , ++pu ) + p->project_to_mesh ( *pr , *pd , *pl , *pu ); } @@ -255,41 +262,41 @@ void NOMAD::Point::project_to_mesh ( const NOMAD::Point & ref , /* display */ /*-----------------------------------------------------------*/ void NOMAD::Point::display ( const NOMAD::Display & out , - const std::string & sep , - int w , - int lim ) const + const std::string & sep , + int w , + int lim ) const { - int nm1 = _n-1; - - // for a limited display of maximum lim elements: - if ( lim > 0 && lim < _n ) - { - - int l1 = (lim + 1) / 2 , l2 = lim / 2 , i; - - // first coordinates: - for ( i = 0 ; i < l1 ; ++i ) - out << std::setw ( w ) << _coords[i] << sep; - - // separator: - out << "..." << sep; - - // last coordinates: - for ( i = _n - l2 ; i < nm1 ; ++i ) - out << std::setw ( w ) << _coords[i] << sep; - } - - // normal display (lim <= 0 or lim >= _n): - else - { - const NOMAD::Double * p = _coords; - for ( int i = 0 ; i < nm1 ; ++i , ++p ) - out << std::setw ( w ) << *p << sep; - } - - // last coordinate (different because there is no separator after that): - if ( _n > 0 ) - out << std::setw ( w ) << _coords[nm1]; + int nm1 = _n-1; + + // for a limited display of maximum lim elements: + if ( lim > 0 && lim < _n ) + { + + int l1 = (lim + 1) / 2 , l2 = lim / 2 , i; + + // first coordinates: + for ( i = 0 ; i < l1 ; ++i ) + out << std::setw ( w ) << _coords[i] << sep; + + // separator: + out << "..." << sep; + + // last coordinates: + for ( i = _n - l2 ; i < nm1 ; ++i ) + out << std::setw ( w ) << _coords[i] << sep; + } + + // normal display (lim <= 0 or lim >= _n): + else + { + const NOMAD::Double * p = _coords; + for ( int i = 0 ; i < nm1 ; ++i , ++p ) + out << std::setw ( w ) << *p << sep; + } + + // last coordinate (different because there is no separator after that): + if ( _n > 0 ) + out << std::setw ( w ) << _coords[nm1]; } /*-----------------------------------------------------------*/ @@ -297,12 +304,12 @@ void NOMAD::Point::display ( const NOMAD::Display & out , /*-----------------------------------------------------------*/ std::istream & NOMAD::operator >> ( std::istream & in , NOMAD::Point & p ) { - int n = p.size(); - for ( int k = 0 ; k < n ; ++k ) - in >> p[k]; - if ( in.fail() ) - throw NOMAD::Point::Bad_Input ( "Point.cpp" , __LINE__ , "in >> x: bad input" ); - return in; + int n = p.size(); + for ( int k = 0 ; k < n ; ++k ) + in >> p[k]; + if ( in.fail() ) + throw NOMAD::Point::Bad_Input ( "Point.cpp" , __LINE__ , "in >> x: bad input" ); + return in; } /*-----------------------------------------------------------*/ @@ -311,19 +318,19 @@ std::istream & NOMAD::operator >> ( std::istream & in , NOMAD::Point & p ) /*-----------------------------------------------------------*/ void NOMAD::Point::set ( int n , const NOMAD::Double * a ) { - if ( n <= 0 || !a ) - return; - - if ( _n != n ) + if ( n <= 0 || !a ) + return; + + if ( _n != n ) { - delete [] _coords; - _n = n; - _coords = new NOMAD::Double [_n]; - } - - NOMAD::Double * p = _coords; - for ( int k = 0 ; k < _n ; ++k , ++p , ++a ) - *p = *a; + delete [] _coords; + _n = n; + _coords = new NOMAD::Double [_n]; + } + + NOMAD::Double * p = _coords; + for ( int k = 0 ; k < _n ; ++k , ++p , ++a ) + *p = *a; } /*-----------------------------------------------------------*/ @@ -331,13 +338,13 @@ void NOMAD::Point::set ( int n , const NOMAD::Double * a ) /*-----------------------------------------------------------*/ bool NOMAD::Point::is_complete ( void ) const { - if ( _n <= 0 ) - return false; - const NOMAD::Double * p = _coords; - for ( int i = 0 ; i < _n ; ++i , ++p ) - if ( !p->is_defined() ) - return false; - return true; + if ( _n <= 0 ) + return false; + const NOMAD::Double * p = _coords; + for ( int i = 0 ; i < _n ; ++i , ++p ) + if ( !p->is_defined() ) + return false; + return true; } /*---------------------------------------------------------------*/ @@ -345,13 +352,13 @@ bool NOMAD::Point::is_complete ( void ) const /*---------------------------------------------------------------*/ bool NOMAD::Point::is_defined ( void ) const { - if ( _n <= 0 ) - return false; - const NOMAD::Double * p = _coords; - for ( int i = 0 ; i < _n ; ++i , ++p ) - if ( p->is_defined() ) - return true; - return false; + if ( _n <= 0 ) + return false; + const NOMAD::Double * p = _coords; + for ( int i = 0 ; i < _n ; ++i , ++p ) + if ( p->is_defined() ) + return true; + return false; } /*---------------------------------------------------------------*/ @@ -359,25 +366,25 @@ bool NOMAD::Point::is_defined ( void ) const /*---------------------------------------------------------------*/ int NOMAD::Point::nb_defined ( void ) const { - const NOMAD::Double * p = _coords; - int k = 0; - for ( int i = 0 ; i < _n ; ++i , ++p ) - if ( p->is_defined() ) - ++k; - return k; -} + const NOMAD::Double * p = _coords; + int k = 0; + for ( int i = 0 ; i < _n ; ++i , ++p ) + if ( p->is_defined() ) + ++k; + return k; +} /*-----------------------------------------------------------*/ /* negation */ /*-----------------------------------------------------------*/ const NOMAD::Point NOMAD::Point::operator - ( void ) const { - NOMAD::Point tmp (_n); - NOMAD::Double * p1 = tmp._coords; - const NOMAD::Double * p2 = _coords; - for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 ) - *p1 = - *p2; - return tmp; + NOMAD::Point tmp (_n); + NOMAD::Double * p1 = tmp._coords; + const NOMAD::Double * p2 = _coords; + for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 ) + *p1 = - *p2; + return tmp; } /*----------------------------------------------------------*/ @@ -385,10 +392,10 @@ const NOMAD::Point NOMAD::Point::operator - ( void ) const /*----------------------------------------------------------*/ const NOMAD::Point & NOMAD::Point::operator *= ( const NOMAD::Double & d ) { - NOMAD::Double * p = _coords; - for ( int k = 0 ; k < _n ; ++k , ++p ) - *p *= d; - return *this; + NOMAD::Double * p = _coords; + for ( int k = 0 ; k < _n ; ++k , ++p ) + *p *= d; + return *this; } /*----------------------------------------------------------*/ @@ -396,18 +403,18 @@ const NOMAD::Point & NOMAD::Point::operator *= ( const NOMAD::Double & d ) /*----------------------------------------------------------*/ const NOMAD::Point NOMAD::Point::operator * ( const NOMAD::Point & p ) const { - if ( p._n != _n ) - throw NOMAD::Point::Bad_Operation ( "Point.cpp" , __LINE__ , - "x * y: x.size != y.size" ); - NOMAD::Point tmp ( _n ); - NOMAD::Double * p1 = tmp._coords; - const NOMAD::Double * p2 = _coords; - const NOMAD::Double * p3 = p._coords; - - for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 , ++p3 ) - *p1 = *p2 * *p3; - - return tmp; + if ( p._n != _n ) + throw NOMAD::Point::Bad_Operation ( "Point.cpp" , __LINE__ , + "x * y: x.size != y.size" ); + NOMAD::Point tmp ( _n ); + NOMAD::Double * p1 = tmp._coords; + const NOMAD::Double * p2 = _coords; + const NOMAD::Double * p3 = p._coords; + + for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 , ++p3 ) + *p1 = *p2 * *p3; + + return tmp; } /*----------------------------------------------------------*/ @@ -415,18 +422,18 @@ const NOMAD::Point NOMAD::Point::operator * ( const NOMAD::Point & p ) const /*----------------------------------------------------------*/ const NOMAD::Point NOMAD::Point::operator / ( const NOMAD::Point & p ) const { - if ( p._n != _n ) - throw NOMAD::Point::Bad_Operation ( "Point.cpp" , __LINE__ , - "x / y: x.size != y.size" ); - NOMAD::Point tmp ( _n ); - NOMAD::Double * p1 = tmp._coords; - const NOMAD::Double * p2 = _coords; - const NOMAD::Double * p3 = p._coords; - - for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 , ++p3 ) - *p1 = *p2 / *p3; - - return tmp; + if ( p._n != _n ) + throw NOMAD::Point::Bad_Operation ( "Point.cpp" , __LINE__ , + "x / y: x.size != y.size" ); + NOMAD::Point tmp ( _n ); + NOMAD::Double * p1 = tmp._coords; + const NOMAD::Double * p2 = _coords; + const NOMAD::Double * p3 = p._coords; + + for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 , ++p3 ) + *p1 = *p2 / *p3; + + return tmp; } /*----------------------------------------------------------*/ @@ -434,18 +441,18 @@ const NOMAD::Point NOMAD::Point::operator / ( const NOMAD::Point & p ) const /*----------------------------------------------------------*/ const NOMAD::Point NOMAD::Point::operator + ( const NOMAD::Point & p ) const { - if ( p._n != _n ) - throw NOMAD::Point::Bad_Operation ( "Point.cpp" , __LINE__ , - "x + y: x.size != y.size" ); - NOMAD::Point tmp ( _n ); - NOMAD::Double * p1 = tmp._coords; - const NOMAD::Double * p2 = _coords; - const NOMAD::Double * p3 = p._coords; - - for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 , ++p3 ) - *p1 = *p2 + *p3; - - return tmp; + if ( p._n != _n ) + throw NOMAD::Point::Bad_Operation ( "Point.cpp" , __LINE__ , + "x + y: x.size != y.size" ); + NOMAD::Point tmp ( _n ); + NOMAD::Double * p1 = tmp._coords; + const NOMAD::Double * p2 = _coords; + const NOMAD::Double * p3 = p._coords; + + for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 , ++p3 ) + *p1 = *p2 + *p3; + + return tmp; } /*----------------------------------------------------------*/ @@ -453,18 +460,18 @@ const NOMAD::Point NOMAD::Point::operator + ( const NOMAD::Point & p ) const /*----------------------------------------------------------*/ const NOMAD::Point NOMAD::Point::operator - ( const NOMAD::Point & p ) const { - if ( p._n != _n ) - throw NOMAD::Point::Bad_Operation ( "Point.cpp" , __LINE__ , - "x - y: x.size != y.size" ); - NOMAD::Point tmp ( _n ); - NOMAD::Double * p1 = tmp._coords; - const NOMAD::Double * p2 = _coords; - const NOMAD::Double * p3 = p._coords; - - for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 , ++p3 ) - *p1 = *p2 - *p3; - - return tmp; + if ( p._n != _n ) + throw NOMAD::Point::Bad_Operation ( "Point.cpp" , __LINE__ , + "x - y: x.size != y.size" ); + NOMAD::Point tmp ( _n ); + NOMAD::Double * p1 = tmp._coords; + const NOMAD::Double * p2 = _coords; + const NOMAD::Double * p3 = p._coords; + + for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 , ++p3 ) + *p1 = *p2 - *p3; + + return tmp; } /*--------------------------------------------------------------------------*/ @@ -473,28 +480,28 @@ const NOMAD::Point NOMAD::Point::operator - ( const NOMAD::Point & p ) const /*--------------------------------------------------------------------------*/ bool NOMAD::Point::operator < ( const NOMAD::Point & p ) const { - if ( this == &p ) - return false; - - if ( _n < p._n ) - return true; - if ( _n > p._n ) - return false; - - const NOMAD::Double * p1 = _coords; - const NOMAD::Double * p2 = p._coords; - - for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 ) + if ( this == &p ) + return false; + + if ( _n < p._n ) + return true; + if ( _n > p._n ) + return false; + + const NOMAD::Double * p1 = _coords; + const NOMAD::Double * p2 = p._coords; + + for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 ) { - - if ( *p1 < *p2 ) - return true; - - if ( *p1 > *p2 ) - return false; - } - - return false; + + if ( *p1 < *p2 ) + return true; + + if ( *p1 > *p2 ) + return false; + } + + return false; } /*---------------------------------------------------------------------*/ @@ -502,40 +509,40 @@ bool NOMAD::Point::operator < ( const NOMAD::Point & p ) const /*---------------------------------------------------------------------*/ bool NOMAD::Point::comp_with_undef ( const NOMAD::Point & p ) const { - if ( this == &p ) - return false; - - if ( _n < p._n ) - return true; - if ( _n > p._n ) - return false; - - const NOMAD::Double * p1 = _coords; - const NOMAD::Double * p2 = p._coords; - - bool p1d , p2d; - - for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 ) + if ( this == &p ) + return false; + + if ( _n < p._n ) + return true; + if ( _n > p._n ) + return false; + + const NOMAD::Double * p1 = _coords; + const NOMAD::Double * p2 = p._coords; + + bool p1d , p2d; + + for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 ) { - p1d = p1->is_defined(); - p2d = p2->is_defined(); - - if ( !p1d && !p2d ) - continue; - - if ( !p1d ) - return true; - - if ( !p2d ) - return false; - - if ( *p1 < *p2 ) - return true; - - if ( *p1 > *p2 ) - return false; - } - return false; + p1d = p1->is_defined(); + p2d = p2->is_defined(); + + if ( !p1d && !p2d ) + continue; + + if ( !p1d ) + return true; + + if ( !p2d ) + return false; + + if ( *p1 < *p2 ) + return true; + + if ( *p1 > *p2 ) + return false; + } + return false; } /*-----------------------------------------------------------*/ @@ -543,18 +550,18 @@ bool NOMAD::Point::comp_with_undef ( const NOMAD::Point & p ) const /*-----------------------------------------------------------*/ bool NOMAD::Point::operator == ( const NOMAD::Point & p ) const { - if ( this == &p ) - return true; - if ( p._n != _n ) - return false; - - const NOMAD::Double * p1 = _coords; - const NOMAD::Double * p2 = p._coords; - for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 ) - if ( *p1 != *p2 ) - return false; - - return true; + if ( this == &p ) + return true; + if ( p._n != _n ) + return false; + + const NOMAD::Double * p1 = _coords; + const NOMAD::Double * p2 = p._coords; + for ( int k = 0 ; k < _n ; ++k , ++p1 , ++p2 ) + if ( *p1 != *p2 ) + return false; + + return true; } /*-----------------------------------------------------------*/ @@ -562,23 +569,43 @@ bool NOMAD::Point::operator == ( const NOMAD::Point & p ) const /*-----------------------------------------------------------*/ const NOMAD::Double NOMAD::Point::get_angle ( const NOMAD::Point & x ) const { - if ( _n != x._n ) - return NOMAD::Double(); - - NOMAD::Double inner_product = 0.0 , norm_1 = 0.0 , norm_2 = 0.0; - - const NOMAD::Double * p1 = _coords; - const NOMAD::Double * p2 = x._coords; - - for ( int i = 0 ; i < _n ; ++i , ++p1 , ++p2 ) + if ( _n != x._n ) + return NOMAD::Double(); + + NOMAD::Double inner_product = 0.0 , norm_1 = 0.0 , norm_2 = 0.0; + + const NOMAD::Double * p1 = _coords; + const NOMAD::Double * p2 = x._coords; + + for ( int i = 0 ; i < _n ; ++i , ++p1 , ++p2 ) { - norm_1 += *p1 * *p1; - norm_2 += *p2 * *p2; - inner_product += *p1 * *p2; - } - - if ( norm_1 == 0.0 || norm_2 == 0.0 ) - return NOMAD::Double(); - - return acos ( ( inner_product / ( norm_1.sqrt() * norm_2.sqrt() ) ).value() ); + norm_1 += *p1 * *p1; + norm_2 += *p2 * *p2; + inner_product += *p1 * *p2; + } + + if ( norm_1 == 0.0 || norm_2 == 0.0 ) + return NOMAD::Double(); + + return acos ( ( inner_product / ( norm_1.sqrt() * norm_2.sqrt() ) ).value() ); +} + + +/*-----------------------------------------------------------*/ +/* get coord */ +/*-----------------------------------------------------------*/ +const NOMAD::Double NOMAD::Point::get_coord (int i) const +{ + return _coords[i]; +} + + +/*-----------------------------------------------------------*/ +/* Set the coordinate j to value v */ +/*-----------------------------------------------------------*/ +void NOMAD::Point::set_coord ( int j , const NOMAD::Double v ) +{ + if (( j < 0 ) || (j >= _n)) + return; + _coords[j] = v; } diff --git a/src/Point.hpp b/src/Point.hpp index 344ade6534eacdb3cfd0a8808c6344549bd8abb0..0a565ae65e0392e63960768692ff5d52eab6a19a 100644 --- a/src/Point.hpp +++ b/src/Point.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Point.hpp - \brief Custom class for points (headers) - \author Sebastien Le Digabel - \date 2010-04-05 - \see Point.cpp -*/ + \file Point.hpp + \brief Custom class for points (headers) + \author Sebastien Le Digabel + \date 2010-04-05 + \see Point.cpp + */ #ifndef __POINT__ #define __POINT__ @@ -48,403 +55,427 @@ #include "Double.hpp" namespace NOMAD { - - /// \c accumulate operator for \c squared_norm(). - struct squared_norm_op { - /** This function returns \c d1+d2^2 and is designed as an - \c accumulate operator. - \param d1 The NOMAD::Double \c d1 -- \b IN. - \param d2 The NOMAD::Double \c d2 -- \b IN. - \return A third NOMAD::Double equal to \c d1+d2^2. - */ - NOMAD::Double operator () ( const NOMAD::Double & d1 , const NOMAD::Double & d2 ) { - return d1 + d2.pow2(); - } - }; - - /// \c accumulate operator for \c size_of(). - struct size_of_op { - /** This function returns \c i+size_of(d) and is designed as an - \c accumulate operator. - \param i The integer \c i -- \b IN. - \param d The NOMAD::Double \c d -- \b IN. - \return An integer equal to \c i+size_of(d). - */ - int operator () ( int i , const NOMAD::Double & d ) { - return i + d.size_of(); - } - }; - - /// Custom class for points. - /** - Coordinates are NOMAD::Double objects. - */ - class Point { - - private: - -#ifdef MEMORY_DEBUG - static int _cardinality; ///< Number of NOMAD::Point objects in memory. - static int _max_cardinality; ///< Max number of NOMAD::Point objects in memory. -#endif - - /** - Max number of coordinates to display. - Default to 20, debug value at -1 (no limit). - */ - static int _display_limit; - - int _n; ///< Dimension of the point. - NOMAD::Double * _coords; ///< Coordinates of the point. - - public: - - /*-------------------------------------------------------------------*/ - - /// Exception class for a bad access with NOMAD::Point objects. - class Bad_Access : public NOMAD::Exception { - public: - /// Constructor. - Bad_Access ( const std::string & file , - int line , - const std::string & msg ) - : NOMAD::Exception ( file , line , msg ) {} - }; - - /// Exception class for NOMAD::Point objects that are not defined. - class Not_Defined : public NOMAD::Exception { - public: - /// Constructor. - Not_Defined ( const std::string & file , - int line , - const std::string & msg ) - : NOMAD::Exception ( file , line , msg ) {} + + /// \c accumulate operator for \c squared_norm(). + struct squared_norm_op { + /** This function returns \c d1+d2^2 and is designed as an + \c accumulate operator. + \param d1 The NOMAD::Double \c d1 -- \b IN. + \param d2 The NOMAD::Double \c d2 -- \b IN. + \return A third NOMAD::Double equal to \c d1+d2^2. + */ + NOMAD::Double operator () ( const NOMAD::Double & d1 , const NOMAD::Double & d2 ) + { + return d1 + d2.pow2(); + } }; - - /// Exception class for input errors with NOMAD::Point objects. - class Bad_Input : public NOMAD::Exception { - public: - /// Constructor. - Bad_Input ( const std::string & file , - int line , - const std::string & msg ) - : NOMAD::Exception ( file , line , msg ) {} + + /// \c accumulate operator for \c size_of(). + struct size_of_op { + /** This function returns \c i+size_of(d) and is designed as an + \c accumulate operator. + \param i The integer \c i -- \b IN. + \param d The NOMAD::Double \c d -- \b IN. + \return An integer equal to \c i+size_of(d). + */ + int operator () ( int i , const NOMAD::Double & d ) + { + return i + d.size_of(); + } }; - /// Exception class for bad operations with NOMAD::Point objects. - class Bad_Operation : public NOMAD::Exception { + /// Custom class for points. + /** + Coordinates are NOMAD::Double objects. + */ + class Point { + + private: + +#ifdef MEMORY_DEBUG + static int _cardinality; ///< Number of NOMAD::Point objects in memory. + static int _max_cardinality; ///< Max number of NOMAD::Point objects in memory. +#endif + + /** + Max number of coordinates to display. + Default to 20, debug value at -1 (no limit). + */ + static int _display_limit; + + int _n; ///< Dimension of the point. + NOMAD::Double * _coords; ///< Coordinates of the point. + public: - /// Constructor. - Bad_Operation ( const std::string & file , - int line , - const std::string & msg ) - : NOMAD::Exception ( file , line , msg ) {} - }; - - /*-------------------------------------------------------------------*/ - + + /*-------------------------------------------------------------------*/ + + /// Exception class for a bad access with NOMAD::Point objects. + class Bad_Access : public NOMAD::Exception { + public: + /// Constructor. + Bad_Access ( const std::string & file , + int line , + const std::string & msg ) + : NOMAD::Exception ( file , line , msg ) {} + }; + + /// Exception class for NOMAD::Point objects that are not defined. + class Not_Defined : public NOMAD::Exception { + public: + /// Constructor. + Not_Defined ( const std::string & file , + int line , + const std::string & msg ) + : NOMAD::Exception ( file , line , msg ) {} + }; + + /// Exception class for input errors with NOMAD::Point objects. + class Bad_Input : public NOMAD::Exception { + public: + /// Constructor. + Bad_Input ( const std::string & file , + int line , + const std::string & msg ) + : NOMAD::Exception ( file , line , msg ) {} + }; + + /// Exception class for bad operations with NOMAD::Point objects. + class Bad_Operation : public NOMAD::Exception { + public: + /// Constructor. + Bad_Operation ( const std::string & file , + int line , + const std::string & msg ) + : NOMAD::Exception ( file , line , msg ) {} + }; + + /*-------------------------------------------------------------------*/ + #ifdef MEMORY_DEBUG - /// Access to the number of NOMAD::Point objects in memory. - /** - \return The number of NOMAD::Point objects in memory. - */ - static int get_cardinality ( void ) { return Point::_cardinality; } - - /// Access to the max number of NOMAD::Point objects in memory. - /** - \return The max number of NOMAD::Point objects in memory. - */ - static int get_max_cardinality ( void ) { return Point::_max_cardinality; } + /// Access to the number of NOMAD::Point objects in memory. + /** + \return The number of NOMAD::Point objects in memory. + */ + static int get_cardinality ( void ) { return Point::_cardinality; } + + /// Access to the max number of NOMAD::Point objects in memory. + /** + \return The max number of NOMAD::Point objects in memory. + */ + static int get_max_cardinality ( void ) { return Point::_max_cardinality; } #endif + + /// Constructor. + /** + \param n Dimension of the point -- \b IN --\b optional (default = 0). + \param d Initial value for all coordinates + -- \b IN -- \b optional (default = undefined real). + */ + explicit Point ( int n = 0 , const NOMAD::Double & d = NOMAD::Double() ); + + /// Copy constructor. + /** + \param p The copied object -- \b IN. + */ + Point ( const Point & p ); + + /// Affectation operator. + /** + \param p The right-hand side object -- \b IN. + \return \c *this as the result of the affectation. + */ + const Point & operator = ( const Point & p ); + + /// Destructor. + virtual ~Point ( void ); + + /// Change the NOMAD::Point dimension. + /** + Sets also all coordinates to d. + \param n New dimension -- \b IN --\b optional (default = 0). + \param d Initial value for all coordinates + -- \b IN -- \b optional (default = undefined real). + */ + void reset ( int n = 0 , const NOMAD::Double & d = NOMAD::Double() ); + + /// Clear the point. + virtual void clear ( void ) { reset(); } + + /// Change the NOMAD::Point dimension. + /** + The values are kept. + \param n New dimension of the point -- \b IN. + */ + void resize ( int n ); + + /// Set a new display limit. + /** + \param dl An integer for the new display limit -- \b IN. + */ + static void set_display_limit ( int dl ) { Point::_display_limit = dl; } + + /// Access to the display limit. + /** + \return The display limit. + */ + static int get_display_limit ( void ) { return Point::_display_limit; } + + /// Const operator \c []. + /** + \param i The index (0 for the first element) -- \b IN. + \return The \c (i+1)th coordinate. + */ + const NOMAD::Double & operator [] ( int i ) const; + + /// Non-const operator \c []. + /** + \param i The index (0 for the first element) -- \b IN. + \return The \c (i+1)th coordinate. + */ + NOMAD::Double & operator [] ( int i ); + + /// Size of the point in memory. + /** + \return An integer for the size of the point in bytes. + */ + virtual int size_of ( void ) const + { + return std::accumulate ( _coords , + _coords+_n , + static_cast<int>(sizeof(_n)) , + size_of_op() ); + } + + /// Access to the dimension of the point. + /** + \return The dimension of the point. + */ + int size ( void ) const { return _n; } + + /// Test if the point is empty (dimension equal to zero). + /** + \return A boolean equal to \c true if the point is empty. + */ + bool empty ( void ) const { return _n==0; } + + /// Set all the coordinates to a specifi value. + /** + \param d The value for all coordinates -- \b IN. + */ + void set ( const NOMAD::Double & d ) const + { + std::fill ( _coords , _coords+_n , d ); + } + + /// Set the coordinates with an array of reals. + /** + \param n Dimension of the point -- \b IN. + \param a Array of size \c n of reals -- \b IN. + */ + void set ( int n , const NOMAD::Double * a ); + + /// Check if all the coordinates are defined. + /** + \return A boolean equal to \c true if all the coordinates are defined. + */ + bool is_complete ( void ) const; + + /// Check if at least one coordinate is defined. + /** + This virtual method is redefined in class NOMAD::Direction. + \return A boolean equal to \c true if at least one coordinate is defined. + */ + virtual bool is_defined ( void ) const; + + /// Count the number of defined values. + /** + \return The number of values that are defined. + */ + int nb_defined ( void ) const; + + /// Squared norm of the point. + /** + \return A NOMAD::Double with the squared norm of the point. + */ + const NOMAD::Double squared_norm ( void ) const + { + return std::accumulate ( _coords , + _coords+_n , + NOMAD::Double(0.0) , + squared_norm_op() ); + } + + /// Norm of the point. + /** + \return A NOMAD::Double with the norm of the point. + */ + const NOMAD::Double norm ( void ) const { return squared_norm().sqrt(); } + + /// Dot product with another point \c x. + /** + \param x The other point \c x -- \b IN. + \return The dot product \c *this \c . \c x. + */ + const NOMAD::Double dot_product ( const Point & x ) const + { + return std::inner_product ( _coords , _coords+_n , x._coords , NOMAD::Double(0.0) ); + } + + /// Angle with another point \c x. + /** + \param x The other point \c x -- \b IN. + \return The angle between \c *this and \c x. + */ + const NOMAD::Double get_angle ( const Point & x ) const; + + /// Mutiplication with a scalar. + /** + - This implements \c *this \c = \c d \c * \c *this. + - The current object \c *this is modified. + \param d The scalar -- \b IN. + \return The point times \c d. + */ + const Point & operator *= ( const NOMAD::Double & d ); + + /// Multiplication with another point. + /** + - The multiplication is done coordinate by coordinate. + - The current object \c *this is not modified. + \param p The other point -- \b IN. + \return A third point equal to \c *this \c .* \c p. + */ + const Point operator * ( const Point & p ) const; + + /// Division with another point. + /** + - The division is done coordinate by coordinate. + - The current object \c *this is not modified. + \param p The other point -- \b IN. + \return A third point equal to \c *this \c ./ \c p. + */ + const Point operator / ( const Point & p ) const; + + /// Addition with another point. + /** + The current object \c *this is not modified. + \param p The other point -- \b IN. + \return A third point equal to \c *this \c + \c p. + */ + const Point operator + ( const Point & p ) const; + + /// Substraction with another point. + /** + The current object \c *this is not modified. + \param p The other point -- \b IN. + \return A third point equal to \c *this \c - \c p. + */ + const Point operator - ( const Point & p ) const; + + /// Negation. + /** + The current object \c *this is not modified. + \return A new point equal to \c -*this. + */ + const Point operator - ( void ) const; + + /// Comparison operator \c <. + /** + \param p The right-hand side object -- \b IN. + \return A boolean equal to \c true if \c *this \c < \c p. + */ + virtual bool operator < ( const Point & p ) const; + + + /// Comparison operator \c ==. + /** + \param p The right-hand side object -- \b IN. + \return A boolean equal to \c true if \c *this \c == \c p. + */ + bool operator == ( const Point & p ) const; + + /// Comparison operator \c !=. + /** + \param p The right-hand side object -- \b IN. + \return A boolean equal to \c true if \c *this \c != \c p. + */ + bool operator != ( const Point & p ) const { return !(*this == p); } + + /// The same as operator \c < but with consideration of undefined values. + /** + \param p The right-hand side object -- \b IN. + \return A boolean equal to \c true if \c *this \c < \c p. + */ + bool comp_with_undef ( const Point & p ) const; + + /// Projection to the mesh. + /** + Projection to the mesh of size delta + ( \c *this \c = \c ref \c + \c k \c * \c delta ). + \param ref Reference for projection -- \b IN. + \param delta Mesh size parameter -- \b IN. + \param lb Lower bound -- \b IN -- \b optional + (default = undefined NOMAD::Point). + \param ub Upper bound -- \b IN -- \b optional + (default = undefined NOMAD::Point). + */ + void project_to_mesh ( const Point & ref , + const Point & delta , + const Point & lb = Point() , + const Point & ub = Point() ); + + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + \param sep A string that is used as a separator between the coordinates + -- \b IN --\b optional (default = one space). + \param w An integer indicating a width for the display of + each coordinate -- \b IN -- \b optional + (default = -1, no limit). + \param lim Max number of coordinates to display -- \b IN + -- \b optional (default = -1, no limit). + */ + virtual void display ( const NOMAD::Display & out , + const std::string & sep = " " , + int w = -1 , + int lim = -1 ) const; + + + /// Set the coordinate j with a specific value. + /** + \param j Coordinate to be set -- \b IN. + \param v Value to put in jth coordinate -- \b IN. + */ + void set_coord ( int j , const NOMAD::Double v ); + + /// get i^th coordinate of the point. + /** + \param i The index of the coordinate -- \b IN. + \return The coordinate \c i of the point. + */ + const NOMAD::Double get_coord ( int i ) const; + + + + }; - /// Constructor. - /** - \param n Dimension of the point -- \b IN --\b optional (default = 0). - \param d Initial value for all coordinates - -- \b IN -- \b optional (default = undefined real). - */ - explicit Point ( int n = 0 , const NOMAD::Double & d = NOMAD::Double() ); - - /// Copy constructor. - /** - \param p The copied object -- \b IN. - */ - Point ( const Point & p ); - - /// Affectation operator. - /** - \param p The right-hand side object -- \b IN. - \return \c *this as the result of the affectation. - */ - const Point & operator = ( const Point & p ); - - /// Destructor. - virtual ~Point ( void ); - - /// Change the NOMAD::Point dimension. - /** - Sets also all coordinates to d. - \param n New dimension -- \b IN --\b optional (default = 0). - \param d Initial value for all coordinates - -- \b IN -- \b optional (default = undefined real). - */ - void reset ( int n = 0 , const NOMAD::Double & d = NOMAD::Double() ); - - /// Clear the point. - virtual void clear ( void ) { reset(); } - - /// Change the NOMAD::Point dimension. - /** - The values are kept. - \param n New dimension of the point -- \b IN. - */ - void resize ( int n ); - - /// Set a new display limit. - /** - \param dl An integer for the new display limit -- \b IN. - */ - static void set_display_limit ( int dl ) { Point::_display_limit = dl; } - - /// Access to the display limit. - /** - \return The display limit. - */ - static int get_display_limit ( void ) { return Point::_display_limit; } - - /// Const operator \c []. - /** - \param i The index (0 for the first element) -- \b IN. - \return The \c (i+1)th coordinate. - */ - const NOMAD::Double & operator [] ( int i ) const; - - /// Non-const operator \c []. - /** - \param i The index (0 for the first element) -- \b IN. - \return The \c (i+1)th coordinate. - */ - NOMAD::Double & operator [] ( int i ); - - /// Size of the point in memory. - /** - \return An integer for the size of the point in bytes. - */ - virtual int size_of ( void ) const - { - return std::accumulate ( _coords , - _coords+_n , - static_cast<int>(sizeof(_n)) , - size_of_op() ); - } - - /// Access to the dimension of the point. - /** - \return The dimension of the point. - */ - int size ( void ) const { return _n; } - - /// Test if the point is empty (dimension equal to zero). - /** - \return A boolean equal to \c true if the point is empty. - */ - bool empty ( void ) const { return _n==0; } - - /// Set all the coordinates to a specifi value. - /** - \param d The value for all coordinates -- \b IN. - */ - void set ( const NOMAD::Double & d ) const - { std::fill ( _coords , _coords+_n , d ); } - - /// Set the coordinates with an array of reals. - /** - \param n Dimension of the point -- \b IN. - \param a Array of size \c n of reals -- \b IN. - */ - void set ( int n , const NOMAD::Double * a ); - - /// Check if all the coordinates are defined. - /** - \return A boolean equal to \c true if all the coordinates are defined. - */ - bool is_complete ( void ) const; - - /// Check if at least one coordinate is defined. - /** - This virtual method is redefined in class NOMAD::Direction. - \return A boolean equal to \c true if at least one coordinate is defined. - */ - virtual bool is_defined ( void ) const; + /*---------------------------------------------------------------------------*/ - /// Count the number of defined values. - /** - \return The number of values that are defined. - */ - int nb_defined ( void ) const; - - /// Squared norm of the point. + /// Display a NOMAD::Point object. /** - \return A NOMAD::Double with the squared norm of the point. - */ - const NOMAD::Double squared_norm ( void ) const + \param out The NOMAD::Display object -- \b IN. + \param p The NOMAD::Point object to be displayed -- \b IN. + \return The NOMAD::Display object. + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::Point & p ) { - return std::accumulate ( _coords , - _coords+_n , - NOMAD::Double(0.0) , - squared_norm_op() ); + p.display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); + return out; } - - /// Norm of the point. - /** - \return A NOMAD::Double with the norm of the point. - */ - const NOMAD::Double norm ( void ) const { return squared_norm().sqrt(); } - - /// Dot product with another point \c x. - /** - \param x The other point \c x -- \b IN. - \return The dot product \c *this \c . \c x. - */ - const NOMAD::Double dot_product ( const Point & x ) const - { return std::inner_product ( _coords , _coords+_n , x._coords , NOMAD::Double(0.0) ); } - - /// Angle with another point \c x. - /** - \param x The other point \c x -- \b IN. - \return The angle between \c *this and \c x. - */ - const NOMAD::Double get_angle ( const Point & x ) const; - - /// Mutiplication with a scalar. - /** - - This implements \c *this \c = \c d \c * \c *this. - - The current object \c *this is modified. - \param d The scalar -- \b IN. - \return The point times \c d. - */ - const Point & operator *= ( const NOMAD::Double & d ); - - /// Multiplication with another point. - /** - - The multiplication is done coordinate by coordinate. - - The current object \c *this is not modified. - \param p The other point -- \b IN. - \return A third point equal to \c *this \c .* \c p. - */ - const Point operator * ( const Point & p ) const; - - /// Division with another point. - /** - - The division is done coordinate by coordinate. - - The current object \c *this is not modified. - \param p The other point -- \b IN. - \return A third point equal to \c *this \c ./ \c p. - */ - const Point operator / ( const Point & p ) const; - - /// Addition with another point. - /** - The current object \c *this is not modified. - \param p The other point -- \b IN. - \return A third point equal to \c *this \c + \c p. - */ - const Point operator + ( const Point & p ) const; - - /// Substraction with another point. - /** - The current object \c *this is not modified. - \param p The other point -- \b IN. - \return A third point equal to \c *this \c - \c p. - */ - const Point operator - ( const Point & p ) const; - - /// Negation. - /** - The current object \c *this is not modified. - \return A new point equal to \c -*this. - */ - const Point operator - ( void ) const; - - /// Comparison operator \c <. - /** - \param p The right-hand side object -- \b IN. - \return A boolean equal to \c true if \c *this \c < \c p. - */ - virtual bool operator < ( const Point & p ) const; - - - /// Comparison operator \c ==. - /** - \param p The right-hand side object -- \b IN. - \return A boolean equal to \c true if \c *this \c == \c p. - */ - bool operator == ( const Point & p ) const; - - /// Comparison operator \c !=. - /** - \param p The right-hand side object -- \b IN. - \return A boolean equal to \c true if \c *this \c != \c p. - */ - bool operator != ( const Point & p ) const { return !(*this == p); } - /// The same as operator \c < but with consideration of undefined values. - /** - \param p The right-hand side object -- \b IN. - \return A boolean equal to \c true if \c *this \c < \c p. - */ - bool comp_with_undef ( const Point & p ) const; - - /// Projection to the mesh. - /** - Projection to the mesh of size delta - ( \c *this \c = \c ref \c + \c k \c * \c delta ). - \param ref Reference for projection -- \b IN. - \param delta Mesh size parameter -- \b IN. - \param lb Lower bound -- \b IN -- \b optional - (default = undefined NOMAD::Point). - \param ub Upper bound -- \b IN -- \b optional - (default = undefined NOMAD::Point). - */ - void project_to_mesh ( const Point & ref , - const Point & delta , - const Point & lb = Point() , - const Point & ub = Point() ); - - /// Display. + /// Input. /** - \param out The NOMAD::Display object -- \b IN. - \param sep A string that is used as a separator between the coordinates - -- \b IN --\b optional (default = one space). - \param w An integer indicating a width for the display of - each coordinate -- \b IN -- \b optional - (default = -1, no limit). - \param lim Max number of coordinates to display -- \b IN - -- \b optional (default = -1, no limit). - */ - virtual void display ( const NOMAD::Display & out , - const std::string & sep = " " , - int w = -1 , - int lim = -1 ) const; - - }; - - /*---------------------------------------------------------------------------*/ - - /// Display a NOMAD::Point object. - /** - \param out The NOMAD::Display object -- \b IN. - \param p The NOMAD::Point object to be displayed -- \b IN. - \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Point & p ) { - p.display ( out , " " , 2 , NOMAD::Point::get_display_limit() ); - return out; - } - - /// Input. - /** - Allows the input of NOMAD::Double objects with operator \c >>. - Can read undefined coordinates (parameter \c UNDEF_STR with default \c "-".) - Example: @@ -457,8 +488,8 @@ namespace NOMAD { \param in A \c std::istream object (can be a file) -- \b IN/OUT. \param p The NOMAD::Point object to be read -- \b OUT. \return The modified \c std::istream object. - */ - std::istream & operator >> ( std::istream & in , Point & p ); + */ + std::istream & operator >> ( std::istream & in , Point & p ); } #endif diff --git a/src/Priority_Eval_Point.cpp b/src/Priority_Eval_Point.cpp index f5059e46854dfc75687aac0ee1d4fdf88d1e608a..014a0bf237c285462b498a44de2588c3fb45cc76 100644 --- a/src/Priority_Eval_Point.cpp +++ b/src/Priority_Eval_Point.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Priority_Eval_Point.cpp - \brief Evaluation point with a priority (implementation) - \author Sebastien Le Digabel - \date 2010-04-22 - \see Priority_Eval_Point.hpp -*/ + \file Priority_Eval_Point.cpp + \brief Evaluation point with a priority (implementation) + \author Sebastien Le Digabel + \date 2010-04-22 + \see Priority_Eval_Point.hpp + */ #include "Priority_Eval_Point.hpp" bool NOMAD::Priority_Eval_Point::_lexicographic_order=false; @@ -51,130 +58,128 @@ bool NOMAD::Priority_Eval_Point::_lexicographic_order=false; /* be evaluated before x2 */ /* . x is a Priority_Eval_Point */ /*------------------------------------------------*/ -bool NOMAD::Priority_Eval_Point::dominates -( const NOMAD::Set_Element<NOMAD::Eval_Point> & x ) const +bool NOMAD::Priority_Eval_Point::dominates ( const NOMAD::Set_Element<NOMAD::Eval_Point> & x ) const { - if ( this == &x ) - return false; - const NOMAD::Eval_Point * x1 = get_element(); - const NOMAD::Eval_Point * x2 = x.get_element(); - - // criterion 0: lexicographic order - if (_lexicographic_order) - return NOMAD::Point(*x1) < NOMAD::Point(*x2); - - - // criterion 1: user criterion: - // ------------ - const NOMAD::Double uep1 = x1->get_user_eval_priority(); - if ( uep1.is_defined() ) - { - const NOMAD::Double uep2 = x2->get_user_eval_priority(); - if ( uep2.is_defined() ) - { - if ( uep1 > uep2 ) - return true; - if ( uep2 > uep1 ) - return false; + if ( this == &x ) + return false; + const NOMAD::Eval_Point * x1 = get_element(); + const NOMAD::Eval_Point * x2 = x.get_element(); + + // criterion 0: lexicographic order + if (_lexicographic_order) + return NOMAD::Point(*x1) < NOMAD::Point(*x2); + + // criterion 1: user criterion: + // ------------ + const NOMAD::Double uep1 = x1->get_user_eval_priority(); + if ( uep1.is_defined() ) + { + const NOMAD::Double uep2 = x2->get_user_eval_priority(); + if ( uep2.is_defined() ) + { + if ( uep1 > uep2 ) + return true; + if ( uep2 > uep1 ) + return false; + } } - } - - // specific Priority_Eval_Point elements of comparison: - NOMAD::Double x_f_sgte; - NOMAD::Double x_h_sgte; - NOMAD::Double x_f_model; - NOMAD::Double x_h_model; - NOMAD::Double x_angle_success_dir; - NOMAD::Double x_angle_simplex_grad; - - x.get_priority_criteria ( x_f_sgte , - x_h_sgte , - x_f_model , - x_h_model , - x_angle_success_dir , - x_angle_simplex_grad ); - - // criterion 2: give priority to already evaluated cache points: - // ------------ - if ( x1->is_in_cache() && !x2->is_in_cache() ) - return true; - if ( x2->is_in_cache() && !x1->is_in_cache() ) - return false; - - // criterion 3: give priority to already evaluated points - // ------------ that are eval_ok: - if ( x1->is_eval_ok() && !x2->is_eval_ok() ) - return true; - if ( x2->is_eval_ok() && !x1->is_eval_ok() ) - return false; - - // criterion 4: true f and h values: - // ----------- - int flag = compare_hf_values ( x1->get_h() , - x1->get_f() , - x2->get_h() , - x2->get_f() ); - if ( flag ) - return ( flag > 0 ); - - // criterion 5: surrogate f and h values: - // ------------ - flag = compare_hf_values ( _h_sgte , _f_sgte , x_h_sgte , x_f_sgte ); - if ( flag ) - return ( flag > 0 ); - - // criterion 6: model f and h values: - // ------------ - flag = compare_hf_values ( _h_model , _f_model , x_h_model , x_f_model ); - if ( flag ) - return ( flag > 0 ); - - - - // criterion 7: check the angle with the last successful direction: - // ------------ - if ( _angle_success_dir.is_defined() && x_angle_success_dir.is_defined() ) - { - if ( _angle_success_dir < x_angle_success_dir ) - return true; - if ( x_angle_success_dir < _angle_success_dir ) - return false; - } - - - // criterion 8: take the point with the best h value: - // ------------ - flag = compare_h_values ( x1->get_h() , x2->get_h() ); - if ( flag ) - return ( flag > 0 ); - - flag = compare_h_values ( _h_sgte , x_h_sgte ); - if ( flag ) - return ( flag > 0 ); - - flag = compare_h_values ( _h_model , x_h_model ); - if ( flag ) - return ( flag > 0 ); - - // criterion 9: random criterion for randomly generated directions: - // ------------- - const NOMAD::Double rep1 = x1->get_rand_eval_priority(); - if ( rep1.is_defined() ) - { - const NOMAD::Double rep2 = x2->get_rand_eval_priority(); - if ( rep2.is_defined() ) - { - if ( rep1 < rep2 ) - return true; - if ( rep2 < rep1 ) - return false; + + // specific Priority_Eval_Point elements of comparison: + NOMAD::Double x_f_sgte; + NOMAD::Double x_h_sgte; + NOMAD::Double x_f_model; + NOMAD::Double x_h_model; + NOMAD::Double x_angle_success_dir; + NOMAD::Double x_angle_simplex_grad; + + x.get_priority_criteria ( x_f_sgte , + x_h_sgte , + x_f_model , + x_h_model , + x_angle_success_dir , + x_angle_simplex_grad ); + + // criterion 2: give priority to already evaluated cache points: + // ------------ + if ( x1->is_in_cache() && !x2->is_in_cache() ) + return true; + if ( x2->is_in_cache() && !x1->is_in_cache() ) + return false; + + // criterion 3: give priority to already evaluated points + // ------------ that are eval_ok: + if ( x1->is_eval_ok() && !x2->is_eval_ok() ) + return true; + if ( x2->is_eval_ok() && !x1->is_eval_ok() ) + return false; + + // criterion 4: true f and h values: + // ----------- + int flag = compare_hf_values ( x1->get_h() , + x1->get_f() , + x2->get_h() , + x2->get_f() ); + if ( flag ) + return ( flag > 0 ); + + // criterion 5: surrogate f and h values: + // ------------ + flag = compare_hf_values ( _h_sgte , _f_sgte , x_h_sgte , x_f_sgte ); + if ( flag ) + return ( flag > 0 ); // return (flag < 0); // CTribes dec 17, 2014 --- flag < 0 used for testing ordonnancement negationiste + + // criterion 6: model f and h values: + // ------------ + flag = compare_hf_values ( _h_model , _f_model , x_h_model , x_f_model ); + if ( flag ) + return ( flag > 0 ); + + + + // criterion 7: check the angle with the last successful direction: + // ------------ + if ( _angle_success_dir.is_defined() && x_angle_success_dir.is_defined() ) + { + if ( _angle_success_dir < x_angle_success_dir ) + return true; + if ( x_angle_success_dir < _angle_success_dir ) + return false; } - } - - // criterion 10: compare the tags: - // ------------- - return x1->get_tag() < x2->get_tag(); - + + + // criterion 8: take the point with the best h value: + // ------------ + flag = compare_h_values ( x1->get_h() , x2->get_h() ); + if ( flag ) + return ( flag > 0 ); + + flag = compare_h_values ( _h_sgte , x_h_sgte ); + if ( flag ) + return ( flag > 0 ); + + flag = compare_h_values ( _h_model , x_h_model ); + if ( flag ) + return ( flag > 0 ); + + // criterion 9: random criterion for randomly generated directions: + // ------------- + const NOMAD::Double rep1 = x1->get_rand_eval_priority(); + if ( rep1.is_defined() ) + { + const NOMAD::Double rep2 = x2->get_rand_eval_priority(); + if ( rep2.is_defined() ) + { + if ( rep1 < rep2 ) + return true; + if ( rep2 < rep1 ) + return false; + } + } + + // criterion 10: compare the tags: + // ------------- + return x1->get_tag() < x2->get_tag(); + } /*-----------------------------------------------*/ @@ -187,16 +192,16 @@ bool NOMAD::Priority_Eval_Point::dominates /* . private method */ /*-----------------------------------------------*/ int NOMAD::Priority_Eval_Point::compare_h_values ( const NOMAD::Double & hx1 , - const NOMAD::Double & hx2 ) const + const NOMAD::Double & hx2 ) const { - if ( hx1.is_defined() && hx2.is_defined() ) - { - if ( hx1 < hx2 ) - return 1; - if ( hx2 < hx1 ) - return -1; - } - return 0; + if ( hx1.is_defined() && hx2.is_defined() ) + { + if ( hx1 < hx2 ) + return 1; + if ( hx2 < hx1 ) + return -1; + } + return 0; } /*-----------------------------------------------*/ @@ -210,60 +215,60 @@ int NOMAD::Priority_Eval_Point::compare_h_values ( const NOMAD::Double & hx1 , /* . private method */ /*-----------------------------------------------*/ int NOMAD::Priority_Eval_Point::compare_hf_values ( const NOMAD::Double & hx1 , - const NOMAD::Double & fx1 , - const NOMAD::Double & hx2 , - const NOMAD::Double & fx2 ) const + const NOMAD::Double & fx1 , + const NOMAD::Double & hx2 , + const NOMAD::Double & fx2 ) const { - if ( fx1.is_defined() && fx2.is_defined() ) - { - - if ( hx1.is_defined() && hx2.is_defined() ) - { - // x1 is feasible: - if ( hx1 <= _h_min ) - { - // both points are feasible: - if ( hx2 <= _h_min ) - { - if ( fx1 < fx2 ) - return 1; - if ( fx2 < fx1 ) - return -1; - } - - // x1 feasible and x2 infeasible: - else - return 1; - } - - // x1 is infeasible: - else - { - // x2 is feasible: - if ( hx2 <= _h_min ) - return -1; - - // both points are infeasible: - if ( ( hx1 < hx2 && fx1 < fx2 ) || - ( hx1 == hx2 && fx1 < fx2 ) || - ( hx1 < hx2 && fx1 == fx2 ) ) - return 1; - - if ( ( hx2 < hx1 && fx2 < fx1 ) || - ( hx2 == hx1 && fx2 < fx1 ) || - ( hx2 < hx1 && fx2 == fx1 ) ) - return -1; - } - } - - // we only have f values: - else - { - if ( fx1 < fx2 ) - return 1; - if ( fx2 < fx1 ) - return -1; - } - } - return 0; + if ( fx1.is_defined() && fx2.is_defined() ) + { + + if ( hx1.is_defined() && hx2.is_defined() ) + { + // x1 is feasible: + if ( hx1 <= _h_min ) + { + // both points are feasible: + if ( hx2 <= _h_min ) + { + if ( fx1 < fx2 ) + return 1; + if ( fx2 < fx1 ) + return -1; + } + + // x1 feasible and x2 infeasible: + else + return 1; + } + + // x1 is infeasible: + else + { + // x2 is feasible: + if ( hx2 <= _h_min ) + return -1; + + // both points are infeasible: + if ( ( hx1 < hx2 && fx1 < fx2 ) || + ( hx1 == hx2 && fx1 < fx2 ) || + ( hx1 < hx2 && fx1 == fx2 ) ) + return 1; + + if ( ( hx2 < hx1 && fx2 < fx1 ) || + ( hx2 == hx1 && fx2 < fx1 ) || + ( hx2 < hx1 && fx2 == fx1 ) ) + return -1; + } + } + + // we only have f values: + else + { + if ( fx1 < fx2 ) + return 1; + if ( fx2 < fx1 ) + return -1; + } + } + return 0; } diff --git a/src/Priority_Eval_Point.hpp b/src/Priority_Eval_Point.hpp index e74885d63ede09dc581e901802f3e55c3e72c1dd..0e9861897b06276cf664eed468693f35d3a98322 100644 --- a/src/Priority_Eval_Point.hpp +++ b/src/Priority_Eval_Point.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Priority_Eval_Point.hpp - \brief Evaluation point with a priority (headers) - \author Sebastien Le Digabel - \date 2010-04-22 - \see Priority_Eval_Point.cpp -*/ + \file Priority_Eval_Point.hpp + \brief Evaluation point with a priority (headers) + \author Sebastien Le Digabel + \date 2010-04-22 + \see Priority_Eval_Point.cpp + */ #ifndef __PRIORITY_EVAL_POINT__ #define __PRIORITY_EVAL_POINT__ @@ -47,181 +54,181 @@ #include "Eval_Point.hpp" namespace NOMAD { - - /// Evaluation point with a priority. - class Priority_Eval_Point : public NOMAD::Set_Element<NOMAD::Eval_Point> { - - private: - - NOMAD::Double _h_min; ///< \c h_min value for comparison operator. - NOMAD::Double _f_sgte; ///< Objective surrogate value. - NOMAD::Double _h_sgte; ///< Feasibility surrogate value. - NOMAD::Double _f_model; ///< Objective model value. - NOMAD::Double _h_model; ///< Feasibility model value. - NOMAD::Double _angle_success_dir; ///< Angle with last successful direction. - NOMAD::Double _angle_simplex_grad; ///< Angle with simplex gradient. - static bool _lexicographic_order; ///< Use lexicographic order for comparison - - /// Affectation operator. - /** - \param x The right-hand side object -- \b IN. - */ - Priority_Eval_Point & operator = ( const Priority_Eval_Point & x ); - - /// Compare the \c h values of two points. - /** - The two points to compare are \c x1 and \c x2. - \param hx1 \c h(x1) -- \b IN. - \param hx2 \c h(x2) -- \b IN. - \return \c h(x1) \c < \c h(x2) - with the following format: - - 1: \c x1 best than \c x2. - - -1: \c x2 best than \c x1. - - 0: undetermined. - */ - int compare_h_values ( const NOMAD::Double & hx1 , - const NOMAD::Double & hx2 ) const; - - /// Compare the \c h and \c f values of two points. - /** - The two points to compare are \c x1 and \c x2. - \param hx1 \c h(x1) -- \b IN. - \param fx1 \c f(x1) -- \b IN. - \param hx2 \c h(x2) -- \b IN. - \param fx2 \c f(x2) -- \b IN. - \return \c (h(x1),f(x1)) \c < \c (h(x2),f(x2)) - with the following format: - - 1: \c x1 best than \c x2. - - -1: \c x2 best than \c x1. - - 0: undetermined. - */ - int compare_hf_values ( const NOMAD::Double & hx1 , - const NOMAD::Double & fx1 , - const NOMAD::Double & hx2 , - const NOMAD::Double & fx2 ) const; - public: - - /// Constructor. - /** - \param x A pointer to the evaluation point -- \b IN. - \param h_min \c h_min value -- \b IN. - */ - explicit Priority_Eval_Point ( const NOMAD::Eval_Point * x , - const NOMAD::Double & h_min ) - : NOMAD::Set_Element<NOMAD::Eval_Point> ( x ) , - _h_min ( h_min ) {} - - /// Copy constructor. - /** - \param pep The copied object -- \b IN. - */ - explicit Priority_Eval_Point ( const Priority_Eval_Point & pep ) - : NOMAD::Set_Element<NOMAD::Eval_Point> ( pep.get_element() ) , - _h_min ( pep._h_min ) , - _f_sgte ( pep._f_sgte ) , - _h_sgte ( pep._h_sgte ) , - _f_model ( pep._f_model ) , - _h_model ( pep._h_model ) , - _angle_success_dir ( pep._angle_success_dir ) , - _angle_simplex_grad ( pep._angle_simplex_grad ) {} - - /// Destructor. - virtual ~Priority_Eval_Point ( void ) {} - - /// Access to specific elements of comparison. - /** - - This method is defined virtual in NOMAD::Set_Element so that + + /// Evaluation point with a priority. + class Priority_Eval_Point : public NOMAD::Set_Element<NOMAD::Eval_Point> { + + private: + + NOMAD::Double _h_min; ///< \c h_min value for comparison operator. + NOMAD::Double _f_sgte; ///< Objective surrogate value. + NOMAD::Double _h_sgte; ///< Feasibility surrogate value. + NOMAD::Double _f_model; ///< Objective model value. + NOMAD::Double _h_model; ///< Feasibility model value. + NOMAD::Double _angle_success_dir; ///< Angle with last successful direction. + NOMAD::Double _angle_simplex_grad; ///< Angle with simplex gradient. + static bool _lexicographic_order; ///< Use lexicographic order for comparison + + /// Affectation operator. + /** + \param x The right-hand side object -- \b IN. + */ + Priority_Eval_Point & operator = ( const Priority_Eval_Point & x ); + + /// Compare the \c h values of two points. + /** + The two points to compare are \c x1 and \c x2. + \param hx1 \c h(x1) -- \b IN. + \param hx2 \c h(x2) -- \b IN. + \return \c h(x1) \c < \c h(x2) + with the following format: + - 1: \c x1 best than \c x2. + - -1: \c x2 best than \c x1. + - 0: undetermined. + */ + int compare_h_values ( const NOMAD::Double & hx1 , + const NOMAD::Double & hx2 ) const; + + /// Compare the \c h and \c f values of two points. + /** + The two points to compare are \c x1 and \c x2. + \param hx1 \c h(x1) -- \b IN. + \param fx1 \c f(x1) -- \b IN. + \param hx2 \c h(x2) -- \b IN. + \param fx2 \c f(x2) -- \b IN. + \return \c (h(x1),f(x1)) \c < \c (h(x2),f(x2)) + with the following format: + - 1: \c x1 best than \c x2. + - -1: \c x2 best than \c x1. + - 0: undetermined. + */ + int compare_hf_values ( const NOMAD::Double & hx1 , + const NOMAD::Double & fx1 , + const NOMAD::Double & hx2 , + const NOMAD::Double & fx2 ) const; + public: + + /// Constructor. + /** + \param x A pointer to the evaluation point -- \b IN. + \param h_min \c h_min value -- \b IN. + */ + explicit Priority_Eval_Point ( const NOMAD::Eval_Point * x , + const NOMAD::Double & h_min ) + : NOMAD::Set_Element<NOMAD::Eval_Point> ( x ) , + _h_min ( h_min ) {} + + /// Copy constructor. + /** + \param pep The copied object -- \b IN. + */ + explicit Priority_Eval_Point ( const Priority_Eval_Point & pep ) + : NOMAD::Set_Element<NOMAD::Eval_Point> ( pep.get_element() ) , + _h_min ( pep._h_min ) , + _f_sgte ( pep._f_sgte ) , + _h_sgte ( pep._h_sgte ) , + _f_model ( pep._f_model ) , + _h_model ( pep._h_model ) , + _angle_success_dir ( pep._angle_success_dir ) , + _angle_simplex_grad ( pep._angle_simplex_grad ) {} + + /// Destructor. + virtual ~Priority_Eval_Point ( void ) {} + + /// Access to specific elements of comparison. + /** + - This method is defined virtual in NOMAD::Set_Element so that \c operator \c < \c (Set_Element x) can invoke it on \c x (which is in fact a \c Priority_Eval_Point). - - This avoids an expensive downcast in \c operator \c < . - \param f_sgte Objective surrogate value -- \b OUT. - \param h_sgte Feasibility surrogate value -- \b OUT. - \param f_model Objective model value -- \b OUT. - \param h_model Feasibility model value -- \b OUT. - \param angle_success_dir Angle with last successful direction -- \b OUT. - \param angle_simplex_grad Angle with simplex gradient -- \b OUT. - */ - virtual void get_priority_criteria ( NOMAD::Double & f_sgte , - NOMAD::Double & h_sgte , - NOMAD::Double & f_model , - NOMAD::Double & h_model , - NOMAD::Double & angle_success_dir , - NOMAD::Double & angle_simplex_grad ) const - { - f_sgte = _f_sgte; - h_sgte = _h_sgte; - f_model = _f_model; - h_model = _h_model; - angle_success_dir = _angle_success_dir; - angle_simplex_grad = _angle_simplex_grad; - } - - /// Comparison operator. - /** - This virtual function directly call \c dominates(). - \param x The right-hand side object -- \b IN. - \return A boolean equal to \c true if \c *this \c < \c x. - */ - virtual bool operator < ( const NOMAD::Set_Element<NOMAD::Eval_Point> & x ) const - { return dominates ( x ); } - - /// Comparison operator. - /** - \param x The right-hand side object -- \b IN. - \return A boolean equal to \c true if \c *this \c < \c x. - */ - bool dominates ( const NOMAD::Set_Element<NOMAD::Eval_Point> & x ) const; - - /// Access to the evaluation point. - /** - \return A pointer to the evaluation point. - */ - const NOMAD::Eval_Point * get_point ( void ) const { return get_element(); } - - /// Set the angle with last successful direction. - /** - \param a The angle with last successful direction -- \b IN. - */ - void set_angle_success_dir ( const NOMAD::Double & a ) { _angle_success_dir = a; } - - /// Set the angle with simplex gradient . - /** - \param a The angle with simplex gradient -- \b IN. - */ - void set_angle_simplex_grad ( const NOMAD::Double & a ) { _angle_simplex_grad = a; } - - - /// Set the objective surrogate value. - /** - \param f The objective surrogate value -- \b IN. - */ - void set_f_sgte ( const NOMAD::Double & f ) { _f_sgte = f; } - - /// Set the feasibility surrogate value. - /** - \param h The feasibility surrogate value -- \b IN. - */ - void set_h_sgte ( const NOMAD::Double & h ) { _h_sgte = h; } - - /// Set the objective model value. - /** - \param f The objective model value -- \b IN. - */ - void set_f_model ( const NOMAD::Double & f ) { _f_model = f; } - - /// Set the feasibility model value. - /** - \param h The feasibility model value -- \b IN. - */ - void set_h_model ( const NOMAD::Double & h ) { _h_model = h; } - - /// Set the lexicographic order for sorting. - /** - */ - static void set_lexicographic_order ( bool order ) { _lexicographic_order = order; } - - - }; + - This avoids an expensive downcast in \c operator \c < . + \param f_sgte Objective surrogate value -- \b OUT. + \param h_sgte Feasibility surrogate value -- \b OUT. + \param f_model Objective model value -- \b OUT. + \param h_model Feasibility model value -- \b OUT. + \param angle_success_dir Angle with last successful direction -- \b OUT. + \param angle_simplex_grad Angle with simplex gradient -- \b OUT. + */ + virtual void get_priority_criteria ( NOMAD::Double & f_sgte , + NOMAD::Double & h_sgte , + NOMAD::Double & f_model , + NOMAD::Double & h_model , + NOMAD::Double & angle_success_dir , + NOMAD::Double & angle_simplex_grad ) const + { + f_sgte = _f_sgte; + h_sgte = _h_sgte; + f_model = _f_model; + h_model = _h_model; + angle_success_dir = _angle_success_dir; + angle_simplex_grad = _angle_simplex_grad; + } + + /// Comparison operator. + /** + This virtual function directly call \c dominates(). + \param x The right-hand side object -- \b IN. + \return A boolean equal to \c true if \c *this \c < \c x. + */ + virtual bool operator < ( const NOMAD::Set_Element<NOMAD::Eval_Point> & x ) const + { return dominates ( x ); } + + /// Comparison operator. + /** + \param x The right-hand side object -- \b IN. + \return A boolean equal to \c true if \c *this \c < \c x. + */ + bool dominates ( const NOMAD::Set_Element<NOMAD::Eval_Point> & x ) const; + + /// Access to the evaluation point. + /** + \return A pointer to the evaluation point. + */ + const NOMAD::Eval_Point * get_point ( void ) const { return get_element(); } + + /// Set the angle with last successful direction. + /** + \param a The angle with last successful direction -- \b IN. + */ + void set_angle_success_dir ( const NOMAD::Double & a ) { _angle_success_dir = a; } + + /// Set the angle with simplex gradient . + /** + \param a The angle with simplex gradient -- \b IN. + */ + void set_angle_simplex_grad ( const NOMAD::Double & a ) { _angle_simplex_grad = a; } + + + /// Set the objective surrogate value. + /** + \param f The objective surrogate value -- \b IN. + */ + void set_f_sgte ( const NOMAD::Double & f ) { _f_sgte = f; } + + /// Set the feasibility surrogate value. + /** + \param h The feasibility surrogate value -- \b IN. + */ + void set_h_sgte ( const NOMAD::Double & h ) { _h_sgte = h; } + + /// Set the objective model value. + /** + \param f The objective model value -- \b IN. + */ + void set_f_model ( const NOMAD::Double & f ) { _f_model = f; } + + /// Set the feasibility model value. + /** + \param h The feasibility model value -- \b IN. + */ + void set_h_model ( const NOMAD::Double & h ) { _h_model = h; } + + /// Set the lexicographic order for sorting. + /** + */ + static void set_lexicographic_order ( bool order ) { _lexicographic_order = order; } + + + }; } #endif diff --git a/src/Quad_Model.cpp b/src/Quad_Model.cpp index 0bb28ef25bea86e82bf6117398d0adc9335945ff..1650b8ec1740cb6f74340af35cad29177fe3e034 100644 --- a/src/Quad_Model.cpp +++ b/src/Quad_Model.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -45,12 +52,11 @@ /*-----------------------------------------------------------*/ /* constructor */ /*-----------------------------------------------------------*/ -NOMAD::Quad_Model::Quad_Model -( const NOMAD::Display & out , - const std::vector<NOMAD::bb_output_type> & bbot , - const NOMAD::Cache & cache , - const NOMAD::Signature & signature ) -: _out ( out ) , +NOMAD::Quad_Model::Quad_Model ( const NOMAD::Display & out , + const std::vector<NOMAD::bb_output_type> & bbot , + const NOMAD::Cache & cache , + const NOMAD::Signature & signature ) +: _out ( out ) , _bbot ( bbot ) , _interpolation_type ( NOMAD::UNDEFINED_INTERPOLATION_TYPE ) , _n ( signature.get_n() ) , @@ -165,7 +171,8 @@ void NOMAD::Quad_Model::init_alpha ( void ) /* check evaluation point outputs before the integration */ /* into an interpolation set (private) */ /*---------------------------------------------------------*/ -bool NOMAD::Quad_Model::check_outputs ( const NOMAD::Point & bbo , int m ) const { +bool NOMAD::Quad_Model::check_outputs ( const NOMAD::Point & bbo , int m ) const +{ if ( bbo.size() != m ) return false; @@ -259,7 +266,8 @@ void NOMAD::Quad_Model::reduce_Y ( const NOMAD::Point & center , _Y.clear(); std::multiset<NOMAD::Model_Sorted_Point>::const_iterator it , end = Ys.end(); - for ( it = Ys.begin() ; it != end ; ++it ) { + for ( it = Ys.begin() ; it != end ; ++it ) + { if ( get_nY() < max_Y_size ) _Y.push_back ( static_cast<NOMAD::Eval_Point *> ( it->get_point() ) ); else @@ -310,7 +318,8 @@ bool NOMAD::Quad_Model::is_within_trust_radius ( const NOMAD::Point & x ) const /*--------------------------------------------------------------*/ void NOMAD::Quad_Model::define_scaling ( const NOMAD::Double & r ) { - if ( _error_flag || _Y.empty() ) { + if ( _error_flag || _Y.empty() ) + { _error_flag = true; return; } @@ -371,9 +380,11 @@ void NOMAD::Quad_Model::define_scaling ( const NOMAD::Double & r ) #endif // compute the scaling (and detect fixed variables): - for ( k = 0 ; k < nY ; ++k ) { + for ( k = 0 ; k < nY ; ++k ) + { - for ( i = 0 ; i < _n ; ++i ) { + for ( i = 0 ; i < _n ; ++i ) + { tmp = ( (*_Y[k])[i] - _ref[i] ).abs(); if ( !_scaling[i].is_defined() || _scaling[i] < tmp ) _scaling[i] = tmp; @@ -429,9 +440,12 @@ void NOMAD::Quad_Model::define_scaling ( const NOMAD::Double & r ) /* LeDigabel, Tribes, 2014 */ /* . looks also for fixed variables */ /*-------------------------------------------------------------------*/ -void NOMAD::Quad_Model::define_scaling_by_directions ( const std::list<NOMAD::Direction> & dirs, const NOMAD::Point & delta_m, const NOMAD::Double & epsilon ) +void NOMAD::Quad_Model::define_scaling_by_directions ( const std::list<NOMAD::Direction> & dirs, + const NOMAD::Point & delta_m, + const NOMAD::Double & epsilon ) { - if ( _error_flag || _Y.empty() ) { + if ( _error_flag || _Y.empty() ) + { _error_flag = true; return; } @@ -671,7 +685,7 @@ bool NOMAD::Quad_Model::unscale ( NOMAD::Point & x ) const } /*-----------------------------------------------------------*/ -/* unscale the slope at a point */ +/* unscale the slope at a point */ /*-----------------------------------------------------------*/ bool NOMAD::Quad_Model::unscale_grad ( NOMAD::Point & x ) const { @@ -694,7 +708,8 @@ bool NOMAD::Quad_Model::unscale_grad ( NOMAD::Point & x ) const /* compute the element (i,j) of the interpolation matrix M(phi,Y) */ /* (private) */ /*------------------------------------------------------------------*/ -double NOMAD::Quad_Model::compute_M ( int i , int j ) const { +double NOMAD::Quad_Model::compute_M ( int i , int j ) const +{ if ( _error_flag ) return 0.0; @@ -716,7 +731,8 @@ double NOMAD::Quad_Model::compute_M ( int i , int j ) const { r = jm2n; i1 = -1; - while ( r > 0 ) { + while ( r > 0 ) + { r -= dec; ++i1; --dec; @@ -742,22 +758,27 @@ void NOMAD::Quad_Model::construct ( bool use_WP , // MFN interpolation: - if ( p1 < _n_alpha ) { + if ( p1 < _n_alpha ) + { _interpolation_type = NOMAD::MFN; _error_flag = !construct_MFN_model ( eps , max_mpn , max_Y_size ); } - else { + else + { + _error_flag = true; // well-poised regression: - if ( use_WP && p1 > _n_alpha ) { + if ( use_WP && p1 > _n_alpha ) + { _interpolation_type = NOMAD::WP_REGRESSION; _error_flag = !construct_WP_model ( max_Y_size ); } // regression: - if ( _error_flag ) { + if ( _error_flag ) + { _interpolation_type = NOMAD::REGRESSION; _error_flag = !construct_regression_model ( eps , max_mpn , max_Y_size ); } @@ -771,21 +792,23 @@ void NOMAD::Quad_Model::construct ( bool use_WP , /* . used in construct_WP_model() */ /* . private */ /*---------------------------------------------------------------*/ -int NOMAD::Quad_Model::find_max_lix -( const NOMAD::Point & li , - const std::vector<NOMAD::Eval_Point *> & Y , - int i1 , - int i2 , - NOMAD::Double & max_lix ) const +int NOMAD::Quad_Model::find_max_lix ( const NOMAD::Point & li , + const std::vector<NOMAD::Eval_Point *> & Y , + int i1 , + int i2 , + NOMAD::Double & max_lix ) const { max_lix = -1.0; int ji = -1; NOMAD::Double tmp; - for ( int j = i1 ; j <= i2 ; ++j ) { + for ( int j = i1 ; j <= i2 ; ++j ) + { tmp = eval ( *Y[j] , li ); - if ( tmp.is_defined() ) { + if ( tmp.is_defined() ) + { tmp = tmp.abs(); - if ( tmp > max_lix ) { + if ( tmp > max_lix ) + { max_lix = tmp; ji = j; } @@ -814,7 +837,8 @@ bool NOMAD::Quad_Model::construct_WP_model ( int max_Y_size ) int i , j , k , p1 = get_nY(); // the number of points (p+1) must be in [1+(n+1)(n+2)/2;MS_MAX_Y_SIZE]: - if ( p1 <= _n_alpha || p1 > max_Y_size ) { + if ( p1 <= _n_alpha || p1 > max_Y_size ) + { #ifdef DEBUG _out << std::endl << "NOMAD::Quad_Model::construct_WP_model(): " @@ -826,7 +850,8 @@ bool NOMAD::Quad_Model::construct_WP_model ( int max_Y_size ) // Lagrange polynomials: std::vector<NOMAD::Point *> l; - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { l.push_back ( new NOMAD::Point ( _n_alpha ) ); for ( j = 0 ; j < _n_alpha ; ++j ) (*l[i])[j] = (i==j) ? 1.0 : 0.0; @@ -845,16 +870,19 @@ bool NOMAD::Quad_Model::construct_WP_model ( int max_Y_size ) // use algo 6.2 p.95 of the DFO book in order to construct Lagrange polynomials: // ----------------------------------------------------------------------------- - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { // 1. point selection (select a point in Y2: Y2[iy2]): // ------------------- - if ( i > 0 ) { + if ( i > 0 ) + { ny2m1 = static_cast<int>(Y2.size())-1; iy2 = find_max_lix ( *l[i] , Y2 , 0 , ny2m1 , max_lix ); - if ( iy2 < 0 ) { + if ( iy2 < 0 ) + { #ifdef DEBUG _out << std::endl << "NOMAD::Quad_Model::construct_WP_model(): " @@ -876,7 +904,8 @@ bool NOMAD::Quad_Model::construct_WP_model ( int max_Y_size ) // ----------------- liyi = eval ( *Y1[i] , *l[i] ); - if ( liyi.abs().value() < 1e-15 ) { + if ( liyi.abs().value() < 1e-15 ) + { #ifdef DEBUG _out << std::endl << "NOMAD::Quad_Model::construct_WP_model(): set Y is not poised" @@ -887,7 +916,8 @@ bool NOMAD::Quad_Model::construct_WP_model ( int max_Y_size ) return false; } - for ( k = 0 ; k < _n_alpha ; ++k ) { + for ( k = 0 ; k < _n_alpha ; ++k ) + { (*l[i])[k] /= liyi; if ( (*l[i])[k].abs().value() < 1e-15 ) (*l[i])[k] = 0.0; @@ -896,9 +926,11 @@ bool NOMAD::Quad_Model::construct_WP_model ( int max_Y_size ) // 3. orthogonalization: // --------------------- for ( j = 0 ; j < _n_alpha ; ++j ) - if ( j != i ) { + if ( j != i ) + { ljyi = eval ( *Y1[i] , *l[j] ); - for ( k = 0 ; k < _n_alpha ; ++k ) { + for ( k = 0 ; k < _n_alpha ; ++k ) + { (*l[j])[k] = (*l[j])[k] - ljyi * (*l[i])[k]; if ( (*l[j])[k].abs().value() < 1e-15 ) (*l[j])[k] = 0.0; @@ -914,8 +946,10 @@ bool NOMAD::Quad_Model::construct_WP_model ( int max_Y_size ) // -------------- int m = static_cast<int> ( _bbot.size() ); for ( i = 0 ; i < m ; ++i ) - if ( _alpha[i] ) { - for ( j = 0 ; j < _n_alpha ; ++j ) { + if ( _alpha[i] ) + { + for ( j = 0 ; j < _n_alpha ; ++j ) + { (*_alpha[i])[j] = 0.0; for ( k = 0 ; k < _n_alpha ; ++k ) (*_alpha[i])[j] += Y1[k]->get_bb_outputs()[i] * (*l[k])[j]; @@ -935,9 +969,11 @@ bool NOMAD::Quad_Model::construct_WP_model ( int max_Y_size ) NOMAD::Double ljyk , lkyk , lix , new_rel_err , cur_rel_err = compute_max_rel_err(); - if ( cur_rel_err.is_defined() && cur_rel_err.value() > 1e-15 ) { + if ( cur_rel_err.is_defined() && cur_rel_err.value() > 1e-15 ) + { - for ( int niter = 0 ; niter < 10 ; ++niter ) { + for ( int niter = 0 ; niter < 10 ; ++niter ) + { ny2m1 = static_cast<int>(Y2.size())-1; @@ -948,10 +984,12 @@ bool NOMAD::Quad_Model::construct_WP_model ( int max_Y_size ) iy2 = -1; ik = -1; - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { j = find_max_lix ( *l[i] , Y2 , 0 , ny2m1 , lix ); - if ( j >= 0 && lix > max_lix ) { + if ( j >= 0 && lix > max_lix ) + { max_lix = lix; iy2 = j; ik = i; @@ -978,8 +1016,10 @@ bool NOMAD::Quad_Model::construct_WP_model ( int max_Y_size ) for ( i = 0 ; i < _n_alpha ; ++i ) (*l[ik])[i] /= lkyk; - for ( j = 0 ; j < _n_alpha ; ++j ) { - if ( j != ik ) { + for ( j = 0 ; j < _n_alpha ; ++j ) + { + if ( j != ik ) + { ljyk = eval ( *Y1[ik] , *l[j] ); for ( i = 0 ; i < _n_alpha ; ++i ) (*l[j])[i] = (*l[j])[i] - ljyk * (*l[ik])[i]; @@ -988,9 +1028,11 @@ bool NOMAD::Quad_Model::construct_WP_model ( int max_Y_size ) // save old alpha and compute new one: for ( i = 0 ; i < m ; ++i ) - if ( _alpha[i] ) { + if ( _alpha[i] ) + { *(old_alpha[i]) = *(_alpha[i]); - for ( j = 0 ; j < _n_alpha ; ++j ) { + for ( j = 0 ; j < _n_alpha ; ++j ) + { (*_alpha[i])[j] = 0.0; for ( k = 0 ; k < _n_alpha ; ++k ) (*_alpha[i])[j] += Y1[k]->get_bb_outputs()[i] * (*l[k])[j]; @@ -1001,7 +1043,8 @@ bool NOMAD::Quad_Model::construct_WP_model ( int max_Y_size ) new_rel_err = compute_max_rel_err(); // if no better error, restore old alpha and exit loop: - if ( !new_rel_err.is_defined() || new_rel_err >= cur_rel_err ) { + if ( !new_rel_err.is_defined() || new_rel_err >= cur_rel_err ) + { tmp_alpha = _alpha; _alpha = old_alpha; old_alpha = tmp_alpha; @@ -1046,7 +1089,8 @@ bool NOMAD::Quad_Model::construct_regression_model ( double eps , int p1 = get_nY(); // the number of points (p+1) must be in [(n+1)(n+2)/2;MS_MAX_Y_SIZE]: - if ( p1 < _n_alpha || p1 > max_Y_size ) { + if ( p1 < _n_alpha || p1 > max_Y_size ) + { #ifdef DEBUG _out << std::endl << "NOMAD::Quad_Model::construct_regression_model(): " @@ -1059,7 +1103,8 @@ bool NOMAD::Quad_Model::construct_regression_model ( double eps , // for this procedure, the number of points is limited to 500 // (because of the SVD decomposition): - if ( p1 > 500 ) { + if ( p1 > 500 ) + { reduce_Y ( NOMAD::Point ( _n , 0.0 ) , 500 ); p1 = 500; } @@ -1069,15 +1114,18 @@ bool NOMAD::Quad_Model::construct_regression_model ( double eps , int i , j , k; double ** F = new double *[_n_alpha]; double ** M = new double *[p1]; - for ( i = 0 ; i < p1 ; ++i ) { + for ( i = 0 ; i < p1 ; ++i ) + { M[i] = new double[_n_alpha]; for ( j = 0 ; j < _n_alpha ; ++j ) M[i][j] = compute_M ( i , j ); } - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { F[i] = new double[_n_alpha]; - for ( j = 0 ; j <= i ; ++j ) { + for ( j = 0 ; j <= i ; ++j ) + { F[i][j] = 0.0; for ( k = 0 ; k < p1 ; ++k ) F[i][j] += M[k][i] * M[k][j]; @@ -1088,7 +1136,8 @@ bool NOMAD::Quad_Model::construct_regression_model ( double eps , #ifdef DEBUG _out << std::endl << "F="; - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { _out << "\t"; for ( j = 0 ; j < _n_alpha ; ++j ) _out << std::setw(12) << F[i][j] << " "; @@ -1108,14 +1157,16 @@ bool NOMAD::Quad_Model::construct_regression_model ( double eps , V[i] = new double[_n_alpha]; std::string error_msg; - if ( NOMAD::SVD_decomposition ( error_msg , F , W , V , _n_alpha , _n_alpha , max_mpn ) ) { + if ( NOMAD::SVD_decomposition ( error_msg , F , W , V , _n_alpha , _n_alpha , max_mpn ) ) + { // compute condition number: compute_cond ( W , _n_alpha , eps ); #ifdef DEBUG _out << std::endl << "F="; - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { _out << "\t"; for ( j = 0 ; j < _n_alpha ; ++j ) _out << std::setw(12) << F[i][j] << " "; @@ -1128,7 +1179,8 @@ bool NOMAD::Quad_Model::construct_regression_model ( double eps , _out << std::endl << std::endl << "cond=" << _cond << std::endl; _out << std::endl << "V="; - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { _out << "\t"; for ( j = 0 ; j < _n_alpha ; ++j ) _out << std::setw(12) << V[i][j] << " "; @@ -1137,7 +1189,9 @@ bool NOMAD::Quad_Model::construct_regression_model ( double eps , #endif } - else { + else + { + #ifdef DEBUG _out << std::endl << "NOMAD::Quad_Model::construct_regression_model(): " << "SVD decomposition (" << error_msg << ")" @@ -1149,7 +1203,8 @@ bool NOMAD::Quad_Model::construct_regression_model ( double eps , // resolution of system F.alpha = M'.f(Y): // --------------------------------------- - if ( !error ) { + if ( !error ) + { int m = static_cast<int> ( _bbot.size() ); for ( i = 0 ; i < m ; ++i ) if ( _alpha[i] ) @@ -1157,7 +1212,8 @@ bool NOMAD::Quad_Model::construct_regression_model ( double eps , } // free memory: - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { delete [] F[i]; delete [] V[i]; } @@ -1182,7 +1238,8 @@ void NOMAD::Quad_Model::compute_cond ( const double * W , int n , double eps ) { double min = NOMAD::INF; double max = -min; - for ( int i = 0 ; i < n ; ++i ) { + for ( int i = 0 ; i < n ; ++i ) + { if ( W[i] < min ) min = W[i]; if ( W[i] > max ) @@ -1203,7 +1260,7 @@ void NOMAD::Quad_Model::solve_regression_system ( double ** M , double ** V , int bbo_index , NOMAD::Point & alpha , - double eps ) const + double eps ) const { // resize the alpha vector: if ( alpha.size() != _n_alpha ) @@ -1213,7 +1270,8 @@ void NOMAD::Quad_Model::solve_regression_system ( double ** M , int i , k , p1 = get_nY(); // solve the system: - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { alpha_tmp[i] = 0.0; for ( k = 0 ; k < p1 ; ++k ) alpha_tmp[i] += M[k][i] * ( _Y[k]->get_bb_outputs()[bbo_index].value() ); @@ -1224,7 +1282,8 @@ void NOMAD::Quad_Model::solve_regression_system ( double ** M , // some W values will be zero (or near zero); // each value that is smaller than eps is ignored - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { alpha_tmp2[i] = 0.0; for ( k = 0 ; k < _n_alpha ; ++k ) if ( W[i] > eps ) @@ -1233,7 +1292,8 @@ void NOMAD::Quad_Model::solve_regression_system ( double ** M , delete [] alpha_tmp; - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { alpha[i] = 0.0; for ( k = 0 ; k < _n_alpha ; ++k ) alpha[i] += V[i][k] * alpha_tmp2[k]; @@ -1261,7 +1321,8 @@ bool NOMAD::Quad_Model::construct_MFN_model ( double eps , int p1 = get_nY(); // the number of points (p+1) must be in [n+1;(n+1)(n+2)/2-1]: - if ( p1 <= _nfree || p1 >= _n_alpha ) { + if ( p1 <= _nfree || p1 >= _n_alpha ) + { #ifdef DEBUG _out << std::endl << "NOMAD::Quad_Model::construct_MFN_model(): " @@ -1273,7 +1334,8 @@ bool NOMAD::Quad_Model::construct_MFN_model ( double eps , // for this procedure, the number of points is limited to 250 // (because of the SVD decomposition): - if ( p1 > 250 ) { + if ( p1 > 250 ) + { reduce_Y ( NOMAD::Point ( _n , 0.0 ) , 250 ); p1 = 250; } @@ -1360,7 +1422,8 @@ bool NOMAD::Quad_Model::construct_MFN_model ( double eps , std::string error_msg; - if ( NOMAD::SVD_decomposition ( error_msg , F , W , V , nF , nF , max_mpn ) ) { + if ( NOMAD::SVD_decomposition ( error_msg , F , W , V , nF , nF , max_mpn ) ) + { // compute condition number: compute_cond ( W , nF , eps ); @@ -1433,12 +1496,12 @@ bool NOMAD::Quad_Model::construct_MFN_model ( double eps , /* resolution of system F.[mu alpha_L]'=[f(Y) 0]' */ /* for MFN interpolation (private) */ /*--------------------------------------------------*/ -void NOMAD::Quad_Model::solve_MFN_system ( double ** F , +void NOMAD::Quad_Model::solve_MFN_system ( double ** F , double * W , double ** V , int bbo_index , NOMAD::Point & alpha , - double eps ) const + double eps ) const { // resize the alpha vector: if ( alpha.size() != _n_alpha ) @@ -1536,7 +1599,8 @@ void NOMAD::Quad_Model::solve_MFN_system ( double ** F , /*-----------------------------------------------------------*/ bool NOMAD::Quad_Model::check_Y ( void ) const { - if ( _Y.empty() ) { + if ( _Y.empty() ) + { #ifdef DEBUG _out << std::endl << "NOMAD::Quad_Model::check_Y(): set Y is empty" << std::endl << std::endl; @@ -1547,9 +1611,11 @@ bool NOMAD::Quad_Model::check_Y ( void ) const int nY = get_nY(); int m = static_cast<int> ( _bbot.size() ); - for ( int k = 0 ; k < nY ; ++k ) { + for ( int k = 0 ; k < nY ; ++k ) + { - if ( _Y[k] == NULL ) { + if ( _Y[k] == NULL ) + { #ifdef DEBUG _out << std::endl << "NOMAD::Quad_Model::check_Y(): NULL pointer in the set Y" @@ -1558,7 +1624,8 @@ bool NOMAD::Quad_Model::check_Y ( void ) const return false; } - if ( _Y[k]->get_eval_status() != NOMAD::EVAL_OK ) { + if ( _Y[k]->get_eval_status() != NOMAD::EVAL_OK ) + { #ifdef DEBUG _out << std::endl << "NOMAD::Quad_Model::check_Y(): a point in Y failed to evaluate" @@ -1569,7 +1636,8 @@ bool NOMAD::Quad_Model::check_Y ( void ) const const NOMAD::Point & bbo = _Y[k]->get_bb_outputs(); - if ( !bbo.is_complete() ) { + if ( !bbo.is_complete() ) + { #ifdef DEBUG _out << std::endl << "NOMAD::Quad_Model::check_Y(): some bb outputs in Y are not defined" @@ -1578,7 +1646,8 @@ bool NOMAD::Quad_Model::check_Y ( void ) const return false; } - if ( bbo.size() != m ) { + if ( bbo.size() != m ) + { #ifdef DEBUG _out << std::endl << "NOMAD::Quad_Model::check_Y(): " @@ -1588,7 +1657,8 @@ bool NOMAD::Quad_Model::check_Y ( void ) const return false; } - if ( _Y[k]->size() != _n ) { + if ( _Y[k]->size() != _n ) + { #ifdef DEBUG _out << std::endl << "NOMAD::Quad_Model::check_Y(): " @@ -1680,17 +1750,22 @@ void NOMAD::Quad_Model::eval_hf ( const NOMAD::Point & x , int m = static_cast<int>(_bbot.size()); NOMAD::Double bboi; - for ( int i = 0 ; i < m ; ++i ) { + for ( int i = 0 ; i < m ; ++i ) + { - if ( _alpha[i] ) { + if ( _alpha[i] ) + { bboi = eval ( x , *_alpha[i] ); - if ( bboi.is_defined() ) { + if ( bboi.is_defined() ) + { - if ( _bbot[i] == NOMAD::EB || _bbot[i] == NOMAD::PEB_E ) { + if ( _bbot[i] == NOMAD::EB || _bbot[i] == NOMAD::PEB_E ) + { - if ( bboi > h_min ) { + if ( bboi > h_min ) + { h.clear(); return; } @@ -1698,9 +1773,12 @@ void NOMAD::Quad_Model::eval_hf ( const NOMAD::Point & x , else if ( ( _bbot[i] == NOMAD::FILTER || _bbot[i] == NOMAD::PB || - _bbot[i] == NOMAD::PEB_P ) ) { - if ( bboi > h_min ) { - switch ( h_norm ) { + _bbot[i] == NOMAD::PEB_P ) ) + { + if ( bboi > h_min ) + { + switch ( h_norm ) + { case NOMAD::L1: h += bboi; break; @@ -1737,15 +1815,22 @@ NOMAD::Double NOMAD::Quad_Model::compute_max_rel_err ( void ) const NOMAD::Double truth_value , model_value , rel_err , max_rel_err; int k , nY = get_nY() , m = static_cast<int> ( _bbot.size() ); - for ( int bbo_index = 0 ; bbo_index < m ; ++bbo_index ) { - if ( _alpha[bbo_index] ) { - for ( k = 0 ; k < nY ; ++k ) { - if ( _Y[k] && _Y[k]->get_eval_status() == NOMAD::EVAL_OK ) { + for ( int bbo_index = 0 ; bbo_index < m ; ++bbo_index ) + { + if ( _alpha[bbo_index] ) + { + for ( k = 0 ; k < nY ; ++k ) + { + if ( _Y[k] && _Y[k]->get_eval_status() == NOMAD::EVAL_OK ) + { truth_value = _Y[k]->get_bb_outputs()[bbo_index]; - if ( truth_value.is_defined() ) { + if ( truth_value.is_defined() ) + { model_value = eval ( *_Y[k] , *_alpha[bbo_index] ); - if ( model_value.is_defined() ) { - if ( truth_value.abs() != 0.0 ) { + if ( model_value.is_defined() ) + { + if ( truth_value.abs() != 0.0 ) + { rel_err = (truth_value-model_value).abs() / truth_value.abs(); if ( !max_rel_err.is_defined() || rel_err > max_rel_err ) max_rel_err = rel_err; @@ -1790,7 +1875,7 @@ void NOMAD::Quad_Model::compute_model_error ( int bbo_index , { truth_value = _Y[k]->get_bb_outputs()[bbo_index]; - if ( truth_value.is_defined() ) + if ( truth_value.is_defined() ) { model_value = eval ( *_Y[k] , *_alpha[bbo_index] ); if ( model_value.is_defined() ) @@ -1798,11 +1883,11 @@ void NOMAD::Quad_Model::compute_model_error ( int bbo_index , rel_err.clear(); if ( truth_value.abs() != 0.0 ) rel_err = (truth_value-model_value).abs() / truth_value.abs(); - else + else { if (truth_value.abs()==model_value.abs()) rel_err=0.0; - else + else rel_err=NOMAD::INF; } if ( !max_rel_err.is_defined() || rel_err > max_rel_err ) @@ -1859,7 +1944,8 @@ void NOMAD::Quad_Model::compute_model_error ( int bbo_index , /*-----------------------------------------------------------*/ void NOMAD::Quad_Model::display_model_coeffs ( const NOMAD::Display & out ) const { - if ( _error_flag ) { + if ( _error_flag ) + { out << "model coefficients: could not be constructed" << std::endl; return; } @@ -1867,11 +1953,13 @@ void NOMAD::Quad_Model::display_model_coeffs ( const NOMAD::Display & out ) cons int m = static_cast<int> ( _bbot.size() ); out << NOMAD::open_block ( "model coefficients" ); - for ( int i = 0 ; i < m ; ++i ) { + for ( int i = 0 ; i < m ; ++i ) + { out << "output #"; out.display_int_w ( i , m ); out << ": "; - if ( _alpha[i] ) { + if ( _alpha[i] ) + { out<< "[ "; _alpha[i]->display ( out , " " , 6 ); out << " ]"; @@ -1891,11 +1979,13 @@ void NOMAD::Quad_Model::display_Y ( const NOMAD::Display & out , { out << NOMAD::open_block ( title ); int nY = get_nY(); - for ( int k = 0 ; k < nY ; ++k ) { + for ( int k = 0 ; k < nY ; ++k ) + { out << "#"; out.display_int_w ( k , nY ); out << ": "; - if ( _Y[k] ) { + if ( _Y[k] ) + { out << "( "; _Y[k]->NOMAD::Point::display ( out , " " , 12 ); out << " ) bbo=[ "; @@ -1914,7 +2004,8 @@ void NOMAD::Quad_Model::display_Y ( const NOMAD::Display & out , /*-------------------------------------------------------*/ void NOMAD::Quad_Model::display_Y_error ( const NOMAD::Display & out ) const { - if ( _error_flag ) { + if ( _error_flag ) + { out << "model error on the interpolation set: cannot be computed" << std::endl; return; @@ -1925,8 +2016,10 @@ void NOMAD::Quad_Model::display_Y_error ( const NOMAD::Display & out ) const int m = static_cast<int> ( _bbot.size() ); for ( i = 0 ; i < m ; ++i ) - if ( _alpha[i] ) { - if ( index >= 0 ) { + if ( _alpha[i] ) + { + if ( index >= 0 ) + { index = -1; break; } @@ -1937,7 +2030,8 @@ void NOMAD::Quad_Model::display_Y_error ( const NOMAD::Display & out ) const NOMAD::Double error , min_rel_err , max_rel_err , avg_rel_err; // only one output: - if ( index >= 0 ) { + if ( index >= 0 ) + { compute_model_error ( index , error , min_rel_err , max_rel_err , avg_rel_err ); out << "model errors on the interpolation set: error=" << error << " min_rel_err=" << min_rel_err @@ -1946,7 +2040,9 @@ void NOMAD::Quad_Model::display_Y_error ( const NOMAD::Display & out ) const } // several outputs: - else { + else + { + out.open_block ( "model error on the interpolation set" ); @@ -1959,7 +2055,8 @@ void NOMAD::Quad_Model::display_Y_error ( const NOMAD::Display & out ) const int cnt = 0; for ( i = 0 ; i < m ; ++i ) - if ( _alpha[i] ) { + if ( _alpha[i] ) + { ++cnt; @@ -1994,15 +2091,15 @@ void NOMAD::Quad_Model::display_Y_error ( const NOMAD::Display & out ) const /*-----------------------------------------------*/ /* display Lagrange polynomials (private) */ /*-----------------------------------------------*/ -void NOMAD::Quad_Model::display_lagrange_polynomials -( const std::vector<NOMAD::Point *> & l , - const std::vector<NOMAD::Eval_Point *> & Y ) const +void NOMAD::Quad_Model::display_lagrange_polynomials ( const std::vector<NOMAD::Point *> & l , + const std::vector<NOMAD::Eval_Point *> & Y ) const { int i , j , nY = static_cast<int> ( Y.size() ); // display Lagrange polynomials: _out << std::endl << NOMAD::open_block ( "Lagrange polynomials" ); - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { _out << "l["; _out.display_int_w ( i , _n_alpha ); _out << "] = [ "; @@ -2013,11 +2110,13 @@ void NOMAD::Quad_Model::display_lagrange_polynomials // display current set Y: _out << std::endl << NOMAD::open_block ( "current set Y" ); - for ( i = 0 ; i < nY ; ++i ) { + for ( i = 0 ; i < nY ; ++i ) + { _out << "Y["; _out.display_int_w ( i , nY ); _out << "] = "; - if ( Y[i] ) { + if ( Y[i] ) + { _out << "( "; Y[i]->NOMAD::Point::display ( _out , " " , 6 , -1 ); _out << " )"; @@ -2032,13 +2131,16 @@ void NOMAD::Quad_Model::display_lagrange_polynomials // display l(Y): should be the identity matrix: NOMAD::Double tmp , err = 0.0; _out << std::endl << NOMAD::open_block ( "l(Y)" ); - for ( i = 0 ; i < _n_alpha ; ++i ) { + for ( i = 0 ; i < _n_alpha ; ++i ) + { _out << "l["; _out.display_int_w ( i , _n_alpha ); _out << "]: "; - for ( j = 0 ; j < _n_alpha ; ++j ) { + for ( j = 0 ; j < _n_alpha ; ++j ) + { tmp.clear(); - if ( j < nY && Y[j] ) { + if ( j < nY && Y[j] ) + { tmp = eval ( *Y[j] , *l[i] ); err += (i==j) ? (tmp-1.0).abs() : tmp.abs(); } diff --git a/src/Quad_Model.hpp b/src/Quad_Model.hpp index b9320c7014bf04cd405894fd942ba57177b67c36..da0edf9d90e0618034c659b09dcd04610702b04f 100644 --- a/src/Quad_Model.hpp +++ b/src/Quad_Model.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Quad_Model.hpp - \brief Quadratic regression or MFN interpolation model (headers) - \author Sebastien Le Digabel - \date 2010-08-31 - \see Quad_Model.cpp -*/ + \file Quad_Model.hpp + \brief Quadratic regression or MFN interpolation model (headers) + \author Sebastien Le Digabel + \date 2010-08-31 + \see Quad_Model.cpp + */ #ifndef __QUAD_MODEL__ #define __QUAD_MODEL__ @@ -48,405 +55,405 @@ #include "Evaluator.hpp" namespace NOMAD { - - /// Class for quadratic regression or MFN interpolation model. - class Quad_Model : private NOMAD::Uncopyable { - - /*-------------------------------------------------------------------------*/ - private: - - const NOMAD::Display & _out; ///< Display. - - std::vector<NOMAD::Eval_Point *> _Y; ///< Interpolation points. - - const std::vector<NOMAD::bb_output_type> & _bbot; ///< Blackbox output types. - - NOMAD::interpolation_type _interpolation_type; ///< Interpolation type. - - int _n; ///< Dimension. - int _nfree; ///< Number of free variables. - int _n_alpha; ///< Number of model coefficients. - bool * _fixed_vars; ///< Fixed variables. - int * _index; ///< Var. indexes with fixed var. - NOMAD::Point ** _alpha; ///< Model coefficients. - NOMAD::Point _center; ///< Model center. - NOMAD::Point _ref; ///< Reference for scaling. - NOMAD::Point _scaling; ///< Scaling. - const NOMAD::Cache & _cache; ///< Cache. - const NOMAD::Signature & _signature; ///< Signature. - bool _error_flag; ///< Error flag. - std::list<NOMAD::Direction> _dirP; ///< Directions used for scaling (may be empty) - NOMAD::Point _delta_m; ///< Mesh size used for scaling - NOMAD::Double _epsilon; ///< Offset for direction scaling - - - NOMAD::Double _cond; ///< Condition number. - - /// Initialize alpha (model parameters). - void init_alpha ( void ); - - /// Check if an unscaled point is in \c B(center,radius) for a given radius. - /** - \param x The unscaled point -- \b IN. - \param radius The radius -- \b IN. - \return \c true is \c x is in \c B(center,radius). - */ - bool is_within_radius ( const NOMAD::Point & x , - const NOMAD::Point & radius ) const; - - /// Check the interpolation set \c Y. - /** - \return \c true if the interpolation set is valid. - */ - bool check_Y ( void ) const; - - /// Check outputs before the integration into \c Y. - /** - \param bbo The outputs -- \b IN. - \param m Number of outputs -- \b IN. - return \c true if the \c m outputs are valid. - */ - bool check_outputs ( const NOMAD::Point & bbo , int m ) const; - - /// Reduce the number of interpolation points. - /** - The points are sorted accorded to their distance to the model center. - \param center Center of the model -- \b IN. - \param max_Y_size Max number of interpolation points -- \b IN. - */ - void reduce_Y ( const NOMAD::Point & center , int max_Y_size ); - - /// Compute condition number. - /** - \param W Matrix W given as a vector -- \b IN. - \param n Size of \c W -- \b IN - \param eps Epsilon -- \b IN. - */ - void compute_cond ( const double * W , int n , double eps ); - - /// Compute the cumulated error of a model for one output. - /** - The errors are computed on the interpolation set \c Y. - \param bbo_index Blackbox output index -- \b IN. - \param error Cumulated error -- \b OUT. - \param min_rel_err Min relative error -- \b OUT. - \param max_rel_err Max relative error -- \b OUT. - \param avg_rel_err Average relative error -- \b OUT. - */ - void compute_model_error ( int bbo_index , - NOMAD::Double & error , - NOMAD::Double & min_rel_err , - NOMAD::Double & max_rel_err , - NOMAD::Double & avg_rel_err ) const; - - /// Compute the maximal relative error of a model. - /** - The error is computed for the interpolation set \c Y. - \return The maximal relative error. - */ - NOMAD::Double compute_max_rel_err ( void ) const; - - /// Compute the element \c (i,j) of the interpolation matrix \c M(phi,Y). - /** - \param i Row index -- \b IN. - \param j Column index -- \b IN. - */ - double compute_M ( int i , int j ) const; - - /// Construct Minimum Frobenius Norm (MFN) model. - /** - - This occurs when \c p+1 \c < \c (n+1)(n+2)/2. - \param eps Epsilon -- \b IN. - \param max_mpn Maximum \c m+n value for SVD matrices -- \b IN. - \param max_Y_size Maximum number of elements in \c Y -- \b IN. - \return \c true if the construction succeeded - */ - bool construct_MFN_model ( double eps , int max_mpn , int max_Y_size ); - - /// Construct regression model. - /** - - This occurs when \c p+1 \c >= \c (n+1)(n+2)/2. - \param eps Epsilon -- \b IN. - \param max_mpn Maximum \c m+n value for SVD matrices -- \b IN. - \param max_Y_size Maximum number of elements in \c Y -- \b IN. - \return \c true if the construction succeeded - */ - bool construct_regression_model ( double eps , - int max_mpn , - int max_Y_size ); - - /// Construct well-poised (WP) model. - /** - \param max_Y_size Maximum number of elements in \c Y -- \b IN. - \return \c true if the construction succeeded - */ - bool construct_WP_model ( int max_Y_size ); - - /// Find interpolation point with max Lagrange polynomial value. - /** - \param li Lagrange polynomial -- \b IN. - \param Y Interpolation points candidates -- \b IN. - \param i1 Initial index in \c Y -- \b IN. - \param i2 Final index in \c Y -- \b IN. - \param max_lix Absolute value of the max value -- \b OUT. - \return Index of interpolation point. - */ - int find_max_lix ( const NOMAD::Point & li , - const std::vector<NOMAD::Eval_Point *> & Y , - int i1 , - int i2 , - NOMAD::Double & max_lix ) const; - - /// Resolution of system \c F.[mu alpha_L]'=[f(Y) 0]' for MFN interpolation. - /** - \param U Matrix \c F=U from the SVD decomposition \c U.W.V' -- \b IN. - \param W Matrix \c W from the SVD decomposition \c U.W.V' -- \b IN. - \param V Matrix \c V from the SVD decomposition \c U.W.V' -- \b IN. - \param bbo_index Blackbox output index -- \b IN. - \param alpha Model parameters -- \b IN. - \param eps Epsilon -- \b IN. - */ - void solve_MFN_system ( double ** U , - double * W , - double ** V , - int bbo_index , - NOMAD::Point & alpha , - double eps ) const; - - /// Resolution of system \c F.alpha=M'.f(Y) for the regression. - /** - \param M Matrix \c M -- \b IN. - \param U Matrix \c F=U from the SVD decomposition \c U.W.V' -- \b IN. - \param W Matrix \c W from the SVD decomposition \c U.W.V' -- \b IN. - \param V Matrix \c V from the SVD decomposition \c U.W.V' -- \b IN. - \param bbo_index Blackbox output index -- \b IN. - \param alpha Model parameters -- \b IN. - \param eps Epsilon -- \b IN. - */ - void solve_regression_system ( double ** M , - double ** U , - double * W , - double ** V , - int bbo_index , - NOMAD::Point & alpha , - double eps ) const; - - /// Display Lagrange polynomials. - /** - \param l Lagrange polynomials -- \b IN. - \param Y Interpolation set -- \b IN. - */ - void display_lagrange_polynomials - ( const std::vector<NOMAD::Point *> & l , - const std::vector<NOMAD::Eval_Point *> & Y ) const; - + + /// Class for quadratic regression or MFN interpolation model. + class Quad_Model : private NOMAD::Uncopyable { + + /*-------------------------------------------------------------------------*/ + private: + + const NOMAD::Display & _out; ///< Display. + + std::vector<NOMAD::Eval_Point *> _Y; ///< Interpolation points. + + const std::vector<NOMAD::bb_output_type> & _bbot; ///< Blackbox output types. + + NOMAD::interpolation_type _interpolation_type; ///< Interpolation type. + + int _n; ///< Dimension. + int _nfree; ///< Number of free variables. + int _n_alpha; ///< Number of model coefficients. + bool * _fixed_vars; ///< Fixed variables. + int * _index; ///< Var. indexes with fixed var. + NOMAD::Point ** _alpha; ///< Model coefficients. + NOMAD::Point _center; ///< Model center. + NOMAD::Point _ref; ///< Reference for scaling. + NOMAD::Point _scaling; ///< Scaling. + const NOMAD::Cache & _cache; ///< Cache. + const NOMAD::Signature & _signature; ///< Signature. + bool _error_flag; ///< Error flag. + std::list<NOMAD::Direction> _dirP; ///< Directions used for scaling (may be empty) + NOMAD::Point _delta_m; ///< Mesh size used for scaling + NOMAD::Double _epsilon; ///< Offset for direction scaling + + + NOMAD::Double _cond; ///< Condition number. + + /// Initialize alpha (model parameters). + void init_alpha ( void ); + + /// Check if an unscaled point is in \c B(center,radius) for a given radius. + /** + \param x The unscaled point -- \b IN. + \param radius The radius -- \b IN. + \return \c true is \c x is in \c B(center,radius). + */ + bool is_within_radius ( const NOMAD::Point & x , + const NOMAD::Point & radius ) const; + + /// Check the interpolation set \c Y. + /** + \return \c true if the interpolation set is valid. + */ + bool check_Y ( void ) const; + + /// Check outputs before the integration into \c Y. + /** + \param bbo The outputs -- \b IN. + \param m Number of outputs -- \b IN. + return \c true if the \c m outputs are valid. + */ + bool check_outputs ( const NOMAD::Point & bbo , int m ) const; + + /// Reduce the number of interpolation points. + /** + The points are sorted accorded to their distance to the model center. + \param center Center of the model -- \b IN. + \param max_Y_size Max number of interpolation points -- \b IN. + */ + void reduce_Y ( const NOMAD::Point & center , int max_Y_size ); + + /// Compute condition number. + /** + \param W Matrix W given as a vector -- \b IN. + \param n Size of \c W -- \b IN + \param eps Epsilon -- \b IN. + */ + void compute_cond ( const double * W , int n , double eps ); + + /// Compute the cumulated error of a model for one output. + /** + The errors are computed on the interpolation set \c Y. + \param bbo_index Blackbox output index -- \b IN. + \param error Cumulated error -- \b OUT. + \param min_rel_err Min relative error -- \b OUT. + \param max_rel_err Max relative error -- \b OUT. + \param avg_rel_err Average relative error -- \b OUT. + */ + void compute_model_error ( int bbo_index , + NOMAD::Double & error , + NOMAD::Double & min_rel_err , + NOMAD::Double & max_rel_err , + NOMAD::Double & avg_rel_err ) const; + + /// Compute the maximal relative error of a model. + /** + The error is computed for the interpolation set \c Y. + \return The maximal relative error. + */ + NOMAD::Double compute_max_rel_err ( void ) const; + + /// Compute the element \c (i,j) of the interpolation matrix \c M(phi,Y). + /** + \param i Row index -- \b IN. + \param j Column index -- \b IN. + */ + double compute_M ( int i , int j ) const; + + /// Construct Minimum Frobenius Norm (MFN) model. + /** + - This occurs when \c p+1 \c < \c (n+1)(n+2)/2. + \param eps Epsilon -- \b IN. + \param max_mpn Maximum \c m+n value for SVD matrices -- \b IN. + \param max_Y_size Maximum number of elements in \c Y -- \b IN. + \return \c true if the construction succeeded + */ + bool construct_MFN_model ( double eps , int max_mpn , int max_Y_size ); + + /// Construct regression model. + /** + - This occurs when \c p+1 \c >= \c (n+1)(n+2)/2. + \param eps Epsilon -- \b IN. + \param max_mpn Maximum \c m+n value for SVD matrices -- \b IN. + \param max_Y_size Maximum number of elements in \c Y -- \b IN. + \return \c true if the construction succeeded + */ + bool construct_regression_model ( double eps , + int max_mpn , + int max_Y_size ); + + /// Construct well-poised (WP) model. + /** + \param max_Y_size Maximum number of elements in \c Y -- \b IN. + \return \c true if the construction succeeded + */ + bool construct_WP_model ( int max_Y_size ); + + /// Find interpolation point with max Lagrange polynomial value. + /** + \param li Lagrange polynomial -- \b IN. + \param Y Interpolation points candidates -- \b IN. + \param i1 Initial index in \c Y -- \b IN. + \param i2 Final index in \c Y -- \b IN. + \param max_lix Absolute value of the max value -- \b OUT. + \return Index of interpolation point. + */ + int find_max_lix ( const NOMAD::Point & li , + const std::vector<NOMAD::Eval_Point *> & Y , + int i1 , + int i2 , + NOMAD::Double & max_lix ) const; + + /// Resolution of system \c F.[mu alpha_L]'=[f(Y) 0]' for MFN interpolation. + /** + \param U Matrix \c F=U from the SVD decomposition \c U.W.V' -- \b IN. + \param W Matrix \c W from the SVD decomposition \c U.W.V' -- \b IN. + \param V Matrix \c V from the SVD decomposition \c U.W.V' -- \b IN. + \param bbo_index Blackbox output index -- \b IN. + \param alpha Model parameters -- \b IN. + \param eps Epsilon -- \b IN. + */ + void solve_MFN_system ( double ** U , + double * W , + double ** V , + int bbo_index , + NOMAD::Point & alpha , + double eps ) const; + + /// Resolution of system \c F.alpha=M'.f(Y) for the regression. + /** + \param M Matrix \c M -- \b IN. + \param U Matrix \c F=U from the SVD decomposition \c U.W.V' -- \b IN. + \param W Matrix \c W from the SVD decomposition \c U.W.V' -- \b IN. + \param V Matrix \c V from the SVD decomposition \c U.W.V' -- \b IN. + \param bbo_index Blackbox output index -- \b IN. + \param alpha Model parameters -- \b IN. + \param eps Epsilon -- \b IN. + */ + void solve_regression_system ( double ** M , + double ** U , + double * W , + double ** V , + int bbo_index , + NOMAD::Point & alpha , + double eps ) const; + + /// Display Lagrange polynomials. + /** + \param l Lagrange polynomials -- \b IN. + \param Y Interpolation set -- \b IN. + */ + void display_lagrange_polynomials + ( const std::vector<NOMAD::Point *> & l , + const std::vector<NOMAD::Eval_Point *> & Y ) const; + #ifdef MODEL_STATS - mutable NOMAD::Double _Yw; ///< Width of the interpolation set \c Y. - - public: - - /// Access to the width of the interpolation set \c X (or \c Y). - /** - \return The width of the interpolation set. - */ - const NOMAD::Double & get_Yw ( void ) const { return _Yw; } + mutable NOMAD::Double _Yw; ///< Width of the interpolation set \c Y. + + public: + + /// Access to the width of the interpolation set \c X (or \c Y). + /** + \return The width of the interpolation set. + */ + const NOMAD::Double & get_Yw ( void ) const { return _Yw; } #endif - - /*-------------------------------------------------------------------------*/ - public: - - /// Constructor. - /** - \param out The NOMAD::Display object -- \b IN. - \param bbot Output types -- \b IN. - \param cache Cache -- \b IN. - \param signature Signature -- \b IN. - */ - Quad_Model ( const NOMAD::Display & out , - const std::vector<NOMAD::bb_output_type> & bbot , - const NOMAD::Cache & cache , - const NOMAD::Signature & signature ); - - /// Destructor. - virtual ~Quad_Model ( void ); - - /// Evaluate a model at a given point. - /** - \param x The point -- \b IN. - \param alpha Model parameters -- \b IN. - \return Model value. - */ - NOMAD::Double eval ( const NOMAD::Point & x , - const NOMAD::Point & alpha ) const; - - /// Compute model \c h and \c f values at a point. - /** - \param x The point -- \b IN. - \param h_min Value of \c h_min -- \b IN.. - \param h_norm Norm used to compute \c h -- \b IN.. - \param h Value of \c h -- \b OUT. - \param f Value of \c f -- \b OUT. - */ - void eval_hf ( const NOMAD::Point & x , - const NOMAD::Double & h_min , - NOMAD::hnorm_type h_norm , - NOMAD::Double & h , - NOMAD::Double & f ) const; - - - /// Access to the interpolation type. - /** - \return The interpolation type. - */ - const NOMAD::interpolation_type & get_interpolation_type ( void ) const - { - return _interpolation_type; - } - - /// Access to the center of the model. - /** - \return The center. - */ - const NOMAD::Point & get_center ( void ) const { return _center; } - - /// Access to the dimension. - /** - \return The dimension \c n. - */ - int get_n ( void ) const { return _n; } - - /// Access to the number of free variables. - /** - \return The number of free variables \c n. - */ - int get_nfree ( void ) const { return _nfree; } - - /// Access to the model parameters. - /** - \return The model parameters \c alpha. - */ - NOMAD::Point ** get_alpha ( void ) const { return _alpha; } - - /// Check if the model is ready for evaluations. - /** - \return A boolean equal to \c true if the model is ready. - */ - bool check ( void ) const; - - /// Access to the fixed variables. - /** - \param i Variable index -- \b IN. - \return \c true if variable \c i is fixed. - */ - bool variable_is_fixed ( int i ) const { return _fixed_vars[i]; } - - /// Access to the number of interpolation points. - /** - \return The number of interpolation points \c nY=p+1. - */ - int get_nY ( void ) const { return static_cast<int> ( _Y.size() ); } - - /// Access to the condition number. - /** - \return The condition number. - */ - const NOMAD::Double & get_cond ( void ) const { return _cond; } - - /// Access to the error flag. - /** - \return The error flag. - */ - bool get_error_flag ( void ) const { return _error_flag; } - - /// Construct the interpolation set \c Y. - /** - \param center Model center -- \b IN. - \param interpolation_radius Interpolation radius -- \b IN. - \param max_Y_size Maximum number of elements in \c Y -- \b IN. - */ - void construct_Y ( const NOMAD::Point & center , - const NOMAD::Point & interpolation_radius , - int max_Y_size ); - - /// Construct \c m models (one by output). - /** - \param use_WP Use or not well-poisedness -- \b IN. - \param eps Epsilon -- \b IN. - \param max_mpn Maximum \c m+n value for SVD matrices -- \b IN. - \param max_Y_size Maximum number of elements in \c Y -- \b IN. - */ - void construct ( bool use_WP , - double eps , - int max_mpn , - int max_Y_size ); - - /// Define scaling to put all coordinates centered in \c [-r;r]. - /** - - Looks also for fixed variables. - \param r The \c r parameter corresponds to \c MODEL_RADIUS_FACTOR -- \b IN. - */ - void define_scaling ( const NOMAD::Double & r ); - - /// Define scaling based on directions. See paper: Reducing the number of function evaluations in Mesh Adaptive Direct Search algorithms, Audet, Ianni, LeDigabel, Tribes, 2014 - /** - - Looks also for fixed variables. - \param dirP The \c dirP parameter corresponds to set of directions formin a hyper-cube centered on poll center -- \b IN. - \param delta_m The \c delta_m parameter is the dimension of the mesh -- \b IN. - \param epsilon The \c epsilon parameter is the hyper-cube offset from the poll center -- \b IN. - */ - void define_scaling_by_directions ( const std::list<NOMAD::Direction> & dirP, const NOMAD::Point & delta_m, const NOMAD::Double &epsilon ); - - - /// Scale a point. - /** - \param x The point to scale -- \b IN/OUT. - \return \c true if the scaling worked. - */ - bool scale ( NOMAD::Point & x ) const; - - /// Unscale a point. - /** - \param x The point to unscale -- \b IN/OUT. - \return \c true if the unscaling worked. - */ - bool unscale ( NOMAD::Point & x ) const; - - /// Unscale the gradient at a point. - /** - \param x The grad to unscale -- \b IN/OUT. - \return \c true if the unscaling worked. - */ - bool unscale_grad ( NOMAD::Point & x ) const; - - - /// Check if a caled point is inside the trust radius. - /** - \param x The scaled point -- \b IN. - \return \c true is \c x is in the trust radius. - */ - bool is_within_trust_radius ( const NOMAD::Point & x ) const; - - /// Display the model coefficients. - /** - \param out The NOMAD::Display object -- \b IN. - */ - void display_model_coeffs ( const NOMAD::Display & out ) const; - - /// Display the interpolation set \c Y. - /** - \param out The NOMAD::Display object -- \b IN. - \param title Title of the display block -- \b IN - --\b optional (default="interpolation set Y"). - */ - void display_Y ( const NOMAD::Display & out , - const std::string & title = "interpolation set Y" ) const; - - /// Display cumulated error on the interpolation points. - /** - \param out The NOMAD::Display object -- \b IN. - */ - void display_Y_error ( const NOMAD::Display & out ) const; - }; + + /*-------------------------------------------------------------------------*/ + public: + + /// Constructor. + /** + \param out The NOMAD::Display object -- \b IN. + \param bbot Output types -- \b IN. + \param cache Cache -- \b IN. + \param signature Signature -- \b IN. + */ + Quad_Model ( const NOMAD::Display & out , + const std::vector<NOMAD::bb_output_type> & bbot , + const NOMAD::Cache & cache , + const NOMAD::Signature & signature ); + + /// Destructor. + virtual ~Quad_Model ( void ); + + /// Evaluate a model at a given point. + /** + \param x The point -- \b IN. + \param alpha Model parameters -- \b IN. + \return Model value. + */ + NOMAD::Double eval ( const NOMAD::Point & x , + const NOMAD::Point & alpha ) const; + + /// Compute model \c h and \c f values at a point. + /** + \param x The point -- \b IN. + \param h_min Value of \c h_min -- \b IN.. + \param h_norm Norm used to compute \c h -- \b IN.. + \param h Value of \c h -- \b OUT. + \param f Value of \c f -- \b OUT. + */ + void eval_hf ( const NOMAD::Point & x , + const NOMAD::Double & h_min , + NOMAD::hnorm_type h_norm , + NOMAD::Double & h , + NOMAD::Double & f ) const; + + + /// Access to the interpolation type. + /** + \return The interpolation type. + */ + const NOMAD::interpolation_type & get_interpolation_type ( void ) const + { + return _interpolation_type; + } + + /// Access to the center of the model. + /** + \return The center. + */ + const NOMAD::Point & get_center ( void ) const { return _center; } + + /// Access to the dimension. + /** + \return The dimension \c n. + */ + int get_n ( void ) const { return _n; } + + /// Access to the number of free variables. + /** + \return The number of free variables \c n. + */ + int get_nfree ( void ) const { return _nfree; } + + /// Access to the model parameters. + /** + \return The model parameters \c alpha. + */ + NOMAD::Point ** get_alpha ( void ) const { return _alpha; } + + /// Check if the model is ready for evaluations. + /** + \return A boolean equal to \c true if the model is ready. + */ + bool check ( void ) const; + + /// Access to the fixed variables. + /** + \param i Variable index -- \b IN. + \return \c true if variable \c i is fixed. + */ + bool variable_is_fixed ( int i ) const { return _fixed_vars[i]; } + + /// Access to the number of interpolation points. + /** + \return The number of interpolation points \c nY=p+1. + */ + int get_nY ( void ) const { return static_cast<int> ( _Y.size() ); } + + /// Access to the condition number. + /** + \return The condition number. + */ + const NOMAD::Double & get_cond ( void ) const { return _cond; } + + /// Access to the error flag. + /** + \return The error flag. + */ + bool get_error_flag ( void ) const { return _error_flag; } + + /// Construct the interpolation set \c Y. + /** + \param center Model center -- \b IN. + \param interpolation_radius Interpolation radius -- \b IN. + \param max_Y_size Maximum number of elements in \c Y -- \b IN. + */ + void construct_Y ( const NOMAD::Point & center , + const NOMAD::Point & interpolation_radius , + int max_Y_size ); + + /// Construct \c m models (one by output). + /** + \param use_WP Use or not well-poisedness -- \b IN. + \param eps Epsilon -- \b IN. + \param max_mpn Maximum \c m+n value for SVD matrices -- \b IN. + \param max_Y_size Maximum number of elements in \c Y -- \b IN. + */ + void construct ( bool use_WP , + double eps , + int max_mpn , + int max_Y_size ); + + /// Define scaling to put all coordinates centered in \c [-r;r]. + /** + - Looks also for fixed variables. + \param r The \c r parameter corresponds to \c MODEL_RADIUS_FACTOR -- \b IN. + */ + void define_scaling ( const NOMAD::Double & r ); + + /// Define scaling based on directions. See paper: Reducing the number of function evaluations in Mesh Adaptive Direct Search algorithms, Audet, Ianni, LeDigabel, Tribes, 2014 + /** + - Looks also for fixed variables. + \param dirP The \c dirP parameter corresponds to set of directions formin a hyper-cube centered on poll center -- \b IN. + \param delta_m The \c delta_m parameter is the dimension of the mesh -- \b IN. + \param epsilon The \c epsilon parameter is the hyper-cube offset from the poll center -- \b IN. + */ + void define_scaling_by_directions ( const std::list<NOMAD::Direction> & dirP, const NOMAD::Point & delta_m, const NOMAD::Double &epsilon ); + + + /// Scale a point. + /** + \param x The point to scale -- \b IN/OUT. + \return \c true if the scaling worked. + */ + bool scale ( NOMAD::Point & x ) const; + + /// Unscale a point. + /** + \param x The point to unscale -- \b IN/OUT. + \return \c true if the unscaling worked. + */ + bool unscale ( NOMAD::Point & x ) const; + + /// Unscale the gradient at a point. + /** + \param x The grad to unscale -- \b IN/OUT. + \return \c true if the unscaling worked. + */ + bool unscale_grad ( NOMAD::Point & x ) const; + + + /// Check if a caled point is inside the trust radius. + /** + \param x The scaled point -- \b IN. + \return \c true is \c x is in the trust radius. + */ + bool is_within_trust_radius ( const NOMAD::Point & x ) const; + + /// Display the model coefficients. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display_model_coeffs ( const NOMAD::Display & out ) const; + + /// Display the interpolation set \c Y. + /** + \param out The NOMAD::Display object -- \b IN. + \param title Title of the display block -- \b IN + --\b optional (default="interpolation set Y"). + */ + void display_Y ( const NOMAD::Display & out , + const std::string & title = "interpolation set Y" ) const; + + /// Display cumulated error on the interpolation points. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display_Y_error ( const NOMAD::Display & out ) const; + }; } #endif diff --git a/src/Quad_Model_Evaluator.cpp b/src/Quad_Model_Evaluator.cpp index 7a6d9f804eba12fd970afae49d669583dc64d403..17380313b371039e222e32d0c902d2e3e3ec6185 100644 --- a/src/Quad_Model_Evaluator.cpp +++ b/src/Quad_Model_Evaluator.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,81 +41,79 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Quad_Model_Evaluator.cpp - \brief NOMAD::Evaluator subclass for quadratic model optimization (implementation) - \author Sebastien Le Digabel - \date 2010-08-31 - \see Quad_Mopel_Evaluator.hpp -*/ + \file Quad_Model_Evaluator.cpp + \brief NOMAD::Evaluator subclass for quadratic model optimization (implementation) + \author Sebastien Le Digabel + \date 2010-08-31 + \see Quad_Mopel_Evaluator.hpp + */ #include "Quad_Model_Evaluator.hpp" /*-----------------------------*/ /* constructor */ /*-----------------------------*/ -NOMAD::Quad_Model_Evaluator::Quad_Model_Evaluator -( const NOMAD::Parameters & p , - const NOMAD::Quad_Model & model ) - : - _n ( model.get_n() ) , - _nm1 ( _n-1 ) , - _m ( p.get_bb_nb_outputs() ) , - _x ( NULL ) , - _alpha ( NULL ) , - _model_ready ( model.check() ) +NOMAD::Quad_Model_Evaluator::Quad_Model_Evaluator ( const NOMAD::Parameters & p , + const NOMAD::Quad_Model & model ) : +_n ( model.get_n() ) , +_nm1 ( _n-1 ) , +_m ( p.get_bb_nb_outputs() ) , +_x ( NULL ) , +_alpha ( NULL ) , +_model_ready ( model.check() ) { - if ( _model_ready ) - { - - int i , j , k , k2 , nalpha = (_n+1)*(_n+2)/2 , nfree = model.get_nfree(); - NOMAD::Point ** model_alpha = model.get_alpha(); - - _x = new double [_n]; - _alpha = new double * [_m]; - - for ( int io = 0 ; io < _m ; ++io ) - { - _alpha[io] = NULL; - if ( model_alpha[io] ) - { - _alpha[io] = new double[nalpha]; - _alpha[io][0] = (*model_alpha[io])[0].value(); - - for ( i = 1 ; i < nalpha ; ++i ) - _alpha[io][i] = 0.0; - - k = 0; - - for ( i = 0 ; i < _n ; ++i ) - { - if ( !model.variable_is_fixed(i) ) - { - ++k; - _alpha[io][i+1 ] = (*model_alpha[io])[k ].value(); - _alpha[io][i+1+_n] = (*model_alpha[io])[k+nfree].value(); - } - } - - k += nfree; - k2 = 2*_n; - - for ( i = 0 ; i < _nm1 ; ++i ) - { - if ( !model.variable_is_fixed(i) ) - { - for ( j = i+1 ; j < _n ; ++j ) - { - ++k2; - if ( !model.variable_is_fixed(j) ) - _alpha[io][k2] = (*model_alpha[io])[++k].value(); - } - } - else - for ( j = i+1 ; j < _n ; ++j ) - ++k2; - } - } - } - } + if ( _model_ready ) + { + + int i , j , k , k2 , nalpha = (_n+1)*(_n+2)/2 , nfree = model.get_nfree(); + NOMAD::Point ** model_alpha = model.get_alpha(); + + _x = new double [_n]; + _alpha = new double * [_m]; + + for ( int io = 0 ; io < _m ; ++io ) + { + _alpha[io] = NULL; + if ( model_alpha[io] ) + { + _alpha[io] = new double[nalpha]; + _alpha[io][0] = (*model_alpha[io])[0].value(); + + for ( i = 1 ; i < nalpha ; ++i ) + _alpha[io][i] = 0.0; + + k = 0; + + for ( i = 0 ; i < _n ; ++i ) + { + if ( !model.variable_is_fixed(i) ) + { + ++k; + _alpha[io][i+1 ] = (*model_alpha[io])[k ].value(); + _alpha[io][i+1+_n] = (*model_alpha[io])[k+nfree].value(); + } + } + + k += nfree; + k2 = 2*_n; + + for ( i = 0 ; i < _nm1 ; ++i ) + { + if ( !model.variable_is_fixed(i) ) + { + for ( j = i+1 ; j < _n ; ++j ) + { + ++k2; + if ( !model.variable_is_fixed(j) ) + _alpha[io][k2] = (*model_alpha[io])[++k].value(); + } + } + else + for ( j = i+1 ; j < _n ; ++j ) + ++k2; + } + } + } + } } /*-----------------------------*/ @@ -116,14 +121,14 @@ NOMAD::Quad_Model_Evaluator::Quad_Model_Evaluator /*-----------------------------*/ NOMAD::Quad_Model_Evaluator::~Quad_Model_Evaluator ( void ) { - if ( _model_ready ) - { - for ( int i = 0 ; i < _m ; ++i ) - if ( _alpha[i] ) - delete [] _alpha[i]; - delete [] _alpha; - delete [] _x; - } + if ( _model_ready ) + { + for ( int i = 0 ; i < _m ; ++i ) + if ( _alpha[i] ) + delete [] _alpha[i]; + delete [] _alpha; + delete [] _x; + } } /*------------------------------------------------------------------------*/ @@ -133,51 +138,59 @@ NOMAD::Quad_Model_Evaluator::~Quad_Model_Evaluator ( void ) /* x is in [-1000;1000] and must be scaled to [-1;1] for the evalutation */ /* */ /*------------------------------------------------------------------------*/ -bool NOMAD::Quad_Model_Evaluator::eval_x -( NOMAD::Eval_Point & x , - const NOMAD::Double & h_max , - bool & count_eval ) const +bool NOMAD::Quad_Model_Evaluator::eval_x ( NOMAD::Eval_Point & x , + const NOMAD::Double & h_max , + bool & count_eval ) const { - - count_eval=false; - if ( !_model_ready ) - return false; - - int i , j , k; - double z , * alpha , * p; - - for ( i = 0 ; i < _n ; ++i ) - _x[i] = x[i].value() / 1000.0; - - for ( int oi = 0 ; oi < _m ; ++oi ) - { - - alpha = _alpha[oi]; - - if ( alpha ) - { - - z = alpha[0]; - p = _x; - - for ( k = 1 ; k <= _n ; ++k , ++p ) - z += *p * ( alpha[k] + 0.5 * alpha[k+_n] * *p ); - - k += _n-1; - - for ( i = 0 ; i < _nm1 ; ++i ) - for ( j = i+1 ; j < _n ; ++j ) - z += alpha[++k] * _x[i] * _x[j]; - - x.set_bb_output ( oi , z ); - } - - else - x.set_bb_output ( oi , 0.0 ); - } - - count_eval = true; - return true; + + count_eval=false; + if ( !_model_ready ) + return false; + + int i , j , k; + double z , * alpha , * p; + + for ( i = 0 ; i < _n ; ++i ) + _x[i] = x[i].value() / 1000.0; + + for ( int oi = 0 ; oi < _m ; ++oi ) + { + + alpha = _alpha[oi]; + + if ( alpha ) + { + + z = alpha[0]; + p = _x; + + for ( k = 1 ; k <= _n ; ++k , ++p ) + z += *p * ( alpha[k] + 0.5 * alpha[k+_n] * *p ); + + k += _n-1; + + for ( i = 0 ; i < _nm1 ; ++i ) + for ( j = i+1 ; j < _n ; ++j ) + z += alpha[++k] * _x[i] * _x[j]; + + + // SLD special rounding to 8 decimals in order to improve numerical stability: + // { + // long double prec = 1e-8; + // z = ( z < 0.0 ? + // -floor(-z/prec + .5) : + // floor( z/prec + .5) ) * prec; + // } + + x.set_bb_output ( oi , z ); + } + + else + x.set_bb_output ( oi , 0.0 ); + } + + count_eval = true; + return true; } @@ -188,38 +201,37 @@ bool NOMAD::Quad_Model_Evaluator::eval_x /* x is in [-1000;1000] and must be scaled to [-1;1] for the evalutation */ /* */ /*------------------------------------------------------------------------*/ -bool NOMAD::Quad_Model_Evaluator::evalGrad_x -(const NOMAD::Point & x , - NOMAD::Point & g , - const int & output_index , - bool & count_eval ) const +bool NOMAD::Quad_Model_Evaluator::evalGrad_x ( const NOMAD::Point & x , + NOMAD::Point & g , + const int & output_index , + bool & count_eval ) const { - - if ( !_model_ready ) - return false; - - double * alpha ; - - for (int i = 0 ; i < _n ; ++i ) - _x[i] = x[i].value() / 1000.0; - - alpha = _alpha[output_index]; - - if ( !alpha ) - return false; - - int i , j , k ; - - for ( k = 1 ; k <= _n ; ++k ) - g[k-1] = alpha[k] + alpha[k+_n] * _x[k-1]; - - - k += _n-1; - - for ( i = 0 ; i < _nm1 ; ++i ) - for ( j = i+1 ; j < _n ; ++j ) - g[i] += alpha[++k] * _x[j]; - - count_eval = true; - return true; + + if ( !_model_ready ) + return false; + + double * alpha ; + + for (int i = 0 ; i < _n ; ++i ) + _x[i] = x[i].value() / 1000.0; + + alpha = _alpha[output_index]; + + if ( !alpha ) + return false; + + int i , j , k ; + + for ( k = 1 ; k <= _n ; ++k ) + g[k-1] = alpha[k] + alpha[k+_n] * _x[k-1]; + + + k += _n-1; + + for ( i = 0 ; i < _nm1 ; ++i ) + for ( j = i+1 ; j < _n ; ++j ) + g[i] += alpha[++k] * _x[j]; + + count_eval = true; + return true; } diff --git a/src/Quad_Model_Evaluator.hpp b/src/Quad_Model_Evaluator.hpp index f3780a5e8db66d689ab42d2ed19212aec3757c89..c99ffe0e53181e45fec9e27933f4907f71a26eee 100644 --- a/src/Quad_Model_Evaluator.hpp +++ b/src/Quad_Model_Evaluator.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ diff --git a/src/Quad_Model_Search.cpp b/src/Quad_Model_Search.cpp index ef61c01f882c22f8a15bd2213f0c6a8fed1e2d83..b4560f04015af0df912d8d1af8ce13ff81484129 100644 --- a/src/Quad_Model_Search.cpp +++ b/src/Quad_Model_Search.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -182,6 +189,7 @@ void NOMAD::Quad_Model_Search::search ( NOMAD::Mads & mads // stats: NOMAD::Stats & stats = mads.get_stats(); + // number of interpolation points: int nY[2]; nY[0] = nY[1] = -1; @@ -217,7 +225,8 @@ void NOMAD::Quad_Model_Search::search ( NOMAD::Mads & mads NOMAD::Signature * signature = xk[i_inc]->get_signature(); if ( !signature ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { std::ostringstream oss; oss << "end of " << NOMAD::MODEL_SEARCH << " (no signature)"; out << std::endl << NOMAD::close_block ( oss.str() ) << std::endl; @@ -227,7 +236,7 @@ void NOMAD::Quad_Model_Search::search ( NOMAD::Mads & mads return; } - // current mesh index: + // current mesh indices: NOMAD::Point mesh_indices = signature->get_mesh()->get_mesh_indices(); @@ -245,6 +254,7 @@ void NOMAD::Quad_Model_Search::search ( NOMAD::Mads & mads return; } + // compute the interpolation radius: points in Y must be at // a max distance of ms_radius_factor times Delta^k: NOMAD::Point Delta , delta; @@ -422,8 +432,10 @@ void NOMAD::Quad_Model_Search::search ( NOMAD::Mads & mads } // end of main loop // check the number of times that not enough points could be considered: - if ( nY[0] <= 1 && nY[1] <= 1 ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) { + if ( nY[0] <= 1 && nY[1] <= 1 ) + { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { std::ostringstream oss; oss << "end of " << NOMAD::MODEL_SEARCH << " (not enough points)"; @@ -437,7 +449,8 @@ void NOMAD::Quad_Model_Search::search ( NOMAD::Mads & mads // check if no model has been computed: if ( !model_ok ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { std::ostringstream oss; oss << "end of " << NOMAD::MODEL_SEARCH << " (model computation or optimization error)"; @@ -507,7 +520,8 @@ void NOMAD::Quad_Model_Search::search ( NOMAD::Mads & mads _all_searches_stats.update ( _one_search_stats ); // final display: - if ( display_degree == NOMAD::FULL_DISPLAY ) { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { std::ostringstream oss; oss << "end of " << NOMAD::MODEL_SEARCH << " (" << success << ")"; out << std::endl << NOMAD::close_block ( oss.str() ) << std::endl; @@ -517,20 +531,20 @@ void NOMAD::Quad_Model_Search::search ( NOMAD::Mads & mads /*---------------------------------------------------------------*/ /* project to mesh and create a trial point (private) */ /*---------------------------------------------------------------*/ -void NOMAD::Quad_Model_Search::create_trial_point -( NOMAD::Evaluator_Control & ev_control , - NOMAD::Point x , - const NOMAD::Quad_Model & model , - NOMAD::Signature & signature , - const NOMAD::Point & mesh_indices , - const NOMAD::Point & delta , - NOMAD::dd_type display_degree , - const NOMAD::Display & out ) +void NOMAD::Quad_Model_Search::create_trial_point ( NOMAD::Evaluator_Control & ev_control , + NOMAD::Point x , + const NOMAD::Quad_Model & model , + NOMAD::Signature & signature , + const NOMAD::Point & mesh_indices , + const NOMAD::Point & delta , + NOMAD::dd_type display_degree , + const NOMAD::Display & out ) { bool proj_to_mesh = _p.get_model_search_proj_to_mesh(); - if ( display_degree == NOMAD::FULL_DISPLAY ) { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { out << "candidate"; if ( proj_to_mesh ) out << " (before projection)"; @@ -553,7 +567,7 @@ void NOMAD::Quad_Model_Search::create_trial_point } - // Round for integer and binary variables: + // Round for integer and variables: bool has_integer=false; bool has_binary=false; for (int i=0;i<n;i++) @@ -570,8 +584,11 @@ void NOMAD::Quad_Model_Search::create_trial_point else if ( _p.get_bb_input_type()[i] == NOMAD::BINARY ) { has_binary=true; - if ( x[i]!= 0.0 ) + if ( x[i] < 0.5 ) + x[i] = 0.0; + else x[i] = 1.0; + } } if ( has_integer && display_degree == NOMAD::FULL_DISPLAY ) @@ -609,6 +626,7 @@ void NOMAD::Quad_Model_Search::create_trial_point tk->Point::operator = ( x ); // compute model f and h in order to accept or reject the trial point: + NOMAD::Double h0 , f0; // model values of f and h at the center NOMAD::Double h1 , f1; // model values of f and h at the trial point @@ -658,7 +676,8 @@ void NOMAD::Quad_Model_Search::create_trial_point } // add the new point to the list of search trial points: - if ( accept_point ) { + if ( accept_point ) + { ev_control.add_eval_point ( tk , display_degree , _p.get_snap_to_bounds() , @@ -667,7 +686,8 @@ void NOMAD::Quad_Model_Search::create_trial_point f1 , h1 ); #ifdef MODEL_STATS - if ( tk ) { + if ( tk ) + { tk->set_mod_use ( 1 ); // 1 for model search tk->set_cond ( model.get_cond() ); tk->set_Yw ( model.get_Yw () ); @@ -678,7 +698,9 @@ void NOMAD::Quad_Model_Search::create_trial_point #endif } - else { + else + { + if ( display_degree == NOMAD::FULL_DISPLAY ) out << "candidate rejected" << std::endl; _one_search_stats.add_MS_rejected(); @@ -694,16 +716,15 @@ void NOMAD::Quad_Model_Search::create_trial_point /* in [-1000;1000] */ /* */ /*---------------------------------------------------------------*/ -bool NOMAD::Quad_Model_Search::optimize_model -( const NOMAD::Quad_Model & model , - const NOMAD::Eval_Point ** xk , - int i_inc , - NOMAD::dd_type display_degree , - const NOMAD::Display & out , - NOMAD::Point & xf , - NOMAD::Point & xi , - bool & stop , - NOMAD::stop_type & stop_reason ) +bool NOMAD::Quad_Model_Search::optimize_model ( const NOMAD::Quad_Model & model , + const NOMAD::Eval_Point ** xk , + int i_inc , + NOMAD::dd_type display_degree , + const NOMAD::Display & out , + NOMAD::Point & xf , + NOMAD::Point & xi , + bool & stop , + NOMAD::stop_type & stop_reason ) { xf.clear(); xi.clear(); @@ -714,7 +735,8 @@ bool NOMAD::Quad_Model_Search::optimize_model int i; // initial displays: - if ( display_degree == NOMAD::FULL_DISPLAY ) { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { std::ostringstream oss; oss << "model optimization"; if ( xk[0] && xk[1] ) @@ -731,6 +753,9 @@ bool NOMAD::Quad_Model_Search::optimize_model // blackbox outputs: model_param.set_BB_OUTPUT_TYPE ( _p.get_bb_output_type() ); + // blackbox inputs: + // Default: all variables are treated as continuous + // barrier parameters: model_param.set_H_MIN ( _p.get_h_min () ); model_param.set_H_NORM ( _p.get_h_norm() ); @@ -799,7 +824,6 @@ bool NOMAD::Quad_Model_Search::optimize_model else model_param.set_MAX_BB_EVAL ( 50000 ); - model_param.set_SNAP_TO_BOUNDS ( true ); // disable user calls: @@ -812,7 +836,7 @@ bool NOMAD::Quad_Model_Search::optimize_model flag_reset_barriers , flag_p1_active ); - NOMAD::Mads::set_flag_check_bimads (false ); + NOMAD::Mads::set_flag_check_bimads ( false ); NOMAD::Mads::set_flag_reset_mesh ( true ); NOMAD::Mads::set_flag_reset_barriers ( true ); NOMAD::Mads::set_flag_p1_active ( false ); @@ -877,15 +901,15 @@ bool NOMAD::Quad_Model_Search::optimize_model // model evaluator creation: NOMAD::Evaluator *ev; - if (model_param.get_nb_obj()==2) + + if ( model_param.get_nb_obj()==2 ) ev =new NOMAD::Multi_Obj_Quad_Model_Evaluator( model_param , model ); else - ev=new NOMAD::Single_Obj_Quad_Model_Evaluator(model_param, model); + ev=new NOMAD::Single_Obj_Quad_Model_Evaluator( model_param, model ); // algorithm creation and execution: NOMAD::Mads mads ( model_param , ev ); - // Handle the case where nb_bb_obj>=2 but no-bimads (case of PhaseOneSearch) ---> need Phase_One_Evaluator for compute_f NOMAD::Phase_One_Evaluator * p1ev=NULL; if ( model_param.get_nb_obj() >= 2 && ! flag_check_bimads ) { @@ -896,11 +920,12 @@ bool NOMAD::Quad_Model_Search::optimize_model NOMAD::stop_type st = mads.run(); delete ev; - if (p1ev) + if ( p1ev ) delete p1ev; // check the stopping criterion: - if ( st == NOMAD::CTRL_C || st == NOMAD::MAX_CACHE_MEMORY_REACHED ) { + if ( st == NOMAD::CTRL_C || st == NOMAD::MAX_CACHE_MEMORY_REACHED ) + { std::ostringstream oss; oss << "model optimization: " << st; error_str = oss.str(); @@ -926,11 +951,13 @@ bool NOMAD::Quad_Model_Search::optimize_model const NOMAD::Eval_Point * best_feas = mads.get_best_feasible (); const NOMAD::Eval_Point * best_infeas = mads.get_best_infeasible(); - if ( best_feas ) { + if ( best_feas ) + { xf = *best_feas; xf *= 0.001; - if ( display_degree == NOMAD::FULL_DISPLAY ) { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { out << "best feasible point after unscaling : ( "; xf.NOMAD::Point::display ( out ); out << " )" << std::endl; @@ -941,11 +968,13 @@ bool NOMAD::Quad_Model_Search::optimize_model else if ( display_degree == NOMAD::FULL_DISPLAY ) out << "no feasible solution" << std::endl; - if ( best_infeas ) { + if ( best_infeas ) + { xi = *best_infeas; xi *= 0.001; - if ( display_degree == NOMAD::FULL_DISPLAY ) { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { out << "best infeasible point before unscaling: ( "; xi.NOMAD::Point::display ( out ); out << " )" << std::endl; @@ -956,12 +985,14 @@ bool NOMAD::Quad_Model_Search::optimize_model else if ( display_degree == NOMAD::FULL_DISPLAY ) out << "no infeasible solution" << std::endl; - if ( !xf.is_defined() && !xi.is_defined() ) { + if ( !xf.is_defined() && !xi.is_defined() ) + { error = true; error_str = "optimization error: no solution"; } } - catch ( std::exception & e ) { + catch ( std::exception & e ) + { error = true; error_str = std::string ( "optimization error: " ) + e.what(); } @@ -979,7 +1010,8 @@ bool NOMAD::Quad_Model_Search::optimize_model // close display block: - if ( display_degree == NOMAD::FULL_DISPLAY ) { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { if ( error ) out.close_block ( error_str ); else diff --git a/src/Quad_Model_Search.hpp b/src/Quad_Model_Search.hpp index 1f2d19e49f4b1981189fafe42a54c75f6b1f8d8d..a00dda51a5a16ff216cee676acfc68a44d4150dc 100644 --- a/src/Quad_Model_Search.hpp +++ b/src/Quad_Model_Search.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Quad_Model_Search.hpp - \brief Quadratic Model search (headers) - \author Sebastien Le Digabel - \date 2010-08-30 - \see Quad_Model_Search.cpp -*/ + \file Quad_Model_Search.hpp + \brief Quadratic Model search (headers) + \author Sebastien Le Digabel + \date 2010-08-30 + \see Quad_Model_Search.cpp + */ #ifndef __QUAD_MODEL_SEARCH__ #define __QUAD_MODEL_SEARCH__ @@ -48,104 +55,105 @@ #include "Multi_Obj_Quad_Model_Evaluator.hpp" namespace NOMAD { - - /// Model search. - class Quad_Model_Search : public NOMAD::Search , private NOMAD::Uncopyable { - - private: - - NOMAD::Model_Stats _one_search_stats; ///< Stats for one search. - NOMAD::Model_Stats _all_searches_stats; ///< Stats for all searches. - - /// Model optimization. - /** - \param model The model -- \b IN. - \param xk The two model centers -- \b IN. - \param i_inc Model center index (\c 0 or \c 1 ) -- \b IN. - \param display_degree Display degree -- \b IN. - \param out The NOMAD::Display object -- \b IN. - \param xf Feasible solution \c xf -- \b OUT. - \param xi Infeasible solution \c xi -- \b OUT. - \param stop Stop flag -- \b OUT. - \param stop_reason Stop reason -- \b OUT. - */ - bool optimize_model ( const NOMAD::Quad_Model & model , - const NOMAD::Eval_Point ** xk , - int i_inc , - NOMAD::dd_type display_degree , - const NOMAD::Display & out , - NOMAD::Point & xf , - NOMAD::Point & xi , - bool & stop , - NOMAD::stop_type & stop_reason ); - - /// Project to mesh and create a trial point. - /** - \param ev_control The NOMAD::Evaluator_Control object -- \b IN. - \param x The point coordinates -- \b IN. - \param model The model -- \b IN. - \param signature Signature -- \b IN. - \param mesh_indices Mesh indic -- \b IN. - \param delta Mesh size parameter -- \b IN. - \param display_degree Display degree -- \b IN. - \param out The NOMAD::Display object -- \b IN. - */ - void create_trial_point - ( NOMAD::Evaluator_Control & ev_control , - NOMAD::Point x , - const NOMAD::Quad_Model & model , - NOMAD::Signature & signature , - const NOMAD::Point & mesh_indices , - const NOMAD::Point & delta , - NOMAD::dd_type display_degree , - const NOMAD::Display & out ); - - /*----------------------------------------------------------------------*/ - - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - */ - Quad_Model_Search ( NOMAD::Parameters & p ) - : NOMAD::Search ( p , NOMAD::MODEL_SEARCH ) {} - /// Destructor. - virtual ~Quad_Model_Search ( void ) {} - - /// Reset. - virtual void reset ( void ) {} - - /// The quadratic model search. - /** - Based on quadratic regression/MFN interpolation models. - \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. - \param nb_search_pts Number of generated search points -- \b OUT. - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - \param success Type of success -- \b OUT. - \param count_search Count or not the search -- \b OUT. - \param new_feas_inc New feasible incumbent -- \b IN/OUT. - \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. - */ - virtual void search ( NOMAD::Mads & mads , - int & nb_search_pts , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - bool & count_search , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ); - //// Display stats. - /** - \param out The NOMAD::Display object -- \b IN. - */ - virtual void display ( const NOMAD::Display & out ) const - { - out << _all_searches_stats; - } - }; + /// Model search. + class Quad_Model_Search : public NOMAD::Search , private NOMAD::Uncopyable { + + private: + + NOMAD::Model_Stats _one_search_stats; ///< Stats for one search. + NOMAD::Model_Stats _all_searches_stats; ///< Stats for all searches. + + /// Model optimization. + /** + \param model The model -- \b IN. + \param xk The two model centers -- \b IN. + \param i_inc Model center index (\c 0 or \c 1 ) -- \b IN. + \param display_degree Display degree -- \b IN. + \param out The NOMAD::Display object -- \b IN. + \param xf Feasible solution \c xf -- \b OUT. + \param xi Infeasible solution \c xi -- \b OUT. + \param stop Stop flag -- \b OUT. + \param stop_reason Stop reason -- \b OUT. + */ + bool optimize_model ( const NOMAD::Quad_Model & model , + const NOMAD::Eval_Point ** xk , + int i_inc , + NOMAD::dd_type display_degree , + const NOMAD::Display & out , + NOMAD::Point & xf , + NOMAD::Point & xi , + bool & stop , + NOMAD::stop_type & stop_reason ); + + /// Project to mesh and create a trial point. + /** + \param ev_control The NOMAD::Evaluator_Control object -- \b IN. + \param x The point coordinates -- \b IN. + \param model The model -- \b IN. + \param signature Signature -- \b IN. + \param mesh_indices Mesh indic -- \b IN. + \param delta Mesh size parameter -- \b IN. + \param display_degree Display degree -- \b IN. + \param out The NOMAD::Display object -- \b IN. + */ + void create_trial_point ( NOMAD::Evaluator_Control & ev_control , + NOMAD::Point x , + const NOMAD::Quad_Model & model , + NOMAD::Signature & signature , + const NOMAD::Point & mesh_indices , + const NOMAD::Point & delta , + NOMAD::dd_type display_degree , + const NOMAD::Display & out ); + + /*----------------------------------------------------------------------*/ + + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + */ + Quad_Model_Search ( NOMAD::Parameters & p ) + : NOMAD::Search ( p , NOMAD::MODEL_SEARCH ) {} + + /// Destructor. + virtual ~Quad_Model_Search ( void ) {} + + /// Reset. + virtual void reset ( void ) {} + + /// The quadratic model search. + /** + Based on quadratic regression/MFN interpolation models. + \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. + \param nb_search_pts Number of generated search points -- \b OUT. + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + \param success Type of success -- \b OUT. + \param count_search Count or not the search -- \b OUT. + \param new_feas_inc New feasible incumbent -- \b IN/OUT. + \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. + */ + virtual void search ( NOMAD::Mads & mads , + int & nb_search_pts , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + bool & count_search , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ); + + + //// Display stats. + /** + \param out The NOMAD::Display object -- \b IN. + */ + virtual void display ( const NOMAD::Display & out ) const + { + out << _all_searches_stats; + } + }; } #endif diff --git a/src/RNG.cpp b/src/RNG.cpp index c37391f209ef2921e906a38914081e68aff524dc..6010f3ef43d484758502d474dc7a029a6548e29b 100644 --- a/src/RNG.cpp +++ b/src/RNG.cpp @@ -1,14 +1,24 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ +/* */ +/* */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ /* C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */ @@ -56,34 +66,34 @@ uint32_t NOMAD::RNG::_z = z_def; void NOMAD::RNG::set_seed(int s) { - if( s<=INT_MAX && s>=0 ) - _s=s; - else + if( s<=INT_MAX && s>=0 ) + _s=s; + else throw NOMAD::Exception ( "RNG.cpp" , __LINE__ , "NOMAD::RNG::set_seed(): invalid seed. Seed should be in [0,INT_MAX]" ); - + reset_seed_to_default(); for ( int i=0 ; i<_s ; i++) - NOMAD::RNG::rand(); - - + NOMAD::RNG::rand(); + + } uint32_t NOMAD::RNG::rand ( void ) { // http://madrabbit.org/~ray/code/xorshf96.c //period 2^96-1 - - uint32_t t; - _x ^= _x << 16; - _x ^= _x >> 5; - _x ^= _x << 1; - - t = _x; - _x = _y; - _y = _z; - _z = t ^ _x ^ _y; - - return _z; + + uint32_t t; + _x ^= _x << 16; + _x ^= _x >> 5; + _x ^= _x << 1; + + t = _x; + _x = _y; + _y = _z; + _z = t ^ _x ^ _y; + + return _z; } @@ -109,9 +119,9 @@ double NOMAD::RNG::normal_rand( double mean , double var ) } double NOMAD::RNG::normal_rand_mean_0 ( double Var , int Nsample ) { - double sum = 0.0; - double a=pow( 3.0*Var,0.5 ); - for ( int i=0 ; i<Nsample ; i++ ) - sum+=NOMAD::RNG::rand(-a,a); - return sum / pow( Nsample,0.5 ); + double sum = 0.0; + double a=pow( 3.0*Var,0.5 ); + for ( int i=0 ; i<Nsample ; i++ ) + sum+=NOMAD::RNG::rand(-a,a); + return sum / pow( Nsample,0.5 ); } diff --git a/src/RNG.hpp b/src/RNG.hpp index c0f8714b860976d11ad9be36bd2f5828a87bca93..bc3e897efb00bed3f3466f31ac96c2375248dc42 100644 --- a/src/RNG.hpp +++ b/src/RNG.hpp @@ -1,14 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ +/* */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -31,10 +40,11 @@ /* */ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ + /** \file RNG.hpp \brief Custom class for random number generator - \author Christophe Tribes and Sebastien Le Digabel + \author Christophe Tribes and Sebastien Le Digabel \date 2011-09-28 \see RNG.cpp */ @@ -48,21 +58,21 @@ using namespace std; namespace NOMAD { - + /// Class for random number generator - /** + /** This class is used to set a seed for the random number generator and get a random integer or a random double between two values. - */ - class RNG { - - public: + */ + class RNG { - /// Get current seed - /* - /return An integer in [0,UINT32_MAX]. - */ + public: + + /// Get current seed + /* + /return An integer in [0,UINT32_MAX]. + */ static int get_seed ( void ) { return static_cast<int>(_s); @@ -76,56 +86,56 @@ namespace NOMAD { _z=z_def; } - /// Set seed - /* - /param s The seed -- \b IN. - */ - static void set_seed(int s); - - - /// Get a random integer as uint32 - /** This function serves to obtain a random number \c - /return An integer in the interval [0,UINT32_MAX]. - */ - static uint32_t rand(); + /// Set seed + /* + /param s The seed -- \b IN. + */ + static void set_seed(int s); + + + /// Get a random integer as uint32 + /** This function serves to obtain a random number \c + /return An integer in the interval [0,UINT32_MAX]. + */ + static uint32_t rand(); - - /// Get a random number having a normal distribution as double - /* + + /// Get a random number having a normal distribution as double + /* /param a Lower bound -- \b IN. /param b Upper bound -- \b IN. /return A double in the interval [a,b]. - */ - static double rand(double a, double b) + */ + static double rand(double a, double b) { return a+((b-a)*NOMAD::RNG::rand())/UINT32_MAX; } - - /// Get a random number approaching a normal distribution (N(0,Var)) as double - // A series of Nsample random numbers Xi in the interval [-sqrt(3*Var);+sqrt(3*Var)] is used -> E[Xi]=0, Var(Xi)=var - // see http://en.wikipedia.org/wiki/Central_limit_theorem - /* - /param Nsample Number of samples for averaging -- \b IN. - /param Var Variance of the target normal distribution -- \b IN. + + /// Get a random number approaching a normal distribution (N(0,Var)) as double + // A series of Nsample random numbers Xi in the interval [-sqrt(3*Var);+sqrt(3*Var)] is used -> E[Xi]=0, Var(Xi)=var + // see http://en.wikipedia.org/wiki/Central_limit_theorem + /* + /param Nsample Number of samples for averaging -- \b IN. + /param Var Variance of the target normal distribution -- \b IN. /return A double in the interval [-sqrt(3*Var);+sqrt(3*Var)]. - */ - static double normal_rand_mean_0( double Var=1 , int Nsample=12 ) ; + */ + static double normal_rand_mean_0( double Var=1 , int Nsample=12 ) ; /// Get a random number approaching a normal distribution ( N(Mean,Var) ) as double - /* - /param Mean Mean of the target normal distribution -- \b IN. - /param Var Variance of the target normal distribution -- \b IN. + /* + /param Mean Mean of the target normal distribution -- \b IN. + /param Var Variance of the target normal distribution -- \b IN. /return A random number. - */ + */ static double normal_rand( double Mean=0 , double Var=1 ) ; - - private: + + private: static uint32_t x_def,y_def,z_def,_x,_y,_z; ///< Default parameter value for the random number generator (_s used as the seed). static int _s; - }; + }; } diff --git a/src/Random_Pickup.cpp b/src/Random_Pickup.cpp index 1770499863776a85ed70c98b18fc05406ffcf7e8..1c26f8322ac17b4a269bba188af2fe954b125004 100644 --- a/src/Random_Pickup.cpp +++ b/src/Random_Pickup.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,24 +41,24 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Random_Pickup.cpp - \brief Class for randomly pick up integers (implementation) - \author Sebastien Le Digabel - \date 2010-04-07 - \see Random_Pickup.hpp -*/ + \file Random_Pickup.cpp + \brief Class for randomly pick up integers (implementation) + \author Sebastien Le Digabel + \date 2010-04-07 + \see Random_Pickup.hpp + */ #include "Random_Pickup.hpp" /*---------------------------------------------------------*/ /* constructor */ /*---------------------------------------------------------*/ NOMAD::Random_Pickup::Random_Pickup ( int n ) - : _n0 ( n ) , - _n ( n ) , - _elts ( new int[n] ) +: _n0 ( n ) , +_n ( n ) , +_elts ( new int[n] ) { - for ( int i = 0 ; i < n ; ++i ) - _elts[i] = i; + for ( int i = 0 ; i < n ; ++i ) + _elts[i] = i; } /*---------------------------------------------------------*/ @@ -59,9 +66,9 @@ NOMAD::Random_Pickup::Random_Pickup ( int n ) /*---------------------------------------------------------*/ void NOMAD::Random_Pickup::reset ( void ) { - _n = _n0; - for ( int i = 0 ; i < _n ; ++i ) - _elts[i] = i; + _n = _n0; + for ( int i = 0 ; i < _n ; ++i ) + _elts[i] = i; } /*---------------------------------------------------------*/ @@ -69,17 +76,18 @@ void NOMAD::Random_Pickup::reset ( void ) /*---------------------------------------------------------*/ int NOMAD::Random_Pickup::pickup ( void ) { - if ( _n == 0 ) - return 0; - int ind = NOMAD::RNG::rand()%_n; - int tmp = _elts[ind]; - if ( ind < _n - 1 ) { - _elts[ind ] = _elts[_n-1]; - _elts[_n-1] = tmp; - } - --_n; - - return tmp; + if ( _n == 0 ) + return 0; + int ind = NOMAD::RNG::rand()%_n; + int tmp = _elts[ind]; + if ( ind < _n - 1 ) + { + _elts[ind ] = _elts[_n-1]; + _elts[_n-1] = tmp; + } + --_n; + + return tmp; } /*---------------------------------------------------------*/ @@ -87,6 +95,6 @@ int NOMAD::Random_Pickup::pickup ( void ) /*---------------------------------------------------------*/ void NOMAD::Random_Pickup::cancel_last_pickup ( void ) { - if ( _n < _n0 ) - ++_n; + if ( _n < _n0 ) + ++_n; } diff --git a/src/Random_Pickup.hpp b/src/Random_Pickup.hpp index b111a8672b8dcee5e5f5a44089066bbe0d01f063..859d61bf1213b327484afa6f717f2433ed0c6a9d 100644 --- a/src/Random_Pickup.hpp +++ b/src/Random_Pickup.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ diff --git a/src/SMesh.cpp b/src/SMesh.cpp index 08746148847e5d58da5e3a2765aedf20b2210d7b..3fefbfc55e6b86c581d3e37f1d9b79bee3ff34a7 100644 --- a/src/SMesh.cpp +++ b/src/SMesh.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file SMesh.cpp - \brief Class for the MADS mesh (implementation) - \author Sebastien Le Digabel - \date 2010-04-06 - \see SMesh.hpp -*/ + \file SMesh.cpp + \brief Class for the MADS mesh (implementation) + \author Sebastien Le Digabel + \date 2010-04-06 + \see SMesh.hpp + */ #include "SMesh.hpp" @@ -47,50 +54,52 @@ /*-----------------------------------------------------------*/ /* update the mesh */ /*-----------------------------------------------------------*/ -void NOMAD::SMesh::update ( NOMAD::success_type success , const NOMAD::Direction *dir) // , const NOMAD::OrthogonalMesh * mesh ) +void NOMAD::SMesh::update ( NOMAD::success_type success , const NOMAD::Direction *dir) { - // defaults: - // full success: lk = lk - 1 - // failure : lk = lk + 1 - - - if ( success == NOMAD::FULL_SUCCESS ) + // defaults: + // full success: lk = lk - 1 + // failure : lk = lk + 1 + + + if ( success == NOMAD::FULL_SUCCESS ) { - _mesh_index -= _coarsening_step; - if ( _mesh_index < -NOMAD::L_LIMITS ) - _mesh_index = -NOMAD::L_LIMITS; - } - else if ( success == NOMAD::UNSUCCESSFUL ) - _mesh_index -= _refining_step; - - if ( _mesh_index > _max_mesh_index ) - _max_mesh_index = _mesh_index; - - - if ( _mesh_index < _min_mesh_index ) - _min_mesh_index = _mesh_index; + _mesh_index -= _coarsening_step; + if ( _mesh_index < -NOMAD::L_LIMITS ) + _mesh_index = -NOMAD::L_LIMITS; + } + else if ( success == NOMAD::UNSUCCESSFUL ) + _mesh_index -= _refining_step; + + if ( _mesh_index > _max_mesh_index ) + _max_mesh_index = _mesh_index; + + + if ( _mesh_index < _min_mesh_index ) + _min_mesh_index = _mesh_index; } /*-----------------------------------------------------------*/ /* Update the provided mesh indices (the Mesh is unchanged). */ /*-----------------------------------------------------------*/ -void NOMAD::SMesh::update ( NOMAD::success_type success , NOMAD::Point & mesh_indices, const NOMAD::Direction *dir ) const +void NOMAD::SMesh::update ( NOMAD::success_type success , + NOMAD::Point & mesh_indices, + const NOMAD::Direction *dir ) const { - - if ( mesh_indices.is_defined() ) - { - for (int i=0; i < mesh_indices.size() ; i++) - { - if ( success == NOMAD::FULL_SUCCESS ) - { - mesh_indices[i] -= _coarsening_step; - if ( mesh_indices[i] < -NOMAD::L_LIMITS ) - mesh_indices[i] = -NOMAD::L_LIMITS; - } - else if ( success == NOMAD::UNSUCCESSFUL ) - mesh_indices[i] -= _refining_step; - } - } + + if ( mesh_indices.is_defined() ) + { + for (int i=0; i < mesh_indices.size() ; i++) + { + if ( success == NOMAD::FULL_SUCCESS ) + { + mesh_indices[i] -= _coarsening_step; + if ( mesh_indices[i] < -NOMAD::L_LIMITS ) + mesh_indices[i] = -NOMAD::L_LIMITS; + } + else if ( success == NOMAD::UNSUCCESSFUL ) + mesh_indices[i] -= _refining_step; + } + } } @@ -99,15 +108,15 @@ void NOMAD::SMesh::update ( NOMAD::success_type success , NOMAD::Point & mesh_in /*-----------------------------------------------------------*/ void NOMAD::SMesh::set_mesh_indices ( const NOMAD::Point & r ) { - if (!r.is_defined()) - _mesh_index=0; - else - _mesh_index=r[0].NOMAD::Double::round(); - - if ( _mesh_index > _max_mesh_index ) - _max_mesh_index = _mesh_index; - if ( _mesh_index < _min_mesh_index ) - _min_mesh_index = _mesh_index; + if ( !r.is_defined() ) + _mesh_index=0; + else + _mesh_index=r[0].NOMAD::Double::round(); // Warning no need to check that the double will convert nicely to an int because mesh_index will range [-50;50] + + if ( _mesh_index > _max_mesh_index ) + _max_mesh_index = _mesh_index; + if ( _mesh_index < _min_mesh_index ) + _min_mesh_index = _mesh_index; } @@ -117,7 +126,9 @@ void NOMAD::SMesh::set_mesh_indices ( const NOMAD::Point & r ) /*-----------------------------------------------------------*/ void NOMAD::SMesh::set_limit_mesh_index ( int l ) { + _limit_mesh_index=l; + } @@ -127,24 +138,24 @@ void NOMAD::SMesh::set_limit_mesh_index ( int l ) /*-----------------------------------------------------------*/ void NOMAD::SMesh::display ( const NOMAD::Display & out ) const { - out << "n : " << get_n() << std::endl - << "mesh update basis : " << _update_basis << std::endl - << "mesh coarsening step: " << _coarsening_step << std::endl - << "mesh refining step : " << _refining_step << std::endl - << "initial mesh size : " - << "(" << _delta_0 << " )" << std::endl; - out << "minimal mesh size : "; - if ( _delta_min.is_defined() ) - out << "(" << _delta_min << " )" << std::endl; - else - out << "none"; - out << std::endl - << "minimal poll size : "; - if ( _Delta_min_is_defined ) - out << "(" << _Delta_min << " )" << std::endl; - else - out << "none"; - out << std::endl; + out << "n : " << get_n() << std::endl + << "mesh update basis : " << _update_basis << std::endl + << "mesh coarsening step: " << _coarsening_step << std::endl + << "mesh refining step : " << _refining_step << std::endl + << "initial mesh size : " + << "(" << _delta_0 << " )" << std::endl; + out << "minimal mesh size : "; + if ( _delta_min.is_defined() ) + out << "(" << _delta_min << " )" << std::endl; + else + out << "none"; + out << std::endl + << "minimal poll size : "; + if ( _Delta_min_is_defined ) + out << "(" << _Delta_min << " )" << std::endl; + else + out << "none"; + out << std::endl; } /*----------------------------------------------------------*/ @@ -152,31 +163,31 @@ void NOMAD::SMesh::display ( const NOMAD::Display & out ) const /* and on the minimal mesh size */ /*----------------------------------------------------------*/ void NOMAD::SMesh::check_min_mesh_sizes ( bool & stop , - NOMAD::stop_type & stop_reason ) const + NOMAD::stop_type & stop_reason ) const { - if ( stop ) - return; - - // 1. mesh index tests: - if ( abs ( _mesh_index ) > NOMAD::L_LIMITS ) - { - stop = true; - stop_reason = NOMAD::L_LIMITS_REACHED; - } - - // 2. delta_k^p (poll size) tests: - if ( check_min_poll_size_criterion ( ) ) - { - stop = true; - stop_reason = NOMAD::DELTA_P_MIN_REACHED; - } - - // 3. delta_k^m (mesh size) tests: - if ( check_min_mesh_size_criterion ( ) ) - { - stop = true; - stop_reason = NOMAD::DELTA_M_MIN_REACHED; - } + if ( stop ) + return; + + // 1. mesh index tests: + if ( abs ( _mesh_index ) > NOMAD::L_LIMITS ) + { + stop = true; + stop_reason = NOMAD::L_LIMITS_REACHED; + } + + // 2. delta_k^p (poll size) tests: + if ( check_min_poll_size_criterion ( ) ) + { + stop = true; + stop_reason = NOMAD::DELTA_P_MIN_REACHED; + } + + // 3. delta_k^m (mesh size) tests: + if ( check_min_mesh_size_criterion ( ) ) + { + stop = true; + stop_reason = NOMAD::DELTA_M_MIN_REACHED; + } } /*-----------------------------------------------------------*/ @@ -184,10 +195,10 @@ void NOMAD::SMesh::check_min_mesh_sizes ( bool & stop , /*-----------------------------------------------------------*/ bool NOMAD::SMesh::check_min_poll_size_criterion ( ) const { - if ( !_Delta_min_is_defined ) - return false; - NOMAD::Point Delta; - return get_Delta ( Delta ); + if ( !_Delta_min_is_defined ) + return false; + NOMAD::Point Delta; + return get_Delta ( Delta ); } /*-----------------------------------------------------------*/ @@ -195,10 +206,10 @@ bool NOMAD::SMesh::check_min_poll_size_criterion ( ) const /*-----------------------------------------------------------*/ bool NOMAD::SMesh::check_min_mesh_size_criterion ( ) const { - if ( !_delta_min.is_defined() ) - return false; - NOMAD::Point delta; - return get_delta ( delta ); + if ( !_delta_min.is_defined() ) + return false; + NOMAD::Point delta; + return get_delta ( delta ); } /*----------------------------------------------------------------*/ @@ -210,29 +221,28 @@ bool NOMAD::SMesh::check_min_mesh_size_criterion ( ) const /*----------------------------------------------------------------*/ bool NOMAD::SMesh::get_delta ( NOMAD::Point & delta ) const { - delta.reset ( _n ); + delta.reset ( _n ); bool delta_min_is_defined=_delta_min.is_defined(); - - - // power_of_tau = tau^{ max{0,l0} - max{0,lk} }: - NOMAD::Double power_of_tau + + // power_of_tau = tau^{ max{0,l0} - max{0,lk} }: + NOMAD::Double power_of_tau = pow ( _update_basis.value() , - ( (_initial_mesh_index > 0) ? _initial_mesh_index : 0) - - ( (_mesh_index > 0) ? _mesh_index : 0) ); - - bool stop = false; - - // delta^k = power_of_tau * delta^0: - for ( int i = 0 ; i < _n ; ++i ) - { - delta[i] = _delta_0[i] * power_of_tau; - if ( !stop && delta_min_is_defined && delta[i] < _delta_min[i] ) - stop = true; - - } - - return stop; + ( (_initial_mesh_index > 0) ? _initial_mesh_index : 0) - + ( (_mesh_index > 0) ? _mesh_index : 0) ); + + bool stop = false; + + // delta^k = power_of_tau * delta^0: + for ( int i = 0 ; i < _n ; ++i ) + { + delta[i] = _delta_0[i] * power_of_tau; + if ( !stop && delta_min_is_defined && delta[i] < _delta_min[i] ) + stop = true; + + } + + return stop; } /*----------------------------------------------------------------*/ @@ -249,7 +259,7 @@ NOMAD::Double NOMAD::SMesh::get_delta ( int i ) const ( (_initial_mesh_index > 0) ? _initial_mesh_index : 0) - ( (_mesh_index > 0) ? _mesh_index : 0) ); - + NOMAD::Double delta = _delta_0[i] * power_of_tau; return delta; @@ -261,20 +271,20 @@ NOMAD::Double NOMAD::SMesh::get_delta ( int i ) const /*----------------------------------------------------------------*/ NOMAD::Point NOMAD::SMesh::get_delta_max ( ) const { - - NOMAD::Point delta_max ( _n ); - - // power_of_tau = tau^{ max{0,l0} - max{0,lk} }: - NOMAD::Double power_of_tau + + NOMAD::Point delta_max ( _n ); + + // power_of_tau = tau^{ max{0,l0} - max{0,lk} }: + NOMAD::Double power_of_tau = pow ( _update_basis.value() , - ( (_initial_mesh_index > 0) ? _initial_mesh_index : 0) - - ( (_min_mesh_index > 0) ? _min_mesh_index : 0) ); - - // delta^k = power_of_tau * delta^0: - for ( int i = 0 ; i < _n ; ++i ) - delta_max[i] = _delta_0[i] * power_of_tau; - - return delta_max; + ( (_initial_mesh_index > 0) ? _initial_mesh_index : 0) - + ( (_min_mesh_index > 0) ? _min_mesh_index : 0) ); + + // delta^k = power_of_tau * delta^0: + for ( int i = 0 ; i < _n ; ++i ) + delta_max[i] = _delta_0[i] * power_of_tau; + + return delta_max; } @@ -284,32 +294,33 @@ NOMAD::Point NOMAD::SMesh::get_delta_max ( ) const /* = delta^0 \tau^{ell_0^+ - ell_k^+ + |ell_k|/2} */ /*-------------------------------------------------------------------*/ /* the function also returns true if all values are < Delta_min */ +/* (stopping criterion MIN_POLL_SIZE) */ /*-------------------------------------------------------------------*/ bool NOMAD::SMesh::get_Delta ( NOMAD::Point & Delta ) const { - - Delta.reset ( _n ); - - // power_of_tau = tau^{ max{0,l0} - max{0,lk} + |lk|/2}: - NOMAD::Double power_of_tau + + Delta.reset ( _n ); + + // power_of_tau = tau^{ max{0,l0} - max{0,lk} + |lk|/2}: + NOMAD::Double power_of_tau = pow ( _update_basis.value() , abs(_mesh_index) / 2.0 + - ( (_initial_mesh_index > 0) ? _initial_mesh_index : 0) - - ( (_mesh_index > 0) ? _mesh_index : 0) ); - - bool stop = true; - - // Delta^k = power_of_tau * Delta^0: - for ( int i = 0 ; i < _n ; ++i ) - { - Delta[i] = _Delta_0[i] * power_of_tau; - if ( !_Delta_min_is_complete || Delta[i] >= _Delta_min[i] ) - stop = false; - + ( (_initial_mesh_index > 0) ? _initial_mesh_index : 0) - + ( (_mesh_index > 0) ? _mesh_index : 0) ); + + bool stop = true; + + // Delta^k = power_of_tau * Delta^0: + for ( int i = 0 ; i < _n ; ++i ) + { + Delta[i] = _Delta_0[i] * power_of_tau; + if ( !_Delta_min_is_complete || Delta[i] >= _Delta_min[i] ) + stop = false; + if ( _Delta_min_is_defined && _Delta_min[i].is_defined() && Delta[i] < _Delta_min[i] ) Delta[i]=_Delta_min[i]; - } - - return stop; + } + + return stop; } /*-------------------------------------------------------------------*/ @@ -331,27 +342,30 @@ NOMAD::Double NOMAD::SMesh::get_Delta ( int i ) const NOMAD::Double Delta = _Delta_0[i] * power_of_tau; if ( _Delta_min_is_defined && _Delta_min[i].is_defined() && Delta < _Delta_min[i] ) - Delta=_Delta_min[i]; + Delta=_Delta_min[i]; return Delta; } -NOMAD::Double NOMAD::SMesh::scale_and_project(int i, const NOMAD::Double & l) const +NOMAD::Double NOMAD::SMesh::scale_and_project(int i, const NOMAD::Double & l, bool round_up ) const { - NOMAD::Double delta = get_delta ( i ); - NOMAD::Double Delta = get_Delta ( i ); - - - if ( delta.is_defined() && Delta.is_defined() && i <= _n) - { - NOMAD::Double d= Delta / delta * l; - return d.NOMAD::Double::round()*delta; - } - else - throw NOMAD::Exception ( "SMesh.cpp" , __LINE__ , - "Mesh scaling and projection cannot be performed!" ); - + NOMAD::Double delta = get_delta ( i ); + NOMAD::Double Delta = get_Delta ( i ); + + + if ( delta.is_defined() && Delta.is_defined() && i <= _n) + { + NOMAD::Double d= Delta / delta * l; + if ( ! round_up ) + return d.NOMAD::Double::round()*delta; + else + return d.NOMAD::Double::ceil()*delta; + } + else + throw NOMAD::Exception ( "SMesh.cpp" , __LINE__ , + "Mesh scaling and projection cannot be performed!" ); + } @@ -359,24 +373,24 @@ NOMAD::Double NOMAD::SMesh::scale_and_project(int i, const NOMAD::Double & l) co NOMAD::Point NOMAD::SMesh::get_mesh_ratio_if_success ( void ) const { - - NOMAD::Double power_of_tau + + NOMAD::Double power_of_tau = pow ( _update_basis.value() , - ( (_initial_mesh_index > 0) ? _initial_mesh_index : 0) - - ( (_mesh_index > 0) ? _mesh_index : 0) ); - - NOMAD::Double power_of_tau_if_success - = pow ( _update_basis.value() , - ( (_initial_mesh_index > 0) ? _initial_mesh_index : 0) - - ( (_mesh_index - _coarsening_step > 0) ? _mesh_index - _coarsening_step : 0) ); - - try - { - NOMAD::Double ratio_scalaire = power_of_tau_if_success/power_of_tau; - return NOMAD::Point( _n , ratio_scalaire ); - } - catch ( NOMAD::Double::Invalid_Value & ) - { - return NOMAD::Point( _n,-1 ); - } + ( (_initial_mesh_index > 0) ? _initial_mesh_index : 0) - + ( (_mesh_index > 0) ? _mesh_index : 0) ); + + NOMAD::Double power_of_tau_if_success + = pow ( _update_basis.value() , + ( (_initial_mesh_index > 0) ? _initial_mesh_index : 0) - + ( (_mesh_index - _coarsening_step > 0) ? _mesh_index - _coarsening_step : 0) ); + + try + { + NOMAD::Double ratio_scalaire = power_of_tau_if_success/power_of_tau; + return NOMAD::Point( _n , ratio_scalaire ); + } + catch ( NOMAD::Double::Invalid_Value & ) + { + return NOMAD::Point( _n,-1 ); + } } diff --git a/src/SMesh.hpp b/src/SMesh.hpp index 00f02118efc2cfcd8a155aac6b0d040029b826c2..ed18f210ff2d48f91ad545f0fc85e1b71c5dbcd6 100644 --- a/src/SMesh.hpp +++ b/src/SMesh.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -65,29 +72,29 @@ namespace NOMAD { (one value for each variable). The scaling is done once based on initial mesh size. - See the MADS papers for more details on the mesh. */ - - class SMesh : public NOMAD::OrthogonalMesh { - - private: - - int _initial_mesh_index; - int _mesh_index; - int _min_mesh_index; ///< Minimal value reached by the mesh index - int _max_mesh_index; ///< Maximal value reached by the mesh index - - /*--------------------------------------------------------------*/ - - /// Private affectation operator. - /** - \param m The right-hand side object -- \b IN. - */ - const SMesh & operator = ( const SMesh & m ); - - /// Check the minimal poll size criterion. - bool check_min_poll_size_criterion ( ) const; - - /// Check the minimal mesh size criterion. - bool check_min_mesh_size_criterion ( ) const; + + class SMesh : public NOMAD::OrthogonalMesh { + + private: + + int _initial_mesh_index; + int _mesh_index; + int _min_mesh_index; ///< Minimal value reached by the mesh index + int _max_mesh_index; ///< Maximal value reached by the mesh index + + /*--------------------------------------------------------------*/ + + /// Private affectation operator. + /** + \param m The right-hand side object -- \b IN. + */ + const SMesh & operator = ( const SMesh & m ); + + /// Check the minimal poll size criterion. + bool check_min_poll_size_criterion ( ) const; + + /// Check the minimal mesh size criterion. + bool check_min_mesh_size_criterion ( ) const; /// Access to the mesh size parameter delta^k. /** @@ -104,40 +111,42 @@ namespace NOMAD { */ NOMAD::Double get_Delta ( int i ) const ; - - - /*--------------------------------------------------------------*/ - - public: - - /// Constructor. - /** - \param delta_0 Initial mesh size delta_0 -- \b IN. - \param Delta_min Minimal poll size Delta_min (may be undefined) -- \b IN. - \param delta_min Minimal mesh size delta_min (may be undefined) -- \b IN. - \param mesh_update_basis Mesh update basis (tau), default=4 -- \b IN. - \param mesh_coarsening_step Mesh coarsening step (w+), default=1 -- \b IN. - \param mesh_refining_step Mesh refining step (w-), default=-1 -- \b IN. - \param initial_mesh_index Initial mesh index ell_0, default=0 -- \b IN. - \param limit_max_mesh_index Limit max of the mesh index, default=L_LIMITS -- \b IN. + + + /*--------------------------------------------------------------*/ + + public: + + /// Constructor. + /** + \param delta_0 Initial mesh size delta_0 -- \b IN. + \param Delta_min Minimal poll size Delta_min (may be undefined) -- \b IN. + \param delta_min Minimal mesh size delta_min (may be undefined) -- \b IN. + \param mesh_update_basis Mesh update basis (tau), default=4 -- \b IN. + \param mesh_coarsening_step Mesh coarsening step (w+), default=1 -- \b IN. + \param mesh_refining_step Mesh refining step (w-), default=-1 -- \b IN. + \param initial_mesh_index Initial mesh index ell_0, default=0 -- \b IN. + \param limit_max_mesh_index Limit max of the mesh index, default=L_LIMITS -- \b IN. \param fixed_variables Fixed variables -- \b IN. - */ - SMesh ( const NOMAD::Point & delta_0 , - const NOMAD::Point & Delta_min , - const NOMAD::Point & delta_min , + */ + SMesh ( const NOMAD::Point& delta_0 , + const NOMAD::Point & Delta_min , + const NOMAD::Point & delta_min , const NOMAD::Point & fixed_variables , - NOMAD::Double mesh_update_basis=4.0, - int mesh_coarsening_step=1, - int mesh_refining_step=-1, - int initial_mesh_index=0, + NOMAD::Double mesh_update_basis=4.0, + int mesh_coarsening_step=1, + int mesh_refining_step=-1, + int initial_mesh_index=0, int limit_max_mesh_index=NOMAD::L_LIMITS) - : NOMAD::OrthogonalMesh ( delta_0, - Delta_min, - delta_min, + : NOMAD::OrthogonalMesh ( false, + delta_0, + Delta_min, + delta_min, fixed_variables, - mesh_update_basis, - mesh_coarsening_step, - mesh_refining_step , + NOMAD::Point(), + mesh_update_basis, + mesh_coarsening_step, + mesh_refining_step , limit_max_mesh_index ), _initial_mesh_index ( initial_mesh_index ), _mesh_index ( _initial_mesh_index ), @@ -145,19 +154,19 @@ namespace NOMAD { _max_mesh_index ( initial_mesh_index ) {} - /// Copy constructor. - /** - \param m The copied object -- \b IN. - */ - SMesh ( const SMesh & m ) - : OrthogonalMesh(m) , - _initial_mesh_index ( m._initial_mesh_index ), - _mesh_index ( m._initial_mesh_index ), - _min_mesh_index( m._initial_mesh_index ), - _max_mesh_index ( m._initial_mesh_index ) {} - - /// Destructor. - virtual ~SMesh ( void ) + /// Copy constructor. + /** + \param m The copied object -- \b IN. + */ + SMesh ( const SMesh & m ) + : OrthogonalMesh(m) , + _initial_mesh_index ( m._initial_mesh_index ), + _mesh_index ( m._initial_mesh_index ), + _min_mesh_index( m._initial_mesh_index ), + _max_mesh_index ( m._initial_mesh_index ) {} + + /// Destructor. + virtual ~SMesh ( void ) { _delta_0.clear(); _Delta_0.clear(); @@ -165,145 +174,146 @@ namespace NOMAD { _Delta_min.clear(); } - - /// Access to the mesh index. - /** - \return A Point with the mesh index. - */ - const NOMAD::Point get_mesh_indices ( void ) const + + /// Access to the mesh index. + /** + \return A Point with the mesh index. + */ + const NOMAD::Point get_mesh_indices ( void ) const { return NOMAD::Point( 1 , NOMAD::Double(_mesh_index) ); } - /// Access to the min mesh index reached so far. - /** - \return A Point with the mesh index. - */ - const NOMAD::Point get_min_mesh_indices ( void ) const + /// Access to the min mesh index reached so far. + /** + \return A Point with the mesh index. + */ + const NOMAD::Point get_min_mesh_indices ( void ) const { return NOMAD::Point( 1 , NOMAD::Double(_min_mesh_index) ); } - - /// Access to the max mesh index reached so far. - /** - \return A Point with the mesh index. - */ - const NOMAD::Point get_max_mesh_indices ( void ) const + + /// Access to the max mesh index reached so far. + /** + \return A Point with the mesh index. + */ + const NOMAD::Point get_max_mesh_indices ( void ) const { return NOMAD::Point( 1 , NOMAD::Double(_max_mesh_index) ); } - - - /// Manually set the mesh index using a point. (set_mesh_indices for consistency with XMesh) - /** - \param r The mesh index provided as a point -- \b IN. - */ - void set_mesh_indices ( const NOMAD::Point & r ); - + + /// Manually set the mesh index using a point. (set_mesh_indices for consistency with XMesh) + /** + \param r The mesh index provided as a point -- \b IN. + */ + void set_mesh_indices ( const NOMAD::Point & r ); + + /// Manually set the limit mesh index used for termination criterion (max value for SMesh). - /** - \param l The limit mesh index for all coordinates -- \b IN. - */ - void set_limit_mesh_index ( int l ); - - - - /// Test if finest mesh so far. - /** - \return True if mesh index greater or equal to the maximal mesh index; False otherwise. - */ - bool is_finest(void) const {return _mesh_index >= _max_mesh_index; } - - - /// Access to the mesh ratios after a success - /** - \return A point with the ratio for each coordinate - */ - NOMAD::Point get_mesh_ratio_if_success( void ) const; - - - /// Update the provided mesh indices (the Mesh is unchanged). - /** - \param success Type of success of the iteration -- \b IN. - \param mesh_indices The mesh indices before and after the update -- \b IN/OUT. - \param dir The direction that is considered (opt) -- \b IN. - */ - void update ( NOMAD::success_type success , NOMAD::Point & mesh_indices, const NOMAD::Direction *dir=NULL ) const ; - - - /// Update the Mesh. - /** - \param success Type of success of the iteration -- \b IN. - \param dir The direction that is considered (opt) -- \b IN. - */ - void update ( NOMAD::success_type success , const NOMAD::Direction *dir=NULL); - - - /// Reset the mesh to its original size (mesh indices). - void reset ( void ) + /** + \param l The limit mesh index for all coordinates -- \b IN. + */ + void set_limit_mesh_index ( int l ); + + + + /// Test if finest mesh so far. + /** + \return True if mesh index greater or equal to the maximal mesh index; False otherwise. + */ + bool is_finest(void) const {return _mesh_index >= _max_mesh_index; } + + + /// Access to the mesh ratios after a success + /** + \return A point with the ratio for each coordinate + */ + NOMAD::Point get_mesh_ratio_if_success( void ) const; + + + /// Update the provided mesh indices (the Mesh is unchanged). + /** + \param success Type of success of the iteration -- \b IN. + \param mesh_indices The mesh indices before and after the update -- \b IN/OUT. + \param dir The direction that is considered (opt) -- \b IN. + */ + void update ( NOMAD::success_type success , NOMAD::Point & mesh_indices, const NOMAD::Direction *dir=NULL ) const ; + + + /// Update the Mesh. + /** + \param success Type of success of the iteration -- \b IN. + \param dir The direction that is considered (opt) -- \b IN. + */ + void update ( NOMAD::success_type success , const NOMAD::Direction *dir=NULL); + + + /// Reset the mesh to its original size (mesh indices). + void reset ( void ) { set_mesh_indices( NOMAD::Point(1,NOMAD::Double(_initial_mesh_index))) ; - _min_mesh_index=_initial_mesh_index ; - _max_mesh_index=_initial_mesh_index; + _min_mesh_index=_initial_mesh_index ; + _max_mesh_index=_initial_mesh_index; } - - /// Access to the mesh size parameter delta^k. - /** - \param delta The mesh size parameter delta^k -- \b OUT. - \return A boolean equal to \c true if all values are - strictly inferior than the associated minimal - mesh size delta_min - (stopping criterion MIN_MESH_SIZE). - */ - virtual bool get_delta ( NOMAD::Point & delta ) const ; - - + + /// Access to the mesh size parameter delta^k. + /** + \param delta The mesh size parameter delta^k -- \b OUT. + \return A boolean equal to \c true if all values are + strictly inferior than the associated minimal + mesh size delta_min + (stopping criterion MIN_MESH_SIZE). + */ + virtual bool get_delta ( NOMAD::Point & delta ) const ; - /// Access to the larget mesh size so far. - /** - \return delta_max The largest mesh size reached so far -- \b OUT. - */ + + + /// Access to the larget mesh size so far. + /** + \return delta_max The largest mesh size reached so far -- \b OUT. + */ NOMAD::Point get_delta_max ( void ) const ; - - /// Access to the poll size parameter Delta^k. - /** - \param Delta The poll size parameter Delta^k -- \b OUT. - \return A boolean equal to \c true if all values are - strictly inferior than the associated minimal - mesh size Delta_min - (stopping criterion MIN_POLL_SIZE). - */ - virtual bool get_Delta ( NOMAD::Point & Delta ) const ; - - /// Check the stopping conditions on the minimal poll and mesh sizes. - /** - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - */ - void check_min_mesh_sizes ( bool & stop , + /// Access to the poll size parameter Delta^k. + /** + \param Delta The poll size parameter Delta^k -- \b OUT. + \return A boolean equal to \c true if all values are + strictly inferior than the associated minimal + mesh size Delta_min + (stopping criterion MIN_POLL_SIZE). + */ + virtual bool get_Delta ( NOMAD::Point & Delta ) const ; + + + /// Check the stopping conditions on the minimal poll and mesh sizes. + /** + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + */ + void check_min_mesh_sizes ( bool & stop , NOMAD::stop_type & stop_reason ) const; - /// Display. - /** - \param out The NOMAD::Display object -- \b IN. - */ - void display ( const NOMAD::Display & out ) const; - - - /// Scale and project the ith component of a vector on the mesh - /** - \param i The vector component number -- \b IN. - \param l The vector component value -- \b IN. - \return The ith component of a vector after mesh scaling and projection - */ - NOMAD::Double scale_and_project(int i, const NOMAD::Double & l) const ; - - - }; + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display ( const NOMAD::Display & out ) const; + + + /// Scale and project the ith component of a vector on the mesh + /** + \param i The vector component number -- \b IN. + \param l The vector component value -- \b IN. + \param round_up Flag for rounding up -- \b IN. + \return The ith component of a vector after mesh scaling and projection + */ + NOMAD::Double scale_and_project(int i, const NOMAD::Double & l, bool round_up ) const ; + + + }; } #endif diff --git a/src/Search.hpp b/src/Search.hpp index a7b6b2e87e0c7f94a7cb46e2d83bd701dacc4c76..034aed14f708cb24af68d9f135489385e1bb5476 100644 --- a/src/Search.hpp +++ b/src/Search.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,92 +41,93 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Search.hpp - \brief Generic class for search strategies (headers) - \author Sebastien Le Digabel - \date 2010-04-08 -*/ + \file Search.hpp + \brief Generic class for search strategies (headers) + \author Sebastien Le Digabel + \date 2010-04-08 + */ #ifndef __SEARCH__ #define __SEARCH__ #include "Evaluator_Control.hpp" namespace NOMAD { - - // Forward declarations. - class Mads; - - /// Generic class for search strategies. - /** - This is an abstract class (it is not possible to create NOMAD::Search objects). - */ - class Search { - - protected: - - NOMAD::Parameters & _p; ///< Parameters. - NOMAD::search_type _type; ///< Search type. - - public: - - /// Constructor. + + // Forward declarations. + class Mads; + + /// Generic class for search strategies. /** - \param p Parameters -- \b IN. - \param t Search type -- \b IN. - */ - Search ( NOMAD::Parameters & p , - NOMAD::search_type t ) - : _p ( p ) , - _type ( t ) {} - - /// Destructor. - virtual ~Search ( void ) {} - - /// The search. - /** - - Has to be implemented by every NOMAD::Search subclass. - - Pure virtual method. - \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. - \param nb_search_pts Number of generated search points -- \b OUT. - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - \param success Type of success -- \b OUT. - \param count_search Count or not the search -- \b OUT. - \param new_feas_inc New feasible incumbent -- \b IN/OUT. - \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. - */ - virtual void search - ( NOMAD::Mads & mads , - int & nb_search_pts , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - bool & count_search , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ) = 0; - - /// Reset. - virtual void reset ( void ) {} - - /// Display. + This is an abstract class (it is not possible to create NOMAD::Search objects). + */ + class Search { + + protected: + + NOMAD::Parameters & _p; ///< Parameters. + NOMAD::search_type _type; ///< Search type. + + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + \param t Search type -- \b IN. + */ + Search ( NOMAD::Parameters & p , + NOMAD::search_type t ) + : _p ( p ) , + _type ( t ) {} + + /// Destructor. + virtual ~Search ( void ) {} + + /// The search. + /** + - Has to be implemented by every NOMAD::Search subclass. + - Pure virtual method. + \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. + \param nb_search_pts Number of generated search points -- \b OUT. + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + \param success Type of success -- \b OUT. + \param count_search Count or not the search -- \b OUT. + \param new_feas_inc New feasible incumbent -- \b IN/OUT. + \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. + */ + virtual void search + ( NOMAD::Mads & mads , + int & nb_search_pts , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + bool & count_search , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ) = 0; + + /// Reset. + virtual void reset ( void ) {} + + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + */ + virtual void display ( const NOMAD::Display & out ) const {} + + }; + + /// Display a NOMAD::Search object. /** - \param out The NOMAD::Display object -- \b IN. - */ - virtual void display ( const NOMAD::Display & out ) const {} - - }; - - /// Display a NOMAD::Search object. - /** \param out The NOMAD::Display object -- \b IN. \param s The NOMAD::Search object to be displayed -- \b IN. \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Search & s ) { - s.display ( out ); - return out; - } - + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::Search & s ) + { + s.display ( out ); + return out; + } + } #endif diff --git a/src/Set_Element.hpp b/src/Set_Element.hpp index 092346af4f3f178807b2992029ad738b01b8199c..510dcf72595c87465875a9bb2cd8098600881be2 100644 --- a/src/Set_Element.hpp +++ b/src/Set_Element.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,132 +41,132 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Set_Element.hpp - \brief Element of a set (headers) - \author Sebastien Le Digabel - \date 2010-04-12 -*/ + \file Set_Element.hpp + \brief Element of a set (headers) + \author Sebastien Le Digabel + \date 2010-04-12 + */ #ifndef __SET_ELEMENT__ #define __SET_ELEMENT__ namespace NOMAD { - - // forward declarations: - class Double; - class Eval_Point; - - /// Generic class for elements of a \c std::set. - /** + + // forward declarations: + class Double; + class Eval_Point; + + /// Generic class for elements of a \c std::set. + /** This is an abstract class (it is not possible to create NOMAD::Set_Element objects). - */ - template <class T> - class Set_Element { - - private: - + */ + template <class T> + class Set_Element { + + private: + #ifdef MEMORY_DEBUG - static int _cardinality; ///< Number of NOMAD::Set_Element objects in memory. - static int _max_cardinality; ///< Max number of NOMAd::Set_Element objects in memory. + static int _cardinality; ///< Number of NOMAD::Set_Element objects in memory. + static int _max_cardinality; ///< Max number of NOMAd::Set_Element objects in memory. #endif - - const T * _el; ///< A pointer to the element. - - /// Affectation operator. - /** - \param se The right-hand side object -- \b IN. - */ - Set_Element & operator = ( const Set_Element & se ); - - /// Copy constructor. - /** - \param se The copied object -- \b IN. - */ - Set_Element ( const Set_Element & se ); - - public: - - /// Constructor. - /** - \param el A pointer on the element -- \b IN. - */ - explicit Set_Element ( const T * el ) : _el ( el ) - { + + const T * _el; ///< A pointer to the element. + + /// Affectation operator. + /** + \param se The right-hand side object -- \b IN. + */ + Set_Element & operator = ( const Set_Element & se ); + + /// Copy constructor. + /** + \param se The copied object -- \b IN. + */ + Set_Element ( const Set_Element & se ); + + public: + + /// Constructor. + /** + \param el A pointer on the element -- \b IN. + */ + explicit Set_Element ( const T * el ) : _el ( el ) + { #ifdef MEMORY_DEBUG - ++Set_Element::_cardinality; - if ( Set_Element::_cardinality > Set_Element::_max_cardinality ) - ++Set_Element::_max_cardinality; + ++Set_Element::_cardinality; + if ( Set_Element::_cardinality > Set_Element::_max_cardinality ) + ++Set_Element::_max_cardinality; #endif - } - - /// Destructor. - virtual ~Set_Element ( void ) - { + } + + /// Destructor. + virtual ~Set_Element ( void ) + { #ifdef MEMORY_DEBUG - --Set_Element::_cardinality; + --Set_Element::_cardinality; #endif - } - - /// Specific NOMAD::Priority_Eval_Point elements of comparison. - /** - - Only NOMAD::Priority_Eval_Point::get_priority_criteria() does something. - - \see Priority_Eval_Point.hpp . - \param c1 A real -- \b IN. - \param c2 A real -- \b IN. - \param c3 A real -- \b IN. - \param c4 A real -- \b IN. - \param c5 A real -- \b IN. - \param c6 A real -- \b IN. - */ - virtual void get_priority_criteria ( NOMAD::Double & c1 , - NOMAD::Double & c2 , - NOMAD::Double & c3 , - NOMAD::Double & c4 , - NOMAD::Double & c5 , - NOMAD::Double & c6 ) const {} - /// Comparison operator. - /** - - Has to be implemented by every NOMAD::Set_Element subclass. - - Pure virtual method. - \param se The right-hand side object -- \b IN. - */ - virtual bool operator < ( const Set_Element & se ) const = 0; - - /// Access to the element. - /** - \return A pointer to the element. - */ - const T * get_element ( void ) const { return _el; } - - /// Set an element. - /** - \param el A pointer to the element -- \b IN. - */ - void set_element ( const T * el ) { _el = el; } - + } + + /// Specific NOMAD::Priority_Eval_Point elements of comparison. + /** + - Only NOMAD::Priority_Eval_Point::get_priority_criteria() does something. + - \see Priority_Eval_Point.hpp . + \param c1 A real -- \b IN. + \param c2 A real -- \b IN. + \param c3 A real -- \b IN. + \param c4 A real -- \b IN. + \param c5 A real -- \b IN. + \param c6 A real -- \b IN. + */ + virtual void get_priority_criteria ( NOMAD::Double & c1 , + NOMAD::Double & c2 , + NOMAD::Double & c3 , + NOMAD::Double & c4 , + NOMAD::Double & c5 , + NOMAD::Double & c6 ) const {} + /// Comparison operator. + /** + - Has to be implemented by every NOMAD::Set_Element subclass. + - Pure virtual method. + \param se The right-hand side object -- \b IN. + */ + virtual bool operator < ( const Set_Element & se ) const = 0; + + /// Access to the element. + /** + \return A pointer to the element. + */ + const T * get_element ( void ) const { return _el; } + + /// Set an element. + /** + \param el A pointer to the element -- \b IN. + */ + void set_element ( const T * el ) { _el = el; } + #ifdef MEMORY_DEBUG - - /// Access to the number of NOMAD::Set_Element objects in memory. - /** - \return Number of NOMAD::Set_Element objects in memory. - */ - static int get_cardinality ( void ) { return Set_Element::_cardinality; } - - /// Access to the max number of NOMAD::Set_Element objects in memory. - /** - \return Max number of NOMAD::Set_Element objects in memory. - */ - static int get_max_cardinality ( void ) { return Set_Element::_max_cardinality; } - + + /// Access to the number of NOMAD::Set_Element objects in memory. + /** + \return Number of NOMAD::Set_Element objects in memory. + */ + static int get_cardinality ( void ) { return Set_Element::_cardinality; } + + /// Access to the max number of NOMAD::Set_Element objects in memory. + /** + \return Max number of NOMAD::Set_Element objects in memory. + */ + static int get_max_cardinality ( void ) { return Set_Element::_max_cardinality; } + #endif - }; - + }; + #ifdef MEMORY_DEBUG - - /// Initialization of _cardinality. - template<class T> int NOMAD::Set_Element<T>::_cardinality = 0; - - /// Initialization of _max_cardinality. - template<class T> int NOMAD::Set_Element<T>::_max_cardinality = 0; + + /// Initialization of _cardinality. + template<class T> int NOMAD::Set_Element<T>::_cardinality = 0; + + /// Initialization of _max_cardinality. + template<class T> int NOMAD::Set_Element<T>::_max_cardinality = 0; #endif } diff --git a/src/Signature.cpp b/src/Signature.cpp index cba5d264adf08725b8f026a83a3288323d235e1a..e2c9288b18a831956a6bbf12b7df0918d1391fc4 100644 --- a/src/Signature.cpp +++ b/src/Signature.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -57,49 +64,58 @@ bool NOMAD::Signature::_warning_has_been_displayed=false; /*--------------------------------------------------*/ /* constructor 1 */ /*--------------------------------------------------*/ -NOMAD::Signature::Signature -( int n , - const std::vector<NOMAD::bb_input_type> & input_types , - const NOMAD::Point & lb , - const NOMAD::Point & ub , - bool use_smesh , - bool anisotropic_mesh , - const NOMAD::Point & initial_poll_size , - const NOMAD::Point & min_poll_size , - const NOMAD::Point & min_mesh_size , - NOMAD::Double & mesh_update_basis , - NOMAD::Double & poll_update_basis , - int & mesh_coarsening_exponent, - int & mesh_refining_exponent, - int initial_mesh_index , - const NOMAD::Point & scaling , - const NOMAD::Point & fixed_variables , - const std::vector<bool> & periodic_variables, - std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & var_groups , - const NOMAD::Display & out ) +NOMAD::Signature::Signature ( int n , + const std::vector<NOMAD::bb_input_type> & input_types , + const NOMAD::Point & lb , + const NOMAD::Point & ub , + const NOMAD::mesh_type & mesh_type , + bool anisotropic_mesh , + const NOMAD::Point & granularity , + const NOMAD::Point & initial_poll_size , + const NOMAD::Point & min_poll_size , + const NOMAD::Point & min_mesh_size , + NOMAD::Double & mesh_update_basis , + NOMAD::Double & poll_update_basis , + int & mesh_coarsening_exponent , + int & mesh_refining_exponent , + int initial_mesh_index , + int limit_mesh_index , + const NOMAD::Point & scaling , + const NOMAD::Point & fixed_variables , + const std::vector<bool> & periodic_variables , + std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & var_groups , + const NOMAD::Display & out ) : _std ( false ) , _out ( out ) { - // Mesh index starts at 0 for an xmesh and decreases as the mesh size decreases + // Mesh index starts at 0 for xmesh and decreases as the mesh size decreases // The mesh index is reset to 0 as the mesh is reset. - if ( ! use_smesh ) - _mesh=new NOMAD::XMesh(anisotropic_mesh, + + if ( mesh_type == NOMAD::XMESH ) + _mesh=new NOMAD::XMesh( anisotropic_mesh, initial_poll_size, min_poll_size, min_mesh_size, fixed_variables, - poll_update_basis, // XMesh set poll update basis (default 2) + poll_update_basis, // XMesh sets poll update basis (default 2) mesh_coarsening_exponent, - mesh_refining_exponent); - else // Mesh index can be provided for isotropic smesh and increases as the mesh size decreases - _mesh=new NOMAD::SMesh(initial_poll_size, // new initial_poll_size ~ old initial mesh size + mesh_refining_exponent , + limit_mesh_index ); + + else if ( mesh_type == NOMAD::SMESH ) + // Mesh index can be provided for isotropic smesh and increases as the mesh size decreases + _mesh=new NOMAD::SMesh(initial_poll_size, // WARNING THIS IS NOT AN ERROR new initial_poll_size ~ old initial mesh size min_poll_size, min_mesh_size, fixed_variables, mesh_update_basis, // SMesh set mesh update basis (default 4) mesh_coarsening_exponent, mesh_refining_exponent, - initial_mesh_index ); + initial_mesh_index , + limit_mesh_index ); + else + throw NOMAD::Signature::Signature_Error ( "Signature.cpp" , __LINE__ , *this , + "NOMAD::Signature::Signature(): a valid mesh type must be given" ); init ( n , input_types , @@ -107,6 +123,7 @@ _out ( out ) ub , scaling , fixed_variables , + granularity , periodic_variables , var_groups ); @@ -120,29 +137,28 @@ _out ( out ) /*--------------------------------------------------*/ /* constructor 2 */ /*--------------------------------------------------*/ -NOMAD::Signature::Signature -( int n , - const std::vector<NOMAD::bb_input_type> & input_types , - const NOMAD::Point & initial_poll_size , - const NOMAD::Point & lb , - const NOMAD::Point & ub , - const std::set<NOMAD::direction_type> & direction_types , - const std::set<NOMAD::direction_type> & sec_poll_dir_types , - const NOMAD::Display & out ) -: _std ( false ) , +NOMAD::Signature::Signature ( int n , + const std::vector<NOMAD::bb_input_type> & input_types , + const NOMAD::Point & initial_poll_size , + const NOMAD::Point & lb , + const NOMAD::Point & ub , + const std::set<NOMAD::direction_type> & direction_types , + const std::set<NOMAD::direction_type> & sec_poll_dir_types , + const NOMAD::Display & out ) +: _std ( false ) , _out ( out ) { if ( static_cast<int> ( input_types.size() ) != n ) throw NOMAD::Signature::Signature_Error ( "Signature.cpp" , __LINE__ , *this , "NOMAD::Signature::Signature(): bad argument: input_types" ); - // Default mesh is isotropic xmesh + // For this constructor, the default mesh is isotropic xmesh //------------------------------------------ _mesh=new NOMAD::XMesh (false, initial_poll_size, NOMAD::Point(), NOMAD::Point(), - NOMAD::Point()); + NOMAD::Point(n)); // automatic creation of groups of variables: @@ -183,6 +199,7 @@ _out ( out ) ub , NOMAD::Point() , NOMAD::Point() , + NOMAD::Point() , std::vector<bool>() , var_groups ); @@ -208,10 +225,11 @@ NOMAD::Signature::Signature ( const NOMAD::Signature & s ) _ub ( s._ub ) , _scaling ( s._scaling ) , _fixed_variables ( s._fixed_variables ) , +_granularity ( s._granularity ) , _input_types ( s._input_types ) , _all_continuous ( s._all_continuous ) , -_has_categorical ( s._has_categorical ) , -_periodic_variables ( s._periodic_variables ) , +_has_categorical ( s._has_categorical ) , +_periodic_variables ( s._periodic_variables ) , _std ( false ) , _feas_success_dir ( s._feas_success_dir ) , _infeas_success_dir ( s._infeas_success_dir ) , @@ -219,10 +237,13 @@ _out (s._out) { - if (dynamic_cast<NOMAD::SMesh*> (s._mesh)) + if ( dynamic_cast<NOMAD::SMesh*> (s._mesh) ) _mesh = new NOMAD::SMesh (*(static_cast<NOMAD::SMesh*>(s._mesh))); - else + else if ( dynamic_cast<NOMAD::XMesh*> (s._mesh) ) _mesh = new NOMAD::XMesh (*(static_cast<NOMAD::XMesh*>(s._mesh))); + else + throw NOMAD::Signature::Signature_Error ( "Signature.cpp" , __LINE__ , *this , + "NOMAD::Signature::Signature(): copy constructor needs a valid mesh_type in the copied object" ); std::list<NOMAD::Variable_Group *>::const_iterator it , end = s._var_groups.end(); for ( it = s._var_groups.begin() ; it != end ; ++it ) @@ -263,6 +284,7 @@ void NOMAD::Signature::clear ( void ) _fixed_variables.clear(); _input_types.clear(); _periodic_variables.clear(); + _granularity.clear(); delete _mesh; } @@ -293,15 +315,15 @@ void NOMAD::Signature::set_infeas_success_dir ( const NOMAD::Direction & d ) /*--------------------------------------------------*/ /* initializations (private) */ /*--------------------------------------------------*/ -void NOMAD::Signature::init -( int n , - const std::vector<NOMAD::bb_input_type> & input_types , - const NOMAD::Point & lb , - const NOMAD::Point & ub , - const NOMAD::Point & scaling , - const NOMAD::Point & fixed_variables , - const std::vector<bool> & periodic_variables , - std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & var_groups ) +void NOMAD::Signature::init ( int n , + const std::vector<NOMAD::bb_input_type> & input_types , + const NOMAD::Point & lb , + const NOMAD::Point & ub , + const NOMAD::Point & scaling , + const NOMAD::Point & fixed_variables , + const NOMAD::Point & granularity , + const std::vector<bool> & periodic_variables , + std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & var_groups ) { // reset directions: _feas_success_dir.clear(); @@ -351,6 +373,14 @@ void NOMAD::Signature::init throw NOMAD::Signature::Signature_Error ( "Signature.cpp" , __LINE__ , *this , "NOMAD::Signature::init(): bad argument: fixed_variables" ); + if ( granularity.empty() ) + _granularity.reset(n,0) ; + else if ( granularity.size() == n ) + _granularity = granularity; + else + throw NOMAD::Signature::Signature_Error ( "Signature.cpp" , __LINE__ , *this , + "NOMAD::Signature::init(): bad argument: granularity" ); + // periodic variables: _periodic_variables = periodic_variables; if ( !_periodic_variables.empty() ) @@ -417,8 +447,6 @@ void NOMAD::Signature::init if ( _has_categorical ) break; } - - } // variable groups: @@ -436,8 +464,6 @@ void NOMAD::Signature::init "NOMAD::Signature::init(): incompatible variable group" ); } - - // if the indices in var_groups have been modified than var_groups is reconstructed to ensure proper ordering if ( mod ) { std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> tmp_var_groups; @@ -492,19 +518,51 @@ int NOMAD::Signature::get_nb_fixed_variables ( void ) const } +/*--------------------------------------------------------*/ +/* Access to the maximum number of points in the poll set */ +/*--------------------------------------------------------*/ +int NOMAD::Signature::get_max_size_poll_set ( void ) const +{ + int m=1; // There is at list one point (the poll center) + + NOMAD::Point delta=_mesh->get_delta(); + NOMAD::Point Delta=_mesh->get_Delta(); + + if ( delta.is_defined() && Delta.is_defined() ) + { + for (int i = 0 ; i < get_n() ; ++i ) + if ( ! _fixed_variables[i].is_defined() ) + { + NOMAD::Double r; + if ( _input_types[i] == NOMAD::CONTINUOUS ) + r=Delta[i]/delta[i]+1; + else if ( _input_types[i] == NOMAD::INTEGER ) + r=Delta[i]+1; + else if ( _input_types[i] == NOMAD::BINARY ) + r=2; + else if ( _input_types[i] == NOMAD::CATEGORICAL ) + r=1; + m= m * static_cast<int> ( r.floor().value() ); + } + } + + return m; +} + + /*--------------------------------------------------*/ /* reset */ /*--------------------------------------------------*/ -void NOMAD::Signature::reset -( int n , - const std::vector<NOMAD::bb_input_type> & input_types , - const NOMAD::Point & lb , - const NOMAD::Point & ub , - const NOMAD::Point & scaling , - const NOMAD::Point & fixed_variables , - const std::vector<bool> & periodic_variables , - std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & var_groups ) +void NOMAD::Signature::reset ( int n , + const std::vector<NOMAD::bb_input_type> & input_types , + const NOMAD::Point & lb , + const NOMAD::Point & ub , + const NOMAD::Point & scaling , + const NOMAD::Point & fixed_variables , + const NOMAD::Point & granularity , + const std::vector<bool> & periodic_variables , + std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & var_groups ) { reset_mesh(); reset_var_groups(); @@ -514,6 +572,7 @@ void NOMAD::Signature::reset ub , scaling , fixed_variables , + granularity , periodic_variables , var_groups ); } @@ -546,9 +605,9 @@ bool NOMAD::Signature::is_compatible ( const NOMAD::Point & x ) const /*-----------------------------------------------------*/ /* compute the directions */ /*-----------------------------------------------------*/ -void NOMAD::Signature::get_directions ( std::list<NOMAD::Direction> & dirs , - NOMAD::poll_type poll , - const NOMAD::Point & poll_center ) +void NOMAD::Signature::get_directions ( std::list<NOMAD::Direction> & dirs , + NOMAD::poll_type poll , + const NOMAD::Point & poll_center ) { NOMAD::Direction * pd; @@ -557,12 +616,12 @@ void NOMAD::Signature::get_directions ( std::list<NOMAD::Direction> & dirs , std::set<int>::const_iterator it_vi , end_vi; int n = get_n(); - NOMAD::Point delta=_mesh->get_delta ( ); - NOMAD::Point Delta=_mesh->get_Delta ( ); + NOMAD::Point delta = _mesh->get_delta ( ); + NOMAD::Point Delta = _mesh->get_Delta ( ); // Reset dir_group_index. - // For each signature, a variable_group has a unique set of directions generated and a unique dir_group_index starting by zero (-1 if no dirs) + // For each signature, a variable_group has a unique set of directions generated and a unique dir_group_index starting by zero (-1 if no dirs) _dir_group_index=-1; // loop on variable groups: @@ -577,8 +636,7 @@ void NOMAD::Signature::get_directions ( std::list<NOMAD::Direction> & dirs , (*it_vg)->get_directions ( dirs_nc , poll , *_mesh ); // _mesh of all directions - // scale with delta and resize the directions to size n; - // also round integer and binary variables: + // Scaling and projection on the mesh end_dir = dirs_nc.end(); if (static_cast<int>(dirs_nc.size())!=0) ++_dir_group_index; @@ -590,47 +648,179 @@ void NOMAD::Signature::get_directions ( std::list<NOMAD::Direction> & dirs , pd = &(*(--dirs.end())); end_vi = var_indexes.end(); - i = 0; + + i = 0; + NOMAD::Double normInfPoint=0; + for ( it_vi = var_indexes.begin() ; it_vi != end_vi ; ++it_vi ,++i ) + { + normInfPoint = std::max( normInfPoint.value() , std::fabs( (*it_dir)[i].value() ) ); + } - for ( it_vi = var_indexes.begin() ; it_vi != end_vi ; ++it_vi ,++i) + i = 0; + for ( it_vi = var_indexes.begin() ; it_vi != end_vi ; ++it_vi ,++i ) { - // Scaling and projection on the mesh - (*pd)[*it_vi] = _mesh->scale_and_project(*it_vi,(*it_dir)[i]); - - // integer variables: - if ( _input_types[*it_vi] == NOMAD::INTEGER ) + if ( _input_types[*it_vi] == NOMAD::BINARY ) { - if ( (*pd)[*it_vi] >= Delta[*it_vi]/3.0 ) - (*pd)[*it_vi] = (*pd)[*it_vi].ceil(); - else if ( (*pd)[*it_vi] <= -Delta[*it_vi]/3.0 ) - (*pd)[*it_vi] = (*pd)[*it_vi].floor(); + if ( (*it_dir)[i] < 0 ) + (*pd)[*it_vi] = 0.0; else - (*pd)[*it_vi] = (*pd)[*it_vi].round(); - } - - // binary variables: - else if ( _input_types[*it_vi] == NOMAD::BINARY ) - { - if ( (*pd)[*it_vi] != 0.0 ) (*pd)[*it_vi] = 1.0; } - // categorical variables: set direction=0: else if ( _input_types[*it_vi] == NOMAD::CATEGORICAL ) (*pd)[*it_vi] = 0.0; + else + { + { + + // Pickup 0, -1, 1 for the integer variable when Delta < 1.0 + if ( _input_types[*it_vi] == NOMAD::INTEGER && Delta[i] < 1.0 ) + { + if ( (*it_dir)[i] > 1.0/3.0 ) + (*pd)[*it_vi] = 1.0 ; + else if ( (*it_dir)[i] < -1.0/3.0 ) + (*pd)[*it_vi] = -1.0; + else + (*pd)[*it_vi] = 0.0; + + } + else + { + // Scaling and projection on the mesh + (*pd)[*it_vi] = _mesh->scale_and_project(*it_vi,(*it_dir)[i]); + + // round for integer variables: + if ( _input_types[*it_vi] == NOMAD::INTEGER ) + { + if ( (*pd)[*it_vi] >= Delta[*it_vi]/3.0 ) + (*pd)[*it_vi] = (*pd)[*it_vi].ceil(); + else if ( (*pd)[*it_vi] <= -Delta[*it_vi]/3.0 ) + (*pd)[*it_vi] = (*pd)[*it_vi].floor(); + else + (*pd)[*it_vi] = (*pd)[*it_vi].round(); + } + } + } + } + } } } } + +/*-----------------------------------------------------------------------------------*/ +/* compute one ORTHO 1 direction for a random group of variable */ +/*-----------------------------------------------------------------------------------*/ +void NOMAD::Signature::get_variable_group_direction ( NOMAD::Direction & dir , + const NOMAD::Point & poll_center ) +{ + + std::set<int>::const_iterator it_vi , end_vi; + + NOMAD::Point delta=_mesh->get_delta ( ); + NOMAD::Point Delta=_mesh->get_Delta ( ); + + + // Reset dir_group_index. + // For each signature, a variable_group has a unique set of directions generated and a unique dir_group_index starting by zero (-1 if no dirs) + _dir_group_index=1; + + size_t n_vg=_var_groups.size(); + int var_group_id=0; + + // Select a variable group; + if ( n_vg > 1 ) + var_group_id=NOMAD::RNG::rand() % n_vg; + + std::list<NOMAD::Variable_Group*>::const_iterator it_vg=_var_groups.begin(); + std::advance(it_vg, var_group_id); + + // scale with delta and resize the directions to size n; + // also round integer and binary variables: + const std::set<int> & var_indexes = (*it_vg)->get_var_indexes(); + NOMAD::Direction dir_nc ( static_cast<int>(var_indexes.size()) , 0.0 , NOMAD::ORTHO_1 ); + + // get a direction INSIDE a unit nc-sphere + if ( (*it_vg)->get_one_direction ( dir_nc ) ) // Get a direction ON a unit nc-sphere + { + + // Randomly scale the direction to be inside the unit nc-sphere + NOMAD::Double s = NOMAD::RNG::rand(0,1); + + // Make sure to have s!=0 + while ( s==0 ) + s=NOMAD::RNG::rand(0,1); + + NOMAD::Double normInfPoint=0; + for ( int i=0; i < static_cast<int>(var_indexes.size()) ; ++i ) + { + normInfPoint = std::max( normInfPoint.value() , std::fabs( (dir_nc)[i].value() ) ); + } + + end_vi = var_indexes.end(); + int i = 0; + for ( it_vi = var_indexes.begin() ; it_vi != end_vi ; ++it_vi ,++i) + { + + if ( _input_types[*it_vi] == NOMAD::BINARY ) + { + if ( dir_nc[i] < 0 ) + dir_nc[*it_vi] = 0.0; + else + dir_nc[*it_vi] = 1.0; + } + // categorical variables: set direction=0: + else if ( _input_types[*it_vi] == NOMAD::CATEGORICAL ) + dir[*it_vi] = 0.0; + else + { + + // Scaling and projection on the mesh ---> round up to prevent getting the current incumbent (0<s<=1) + { + + // Pickup 0, -1, 1 for the integer variable when Delta < 1.0 + if ( _input_types[*it_vi] == NOMAD::INTEGER && Delta[i] < 1.0 ) + { + if ( dir_nc[i] > 1.0/3.0 ) + dir[*it_vi] = 1.0 ; + else if ( dir_nc[i] < -1.0/3.0 ) + dir[*it_vi] = -1.0; + else + dir[*it_vi] = 0.0; + + } + else + { + + dir[*it_vi] = _mesh->scale_and_project( *it_vi, dir_nc[i] * s, true); + + // integer variables: + if ( _input_types[*it_vi] == NOMAD::INTEGER ) + { + if ( dir[*it_vi] >= Delta[*it_vi]/3.0 ) + dir[*it_vi] = dir[*it_vi].ceil(); + else if ( dir[*it_vi] <= -Delta[*it_vi]/3.0 ) + dir[*it_vi] = dir[*it_vi].floor(); + else + dir[*it_vi] = dir[*it_vi].round(); + } + } + } + } + } + } + +} + + /*----------------------------------------------------------------*/ /* get just one direction for a given mesh (used by VNS search) */ /*----------------------------------------------------------------*/ -void NOMAD::Signature::get_one_direction ( NOMAD::Direction & dir , int ell) const +void NOMAD::Signature::get_one_direction ( NOMAD::Direction & dir , int ell) { - int i; std::set<int>::const_iterator it_vi , end_vi; // get delta_m (mesh size parameter): @@ -641,10 +831,10 @@ void NOMAD::Signature::get_one_direction ( NOMAD::Direction & dir , int ell) con dir.reset ( n , 0.0 ); dir.set_type ( NOMAD::UNDEFINED_DIRECTION ); - // The mesh indices are modified and must be reset properly once the one direction is obtained - const NOMAD::Point old_mesh_indices=_mesh->get_mesh_indices(); - NOMAD::Point modified_mesh_indices(n,NOMAD::Double(ell)); - _mesh->set_mesh_indices(modified_mesh_indices); + // The mesh indices are modified and will be reset properly once the one direction is obtained + const NOMAD::Point old_mesh_indices = _mesh->get_mesh_indices(); + NOMAD::Point modified_mesh_indices( n , NOMAD::Double(ell) ); + _mesh->set_mesh_indices( modified_mesh_indices ); // loop on variable groups: std::list<NOMAD::Variable_Group*>::const_iterator end_vg = _var_groups.end() , it_vg; @@ -653,52 +843,75 @@ void NOMAD::Signature::get_one_direction ( NOMAD::Direction & dir , int ell) con const std::set<int> & var_indexes = (*it_vg)->get_var_indexes(); - // get the direction for the current group of variables: NOMAD::Direction dir_nc ( static_cast<int>(var_indexes.size()) , 0.0 , NOMAD::UNDEFINED_DIRECTION ); // get a direction on a unit nc-sphere if ( (*it_vg)->get_one_direction ( dir_nc ) ) { - // scale with delta_m and round integer and binary variables: + + NOMAD::Double normInfPoint=0; + for ( int i=0; i < static_cast<int>(var_indexes.size()) ; ++i ) + { + normInfPoint = std::max( normInfPoint.value() , std::fabs( (dir_nc)[i].value() ) ); + } + + + // scale with delta and round integer and binary variables: end_vi = var_indexes.end(); - i = 0; - for ( it_vi = var_indexes.begin() ; it_vi != end_vi ; ++it_vi ) + int i = 0; + for ( it_vi = var_indexes.begin() ; it_vi != end_vi ; ++it_vi, ++i ) { - dir[*it_vi]=_mesh->scale_and_project(*it_vi,dir_nc[i++]); - - - // integer variables: - if ( _input_types[*it_vi] == NOMAD::INTEGER ) + if ( _input_types[*it_vi] == NOMAD::BINARY ) { - if ( dir[*it_vi] >= Delta[*it_vi]/3.0 ) - dir[*it_vi] = ceil ( dir[*it_vi].value() ); - else if ( dir [*it_vi] <= -Delta[*it_vi]/3.0 ) - dir[*it_vi] = floor ( dir[*it_vi].value() ); + if ( dir_nc[i] < 0 ) + dir[*it_vi] = 0.0; else - { - double x=dir[*it_vi].value(); - dir[*it_vi] = (x>0)? floor(x+0.5): ceil(x-0.5); - } - } - - // binary variables: - else if ( _input_types[*it_vi] == NOMAD::BINARY ) - { - if ( dir[*it_vi] != 0.0 ) dir[*it_vi] = 1.0; } - // categorical variables: set direction=0: else if ( _input_types[*it_vi] == NOMAD::CATEGORICAL ) dir[*it_vi] = 0.0; + else + { + { + // Pickup 0, -1, 1 for the integer variable when Delta < 1.0 + if ( _input_types[*it_vi] == NOMAD::INTEGER && Delta[i] < 1.0 ) + { + if ( dir_nc[i] > 1.0/3.0 ) + dir[*it_vi] = 1.0 ; + else if ( dir_nc[i] < -1.0/3.0 ) + dir[*it_vi] = -1.0; + else + dir[*it_vi] = 0.0; + + } + else + { + + + dir[*it_vi]=_mesh->scale_and_project(*it_vi , dir_nc[i]); + + // integer variables: + if ( _input_types[*it_vi] == NOMAD::INTEGER ) + { + if ( dir[*it_vi] >= Delta[*it_vi]/3.0 ) + dir[*it_vi] = dir[*it_vi].ceil() ; + else if ( dir [*it_vi] <= -Delta[*it_vi]/3.0 ) + dir[*it_vi] = dir[*it_vi].floor(); + else + dir[*it_vi] = dir[*it_vi].round(); + } + } + } + } } } } // Reset the mesh indices to their previous values - _mesh->set_mesh_indices(old_mesh_indices); + _mesh->set_mesh_indices( old_mesh_indices ); } /*----------------------------------*/ @@ -840,7 +1053,7 @@ bool NOMAD::Signature::treat_periodic_variables ( NOMAD::Point & x { if ( bbit == NOMAD::INTEGER ) - new_x.round(); + new_x = new_x.round(); if (new_dir) (*new_dir)[i] += new_x - xi; @@ -1058,6 +1271,14 @@ bool NOMAD::Signature::operator < ( const NOMAD::Signature & s ) const if ( !p1_empty && _periodic_variables[i] != s._periodic_variables[i] ) return _periodic_variables[i]; + // granularity: + // ------------------- + if ( _granularity[i].comp_with_undef ( s._granularity[i] ) ) + return true; + if ( s._granularity[i].comp_with_undef ( _granularity[i] ) ) + return false; + + // mesh: // ----- if ( _mesh->get_initial_mesh_size() != s._mesh->get_initial_mesh_size() && diff --git a/src/Signature.hpp b/src/Signature.hpp index 44dcd320b3df51769aad0f7459535c9d4f751f13..a779202fd8f4db145f1c441c85b0c7e83437e699 100644 --- a/src/Signature.hpp +++ b/src/Signature.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -61,6 +68,7 @@ namespace NOMAD { NOMAD::Point _ub; ///< Upper bounds. NOMAD::Point _scaling; ///< Scaling. NOMAD::Point _fixed_variables; ///< Fixed variables. + NOMAD::Point _granularity; ///< Granularity of variables. std::vector<NOMAD::bb_input_type> _input_types; ///< Input types. @@ -117,18 +125,19 @@ namespace NOMAD { \param ub Upper bounds -- \b IN. \param scaling Scaling -- \b IN. \param fixed_variables Fixed variables -- \b IN. + \param granularity Min granularity of var -- \b IN. \param periodic_variables Periodic variables -- \b IN. \param var_groups Groups of variables -- \b IN. */ - void init - ( int n , - const std::vector<NOMAD::bb_input_type> & input_types , - const NOMAD::Point & lb , - const NOMAD::Point & ub , - const NOMAD::Point & scaling , - const NOMAD::Point & fixed_variables , - const std::vector<bool> & periodic_variables , - std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & var_groups ); + void init ( int n , + const std::vector<NOMAD::bb_input_type> & input_types , + const NOMAD::Point & lb , + const NOMAD::Point & ub , + const NOMAD::Point & scaling , + const NOMAD::Point & fixed_variables , + const NOMAD::Point & granularity , + const std::vector<bool> & periodic_variables , + std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & var_groups ); /// Reset groups of variables. void reset_var_groups ( void ); @@ -165,47 +174,49 @@ namespace NOMAD { /// Constructor #1. /** Advanced version. - \param n Number of variables -- \b IN. - \param input_types Types of the variables -- \b IN. - \param use_smesh Type of mesh (SMesh, XMesh) -- \b IN. - \param anisotropic_mesh Anisotropy of mesh (XMesh) -- \b IN. - \param initial_poll_size Initial poll size -- \b IN. - \param min_poll_size Minimum poll size -- \b IN. - \param min_mesh_size Minimim mesh size -- \b IN. - \param mesh_update_basis Mesh update basis -- \b IN. - \param poll_update_basis Poll update basis -- \b IN. - \param mesh_coarsening_exponent Mesh coarsening exponent -- \b IN. - \param mesh_refining_exponent Mesh refining exponent -- \b IN. - \param initial_mesh_index Initial mesh index -- \b IN. - \param lb Lower bounds -- \b IN. - \param ub Upper bounds -- \b IN. - \param scaling Scaling -- \b IN. - \param fixed_variables Fixed variables -- \b IN. - \param periodic_variables Periodic variables -- \b IN. - \param var_groups Groups of variables -- \b IN. - \param out Display -- \b IN. - */ - Signature - ( int n , - const std::vector<NOMAD::bb_input_type> & input_types , - const NOMAD::Point & lb , - const NOMAD::Point & ub , - bool use_smesh , - bool anisotropic_mesh , - const NOMAD::Point & initial_poll_size , - const NOMAD::Point & min_poll_size , - const NOMAD::Point & min_mesh_size , - NOMAD::Double & mesh_update_basis , - NOMAD::Double & poll_update_basis , - int & mesh_coarsening_exponent, - int & mesh_refining_exponent, - int initial_mesh_index , - const NOMAD::Point & scaling , - const NOMAD::Point & fixed_variables , - const std::vector<bool> & periodic_variables, - std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & var_groups , - const NOMAD::Display & out=NOMAD::Display() - ); + \param n Number of variables -- \b IN. + \param input_types Types of the variables -- \b IN. + \param mesh_type Type of mesh (SMesh,XMesh,GMesh)-- \b IN. + \param anisotropic_mesh Anisotropy of mesh (XMesh) -- \b IN. + \param granularity Gramularity of variables -- \b IN. + \param initial_poll_size Initial poll size -- \b IN. + \param min_poll_size Minimum poll size -- \b IN. + \param min_mesh_size Minimim mesh size -- \b IN. + \param mesh_update_basis Mesh update basis -- \b IN. + \param poll_update_basis Poll update basis -- \b IN. + \param mesh_coarsening_exponent Mesh coarsening exponent -- \b IN. + \param mesh_refining_exponent Mesh refining exponent -- \b IN. + \param initial_mesh_index Initial mesh index -- \b IN. + \param limit_mesh_index Limit mesh index -- \b IN. + \param lb Lower bounds -- \b IN. + \param ub Upper bounds -- \b IN. + \param scaling Scaling -- \b IN. + \param fixed_variables Fixed variables -- \b IN. + \param periodic_variables Periodic variables -- \b IN. + \param var_groups Groups of variables -- \b IN. + \param out Display -- \b IN. + */ + Signature ( int n , + const std::vector<NOMAD::bb_input_type> & input_types , + const NOMAD::Point & lb , + const NOMAD::Point & ub , + const NOMAD::mesh_type & mesh_type , + bool anisotropic_mesh , + const NOMAD::Point & granularity , + const NOMAD::Point & initial_poll_size , + const NOMAD::Point & min_poll_size , + const NOMAD::Point & min_mesh_size , + NOMAD::Double & mesh_update_basis , + NOMAD::Double & poll_update_basis , + int & mesh_coarsening_exponent, + int & mesh_refining_exponent, + int initial_mesh_index, + int limit_mesh_index , + const NOMAD::Point & scaling , + const NOMAD::Point & fixed_variables , + const std::vector<bool> & periodic_variables, + std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & var_groups , + const NOMAD::Display & out=NOMAD::Display() ); /// Constructor #2. /** @@ -219,15 +230,14 @@ namespace NOMAD { \param sec_poll_dir_types Types of directions for secondary poll -- \b IN. \param out Display -- \b IN. */ - Signature ( int n , + Signature ( int n , const std::vector<NOMAD::bb_input_type> & input_types , - const NOMAD::Point & initial_poll_size , + const NOMAD::Point & initial_poll_size , const NOMAD::Point & lb , const NOMAD::Point & ub , const std::set<NOMAD::direction_type> & direction_types , const std::set<NOMAD::direction_type> & sec_poll_dir_types , - const NOMAD::Display & out = NOMAD::Display() - ); + const NOMAD::Display & out = NOMAD::Display() ); /// Copy constructor. /** @@ -246,18 +256,19 @@ namespace NOMAD { \param ub Upper bounds -- \b IN. \param scaling Scaling -- \b IN. \param fixed_variables Fixed variables -- \b IN. + \param granularity Gramularity of var -- \b IN. \param periodic_variables Periodic variables -- \b IN. \param var_groups Groups of variables -- \b IN. */ - void reset - ( int n , - const std::vector<NOMAD::bb_input_type> & input_types , - const NOMAD::Point & lb , - const NOMAD::Point & ub , - const NOMAD::Point & scaling , - const NOMAD::Point & fixed_variables , - const std::vector<bool> & periodic_variables , - std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & var_groups ); + void reset ( int n , + const std::vector<NOMAD::bb_input_type> & input_types , + const NOMAD::Point & lb , + const NOMAD::Point & ub , + const NOMAD::Point & scaling , + const NOMAD::Point & fixed_variables , + const NOMAD::Point & granularity , + const std::vector<bool> & periodic_variables , + std::set<NOMAD::Variable_Group*,NOMAD::VG_Comp> & var_groups ); /// Define a signature to be standard. void set_std ( void ) { _std = true; } @@ -315,7 +326,7 @@ namespace NOMAD { (after the treatment; may be \c NULL) -- \b OUT. \return A boolean equal to \c true if \c x has been modified. */ - bool treat_periodic_variables ( NOMAD::Point & x , + bool treat_periodic_variables ( NOMAD::Point & x , const NOMAD::Direction * old_dir , NOMAD::Direction *& new_dir ); @@ -331,6 +342,13 @@ namespace NOMAD { */ const NOMAD::Point & get_ub ( void ) const { return _ub; } + /// Access to the granularity. + /** + \return The granularity. + */ + const NOMAD::Point & get_granularity ( void ) const { return _granularity; } + + /// Access to the mesh. /** \return The orthogonal mesh. @@ -340,8 +358,8 @@ namespace NOMAD { /// Update the Mesh (poll and mesh sizes). /** - \param success Type of success of the iteration -- \b IN. - \param dir Direction of the iteration (optional) -- \b IN. + \param success Type of success of the iteration -- \b IN. + \param dir Direction of the iteration (optional) -- \b IN. */ void update_mesh ( NOMAD::success_type success, const NOMAD::Direction * dir=NULL ) { @@ -357,8 +375,10 @@ namespace NOMAD { /** /param mesh_indices */ - void reset_mesh ( NOMAD::Point & mesh_indices ) { _mesh->set_mesh_indices( mesh_indices); } - + void reset_mesh ( NOMAD::Point & mesh_indices ) + { + _mesh->set_mesh_indices( mesh_indices); + } /// Access to the scaling. /** @@ -380,6 +400,12 @@ namespace NOMAD { int get_nb_fixed_variables ( void ) const; + /// Access to the maximum number points in the poll set. + /** + \return The maximum number of points in the poll set. + */ + int get_max_size_poll_set( void ) const; + /// Access to the feasible successful direction. /** @@ -443,15 +469,6 @@ namespace NOMAD { return _input_types; } - /// Access to the input types. - /** - \return The input types. - */ - const std::vector<NOMAD::bb_input_type> & get_input_type ( void ) const - { - return _input_types; - } - /// Access to the groups of variables. /** \return The groups of variables. @@ -461,7 +478,6 @@ namespace NOMAD { return _var_groups; } - /// Check the compatibility of a point. /** - Only the number of variables is checked. @@ -473,26 +489,36 @@ namespace NOMAD { */ bool is_compatible ( const NOMAD::Point & x ) const; + /// Access to the directions. /** - - The computed directions already include Delta^k_m. + - The computed directions already include delta^k. \param dirs List of directions -- \b OUT. \param poll Type of poll (primary or secondary) -- \b IN. \param poll_center Poll center -- \b IN. */ - void get_directions ( std::list<NOMAD::Direction> & dirs , - NOMAD::poll_type poll , - const NOMAD::Point & poll_center ); + void get_directions ( std::list<NOMAD::Direction> & dirs , + NOMAD::poll_type poll , + const NOMAD::Point & poll_center ); + /// Access to a direction for a random variable group. + /** + - The computed direction already include delta^k. + \param dir The direction -- \b OUT. + \param poll_center Poll center -- \b IN. + */ + void get_variable_group_direction ( NOMAD::Direction & dir , + const NOMAD::Point & poll_center ); + /// Access to one direction for a given mesh. /** Used for example in the VNS search. \param dir The direction -- \b OUT. \param mesh_index Mesh index ell -- \b IN. */ - void get_one_direction ( NOMAD::Direction & dir , - int mesh_index ) const; + void get_one_direction ( NOMAD::Direction & dir , + int mesh_index ) ; /// Comparison operator \c < . @@ -543,7 +569,8 @@ namespace NOMAD { \return The NOMAD::Display object. */ inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Signature & s ) { + const NOMAD::Signature & s ) + { s.display ( out ); return out; } diff --git a/src/Signature_Element.hpp b/src/Signature_Element.hpp index fa0357d8b9709213ed1fc7c3c6ae83ae3928eee8..c6e1a037b10cd9d07dd018b89ece732469daa47c 100644 --- a/src/Signature_Element.hpp +++ b/src/Signature_Element.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ diff --git a/src/Single_Obj_Quad_Model_Evaluator.hpp b/src/Single_Obj_Quad_Model_Evaluator.hpp index 7580717ad9f593d9449858103a180ee54c021757..af4d42934643450e743abae9fd14a021468c10d7 100644 --- a/src/Single_Obj_Quad_Model_Evaluator.hpp +++ b/src/Single_Obj_Quad_Model_Evaluator.hpp @@ -1,8 +1,8 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ +/* Copyright (C) 2001-2015 Mark Abramson - Brigham Young University, Provo */ /* Charles Audet - Ecole Polytechnique, Montreal */ /* Gilles Couture - Ecole Polytechnique, Montreal */ /* John Dennis - Rice University, Houston */ @@ -37,7 +37,7 @@ /** \file Single_Obj_Quad_Model_Evaluator.hpp \brief NOMAD::Evaluator subclass for quadratic model optimization (headers) - \author Christophe Tribes + \author Christophe Tribes \date 2014-06-19 \see Single_Obj_Quad_Model_Evaluator.cpp */ @@ -48,37 +48,37 @@ #include "Evaluator.hpp" namespace NOMAD { - - /// Single objective NOMAD::Evaluator subclass for quadratic model. - class Single_Obj_Quad_Model_Evaluator : public NOMAD::Quad_Model_Evaluator, public NOMAD::Evaluator { - - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - \param model Model -- \b IN. - */ - Single_Obj_Quad_Model_Evaluator ( const NOMAD::Parameters & p , - const NOMAD::Quad_Model & model ) : NOMAD::Quad_Model_Evaluator(p,model),NOMAD::Evaluator(p){_is_model_evaluator=true;} - - /// Destructor. - virtual ~Single_Obj_Quad_Model_Evaluator ( void ){;} - - - /// Evaluate the blackboxes quad model at a given trial point - /** - \param x point to evaluate -- \b IN/OUT. - \param h_max h_max for barrier -- \b IN. - \param count_eval Count eval if true -- \b IN. - */ - virtual bool eval_x ( NOMAD::Eval_Point & x , - const NOMAD::Double & h_max , - bool & count_eval ) const {return Quad_Model_Evaluator::eval_x(x,h_max,count_eval);} - - - - }; + + /// Single objective NOMAD::Evaluator subclass for quadratic model. + class Single_Obj_Quad_Model_Evaluator : public NOMAD::Quad_Model_Evaluator, public NOMAD::Evaluator { + + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + \param model Model -- \b IN. + */ + Single_Obj_Quad_Model_Evaluator ( const NOMAD::Parameters & p , + const NOMAD::Quad_Model & model ) : NOMAD::Quad_Model_Evaluator(p,model),NOMAD::Evaluator(p){_is_model_evaluator=true;} + + /// Destructor. + virtual ~Single_Obj_Quad_Model_Evaluator ( void ){;} + + + /// Evaluate the blackboxes quad model at a given trial point + /** + \param x point to evaluate -- \b IN/OUT. + \param h_max h_max for barrier -- \b IN. + \param count_eval Count eval if true -- \b IN. + */ + virtual bool eval_x ( NOMAD::Eval_Point & x , + const NOMAD::Double & h_max , + bool & count_eval ) const {return Quad_Model_Evaluator::eval_x(x,h_max,count_eval);} + + + + }; } #endif diff --git a/src/Slave.cpp b/src/Slave.cpp index cb73ff58c1ed109158ef7d25385864e6bad6073b..b9c279926100edc6b669a7ad8688cb9a0fb37f3b 100644 --- a/src/Slave.cpp +++ b/src/Slave.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -66,7 +73,8 @@ void NOMAD::Slave::init ( void ) const #endif // Slave::force_quit() will be called if ctrl-c is pressed: - if ( !NOMAD::Slave::is_master() ) { + if ( !NOMAD::Slave::is_master() ) + { NOMAD::Evaluator::force_quit(); @@ -84,7 +92,8 @@ void NOMAD::Slave::init ( void ) const /*----------------------------------------*/ int NOMAD::Slave::get_rank ( void ) { - if ( NOMAD::Slave::_rank < 0 ) { + if ( NOMAD::Slave::_rank < 0 ) + { #ifdef USE_MPI MPI_Comm_rank ( MPI_COMM_WORLD, &NOMAD::Slave::_rank ); #else @@ -100,7 +109,8 @@ int NOMAD::Slave::get_rank ( void ) /*----------------------------------------*/ int NOMAD::Slave::get_nb_processes ( void ) { - if ( NOMAD::Slave::_np < 0 ) { + if ( NOMAD::Slave::_np < 0 ) + { #ifdef USE_MPI MPI_Comm_size ( MPI_COMM_WORLD, &NOMAD::Slave::_np ); #else @@ -122,7 +132,8 @@ void NOMAD::Slave::run ( void ) const NOMAD::Eval_Point * x = NULL; bool count_eval = false; - while ( true ) { + while ( true ) + { // receive signal from master: // --------------------------- @@ -135,7 +146,8 @@ void NOMAD::Slave::run ( void ) const // EVAL signal: // ------------ - if ( signal == NOMAD::EVAL_SIGNAL ) { + if ( signal == NOMAD::EVAL_SIGNAL ) + { // receive and evaluate the point: x = eval_point ( count_eval ); @@ -161,7 +173,8 @@ void NOMAD::Slave::run ( void ) const // WAIT signal: // ------------ - // else if ( signal == NOMAD::WAIT_SIGNAL ) { + // else if ( signal == NOMAD::WAIT_SIGNAL ) + //{ // } } @@ -195,7 +208,8 @@ void NOMAD::Slave::init_slaves ( const NOMAD::Display & out ) NOMAD::Clock clk; // 1. launch requests: - for ( source = 1 ; source < NOMAD::Slave::_np ; ++source ) { + for ( source = 1 ; source < NOMAD::Slave::_np ; ++source ) + { req[source] = new MPI_Request; NOMAD::Slave::receive_data ( &signal , 1 , MPI_CHAR , source , req[source] ); if ( display_degree == NOMAD::FULL_DISPLAY ) @@ -302,7 +316,8 @@ void NOMAD::Slave::stop_slaves ( const NOMAD::Display & out ) MPI_Request ** req = new MPI_Request * [ NOMAD::Slave::_np ]; // 1. launch requests: - for ( source = 1 ; source < NOMAD::Slave::_np ; ++source ) { + for ( source = 1 ; source < NOMAD::Slave::_np ; ++source ) + { req[source] = new MPI_Request; NOMAD::Slave::receive_data ( &signal , 1 , MPI_CHAR , source , req[source] ); if ( display_degree == NOMAD::FULL_DISPLAY ) @@ -311,15 +326,19 @@ void NOMAD::Slave::stop_slaves ( const NOMAD::Display & out ) // 2. test requests (with a maximal delay of MAX_REQ_WAIT): int cnt = 0 , flag; - while ( nb_stopped < nb_slaves && clk.get_real_time() < NOMAD::MAX_REQ_WAIT ) { + while ( nb_stopped < nb_slaves && clk.get_real_time() < NOMAD::MAX_REQ_WAIT ) + { - for ( source = 1 ; source < NOMAD::Slave::_np ; ++source ) { + for ( source = 1 ; source < NOMAD::Slave::_np ; ++source ) + { - if ( req[source] ) { + if ( req[source] ) + { MPI_Test ( req[source] , &flag , &status ); - if ( flag ) { + if ( flag ) + { MPI_Wait ( req[source] , &status ); @@ -342,8 +361,10 @@ void NOMAD::Slave::stop_slaves ( const NOMAD::Display & out ) NOMAD::Slave::_stop_ok = true; // 3. delete requests: - for ( source = 1 ; source < NOMAD::Slave::_np ; ++source ) { - if ( req[source] ) { + for ( source = 1 ; source < NOMAD::Slave::_np ; ++source ) + { + if ( req[source] ) + { MPI_Cancel ( req[source] ); delete req[source]; NOMAD::Slave::_stop_ok = false; @@ -371,7 +392,8 @@ int NOMAD::Slave::receive_data ( void * buf , int tag = ( NOMAD::Slave::is_master() ) ? source : NOMAD::Slave::get_rank(); // immediate receive: - if ( req ) { + if ( req ) + { if ( source == MPI_ANY_SOURCE ) throw NOMAD::Exception ( "Slave.cpp" , __LINE__ , "Slave::receive_data(): immediate receive with no source" ); @@ -379,7 +401,8 @@ int NOMAD::Slave::receive_data ( void * buf , } // normal receive: - else { + else + { MPI_Status status; if ( source == MPI_ANY_SOURCE ) tag = MPI_ANY_TAG; @@ -459,7 +482,8 @@ NOMAD::Eval_Point * NOMAD::Slave::eval_point ( bool & count_eval ) const try { eval_ok = _ev->eval_x ( *x , h_max , count_eval ); } - catch ( ... ) { + catch ( ... ) + { eval_ok = false; } @@ -485,12 +509,15 @@ void NOMAD::Slave::send_eval_result ( const NOMAD::Eval_Point * x , const NOMAD::Point & bbo = x->get_bb_outputs(); // bb_outputs (m values): - for ( int i = 0 ; i < m ; ++i ) { - if ( bbo[i].is_defined() ) { + for ( int i = 0 ; i < m ; ++i ) + { + if ( bbo[i].is_defined() ) + { dtab[i ] = bbo[i].value(); dtab[i+m] = 1.0; } - else { + else + { dtab[i ] = NOMAD::INF; dtab[i+m] = -1.0; } diff --git a/src/Slave.hpp b/src/Slave.hpp index 03ae58a9f7cf9d50a6d850051f9f50d92b3f0d4b..62a9d6dfe66e68f21c35558891926053cce6137b 100644 --- a/src/Slave.hpp +++ b/src/Slave.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,213 +41,217 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Slave.hpp - \brief Slave process (headers) - \author Sebastien Le Digabel - \date 2010-04-22 - \see Slave.cpp -*/ + \file Slave.hpp + \brief Slave process (headers) + \author Sebastien Le Digabel + \date 2010-04-22 + \see Slave.cpp + */ #ifndef __SLAVE__ #define __SLAVE__ #include "Evaluator.hpp" namespace NOMAD { - - /// Slave process for the parallel version. - class Slave : private NOMAD::Uncopyable { - - private: - - static int _rank; /// Process rank. - static int _np; /// Number of processes. - - static int _data_sent; /// Stats on the sent data. - static int _data_rcvd; /// Stats on the received data. - - static bool _are_running; ///< \c true if the slaves are running. - static bool _stop_ok; ///< \c true if the slaves stopped without error. - - const NOMAD::Parameters * _p; ///< Parameters (may be NULL). - NOMAD::Evaluator * _ev; ///< Evaluator (may be NULL). - - /// Initializations. - void init ( void ) const; - - /// Force quit. - /** - - Called by pressing Ctrl-C. - - Does nothing: the slave will be stopped by the master. - \param signalValue Signal value -- \b IN. - */ - static void force_quit ( int signalValue ) {} - - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - \param ev A pointer to an evaluator -- \b IN. - */ - Slave ( const NOMAD::Parameters & p , NOMAD::Evaluator * ev ) - { _p=&p; _ev=ev; init(); } - - /// Destructor. - virtual ~Slave ( void ) {} - - /// Run the slave code. - void run ( void ) const; - - /// Access to the stat \c _data_sent. - /** - \return The stat \c _data_sent. - */ - static int get_data_sent ( void ) { return Slave::_data_sent; } - - /// Access to the stat \c _data_rcvd. - /** - \return The stat \c _data_rcvd. - */ - static int get_data_rcvd ( void ) { return Slave::_data_rcvd; } - /// Access to the process rank. - /** - \return The process rank. - */ - static int get_rank ( void ); - - /// Access to the number of processes. - /** - \return The number of processes. - */ - static int get_nb_processes ( void ); - - /// Check if the slaves are running. - /** - \return A boolean equal to \c true if the slaves are running. - */ - static bool are_running ( void ) { return _are_running; } - - /// Check if the current slave is the master. - /** - \return A boolean equal to \c true if the current slave is the master. - */ - static bool is_master ( void ) { return ( Slave::get_rank() == 0 ); } - - /// Initialize all the slaves. - /** - \param out Display -- \b IN. - */ - static void init_slaves ( const NOMAD::Display & out ); - - /// Stop all the slaves. - /** - \param out Display -- \b IN. - */ - static void stop_slaves ( const NOMAD::Display & out ); - + /// Slave process for the parallel version. + class Slave : private NOMAD::Uncopyable { + + private: + + static int _rank; /// Process rank. + static int _np; /// Number of processes. + + static int _data_sent; /// Stats on the sent data. + static int _data_rcvd; /// Stats on the received data. + + static bool _are_running; ///< \c true if the slaves are running. + static bool _stop_ok; ///< \c true if the slaves stopped without error. + + const NOMAD::Parameters * _p; ///< Parameters (may be NULL). + NOMAD::Evaluator * _ev; ///< Evaluator (may be NULL). + + /// Initializations. + void init ( void ) const; + + /// Force quit. + /** + - Called by pressing Ctrl-C. + - Does nothing: the slave will be stopped by the master. + \param signalValue Signal value -- \b IN. + */ + static void force_quit ( int signalValue ) {} + + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + \param ev A pointer to an evaluator -- \b IN. + */ + Slave ( const NOMAD::Parameters & p , NOMAD::Evaluator * ev ) + { + _p=&p; + _ev=ev; + init(); + } + + /// Destructor. + virtual ~Slave ( void ) {} + + /// Run the slave code. + void run ( void ) const; + + /// Access to the stat \c _data_sent. + /** + \return The stat \c _data_sent. + */ + static int get_data_sent ( void ) { return Slave::_data_sent; } + + /// Access to the stat \c _data_rcvd. + /** + \return The stat \c _data_rcvd. + */ + static int get_data_rcvd ( void ) { return Slave::_data_rcvd; } + + /// Access to the process rank. + /** + \return The process rank. + */ + static int get_rank ( void ); + + /// Access to the number of processes. + /** + \return The number of processes. + */ + static int get_nb_processes ( void ); + + /// Check if the slaves are running. + /** + \return A boolean equal to \c true if the slaves are running. + */ + static bool are_running ( void ) { return _are_running; } + + /// Check if the current slave is the master. + /** + \return A boolean equal to \c true if the current slave is the master. + */ + static bool is_master ( void ) { return ( Slave::get_rank() == 0 ); } + + /// Initialize all the slaves. + /** + \param out Display -- \b IN. + */ + static void init_slaves ( const NOMAD::Display & out ); + + /// Stop all the slaves. + /** + \param out Display -- \b IN. + */ + static void stop_slaves ( const NOMAD::Display & out ); + #ifdef USE_MPI - - private: - - /// Receive and evaluate a point from the master. - /** - \param count_eval Flag indicating if the evaluation has to be counted - or not -- \b OUT. - \return A pointer to the point. - */ - NOMAD::Eval_Point * eval_point ( bool & count_eval ) const; - - /// Send an evaluation result to the master. - /** - \param x The evaluation point -- \b IN. - \param count_eval Flag indicating if the evaluation has to be counted - or not -- \b IN. - */ - void send_eval_result ( const NOMAD::Eval_Point * x , bool count_eval ) const; - - /// Send data. - /** - \param buf Data to send -- \b IN. - \param count Data quantity -- \b IN. - \param datatype Data type -- \b IN. - \param dest Destination -- \b IN. - \param ready_send Flag equal to \c true if \c Rsend is used instead of \c Send - -- \b IN. - */ - static void send_data ( const void * buf , - int count , - MPI_Datatype datatype , - int dest , - bool ready_send ); - - /// Receive data. - /** - \param buf Data to receive -- \b OUT. - \param count Data quantity -- \b IN. - \param datatype Data type -- \b IN. - \param source Source (may be \c MPI_ANY_SOURCE) -- \b IN. - \param req Pointer to a MPI request (may be \c NULL) -- \b IN/OUT. - \return The source. - */ - static int receive_data ( void * buf , - int count , - MPI_Datatype datatype , - int source , - MPI_Request * req ); - - /// Wait for a MPI request. - /** - \param req The request -- \b IN/OUT. - */ - static void wait_request ( MPI_Request & req ); - - public: - - /// Send an evaluation point to a slave. - /** - \param x A pointer to the evaluation point to send -- \b IN. - \param slave_rank Destination -- \b IN. - \param h_max Maximal feasibility value \c h_max -- \b IN. - */ - void send_eval_point ( const NOMAD::Eval_Point * x , - int slave_rank , - const NOMAD::Double & h_max ) const; - - /// Receive an evaluation result from a slave. - /** - \param slave_rank Source -- \b IN. - \param x A pointer to the evaluation point received -- \b OUT. - \param eval_ok Flag indicating if the evaluation succeeded -- \b OUT. - \param count_eval Flag indicating if the evaluation has to be counted - or not -- \b OUT. - */ - void receive_eval_result ( int slave_rank , - NOMAD::Eval_Point * x , - bool & eval_ok , - bool & count_eval ) const; - - /// Receive a signal from a slave. - /** - \param signal The signal -- \b OUT. - \return The source. - */ - static int receive_signal ( char & signal ) - { - return Slave::receive_data ( &signal , 1 , MPI_CHAR , MPI_ANY_SOURCE , NULL ); - } - - /// Send a signal to a slave. - /** - \param signal The signal -- \b IN. - \param slave_rank Destination -- \b IN. - */ - static void send_signal ( char signal , int slave_rank ) - { - Slave::send_data ( &signal , 1 , MPI_CHAR , slave_rank , true ); - } - + + private: + + /// Receive and evaluate a point from the master. + /** + \param count_eval Flag indicating if the evaluation has to be counted + or not -- \b OUT. + \return A pointer to the point. + */ + NOMAD::Eval_Point * eval_point ( bool & count_eval ) const; + + /// Send an evaluation result to the master. + /** + \param x The evaluation point -- \b IN. + \param count_eval Flag indicating if the evaluation has to be counted + or not -- \b IN. + */ + void send_eval_result ( const NOMAD::Eval_Point * x , bool count_eval ) const; + + /// Send data. + /** + \param buf Data to send -- \b IN. + \param count Data quantity -- \b IN. + \param datatype Data type -- \b IN. + \param dest Destination -- \b IN. + \param ready_send Flag equal to \c true if \c Rsend is used instead of \c Send + -- \b IN. + */ + static void send_data ( const void * buf , + int count , + MPI_Datatype datatype , + int dest , + bool ready_send ); + + /// Receive data. + /** + \param buf Data to receive -- \b OUT. + \param count Data quantity -- \b IN. + \param datatype Data type -- \b IN. + \param source Source (may be \c MPI_ANY_SOURCE) -- \b IN. + \param req Pointer to a MPI request (may be \c NULL) -- \b IN/OUT. + \return The source. + */ + static int receive_data ( void * buf , + int count , + MPI_Datatype datatype , + int source , + MPI_Request * req ); + + /// Wait for a MPI request. + /** + \param req The request -- \b IN/OUT. + */ + static void wait_request ( MPI_Request & req ); + + public: + + /// Send an evaluation point to a slave. + /** + \param x A pointer to the evaluation point to send -- \b IN. + \param slave_rank Destination -- \b IN. + \param h_max Maximal feasibility value \c h_max -- \b IN. + */ + void send_eval_point ( const NOMAD::Eval_Point * x , + int slave_rank , + const NOMAD::Double & h_max ) const; + + /// Receive an evaluation result from a slave. + /** + \param slave_rank Source -- \b IN. + \param x A pointer to the evaluation point received -- \b OUT. + \param eval_ok Flag indicating if the evaluation succeeded -- \b OUT. + \param count_eval Flag indicating if the evaluation has to be counted + or not -- \b OUT. + */ + void receive_eval_result ( int slave_rank , + NOMAD::Eval_Point * x , + bool & eval_ok , + bool & count_eval ) const; + + /// Receive a signal from a slave. + /** + \param signal The signal -- \b OUT. + \return The source. + */ + static int receive_signal ( char & signal ) + { + return Slave::receive_data ( &signal , 1 , MPI_CHAR , MPI_ANY_SOURCE , NULL ); + } + + /// Send a signal to a slave. + /** + \param signal The signal -- \b IN. + \param slave_rank Destination -- \b IN. + */ + static void send_signal ( char signal , int slave_rank ) + { + Slave::send_data ( &signal , 1 , MPI_CHAR , slave_rank , true ); + } + #endif - }; + }; } #endif diff --git a/src/Speculative_Search.cpp b/src/Speculative_Search.cpp index 468e97d1114e2e415f0dfcdf92a2582e3e12b0cb..bf9a6f82ee627e313cbe408823dce10818577ead 100644 --- a/src/Speculative_Search.cpp +++ b/src/Speculative_Search.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -76,14 +83,14 @@ void NOMAD::Speculative_Search::search ( NOMAD::Mads & mads const NOMAD::Display & out = _p.out(); NOMAD::dd_type display_degree = out.get_search_dd(); - if ( display_degree == NOMAD::FULL_DISPLAY ) { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { std::ostringstream oss; oss << NOMAD::SPEC_SEARCH; out << std::endl << NOMAD::open_block ( oss.str() ) << std::endl; } - //int lkm1; // l_{k-1} - // int lk; // l_k + int n; NOMAD::Signature * signature; NOMAD::Point delta_m_k; @@ -104,7 +111,8 @@ void NOMAD::Speculative_Search::search ( NOMAD::Mads & mads { const NOMAD::Direction * dir = x[i]->get_direction(); - if ( dir && ( dir->is_mads() || dir->get_type()==NOMAD::MODEL_SEARCH_DIR ) ) { + if ( dir && ( dir->is_mads() || dir->get_type()==NOMAD::MODEL_SEARCH_DIR ) ) + { // get the x_k's signature: signature = x[i]->get_signature(); @@ -144,6 +152,7 @@ void NOMAD::Speculative_Search::search ( NOMAD::Mads & mads factor[k]=0; } + NOMAD::Point mesh_indices_k( x[i]->get_signature()->get_mesh()->get_mesh_indices() ); signature->get_mesh()->update( NOMAD::FULL_SUCCESS, mesh_indices_k , dir ); @@ -155,10 +164,10 @@ void NOMAD::Speculative_Search::search ( NOMAD::Mads & mads sk->set ( n , _p.get_bb_nb_outputs() ); sk->set_signature ( signature ); sk->set_direction ( &new_dir ); - sk->Point::operator = ( xkm1 + new_dir ); - if ( display_degree == NOMAD::FULL_DISPLAY ) { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { out << "trial point #" << sk->get_tag() << ": ( "; sk->Point::display ( out ," " , 2 , NOMAD::Point::get_display_limit() ); @@ -179,7 +188,7 @@ void NOMAD::Speculative_Search::search ( NOMAD::Mads & mads nb_search_pts = ev_control.get_nb_eval_points(); - // eval_list_of_points:s + // eval_list_of_points: // -------------------- new_feas_inc = new_infeas_inc = NULL; @@ -193,7 +202,8 @@ void NOMAD::Speculative_Search::search ( NOMAD::Mads & mads new_infeas_inc , success ); - if ( display_degree == NOMAD::FULL_DISPLAY ) { + if ( display_degree == NOMAD::FULL_DISPLAY ) + { std::ostringstream oss; oss << "end of speculative search (" << success << ")"; out << NOMAD::close_block ( oss.str() ) << std::endl; diff --git a/src/Speculative_Search.hpp b/src/Speculative_Search.hpp index e0db82d82e1325caf3f0904e8de6f26d14bab508..af9946e5b04a3f7b74e4bbd49d661871e50ff344 100644 --- a/src/Speculative_Search.hpp +++ b/src/Speculative_Search.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Speculative_Search.hpp - \brief Speculative search (headers) - \author Sebastien Le Digabel - \date 2010-04-12 - \see Speculative.cpp -*/ + \file Speculative_Search.hpp + \brief Speculative search (headers) + \author Sebastien Le Digabel + \date 2010-04-12 + \see Speculative.cpp + */ #ifndef __SPECULATIVE_SEARCH__ #define __SPECULATIVE_SEARCH__ @@ -47,57 +54,57 @@ #include "Mads.hpp" namespace NOMAD { - - /// Speculative search. - /** - The speculative search consists in looking further away along - the successful direction after an improvement. - */ - class Speculative_Search : public NOMAD::Search , private NOMAD::Uncopyable { - - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - */ - Speculative_Search ( NOMAD::Parameters & p ) - : NOMAD::Search ( p , NOMAD::SPEC_SEARCH ) {} - /// Destructor. - virtual ~Speculative_Search ( void ) {} - - /// The speculative search. + /// Speculative search. /** - - x_k = x_{k-1} + Delta^m_{k-1} d \n + The speculative search consists in looking further away along + the successful direction after an improvement. + */ + class Speculative_Search : public NOMAD::Search , private NOMAD::Uncopyable { + + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + */ + Speculative_Search ( NOMAD::Parameters & p ) + : NOMAD::Search ( p , NOMAD::SPEC_SEARCH ) {} + + /// Destructor. + virtual ~Speculative_Search ( void ) {} + + /// The speculative search. + /** + - x_k = x_{k-1} + Delta^m_{k-1} d \n s_k = x_{k-1} + Delta^m_{k-1} d if ell_{k-1} > 0 \n - or tau * Delta^m_{k-1} d otherwise. - - The directions that we use already contain Delta^m: + or tau * Delta^m_{k-1} d otherwise. + - The directions that we use already contain Delta^m: direction = Delta^m_{k-1} d - - The following test + - The following test \code - if ( new_feas_inc || new_infeas_inc ) + if ( new_feas_inc || new_infeas_inc ) \endcode - is equal to \c true and has already been made in \c Mads.cpp. - - \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. - \param nb_search_pts Number of generated search points -- \b OUT. - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - \param success Type of success -- \b OUT. - \param count_search Count or not the search -- \b OUT. - \param new_feas_inc New feasible incumbent -- \b IN/OUT. - \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. - */ - virtual void search ( NOMAD::Mads & mads , - int & nb_search_pts , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - bool & count_search , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ); - }; + is equal to \c true and has already been made in \c Mads.cpp. + + \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. + \param nb_search_pts Number of generated search points -- \b OUT. + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + \param success Type of success -- \b OUT. + \param count_search Count or not the search -- \b OUT. + \param new_feas_inc New feasible incumbent -- \b IN/OUT. + \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. + */ + virtual void search ( NOMAD::Mads & mads , + int & nb_search_pts , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + bool & count_search , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ); + }; } #endif diff --git a/src/Stats.cpp b/src/Stats.cpp index 15479e00858d44f90f8c4c8a45d08af68857052d..198437691fd0026b672afbe1969ec1f6b5db7659 100644 --- a/src/Stats.cpp +++ b/src/Stats.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Stats.cpp - \brief Algorithm stats (implementation) - \author Sebastien Le Digabel - \date 2010-04-22 - \see Stats.hpp -*/ + \file Stats.cpp + \brief Algorithm stats (implementation) + \author Sebastien Le Digabel + \date 2010-04-22 + \see Stats.hpp + */ #include "Stats.hpp" /*---------------------------------------------------------*/ @@ -47,56 +54,56 @@ /*---------------------------------------------------------*/ NOMAD::Stats & NOMAD::Stats::operator = ( const NOMAD::Stats & s ) { - _eval = s._eval; - _sim_bb_eval = s._sim_bb_eval; - _sgte_eval = s._sgte_eval; - _bb_eval = s._bb_eval; - _block_eval = s._block_eval; - _failed_eval = s._failed_eval; - _cache_hits = s._cache_hits; - _interrupted_eval = s._interrupted_eval; - _iterations = s._iterations; - _nb_poll_searches = s._nb_poll_searches; - _poll_pts = s._poll_pts; - _poll_success = s._poll_success; - _nb_success_dyn_dir= s._nb_success_dyn_dir; - _nb_ext_polls = s._nb_ext_polls; - _ext_poll_pts = s._ext_poll_pts; - _ext_poll_succ = s._ext_poll_succ; - _ext_poll_bb_eval = s._ext_poll_bb_eval; - _ext_poll_descents = s._ext_poll_descents; - _nb_spec_searches = s._nb_spec_searches; - _spec_pts = s._spec_pts; - _spec_success = s._spec_success; - _nb_LH_searches = s._nb_LH_searches; - _LH_pts = s._LH_pts; - _LH_success = s._LH_success; - _nb_cache_searches = s._nb_cache_searches; - _CS_pts = s._CS_pts; - _CS_success = s._CS_success; - _model_stats = s._model_stats; - _nb_VNS_searches = s._nb_VNS_searches; - _VNS_pts = s._VNS_pts; - _VNS_success = s._VNS_success; - _VNS_bb_eval = s._VNS_bb_eval; - _VNS_sgte_eval = s._VNS_sgte_eval; - _nb_usr_searches = s._nb_usr_searches; - _usr_srch_pts = s._usr_srch_pts; - _usr_srch_success = s._usr_srch_success; - _p1_iterations = s._p1_iterations; - _p1_bbe = s._p1_bbe; - _mads_runs = s._mads_runs; - _clock = s._clock; - _stat_sum = s._stat_sum; - _stat_avg = s._stat_avg; - _cnt_avg = s._cnt_avg; - + _eval = s._eval; + _sim_bb_eval = s._sim_bb_eval; + _sgte_eval = s._sgte_eval; + _bb_eval = s._bb_eval; + _block_eval = s._block_eval; + _failed_eval = s._failed_eval; + _cache_hits = s._cache_hits; + _interrupted_eval = s._interrupted_eval; + _iterations = s._iterations; + _nb_poll_searches = s._nb_poll_searches; + _poll_pts = s._poll_pts; + _poll_success = s._poll_success; + _nb_success_dyn_dir= s._nb_success_dyn_dir; + _nb_ext_polls = s._nb_ext_polls; + _ext_poll_pts = s._ext_poll_pts; + _ext_poll_succ = s._ext_poll_succ; + _ext_poll_bb_eval = s._ext_poll_bb_eval; + _ext_poll_descents = s._ext_poll_descents; + _nb_spec_searches = s._nb_spec_searches; + _spec_pts = s._spec_pts; + _spec_success = s._spec_success; + _nb_LH_searches = s._nb_LH_searches; + _LH_pts = s._LH_pts; + _LH_success = s._LH_success; + _nb_cache_searches = s._nb_cache_searches; + _CS_pts = s._CS_pts; + _CS_success = s._CS_success; + _model_stats = s._model_stats; + _nb_VNS_searches = s._nb_VNS_searches; + _VNS_pts = s._VNS_pts; + _VNS_success = s._VNS_success; + _VNS_bb_eval = s._VNS_bb_eval; + _VNS_sgte_eval = s._VNS_sgte_eval; + _nb_usr_searches = s._nb_usr_searches; + _usr_srch_pts = s._usr_srch_pts; + _usr_srch_success = s._usr_srch_success; + _p1_iterations = s._p1_iterations; + _p1_bbe = s._p1_bbe; + _mads_runs = s._mads_runs; + _clock = s._clock; + _stat_sum = s._stat_sum; + _stat_avg = s._stat_avg; + _cnt_avg = s._cnt_avg; + #ifdef USE_MPI - _asynchronous_success = s._asynchronous_success; - _MPI_data_size = s._MPI_data_size; + _asynchronous_success = s._asynchronous_success; + _MPI_data_size = s._MPI_data_size; #endif - - return *this; + + return *this; } /*---------------------------------------------------------*/ @@ -104,11 +111,11 @@ NOMAD::Stats & NOMAD::Stats::operator = ( const NOMAD::Stats & s ) /*---------------------------------------------------------*/ void NOMAD::Stats::reset ( void ) { - _eval = + _eval = _sim_bb_eval = _sgte_eval = _bb_eval = - _block_eval = + _block_eval = _failed_eval = _cache_hits = _interrupted_eval = @@ -140,21 +147,21 @@ void NOMAD::Stats::reset ( void ) _usr_srch_success = _p1_iterations = _p1_bbe = - _nb_success_dyn_dir = + _nb_success_dyn_dir = _mads_runs = 0; - - _model_stats.reset(); - - _stat_sum.clear(); - _stat_avg.clear(); - _cnt_avg = 0; - + + _model_stats.reset(); + + _stat_sum.clear(); + _stat_avg.clear(); + _cnt_avg = 0; + #ifdef USE_MPI - _asynchronous_success = 0; - _MPI_data_size = -1; + _asynchronous_success = 0; + _MPI_data_size = -1; #endif - - _clock.reset(); + + _clock.reset(); } /*---------------------------------------------------------*/ @@ -165,58 +172,59 @@ void NOMAD::Stats::reset ( void ) /*---------------------------------------------------------*/ void NOMAD::Stats::update ( const NOMAD::Stats & s , bool for_search ) { - _eval += s._eval; - _sim_bb_eval += s._sim_bb_eval; - _sgte_eval += s._sgte_eval; - _bb_eval += s._bb_eval; - _block_eval += s._block_eval; - _failed_eval += s._failed_eval; - _cache_hits += s._cache_hits; - _interrupted_eval += s._interrupted_eval; - _nb_ext_polls += s._nb_ext_polls; - _ext_poll_pts += s._ext_poll_pts; - _ext_poll_succ += s._ext_poll_succ; - _ext_poll_bb_eval += s._ext_poll_bb_eval; - _ext_poll_descents += s._ext_poll_descents; - _nb_LH_searches += s._nb_LH_searches; - _LH_pts += s._LH_pts; - _LH_success += s._LH_success; - _nb_cache_searches += s._nb_cache_searches; - _CS_pts += s._CS_pts; - _CS_success += s._CS_success; - _nb_usr_searches += s._nb_usr_searches; - _usr_srch_pts += s._usr_srch_pts; - _usr_srch_success += s._usr_srch_success; - _nb_success_dyn_dir += s._nb_success_dyn_dir; - + _eval += s._eval; + _sim_bb_eval += s._sim_bb_eval; + _sgte_eval += s._sgte_eval; + _bb_eval += s._bb_eval; + _block_eval += s._block_eval; + _failed_eval += s._failed_eval; + _cache_hits += s._cache_hits; + _interrupted_eval += s._interrupted_eval; + _nb_ext_polls += s._nb_ext_polls; + _ext_poll_pts += s._ext_poll_pts; + _ext_poll_succ += s._ext_poll_succ; + _ext_poll_bb_eval += s._ext_poll_bb_eval; + _ext_poll_descents += s._ext_poll_descents; + _nb_LH_searches += s._nb_LH_searches; + _LH_pts += s._LH_pts; + _LH_success += s._LH_success; + _nb_cache_searches += s._nb_cache_searches; + _CS_pts += s._CS_pts; + _CS_success += s._CS_success; + _nb_usr_searches += s._nb_usr_searches; + _usr_srch_pts += s._usr_srch_pts; + _usr_srch_success += s._usr_srch_success; + _nb_success_dyn_dir += s._nb_success_dyn_dir; + #ifdef USE_MPI - _asynchronous_success += s._asynchronous_success; - _MPI_data_size = s._MPI_data_size; + _asynchronous_success += s._asynchronous_success; + _MPI_data_size = s._MPI_data_size; #endif - - // _stat_sum and _stat_avg: - int tmp = _cnt_avg + s._cnt_avg; - update_stat_sum ( s._stat_sum ); - update_stat_avg ( s._stat_avg ); - _cnt_avg = tmp; - - // specific updates when for_search==false: - if ( !for_search ) { - _nb_poll_searches += s._nb_poll_searches; - _poll_pts += s._poll_pts; - _poll_success += s._poll_success; - _nb_spec_searches += s._nb_spec_searches; - _spec_pts += s._spec_pts; - _spec_success += s._spec_success; - _nb_VNS_searches += s._nb_VNS_searches; - _VNS_pts += s._VNS_pts; - _VNS_success += s._VNS_success; - _VNS_bb_eval += s._VNS_bb_eval; - _VNS_sgte_eval += s._VNS_sgte_eval; - _p1_iterations += s._p1_iterations; - _p1_bbe += s._p1_bbe; - _iterations += s._iterations; - } + + // _stat_sum and _stat_avg: + int tmp = _cnt_avg + s._cnt_avg; + update_stat_sum ( s._stat_sum ); + update_stat_avg ( s._stat_avg ); + _cnt_avg = tmp; + + // specific updates when for_search==false: + if ( !for_search ) + { + _nb_poll_searches += s._nb_poll_searches; + _poll_pts += s._poll_pts; + _poll_success += s._poll_success; + _nb_spec_searches += s._nb_spec_searches; + _spec_pts += s._spec_pts; + _spec_success += s._spec_success; + _nb_VNS_searches += s._nb_VNS_searches; + _VNS_pts += s._VNS_pts; + _VNS_success += s._VNS_success; + _VNS_bb_eval += s._VNS_bb_eval; + _VNS_sgte_eval += s._VNS_sgte_eval; + _p1_iterations += s._p1_iterations; + _p1_bbe += s._p1_bbe; + _iterations += s._iterations; + } } /*---------------------------------------------------------*/ @@ -224,12 +232,12 @@ void NOMAD::Stats::update ( const NOMAD::Stats & s , bool for_search ) /*---------------------------------------------------------*/ void NOMAD::Stats::update_stat_sum ( const NOMAD::Double & d ) { - if ( !d.is_defined() ) - return; - if ( _stat_sum.is_defined() ) - _stat_sum += d; - else - _stat_sum = d; + if ( !d.is_defined() ) + return; + if ( _stat_sum.is_defined() ) + _stat_sum += d; + else + _stat_sum = d; } /*---------------------------------------------------------*/ @@ -237,13 +245,13 @@ void NOMAD::Stats::update_stat_sum ( const NOMAD::Double & d ) /*---------------------------------------------------------*/ void NOMAD::Stats::update_stat_avg ( const NOMAD::Double & d ) { - if ( !d.is_defined() ) - return; - if ( _stat_avg.is_defined() ) - _stat_avg += d; - else - _stat_avg = d; - ++_cnt_avg; + if ( !d.is_defined() ) + return; + if ( _stat_avg.is_defined() ) + _stat_avg += d; + else + _stat_avg = d; + ++_cnt_avg; } /*---------------------------------------------------------*/ @@ -251,115 +259,118 @@ void NOMAD::Stats::update_stat_avg ( const NOMAD::Double & d ) /*---------------------------------------------------------*/ void NOMAD::Stats::display ( const NOMAD::Display & out ) const { - out << "MADS iterations : " << _iterations; - if ( _p1_iterations > 0 ) - out << " (phase one: " << _p1_iterations << ")"; - out << std::endl; - if ( _sgte_cost > 0 ) - out << "bb evaluations (with sgte cost) : " << get_bb_eval(); - else - out << "blackbox evaluations : " << _bb_eval; - out << std::endl; - if ( _block_eval > 0) - out << "Block of evaluations : " << _block_eval; - if ( _p1_bbe > 0 ) - out << " (phase one: " << _p1_bbe << ")"; - out << std::endl; - if ( _sim_bb_eval != _bb_eval ) - out << "simulated blackbox evaluations : " << _sim_bb_eval << std::endl; - out << "evaluations : " << _eval << std::endl; - if ( _sgte_cost > 0 || _sgte_eval > 0 ) - out << "surrogate evaluations : " << _sgte_eval << std::endl; - out << "failed evaluations : " << _failed_eval; - if ( _failed_eval > 0 && _failed_eval==_bb_eval+_sgte_eval ) - out << " (all evaluations failed)"; - out << std::endl; - - out << "interrupted sequences of eval. : " << _interrupted_eval << std::endl; - - if ( _mads_runs > 1 ) - out << "number of MADS runs : " << _mads_runs << std::endl; - - out << "cache hits : " << _cache_hits << std::endl - - << "number of poll searches : " << _nb_poll_searches << std::endl; - if ( _nb_poll_searches > 0 ) - out << "poll successes : " << _poll_success << std::endl - << "poll points : " << _poll_pts << std::endl; - - out << "dyn. direction successes : " << _nb_success_dyn_dir << std::endl; - - if ( _nb_ext_polls > 0 ) - out << "number of extended polls : " << _nb_ext_polls << std::endl - << "number of ext. poll descents : " << _ext_poll_descents << std::endl - << "number of ext. poll successes : " << _ext_poll_succ << std::endl - << "number of ext. poll points : " << _ext_poll_pts << std::endl - << "number of ext. poll bb eval : " << _ext_poll_bb_eval << std::endl; - out << "number of speculative searches : " << _nb_spec_searches << std::endl; - if ( _nb_spec_searches > 0 ) - out << "speculative search successes : " << _spec_success << std::endl - << "speculative search points : " << _spec_pts << std::endl; - out << "number of user searches : " << _nb_usr_searches << std::endl; - if ( _nb_usr_searches > 0 ) - out << "user search successes : " << _usr_srch_success << std::endl - << "user search points : " << _usr_srch_pts << std::endl; - out << "number of LH searches : " << _nb_LH_searches << std::endl; - if ( _nb_LH_searches > 0 ) - out << "LH search successes : " << _LH_success << std::endl - << "LH search points : " << _LH_pts << std::endl; - out << "number of cache searches : " << _nb_cache_searches << std::endl; - if ( _nb_cache_searches > 0 ) - out << "cache search successes : " << _CS_success << std::endl - << "cache search points : " << _CS_pts << std::endl; - out << "number of VNS searches : " << _nb_VNS_searches << std::endl; - if ( _nb_VNS_searches > 0 ) { - out << "VNS search successes : " << _VNS_success << std::endl - << "VNS search points : " << _VNS_pts << std::endl - << "VNS blackbox evaluations : " << _VNS_bb_eval << std::endl; - if ( _VNS_sgte_eval > 0 ) - out << "VNS surrogate evaluations : " << _VNS_sgte_eval << std::endl; - } - if ( _model_stats.get_nb_models() > 0 ) { + out << "MADS iterations : " << _iterations; + if ( _p1_iterations > 0 ) + out << " (phase one: " << _p1_iterations << ")"; + out << std::endl; + if ( _sgte_cost > 0 ) + out << "bb evaluations (with sgte cost) : " << get_bb_eval(); + else + out << "blackbox evaluations : " << _bb_eval; + out << std::endl; + if ( _block_eval > 0) + out << "Block of evaluations : " << _block_eval; + if ( _p1_bbe > 0 ) + out << " (phase one: " << _p1_bbe << ")"; + out << std::endl; + if ( _sim_bb_eval != _bb_eval ) + out << "simulated blackbox evaluations : " << _sim_bb_eval << std::endl; + out << "evaluations : " << _eval << std::endl; + if ( _sgte_cost > 0 || _sgte_eval > 0 ) + out << "surrogate evaluations : " << _sgte_eval << std::endl; + out << "failed evaluations : " << _failed_eval; + if ( _failed_eval > 0 && _failed_eval==_bb_eval+_sgte_eval ) + out << " (all evaluations failed)"; + out << std::endl; + + out << "interrupted sequences of eval. : " << _interrupted_eval << std::endl; + + if ( _mads_runs > 1 ) + out << "number of MADS runs : " << _mads_runs << std::endl; + + out << "cache hits : " << _cache_hits << std::endl + + << "number of poll searches : " << _nb_poll_searches << std::endl; + if ( _nb_poll_searches > 0 ) + out << "poll successes : " << _poll_success << std::endl + << "poll points : " << _poll_pts << std::endl; + + out << "dyn. direction successes : " << _nb_success_dyn_dir << std::endl; + + if ( _nb_ext_polls > 0 ) + out << "number of extended polls : " << _nb_ext_polls << std::endl + << "number of ext. poll descents : " << _ext_poll_descents << std::endl + << "number of ext. poll successes : " << _ext_poll_succ << std::endl + << "number of ext. poll points : " << _ext_poll_pts << std::endl + << "number of ext. poll bb eval : " << _ext_poll_bb_eval << std::endl; + out << "number of speculative searches : " << _nb_spec_searches << std::endl; + if ( _nb_spec_searches > 0 ) + out << "speculative search successes : " << _spec_success << std::endl + << "speculative search points : " << _spec_pts << std::endl; + out << "number of user searches : " << _nb_usr_searches << std::endl; + if ( _nb_usr_searches > 0 ) + out << "user search successes : " << _usr_srch_success << std::endl + << "user search points : " << _usr_srch_pts << std::endl; + out << "number of LH searches : " << _nb_LH_searches << std::endl; + if ( _nb_LH_searches > 0 ) + out << "LH search successes : " << _LH_success << std::endl + << "LH search points : " << _LH_pts << std::endl; + out << "number of cache searches : " << _nb_cache_searches << std::endl; + if ( _nb_cache_searches > 0 ) + out << "cache search successes : " << _CS_success << std::endl + << "cache search points : " << _CS_pts << std::endl; + out << "number of VNS searches : " << _nb_VNS_searches << std::endl; + if ( _nb_VNS_searches > 0 ) + { + out << "VNS search successes : " << _VNS_success << std::endl + << "VNS search points : " << _VNS_pts << std::endl + << "VNS blackbox evaluations : " << _VNS_bb_eval << std::endl; + if ( _VNS_sgte_eval > 0 ) + out << "VNS surrogate evaluations : " << _VNS_sgte_eval << std::endl; + } + if ( _model_stats.get_nb_models() > 0 ) + { #ifdef DEBUG - out << NOMAD::open_block ( "model stats" ) - << _model_stats - << NOMAD::close_block(); + out << NOMAD::open_block ( "model stats" ) + << _model_stats + << NOMAD::close_block(); #else - out << "number of models built : " - << _model_stats.get_nb_models() << std::endl - << "number of model searches : " - << _model_stats.get_MS_nb_searches() << std::endl; - if ( _model_stats.get_MS_nb_searches() > 0 ) { - out << "model search successes : " - << _model_stats.get_MS_success() << std::endl - << "model search points : " - << _model_stats.get_MS_pts() << std::endl - << "model search blackbox eval. : " - << _model_stats.get_MS_bb_eval() << std::endl; - if ( _model_stats.get_MS_sgte_eval() > 0 ) - out << "model search sgte evaluations : " - << _model_stats.get_MS_sgte_eval() << std::endl; - } + out << "number of models built : " + << _model_stats.get_nb_models() << std::endl + << "number of model searches : " + << _model_stats.get_MS_nb_searches() << std::endl; + if ( _model_stats.get_MS_nb_searches() > 0 ) + { + out << "model search successes : " + << _model_stats.get_MS_success() << std::endl + << "model search points : " + << _model_stats.get_MS_pts() << std::endl + << "model search blackbox eval. : " + << _model_stats.get_MS_bb_eval() << std::endl; + if ( _model_stats.get_MS_sgte_eval() > 0 ) + out << "model search sgte evaluations : " + << _model_stats.get_MS_sgte_eval() << std::endl; + } #endif - } - else - out << "no model has been constructed" << std::endl; + } + else + out << "no model has been constructed" << std::endl; #ifdef USE_MPI - out << "number of asynchronous successes: " << _asynchronous_success << std::endl; - out << "total size of MPI communications: "; - if ( _MPI_data_size < 0 ) - out << "-"; - else - out.display_size_of ( _MPI_data_size ); - out << std::endl; + out << "number of asynchronous successes: " << _asynchronous_success << std::endl; + out << "total size of MPI communications: "; + if ( _MPI_data_size < 0 ) + out << "-"; + else + out.display_size_of ( _MPI_data_size ); + out << std::endl; #endif - - out << "wall-clock time : "; - out.display_time ( _clock.get_real_time() ); - out << std::endl; - - if ( _stat_sum.is_defined() ) - out << "stat sum : " << _stat_sum << std::endl; - if ( _stat_avg.is_defined() ) - out << "stat avg : " << get_stat_avg() << std::endl; - } + + out << "wall-clock time : "; + out.display_time ( _clock.get_real_time() ); + out << std::endl; + + if ( _stat_sum.is_defined() ) + out << "stat sum : " << _stat_sum << std::endl; + if ( _stat_avg.is_defined() ) + out << "stat avg : " << get_stat_avg() << std::endl; +} diff --git a/src/Stats.hpp b/src/Stats.hpp index db9cf2aa71343293d028beef3fd2827b0c7f6b83..f26323d08bfb80aeaa956045680429d7b3a0cd3a 100644 --- a/src/Stats.hpp +++ b/src/Stats.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file Stats.hpp - \brief Algorithm stats (headers) - \author Sebastien Le Digabel - \date 2010-04-22 - \see Stats.cpp -*/ + \file Stats.hpp + \brief Algorithm stats (headers) + \author Sebastien Le Digabel + \date 2010-04-22 + \see Stats.cpp + */ #ifndef __STATS__ #define __STATS__ @@ -48,493 +55,494 @@ #include "Model_Stats.hpp" namespace NOMAD { - - /// Algorithm stats. - class Stats { - - private: - - /// Number of evaluations. - /** - Blackbox evaluations + cache hits. - */ - int _eval; - - /// Number of simulated blackbox evaluations. - /** - Blackbox evaluations + initial cache hits. - */ - int _sim_bb_eval; - - int _sgte_eval; ///< Number of surrogate evaluations. - int _sgte_cost; ///< Surrogate cost. - int _bb_eval; ///< Number of blackbox evaluations. - int _block_eval; ///< Number of block of evaluations. - int _failed_eval; ///< Number of failed evaluations. - int _cache_hits; ///< Number of cache hits. - int _interrupted_eval; ///< Number of interrupted sequence of evaluations. - int _iterations; ///< Number of iterations. - NOMAD::Double _stat_sum; ///< Sum stat (output of type NOMAD::STAT_SUM). - NOMAD::Double _stat_avg; ///< Average stat (output of type NOMAD::STAT_AVG). - int _cnt_avg; ///< Number of values for the \c avg stat. - int _p1_iterations; ///< Iterations in MADS phase one. - int _p1_bbe; ///< Blackbox evaluations in phase one. - NOMAD::Clock _clock; ///< Wall-clock time. - int _mads_runs; ///< Number of MADS runs (for multi-objective runs). - - // Polls: - int _nb_poll_searches; ///< Number of poll searches. - int _poll_pts; ///< Number of poll points. - int _poll_success; ///< Number of poll successes. - - // Extended polls: - int _nb_ext_polls; ///< Number of extended polls. - int _ext_poll_pts; ///< Number of extended poll points. - int _ext_poll_succ; ///< Number of extended poll successes. - int _ext_poll_bb_eval; ///< Number of extended poll blackbox evaluations. - int _ext_poll_descents; ///< Number of extended poll descents. - - // Speculative searches: - int _nb_spec_searches; ///< Number of speculative searches. - int _spec_pts; ///< Number of speculative search points. - int _spec_success; ///< Number of speculative search successes. - + + /// Algorithm stats. + class Stats { + + private: + + /// Number of evaluations. + /** + Blackbox evaluations + cache hits. + */ + int _eval; + + /// Number of simulated blackbox evaluations. + /** + Blackbox evaluations + initial cache hits. + */ + int _sim_bb_eval; + + int _sgte_eval; ///< Number of surrogate evaluations. + int _sgte_cost; ///< Surrogate cost. + int _bb_eval; ///< Number of blackbox evaluations. + int _block_eval; ///< Number of block of evaluations. + int _failed_eval; ///< Number of failed evaluations. + int _cache_hits; ///< Number of cache hits. + int _interrupted_eval; ///< Number of interrupted sequence of evaluations. + int _iterations; ///< Number of iterations. + NOMAD::Double _stat_sum; ///< Sum stat (output of type NOMAD::STAT_SUM). + NOMAD::Double _stat_avg; ///< Average stat (output of type NOMAD::STAT_AVG). + int _cnt_avg; ///< Number of values for the \c avg stat. + int _p1_iterations; ///< Iterations in MADS phase one. + int _p1_bbe; ///< Blackbox evaluations in phase one. + NOMAD::Clock _clock; ///< Wall-clock time. + int _mads_runs; ///< Number of MADS runs (for multi-objective runs). + + // Polls: + int _nb_poll_searches; ///< Number of poll searches. + int _poll_pts; ///< Number of poll points. + int _poll_success; ///< Number of poll successes. + + // Extended polls: + int _nb_ext_polls; ///< Number of extended polls. + int _ext_poll_pts; ///< Number of extended poll points. + int _ext_poll_succ; ///< Number of extended poll successes. + int _ext_poll_bb_eval; ///< Number of extended poll blackbox evaluations. + int _ext_poll_descents; ///< Number of extended poll descents. + + // Speculative searches: + int _nb_spec_searches; ///< Number of speculative searches. + int _spec_pts; ///< Number of speculative search points. + int _spec_success; ///< Number of speculative search successes. + #ifdef USE_MPI - int _asynchronous_success; ///< Number of asynchronous successes. - int _MPI_data_size; ///< Size of MPI messages. + int _asynchronous_success; ///< Number of asynchronous successes. + int _MPI_data_size; ///< Size of MPI messages. #endif - - // LH searches: - int _nb_LH_searches; ///< Number of Latin-Hypercube (LH) searches. - int _LH_pts; ///< Number of Latin-Hypercube (LH) search points. - int _LH_success; ///< Number of LH search successes. - - // Cache searches: - int _nb_cache_searches; ///< Number of cache searches (CS). - int _CS_pts; ///< Number of CS search points. - int _CS_success; ///< Number of CS search successes. - - /// Model stats. - NOMAD::Model_Stats _model_stats; - - // VNS searches: - int _nb_VNS_searches; ///< Number of VNS searches. - int _VNS_pts; ///< Number of VNS search points. - int _VNS_success; ///< Number of VNS search successes. - int _VNS_bb_eval; ///< Number of VNS blackbox evaluations. - int _VNS_sgte_eval; ///< Number of VNS surrogate evaluations. - - // User searches: - int _nb_usr_searches; ///< Number of user searches. - int _usr_srch_pts; ///< Number of user search points. - int _usr_srch_success; ///< Number of user search successes. - - // Dynamic management of poll directions - int _nb_success_dyn_dir; ///< Number of successfull polling in the direction added dynamically - - -public: - - /// Constructor. - /** - \param sgte_cost Surrogate cost -- \b IN -- \b optional (default = \c -1). - */ - explicit Stats ( int sgte_cost = -1 ) : _sgte_cost(sgte_cost) { reset(); } - - /// Copy constructor. - /** - \param s The copied object -- \b IN. - */ - explicit Stats ( const Stats & s ) - : _eval ( s._eval ) , - _sim_bb_eval ( s._sim_bb_eval ) , - _sgte_eval ( s._sgte_eval ) , - _sgte_cost ( s._sgte_cost ) , - _bb_eval ( s._bb_eval ) , - _block_eval ( s._block_eval ) , - _failed_eval ( s._failed_eval ) , - _cache_hits ( s._cache_hits ) , - _interrupted_eval ( s._interrupted_eval ) , - _iterations ( s._iterations ) , - _stat_sum ( s._stat_sum ) , - _stat_avg ( s._stat_avg ) , - _cnt_avg ( s._cnt_avg ) , - _p1_iterations ( s._p1_iterations ) , - _p1_bbe ( s._p1_bbe ) , - _clock ( s._clock ) , - _mads_runs ( s._mads_runs ) , - _nb_poll_searches ( s._nb_poll_searches ) , - _poll_pts ( s._poll_pts ) , - _poll_success ( s._poll_success ) , - _nb_ext_polls ( s._nb_ext_polls ) , - _ext_poll_pts ( s._ext_poll_pts ) , - _ext_poll_succ ( s._ext_poll_succ ) , - _ext_poll_bb_eval ( s._ext_poll_bb_eval ) , - _ext_poll_descents ( s._ext_poll_descents ) , - _nb_spec_searches ( s._nb_spec_searches ) , - _spec_pts ( s._spec_pts ) , - _spec_success ( s._spec_success ) , + + // LH searches: + int _nb_LH_searches; ///< Number of Latin-Hypercube (LH) searches. + int _LH_pts; ///< Number of Latin-Hypercube (LH) search points. + int _LH_success; ///< Number of LH search successes. + + // Cache searches: + int _nb_cache_searches; ///< Number of cache searches (CS). + int _CS_pts; ///< Number of CS search points. + int _CS_success; ///< Number of CS search successes. + + /// Model stats. + NOMAD::Model_Stats _model_stats; + + // VNS searches: + int _nb_VNS_searches; ///< Number of VNS searches. + int _VNS_pts; ///< Number of VNS search points. + int _VNS_success; ///< Number of VNS search successes. + int _VNS_bb_eval; ///< Number of VNS blackbox evaluations. + int _VNS_sgte_eval; ///< Number of VNS surrogate evaluations. + + // User searches: + int _nb_usr_searches; ///< Number of user searches. + int _usr_srch_pts; ///< Number of user search points. + int _usr_srch_success; ///< Number of user search successes. + + // Dynamic management of poll directions + int _nb_success_dyn_dir; ///< Number of successfull polling in the direction added dynamically + + + public: + + /// Constructor. + /** + \param sgte_cost Surrogate cost -- \b IN -- \b optional (default = \c -1). + */ + explicit Stats ( int sgte_cost = -1 ) : _sgte_cost(sgte_cost) { reset(); } + + /// Copy constructor. + /** + \param s The copied object -- \b IN. + */ + explicit Stats ( const Stats & s ) + : _eval ( s._eval ) , + _sim_bb_eval ( s._sim_bb_eval ) , + _sgte_eval ( s._sgte_eval ) , + _sgte_cost ( s._sgte_cost ) , + _bb_eval ( s._bb_eval ) , + _block_eval ( s._block_eval ) , + _failed_eval ( s._failed_eval ) , + _cache_hits ( s._cache_hits ) , + _interrupted_eval ( s._interrupted_eval ) , + _iterations ( s._iterations ) , + _stat_sum ( s._stat_sum ) , + _stat_avg ( s._stat_avg ) , + _cnt_avg ( s._cnt_avg ) , + _p1_iterations ( s._p1_iterations ) , + _p1_bbe ( s._p1_bbe ) , + _clock ( s._clock ) , + _mads_runs ( s._mads_runs ) , + _nb_poll_searches ( s._nb_poll_searches ) , + _poll_pts ( s._poll_pts ) , + _poll_success ( s._poll_success ) , + _nb_ext_polls ( s._nb_ext_polls ) , + _ext_poll_pts ( s._ext_poll_pts ) , + _ext_poll_succ ( s._ext_poll_succ ) , + _ext_poll_bb_eval ( s._ext_poll_bb_eval ) , + _ext_poll_descents ( s._ext_poll_descents ) , + _nb_spec_searches ( s._nb_spec_searches ) , + _spec_pts ( s._spec_pts ) , + _spec_success ( s._spec_success ) , #ifdef USE_MPI - _asynchronous_success ( s._asynchronous_success ) , - _MPI_data_size ( s._MPI_data_size ) , + _asynchronous_success ( s._asynchronous_success ) , + _MPI_data_size ( s._MPI_data_size ) , #endif - _nb_LH_searches ( s._nb_LH_searches ) , - _LH_pts ( s._LH_pts ) , - _LH_success ( s._LH_success ) , - _nb_cache_searches ( s._nb_cache_searches ) , - _CS_pts ( s._CS_pts ) , - _CS_success ( s._CS_success ) , - _nb_VNS_searches ( s._nb_VNS_searches ) , - _VNS_pts ( s._VNS_pts ) , - _VNS_success ( s._VNS_success ) , - _VNS_bb_eval ( s._VNS_bb_eval ) , - _VNS_sgte_eval ( s._VNS_sgte_eval ) , - _nb_usr_searches ( s._nb_usr_searches ) , - _usr_srch_pts ( s._usr_srch_pts ) , - _usr_srch_success ( s._usr_srch_success ) , - _nb_success_dyn_dir ( s._nb_success_dyn_dir ) {} - - /// Affectation operator. - /** - \param s The right-hand side object -- \b IN. - */ - Stats & operator = ( const Stats & s ); - - /// Destructor. - virtual ~Stats ( void ) {} - - /// Reset the stats. - void reset ( void ); - - /// Update stats from another NOMAD::Stats object. - /** - \param s The other NOMAD::Stats object -- \b IN. - \param for_search A flag equal to \c true if the method - has been invoked within a search step - -- \b IN. - */ - void update ( const Stats & s , bool for_search ); - - /// Update the \c sum stat. - /** - \param d New \c sum element -- \b IN. - */ - void update_stat_sum ( const NOMAD::Double & d ); - - /// Update the \c avg stat. - /** - \param d New \c avg element -- \b IN. - */ - void update_stat_avg ( const NOMAD::Double & d ); - - /// Add \c 1 to stat \c _mads_run. - void add_mads_run ( void ) { ++_mads_runs; } - - /// Set the number of MADS runs. - void set_mads_runs ( int mads_runs ) { _mads_runs = mads_runs; } - - /// Add \c 1 to stat \c _eval. - void add_eval ( void ) { ++_eval; } - - /// Add \c 1 to stat \c _sim_bb_eval. - void add_sim_bb_eval ( void ) { ++_sim_bb_eval; } - - /// Add \c 1 to stat \c _sgte_eval. - void add_sgte_eval ( void ) { ++_sgte_eval; } - - /// Add \c count_eval to stat \c _sgte_eval. - void add_sgte_eval ( int count_eval ) { _sgte_eval+=count_eval; } - - /// Add \c 1 to stat \c _bb_eval. - void add_bb_eval ( void ) { ++_bb_eval; } - - /// Add \c 1 to stat \c _block_eval. - void add_one_block_eval ( void ) { ++_block_eval; } - - /// Add \c count_eval to stat \c _bb_eval. - void add_bb_eval ( int count_eval ) { _bb_eval+=count_eval; } - - /// Add \c 1 to stat \c _failed_eval. - void add_failed_eval ( void ) { ++_failed_eval; } - - /// Add \c 1 to stat \c _cache_hits. - void add_cache_hit ( void ) { ++_cache_hits; } - - /// Add \c 1 to stat \c _interrupted_eval. - void add_interrupted_eval ( void ) { ++_interrupted_eval; } - - /// Add \c 1 to stat \c _iterations. - void add_iteration ( void ) { ++_iterations; } - - /// Add \c 1 to stat \c _nb_poll_searches. - void add_nb_poll_searches ( void ) { ++_nb_poll_searches; } - - /// Add \c 1 to stat \c _poll_success. - void add_poll_success ( void ) { ++_poll_success; } - - /// Add \c 1 to stat \c _nb_ext_polls. - void add_nb_ext_polls ( void ) { ++_nb_ext_polls; } - - /// Add \c 1 to stat \c _ext_poll_succ. - void add_ext_poll_succ ( void ) { ++_ext_poll_succ; } - - /// Add \c 1 to stat \c _ext_poll_descents. - void add_ext_poll_descent ( void ) { ++_ext_poll_descents; } - - /// Add \c 1 to stat \c _nb_spec_searches. - void add_nb_spec_searches ( void ) { ++_nb_spec_searches; } - - /// Add \c 1 to stat \c _spec_success. - void add_spec_success ( void ) { ++_spec_success; } - - /// Add \c 1 to stat \c _LH_success. - void add_LH_success ( void ) { ++_LH_success; } - - /// Add \c 1 to stat \c _nb_cache_searches. - void add_nb_cache_searches ( void ) { ++_nb_cache_searches; } - - /// Add \c 1 to stat \c _nb_LH_searches. - void add_nb_LH_searches ( void ) { ++_nb_LH_searches; } - - /// Add \c 1 to stat \c _CS_success. - void add_CS_success ( void ) { ++_CS_success; } - - /// Add \c 1 to stat \c _nb_VNS_searches. - void add_nb_VNS_searches ( void ) { ++_nb_VNS_searches; } - - /// Add \c 1 to stat \c _VNS_success. - void add_VNS_success ( void ) { ++_VNS_success; } - - /// Add \c 1 to stat \c _nb_usr_searches. - void add_nb_usr_searches ( void ) { ++_nb_usr_searches; } - - /// Add \c 1 to stat \c _usr_srch_success. - void add_usr_srch_success ( void ) { ++_usr_srch_success; } - - - /// Add \c 1 to stat \c _nb_success_dyn_dir. - void add_nb_success_dyn_dir(void) {++_nb_success_dyn_dir;} - - /// Add an integer to stat \c _p1_iterations. - /** - \param i The integer -- \b IN. - */ - void add_p1_iterations ( int i ) { _p1_iterations += i; } - - /// Add an integer to stat \c _p1_bbe. - /** - \param i The integer -- \b IN. - */ - void add_p1_bbe ( int i ) { _p1_bbe += i; } - - /// Add an integer to stat \c _poll_pts. - /** - \param i The integer -- \b IN. - */ - void add_poll_pts ( int i ) { _poll_pts += i; } - - /// Add an integer to stat \c _ext_poll_pts. - /** - \param i The integer -- \b IN. - */ - void add_ext_poll_pts ( int i ) { _ext_poll_pts += i; } - - /// Add an integer to stat \c _ext_poll_bb_eval. - /** - \param i The integer -- \b IN. - */ - void add_ext_poll_bb_eval ( int i ) { _ext_poll_bb_eval += i;} - - /// Add an integer to stat \c _spec_pts. - /** - \param i The integer -- \b IN. - */ - void add_spec_pts ( int i ) { _spec_pts += i; } - - /// Add an integer to stat \c _LH_pts. - /** - \param i The integer -- \b IN. - */ - void add_LH_pts ( int i ) { _LH_pts += i; } - - /// Add an integer to stat \c _CS_pts. - /** - \param i The integer -- \b IN. - */ - void add_CS_pts ( int i ) { _CS_pts += i; } - - /// Update model stats. - void update_model_stats ( const NOMAD::Model_Stats & ms ) - { - _model_stats.update ( ms ); - } - - /// Add an integer to stat \c _VNS_pts. - /** - \param i The integer -- \b IN. - */ - void add_VNS_pts ( int i ) { _VNS_pts += i; } - - /// Add an integer to stat \c _VNS_bb_eval. - /** - \param i The integer -- \b IN. - */ - void add_VNS_bb_eval ( int i ) { _VNS_bb_eval += i; } - - /// Add an integer to stat \c _VNS_sgte_eval. - /** - \param i The integer -- \b IN. - */ - void add_VNS_sgte_eval ( int i ) { _VNS_sgte_eval += i; } - - /// Add an integer to stat \c _usr_srch_pts. - /** - \param i The integer -- \b IN. - */ - void add_usr_srch_pts ( int i ) { _usr_srch_pts += i; } - + _nb_LH_searches ( s._nb_LH_searches ) , + _LH_pts ( s._LH_pts ) , + _LH_success ( s._LH_success ) , + _nb_cache_searches ( s._nb_cache_searches ) , + _CS_pts ( s._CS_pts ) , + _CS_success ( s._CS_success ) , + _nb_VNS_searches ( s._nb_VNS_searches ) , + _VNS_pts ( s._VNS_pts ) , + _VNS_success ( s._VNS_success ) , + _VNS_bb_eval ( s._VNS_bb_eval ) , + _VNS_sgte_eval ( s._VNS_sgte_eval ) , + _nb_usr_searches ( s._nb_usr_searches ) , + _usr_srch_pts ( s._usr_srch_pts ) , + _usr_srch_success ( s._usr_srch_success ) , + _nb_success_dyn_dir ( s._nb_success_dyn_dir ) {} + + /// Affectation operator. + /** + \param s The right-hand side object -- \b IN. + */ + Stats & operator = ( const Stats & s ); + + /// Destructor. + virtual ~Stats ( void ) {} + + /// Reset the stats. + void reset ( void ); + + /// Update stats from another NOMAD::Stats object. + /** + \param s The other NOMAD::Stats object -- \b IN. + \param for_search A flag equal to \c true if the method + has been invoked within a search step + -- \b IN. + */ + void update ( const Stats & s , bool for_search ); + + /// Update the \c sum stat. + /** + \param d New \c sum element -- \b IN. + */ + void update_stat_sum ( const NOMAD::Double & d ); + + /// Update the \c avg stat. + /** + \param d New \c avg element -- \b IN. + */ + void update_stat_avg ( const NOMAD::Double & d ); + + /// Add \c 1 to stat \c _mads_run. + void add_mads_run ( void ) { ++_mads_runs; } + + /// Set the number of MADS runs. + void set_mads_runs ( int mads_runs ) { _mads_runs = mads_runs; } + + /// Add \c 1 to stat \c _eval. + void add_eval ( void ) { ++_eval; } + + /// Add \c 1 to stat \c _sim_bb_eval. + void add_sim_bb_eval ( void ) { ++_sim_bb_eval; } + + /// Add \c 1 to stat \c _sgte_eval. + void add_sgte_eval ( void ) { ++_sgte_eval; } + + /// Add \c count_eval to stat \c _sgte_eval. + void add_sgte_eval ( int count_eval ) { _sgte_eval+=count_eval; } + + /// Add \c 1 to stat \c _bb_eval. + void add_bb_eval ( void ) { ++_bb_eval; } + + /// Add \c 1 to stat \c _block_eval. + void add_one_block_eval ( void ) { ++_block_eval; } + + /// Add \c count_eval to stat \c _bb_eval. + void add_bb_eval ( int count_eval ) { _bb_eval+=count_eval; } + + /// Add \c 1 to stat \c _failed_eval. + void add_failed_eval ( void ) { ++_failed_eval; } + + /// Add \c 1 to stat \c _cache_hits. + void add_cache_hit ( void ) { ++_cache_hits; } + + /// Add \c 1 to stat \c _interrupted_eval. + void add_interrupted_eval ( void ) { ++_interrupted_eval; } + + /// Add \c 1 to stat \c _iterations. + void add_iteration ( void ) { ++_iterations; } + + /// Add \c 1 to stat \c _nb_poll_searches. + void add_nb_poll_searches ( void ) { ++_nb_poll_searches; } + + /// Add \c 1 to stat \c _poll_success. + void add_poll_success ( void ) { ++_poll_success; } + + /// Add \c 1 to stat \c _nb_ext_polls. + void add_nb_ext_polls ( void ) { ++_nb_ext_polls; } + + /// Add \c 1 to stat \c _ext_poll_succ. + void add_ext_poll_succ ( void ) { ++_ext_poll_succ; } + + /// Add \c 1 to stat \c _ext_poll_descents. + void add_ext_poll_descent ( void ) { ++_ext_poll_descents; } + + /// Add \c 1 to stat \c _nb_spec_searches. + void add_nb_spec_searches ( void ) { ++_nb_spec_searches; } + + /// Add \c 1 to stat \c _spec_success. + void add_spec_success ( void ) { ++_spec_success; } + + /// Add \c 1 to stat \c _LH_success. + void add_LH_success ( void ) { ++_LH_success; } + + /// Add \c 1 to stat \c _nb_cache_searches. + void add_nb_cache_searches ( void ) { ++_nb_cache_searches; } + + /// Add \c 1 to stat \c _nb_LH_searches. + void add_nb_LH_searches ( void ) { ++_nb_LH_searches; } + + /// Add \c 1 to stat \c _CS_success. + void add_CS_success ( void ) { ++_CS_success; } + + /// Add \c 1 to stat \c _nb_VNS_searches. + void add_nb_VNS_searches ( void ) { ++_nb_VNS_searches; } + + /// Add \c 1 to stat \c _VNS_success. + void add_VNS_success ( void ) { ++_VNS_success; } + + /// Add \c 1 to stat \c _nb_usr_searches. + void add_nb_usr_searches ( void ) { ++_nb_usr_searches; } + + /// Add \c 1 to stat \c _usr_srch_success. + void add_usr_srch_success ( void ) { ++_usr_srch_success; } + + + /// Add \c 1 to stat \c _nb_success_dyn_dir. + void add_nb_success_dyn_dir(void) {++_nb_success_dyn_dir;} + + /// Add an integer to stat \c _p1_iterations. + /** + \param i The integer -- \b IN. + */ + void add_p1_iterations ( int i ) { _p1_iterations += i; } + + /// Add an integer to stat \c _p1_bbe. + /** + \param i The integer -- \b IN. + */ + void add_p1_bbe ( int i ) { _p1_bbe += i; } + + /// Add an integer to stat \c _poll_pts. + /** + \param i The integer -- \b IN. + */ + void add_poll_pts ( int i ) { _poll_pts += i; } + + /// Add an integer to stat \c _ext_poll_pts. + /** + \param i The integer -- \b IN. + */ + void add_ext_poll_pts ( int i ) { _ext_poll_pts += i; } + + /// Add an integer to stat \c _ext_poll_bb_eval. + /** + \param i The integer -- \b IN. + */ + void add_ext_poll_bb_eval ( int i ) { _ext_poll_bb_eval += i;} + + /// Add an integer to stat \c _spec_pts. + /** + \param i The integer -- \b IN. + */ + void add_spec_pts ( int i ) { _spec_pts += i; } + + /// Add an integer to stat \c _LH_pts. + /** + \param i The integer -- \b IN. + */ + void add_LH_pts ( int i ) { _LH_pts += i; } + + /// Add an integer to stat \c _CS_pts. + /** + \param i The integer -- \b IN. + */ + void add_CS_pts ( int i ) { _CS_pts += i; } + + /// Update model stats. + void update_model_stats ( const NOMAD::Model_Stats & ms ) + { + _model_stats.update ( ms ); + } + + /// Add an integer to stat \c _VNS_pts. + /** + \param i The integer -- \b IN. + */ + void add_VNS_pts ( int i ) { _VNS_pts += i; } + + /// Add an integer to stat \c _VNS_bb_eval. + /** + \param i The integer -- \b IN. + */ + void add_VNS_bb_eval ( int i ) { _VNS_bb_eval += i; } + + /// Add an integer to stat \c _VNS_sgte_eval. + /** + \param i The integer -- \b IN. + */ + void add_VNS_sgte_eval ( int i ) { _VNS_sgte_eval += i; } + + /// Add an integer to stat \c _usr_srch_pts. + /** + \param i The integer -- \b IN. + */ + void add_usr_srch_pts ( int i ) { _usr_srch_pts += i; } + #ifdef USE_MPI - - /// Add \c 1 to stat \c _asynchronous_success. - void add_asynchronous_success ( void ) { ++_asynchronous_success; } - - /// Add an integer to stat \c _MPI_data_size. - /** - \param i The integer -- \b IN. - */ - void set_MPI_data_size ( int i ) { _MPI_data_size = i; } + + /// Add \c 1 to stat \c _asynchronous_success. + void add_asynchronous_success ( void ) { ++_asynchronous_success; } + + /// Add an integer to stat \c _MPI_data_size. + /** + \param i The integer -- \b IN. + */ + void set_MPI_data_size ( int i ) { _MPI_data_size = i; } #endif - - /// Access to the stat \c _eval. - /** - \return The stat \c _eval. - */ - int get_eval ( void ) const { return _eval; } - - /// Access to the stat \c _sim_bb_eval. - /** - \return The stat \c _sim_bb_eval. - */ - int get_sim_bb_eval ( void ) const { return _sim_bb_eval; } - - /// Access to the stat \c _sgte_eval. - /** - \return The stat \c _sgte_eval. - */ - int get_sgte_eval ( void ) const { return _sgte_eval; } - - /// Access to the real time stat. - /** - \return The real time stat. - */ - int get_real_time ( void ) const { return _clock.get_real_time(); } - - /// Access to the stat \c _iterations. - /** - \return The stat \c _iterations. - */ - int get_iterations ( void ) const { return _iterations; } - - /// Access to the stat \c _failed_eval. - /** - \return The stat \c _failed_eval. - */ - int get_failed_eval ( void ) const { return _failed_eval; } - - /// Access to the stat \c _mads_runs. - /** - \return The stat \c _mads_runs. - */ - int get_mads_runs ( void ) const { return _mads_runs; } - - /// Access to the stat \c _LH_pts. - /** - \return The stat \c _LH_pts. - */ - int get_LH_pts ( void ) const { return _LH_pts; } - - /// Access to the stat \c _CS_pts. - /** - \return The stat \c _CS_pts. - */ - int get_CS_pts ( void ) const { return _CS_pts; } - - /// Access to the stat \c _VNS_bb_eval. - /** - \return The stat \c _VNS_bb_eval. - */ - int get_VNS_bb_eval ( void ) const { return _VNS_bb_eval; } - - /// Access to the stat \c _VNS_sgte_eval. - /** - \return The stat \c _VNS_sgte_eval. - */ - int get_VNS_sgte_eval ( void ) const { return _VNS_sgte_eval; } - - /// Access to the number of cache hits. - /** - \return The number of cache hits. - */ - int get_cache_hits ( void ) const { return _cache_hits; } - - /// Access to the number of blackbox evaluations (includes surrogate cost). - /** - \return The number of blackbox evaluations. - */ - int get_bb_eval ( void ) const - { - return ( _sgte_cost > 0 ) ? _bb_eval + _sgte_eval / _sgte_cost : _bb_eval; - } - - - /// Access to the number of block of evaluations (includes bb and surrogates). - /** - \return The number of blackbox evaluations. - */ - int get_block_eval ( void ) const - { - return _block_eval; - } - - /// Access to the \c sum stat. - /** - \return The \c sum stat. - */ - NOMAD::Double get_stat_sum ( void ) const { return _stat_sum; } - - /// Access to the \c avg stat. - /** - \return The \c avg stat. - */ - NOMAD::Double get_stat_avg ( void ) const - { - return ( _cnt_avg > 0 ) ? _stat_avg/_cnt_avg : NOMAD::Double(); - } - - /// Access to the model stats. - /** - \return The model stats. - */ - const NOMAD::Model_Stats & get_model_stats ( void ) const { return _model_stats; } - - /// Display. + + /// Access to the stat \c _eval. + /** + \return The stat \c _eval. + */ + int get_eval ( void ) const { return _eval; } + + /// Access to the stat \c _sim_bb_eval. + /** + \return The stat \c _sim_bb_eval. + */ + int get_sim_bb_eval ( void ) const { return _sim_bb_eval; } + + /// Access to the stat \c _sgte_eval. + /** + \return The stat \c _sgte_eval. + */ + int get_sgte_eval ( void ) const { return _sgte_eval; } + + /// Access to the real time stat. + /** + \return The real time stat. + */ + int get_real_time ( void ) const { return _clock.get_real_time(); } + + /// Access to the stat \c _iterations. + /** + \return The stat \c _iterations. + */ + int get_iterations ( void ) const { return _iterations; } + + /// Access to the stat \c _failed_eval. + /** + \return The stat \c _failed_eval. + */ + int get_failed_eval ( void ) const { return _failed_eval; } + + /// Access to the stat \c _mads_runs. + /** + \return The stat \c _mads_runs. + */ + int get_mads_runs ( void ) const { return _mads_runs; } + + /// Access to the stat \c _LH_pts. + /** + \return The stat \c _LH_pts. + */ + int get_LH_pts ( void ) const { return _LH_pts; } + + /// Access to the stat \c _CS_pts. + /** + \return The stat \c _CS_pts. + */ + int get_CS_pts ( void ) const { return _CS_pts; } + + /// Access to the stat \c _VNS_bb_eval. + /** + \return The stat \c _VNS_bb_eval. + */ + int get_VNS_bb_eval ( void ) const { return _VNS_bb_eval; } + + /// Access to the stat \c _VNS_sgte_eval. + /** + \return The stat \c _VNS_sgte_eval. + */ + int get_VNS_sgte_eval ( void ) const { return _VNS_sgte_eval; } + + /// Access to the number of cache hits. + /** + \return The number of cache hits. + */ + int get_cache_hits ( void ) const { return _cache_hits; } + + /// Access to the number of blackbox evaluations (includes surrogate cost). + /** + \return The number of blackbox evaluations. + */ + int get_bb_eval ( void ) const + { + return ( _sgte_cost > 0 ) ? _bb_eval + _sgte_eval / _sgte_cost : _bb_eval; + } + + + /// Access to the number of block of evaluations (includes bb and surrogates). + /** + \return The number of blackbox evaluations. + */ + int get_block_eval ( void ) const + { + return _block_eval; + } + + /// Access to the \c sum stat. + /** + \return The \c sum stat. + */ + NOMAD::Double get_stat_sum ( void ) const { return _stat_sum; } + + /// Access to the \c avg stat. + /** + \return The \c avg stat. + */ + NOMAD::Double get_stat_avg ( void ) const + { + return ( _cnt_avg > 0 ) ? _stat_avg/_cnt_avg : NOMAD::Double(); + } + + /// Access to the model stats. + /** + \return The model stats. + */ + const NOMAD::Model_Stats & get_model_stats ( void ) const { return _model_stats; } + + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display ( const NOMAD::Display & out ) const; + }; + + /// Display a NOMAD::Stats object. /** - \param out The NOMAD::Display object -- \b IN. - */ - void display ( const NOMAD::Display & out ) const; - }; - - /// Display a NOMAD::Stats object. - /** \param out The NOMAD::Display object -- \b IN. \param s The NOMAD::Stats object to be displayed -- \b IN. \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Stats & s ) { - s.display ( out ); - return out; - } + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::Stats & s ) + { + s.display ( out ); + return out; + } } #endif diff --git a/src/TGP_Model.cpp b/src/TGP_Model.cpp deleted file mode 100644 index b5005f6055e2ac439798e019ba89e2fc028aec08..0000000000000000000000000000000000000000 --- a/src/TGP_Model.cpp +++ /dev/null @@ -1,1551 +0,0 @@ -/*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ -/* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ -/* */ -/* funded in part by AFOSR and Exxon Mobil */ -/* */ -/* Author: Sebastien Le Digabel */ -/* */ -/* Contact information: */ -/* Ecole Polytechnique de Montreal - GERAD */ -/* C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */ -/* e-mail: nomad@gerad.ca */ -/* phone : 1-514-340-6053 #6928 */ -/* fax : 1-514-340-5665 */ -/* */ -/* 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 <http://www.gnu.org/licenses/>. */ -/* */ -/* You can find information on the NOMAD software at www.gerad.ca/nomad */ -/*-------------------------------------------------------------------------------------*/ -/** - \file TGP_Model.cpp - \brief TGP (Bayesian treed Gaussian process) model for all outputs (implementation) - \author Sebastien Le Digabel - \date 2011-02-07 - \see TGP_Model.hpp -*/ - -#ifndef USE_TGP - -int TGP_DUMMY; // avoids that TGP_Model.o has no symbols with ranlib - -#else - -#include "TGP_Model.hpp" - -/*-----------------------------------*/ -/* constructor 1/2 */ -/*-----------------------------------*/ -NOMAD::TGP_Model::TGP_Model ( int n0 , - const std::vector<NOMAD::bb_output_type> & bbot , - const NOMAD::Display & out , - NOMAD::TGP_mode_type mode ) - : _out ( out ) , - _bbot ( bbot ) , - _p ( 0 ) , - _n0 ( n0 ) , - _n ( 0 ) , - _n_XX ( 0 ) , - _av_index ( NULL ) , - _fv_index ( NULL ) , - _X ( NULL ) , - _XX ( NULL ) , - _Ds2x ( NULL ) , - _improv ( NULL ) , - _model_computed ( false ) , - _nep_flag ( false ) , - _tgp_mode ( mode ) , - _tgp_models ( NULL ) , - _tgp_rect ( NULL ) , - _tgp_linburn ( true ) , - _usr_pmax ( -1 ) , - _tgp_verb ( false ) -{ - _usr_BTE[0] = _usr_BTE[1] = _usr_BTE[2] = -1; - - // user mode: this is not the good constructor to call: - if ( mode == NOMAD::TGP_USER ) - throw NOMAD::Exception ( "TGP_Model.cpp" , __LINE__ , - "this constructor only accepts fast or precise TGP modes" ); - - _error_str = "NOMAD::TGP_Model::set_X() has not been called"; -} - -/*--------------------------------------------------------*/ -/* constructor 2/2 (with user BTE and pmax and no bbot) */ -/*--------------------------------------------------------*/ -NOMAD::TGP_Model::TGP_Model ( int n0 , - const NOMAD::Display & out , - int BTE[3] , - bool linburn , - int pmax , - bool verb ) - : _out ( out ) , - _p ( 0 ) , - _n0 ( n0 ) , - _n ( 0 ) , - _n_XX ( 0 ) , - _av_index ( NULL ) , - _fv_index ( NULL ) , - _X ( NULL ) , - _XX ( NULL ) , - _Ds2x ( NULL ) , - _improv ( NULL ) , - _model_computed ( false ) , - _nep_flag ( false ) , - _tgp_mode ( NOMAD::TGP_USER ) , - _tgp_models ( NULL ) , - _tgp_rect ( NULL ) , - _tgp_linburn ( linburn ) , - _usr_pmax ( pmax ) , - _tgp_verb ( verb ) -{ - - // user BTE parameters: - _usr_BTE[0] = BTE[0]; - _usr_BTE[1] = BTE[1]; - _usr_BTE[2] = BTE[2]; - - // default bbot: just one objective output: - _bbot.push_back ( NOMAD::OBJ ); - - _error_str = "NOMAD::TGP_Model::set_X() has not been called"; -} - -/*--------------------------------------------*/ -/* destructor */ -/*--------------------------------------------*/ -NOMAD::TGP_Model::~TGP_Model ( void ) -{ - clear(); - - if ( _Ds2x ) { - int i , m = _bbot.size(); - for ( i = 0 ; i < m ; ++i ) - if ( _Ds2x[i] ) - delete [] _Ds2x[i]; - delete [] _Ds2x; - } - - if ( _improv ) - delete [] _improv; -} - -/*--------------------------------------------*/ -/* clear memory (private) */ -/*--------------------------------------------*/ -/* members that depend only on constructor */ -/* arguments are not reseted here */ -/*--------------------------------------------*/ -void NOMAD::TGP_Model::clear ( void ) -{ - int i; - - if ( _av_index ) { - delete [] _av_index; - _av_index = NULL; - } - - if ( _fv_index ) { - delete [] _fv_index; - _fv_index = NULL; - } - - if ( _X ) { - for ( i = 0 ; i < _p ; ++i ) - delete [] _X[i]; - delete [] _X; - _X = NULL; - } - - if ( _XX ) { - for ( i = 0 ; i < _n_XX ; ++i ) - delete [] _XX[i]; - delete [] _XX; - _XX = NULL; - } - - if ( _tgp_models ) { - int m = _bbot.size(); - for ( i = 0 ; i < m ; ++i ) - if ( _tgp_models[i] ) { - delete _tgp_models[i]; - } - delete [] _tgp_models; - _tgp_models = NULL; - } - - if ( _tgp_rect ) { - delete_matrix ( _tgp_rect ); - _tgp_rect = NULL; - } - - _error_str.clear(); - _lb.clear(); - _ub.clear(); - _fv.clear(); - - _p = _n = _n_XX = 0; - - _model_computed = false; -} - -/*--------------------------------------------*/ -/* set the interpolation set X (1/2) */ -/*--------------------------------------------*/ -bool NOMAD::TGP_Model::set_X ( const NOMAD::Cache & cache , // only truth evals - const NOMAD::Point * center , // the incumbent - int seed , - bool remove_fv ) -{ - std::vector<const NOMAD::Eval_Point *> X; - - const NOMAD::Eval_Point * cur = cache.begin(); - while ( cur ) { - X.push_back ( cur ); - cur = cache.next(); - } - - return set_X ( X , center , seed , remove_fv ); -} - -/*--------------------------------------------*/ -/* set the interpolation set X (2/2) */ -/*--------------------------------------------*/ -bool NOMAD::TGP_Model::set_X -( const std::vector<const NOMAD::Eval_Point *> & X , - const NOMAD::Point * center , - int seed , - bool remove_fv ) -{ - clear(); - _nep_flag = false; - - if ( X.size() <= 1 ) { - _error_str = ( X.empty() ) ? - "interpolation set X is empty" : "only one point in interpolation set X"; - _nep_flag = true; - return false; - } - - // filter and sort X: - std::list<const NOMAD::Eval_Point *> filtered_X; - _p = filter_and_sort_X ( X , center , filtered_X ); - - if ( _p == 0 ) { - _error_str = "no valid interpolation point"; - _nep_flag = true; - return false; - } - - int pmin , pmax; - bool valid = false; - - while ( !valid ) { - - _n = check_fixed_variables ( filtered_X , remove_fv ); - - if ( _n <= 1 ) { - _error_str = ( _n == 0 ) ? - "only fixed variables" : "interpolation set of dimension 1"; - return false; - } - - // get the limits pmin <= p <= pmax: - if ( !get_p_limits ( _n , pmin , pmax ) ) - return false; - - if ( _p < pmin ) { - std::ostringstream oss; - oss << "not enough interpolation points (" - << _p << "<=" << pmin << ")"; - _error_str = oss.str(); - _nep_flag = true; - return false; - } - - // reduce the number of interpolation points: - if ( _p > pmax ) { - filtered_X.resize ( pmax ); - _p = pmax; - valid = false; - } - - // the interpolation set has a valid size: - else - valid = true; - } - - // display limits on p: -#ifdef TGP_DEBUG - _out << std::endl - << "number of interpolation points: " - << pmin << " <= p=" << _p << " <= " << pmax - << std::endl; -#endif - - // create interpolation matrix X: - int i = 0 , j; - _X = new double * [_p]; - - std::list<const NOMAD::Eval_Point *>::const_iterator - it , end = filtered_X.end(); - for ( it = filtered_X.begin() ; it != end ; ++it , ++i ) { - _X[i] = new double[_n]; - for ( j = 0 ; j < _n ; ++j ) - _X[i][j] = (**it)[_fv_index[j]].value(); - } - - // check that X is of full rank: - if ( !NOMAD::TGP_Model::check_full_rank ( _X , _p , _n ) ) { - _error_str = "X is not of full rank"; - return false; - } - - // construct individual TGP models (one for each output): - int m = _bbot.size(); - _tgp_models = new NOMAD::TGP_Output_Model * [m]; - for ( i = 0 ; i < m ; ++i ) { - _tgp_models[i] = NULL; - if ( _bbot[i] == NOMAD::OBJ || NOMAD::bbot_is_constraint(_bbot[i]) ) - _tgp_models[i] = new NOMAD::TGP_Output_Model ( filtered_X , - i , - seed , - _out ); - } - - return _error_str.empty(); -} - -/*----------------------------------------------------*/ -/* get the limits pmin <= p <= pmax (private) */ -/*----------------------------------------------------*/ -bool NOMAD::TGP_Model::get_p_limits ( int n , int & pmin , int & pmax ) -{ - if ( n <= 0 ) { - _error_str = "bad value of n for the computation of pmin and pmax"; - return false; - } - - // TGP fast mode: - // -------------- - // - // example of some values for pmin and pmax: - // - // n pmin pmax - // - // 2 7 30 - // 3 8 30 - // 4 9 30 - // 5 10 30 - // 6 11 32 - // 7 12 35 - // 8 13 37 - // 9 14 40 - // 10 15 42 - // 20 25 60 - // 50 55 94 - // 55 60 99 - // 56 61 100 - // 57 62 100 - // 95 100 100 - // 96 101 101 - // 100 105 105 - - if ( _tgp_mode == NOMAD::TGP_FAST ) { - pmin = n+5; - - pmax = static_cast<int> ( floor ( sqrt(180.0*n) ) ); - - if ( pmax > 100 ) - pmax = 100; - - if ( pmax < 30 ) - pmax = 30; - - if ( pmax < pmin ) - pmax = pmin; - - return true; - } - - // TGP precise mode: pmin=n+1 and pmax=100 - // ----------------- - if ( _tgp_mode == NOMAD::TGP_PRECISE ) { - pmin = n+1; - pmax = 100; - return true; - } - - // TGP user mode: pmin=n+1 and pmax is user decided with constructor 2/2 - // -------------- - if ( _tgp_mode == NOMAD::TGP_USER ) { - pmin = n+1; - pmax = _usr_pmax; - if ( pmax < pmin ) { - std::ostringstream oss; - oss << "user pmax value must be > " << n; - _error_str = oss.str(); - return false; - } - return true; - } - - return true; -} - -/*----------------------------------------------*/ -/* get the TGP BTE parameters (private) */ -/*----------------------------------------------*/ -bool NOMAD::TGP_Model::get_BTE ( int BTE[3] ) -{ - // fast TGP mode: - // -------------- - // . if p=pmin, then B=2000 - // . if p=pmax, then B=1000 - // . if pmin<p<pmax, a linear relation is used - // . B is rounded so that 10 divides it - // . T=3B - // . E=10 (E divides T-B) - if ( _tgp_mode == NOMAD::TGP_FAST ) { - - int pmin , pmax; - get_p_limits ( _n , pmin , pmax ); - - double a = 1000.0 / (pmin-pmax); - double b = 2000 - a * pmin; - - BTE[0] = static_cast<int> ( 10.0 * floor ( (a * _p + b) / 10.0 ) ); - BTE[1] = 3*BTE[0]; - BTE[2] = 10; - } - - // precise TGP mode: - // ----------------- - else if ( _tgp_mode == NOMAD::TGP_PRECISE ) { - BTE[0] = 2000; - BTE[1] = 7000; - BTE[2] = 2; - } - - // user mode: - // ---------- - else { - BTE[0] = _usr_BTE[0]; - BTE[1] = _usr_BTE[1]; - BTE[2] = _usr_BTE[2]; - - // check the user BTE parameters: - if ( BTE[0] <= 0 || - BTE[1] <= 0 || - BTE[2] <= 0 || - BTE[1] <= BTE[0] ) { - _error_str = "error with user BTE"; - return false; - } - } - - return true; -} - -/*--------------------------------------------------------------*/ -/* compute the ranges, check the fixed variables, set the */ -/* different indexes, and return the number of free variables */ -/* (private) */ -/*--------------------------------------------------------------*/ -int NOMAD::TGP_Model::check_fixed_variables -( const std::list<const NOMAD::Eval_Point *> & X , - bool remove_fv ) -{ - - int i; - - if ( !_av_index ) { - _av_index = new int [_n0]; - for ( i = 0 ; i < _n0 ; ++i ) - _av_index[i] = -1; - } - - _lb = NOMAD::Point ( _n0 ); - _ub = NOMAD::Point ( _n0 ); - _fv = NOMAD::Point ( _n0 ); - - // compute ranges: - std::list<const NOMAD::Eval_Point *>::const_iterator it , end = X.end(); - for ( it = X.begin() ; it != end ; ++it ) { - for ( i = 0 ; i < _n0 ; ++i ) { - if ( !_lb[i].is_defined() || (**it)[i] < _lb[i] ) - _lb[i] = (**it)[i]; - if ( !_ub[i].is_defined() || (**it)[i] > _ub[i] ) - _ub[i] = (**it)[i]; - } - } - - // compute n (number of free variables), the fixed variables, and the indexes: - int n = 0; - - std::vector<int> fv_index_tmp; - for ( i = 0 ; i < _n0 ; ++i ) { - if ( remove_fv && _lb[i] == _ub[i] ) { - _fv [i] = _lb[i]; - _av_index[i] = -1; - } - else { - fv_index_tmp.push_back ( i ); - _av_index[i] = n++; - } - } - - // complete the fixed var index construction: - if ( _fv_index ) - delete [] _fv_index; - _fv_index = NULL; - - if ( n > 0 ) { - _fv_index = new int[n]; - for ( i = 0 ; i < n ; ++i ) - _fv_index[i] = fv_index_tmp[i]; - } - - return n; -} - -/*--------------------------------------------------------*/ -/* filter and sort an interpolation set X (private) */ -/* . the points are sorted relatively to the distance */ -/* from the center */ -/* . if the center is not defined (equal to NULL), */ -/* an alternate center is constructed */ -/*--------------------------------------------------------*/ -int NOMAD::TGP_Model::filter_and_sort_X -( const std::vector<const NOMAD::Eval_Point *> & X , - const NOMAD::Point * center , - std::list<const NOMAD::Eval_Point *> & filtered_X ) const -{ - NOMAD::Point alt_center; - const NOMAD::Eval_Point * cur = NULL; - int p0 = X.size() , i; - - // alternate center if center==NULL: - if ( !center ) { - int j; - NOMAD::Point lb(_n0) , ub(_n0); - for ( i = 0 ; i < p0 ; ++i ) { - cur = X[i]; - if ( test_interpolation_point ( cur ) ) { - for ( j = 0 ; j < _n0 ; ++j ) { - if ( !lb[j].is_defined() || (*cur)[j] < lb[j] ) - lb[j] = (*cur)[j]; - if ( !ub[j].is_defined() || (*cur)[j] > ub[j] ) - ub[j] = (*cur)[j]; - } - } - } - alt_center = NOMAD::Point(_n0); - for ( j = 0 ; j < _n0 ; ++j ) - alt_center[j] = ( lb[j] + ub[j] ) / 2.0; - } - - // X_tmp is used to sort the points: - std::multiset<NOMAD::Model_Sorted_Point> tmp_X; - - for ( i = 0 ; i < p0 ; ++i ) { - - cur = X[i]; - - // test if the interpolation point is valid for interpolation: - if ( test_interpolation_point ( cur ) ) { - - NOMAD::Model_Sorted_Point sorted_pt - ( &NOMAD::Cache::get_modifiable_point (*cur) , - (center) ? *center : alt_center ); - - tmp_X.insert ( sorted_pt ); - } - } - - // copy the set X_tmp to filtered_X: - std::multiset<NOMAD::Model_Sorted_Point>::const_iterator it , end = tmp_X.end(); - for ( it = tmp_X.begin() ; it != end ; ++it ) - filtered_X.push_back ( static_cast<NOMAD::Eval_Point *> ( it->get_point() ) ); - - return filtered_X.size(); -} - -/*-----------------------------------------------------*/ -/* tests to check if an interpolation point is valid */ -/* (private) */ -/*-----------------------------------------------------*/ -bool NOMAD::TGP_Model::test_interpolation_point ( const NOMAD::Eval_Point * x ) const -{ - if ( !x || x->size() != _n0 || !x->is_eval_ok() ) - return false; - - int m = _bbot.size(); - const NOMAD::Point & bbo = x->get_bb_outputs(); - - if ( bbo.size() != m ) - return false; - - for ( int j = 0 ; j < m ; ++j ) - if ( ( _bbot[j] == NOMAD::OBJ || NOMAD::bbot_is_constraint(_bbot[j]) ) && - ( !bbo[j].is_defined() || bbo[j].abs() > NOMAD::MODEL_MAX_OUTPUT ) ) - return false; - - // point is valid: - return true; -} - -/*--------------------------------------------*/ -/* compute the models (one for each output) */ -/*--------------------------------------------*/ -bool NOMAD::TGP_Model::compute -( std::vector<NOMAD::Eval_Point *> & XX_pts , // IN/OUT - bool compute_Ds2x , // IN - bool compute_improv , // IN - bool pred_outside_bnds ) // IN -{ - _model_computed = false; - - if ( !_error_str.empty() ) - return false; - - int i , j , index_obj = -1 , n_XX0 = XX_pts.size() , m = _bbot.size(); - - // check bbot: there must be exactly one objective: - for ( i = 0 ; i < m ; ++i ) { - if ( _bbot[i] == NOMAD::OBJ ) { - if ( index_obj < 0 ) - index_obj = i; - else { - _error_str = "more than one objective"; - return false; - } - } - } - if ( index_obj < 0 ) { - _error_str = "no objective"; - return false; - } - - // check n_XX0: - if ( n_XX0 == 0 ) { - _error_str = "no user-provided prediction point"; - return false; - } - - // reset XX_pts outputs: - for ( i = 0 ; i < n_XX0 ; ++i ) { - for ( j = 0 ; j < m ; ++j ) - XX_pts[i]->set_bb_output ( j , NOMAD::Double() ); - XX_pts[i]->set_eval_status ( NOMAD::EVAL_FAIL ); - } - - // create the XX matrix (prediction points): - std::vector<NOMAD::Eval_Point *> XX_filtered_pts; - NOMAD::Eval_Point * cur2; - - // the list of points has to be filtered: - NOMAD::Double tmp; - bool chk; - - for ( i = 0 ; i < n_XX0 ; ++i ) { - if ( XX_pts[i]->size() == _n0 ) { - cur2 = XX_pts[i]; - chk = true; - for ( j = 0 ; j < _n0 ; ++j ) { - tmp = (*cur2)[j]; - if ( !pred_outside_bnds && ( tmp < _lb[j] || tmp > _ub[j] ) ) { - chk = false; - break; - } - } - if ( chk ) - XX_filtered_pts.push_back ( cur2 ); - } - } - - if ( _XX ) { - for ( i = 0 ; i < _n_XX ; ++i ) - delete [] _XX[i]; - delete [] _XX; - } - - _n_XX = XX_filtered_pts.size(); - - if ( _n_XX == 0 ) { - _error_str = "no prediction point after filtering"; - return false; - } - - _XX = new double * [_n_XX]; - for ( i = 0 ; i < _n_XX ; ++i ) { - _XX[i] = new double[_n]; - for ( j = 0 ; j < _n ; ++j ) - _XX[i][j] = (*XX_filtered_pts[i])[_fv_index[j]].value(); - } - - // Xsplit: X+XX: size = nsplit x n: - int nsplit = _p + _n_XX; - double ** Xsplit = new double * [nsplit]; - - for ( i = 0 ; i < _p ; ++i ) { - Xsplit[i] = new double [_n]; - for ( j = 0 ; j < _n ; ++j ) - Xsplit[i][j] = _X[i][j]; - } - - for ( i = _p ; i < nsplit ; ++i ) { - Xsplit[i] = new double [_n]; - for ( j = 0 ; j < _n ; ++j ) - Xsplit[i][j] = _XX[i-_p][j]; - } - - // get the rectangle: - if ( _tgp_rect ) - delete_matrix ( _tgp_rect ); - _tgp_rect = get_data_rect ( Xsplit , nsplit , _n ); - - // TGP parameters: - Params tgp_params ( _n ); - double * dparams = NOMAD::TGP_Model::get_TGP_dparams ( _n ); - tgp_params.read_double ( dparams ); - delete [] dparams; - - int BTE[3]; - if ( !get_BTE ( BTE ) ) { - for ( i = 0 ; i < nsplit ; ++i ) - delete [] Xsplit[i]; - delete [] Xsplit; - return false; - } - - // display BTE: -#ifdef TGP_DEBUG - _out << std::endl - << "BTE={" << BTE[0] << ", " << BTE[1] << ", " << BTE[2] << "}" - << std::endl; -#endif - - // compute the individual TGP models (one for each output): - double * ZZ = new double [_n_XX]; - - // Ds2x, expected reduction in predictive variance: - if ( _Ds2x == NULL ) { - _Ds2x = new double * [m]; - for ( i = 0 ; i < m ; ++i ) - _Ds2x[i] = NULL; - } - else { - for ( i = 0 ; i < m ; ++i ) - if ( _Ds2x[i] ) { - delete [] _Ds2x[i]; - _Ds2x[i] = NULL; - } - } - - // improv, expected improvement of the objective (ranks): - if ( _improv ) { - delete [] _improv; - _improv = NULL; - } - if ( compute_improv ) - _improv = new int [_n_XX]; - - for ( i = 0 ; i < m ; ++i ) { - - if ( _tgp_models[i] ) { - - _Ds2x[i] = ( compute_Ds2x ) ? new double [_n_XX] : NULL; - - _tgp_models[i]->compute ( _X , - _XX , - Xsplit , - _n , - _n_XX , - nsplit , - &tgp_params , - _tgp_rect , - BTE , - _tgp_linburn , - _tgp_verb , - ZZ , - _Ds2x[i] , - (i==index_obj) ? _improv : NULL ); - - // set XX_pts outputs #i: - for ( j = 0 ; j < _n_XX ; ++j ) { - XX_filtered_pts[j]->set_bb_output ( i , ZZ[j] ); - XX_filtered_pts[j]->set_eval_status ( NOMAD::EVAL_OK ); - } - - // check if TGP has been interrupted: - if ( NOMAD::TGP_Output_Model::get_force_quit() ) { - _error_str = "TGP has been interrupted with ctrl-c"; - break; - } - } - } - - // clear memory: - for ( i = 0 ; i < nsplit ; ++i ) - delete [] Xsplit[i]; - delete [] Xsplit; - delete [] ZZ; - - _model_computed = _error_str.empty(); - - return _model_computed; -} - -/*--------------------------------------------*/ -/* prediction at one point */ -/* (x can be of size _n or _n0) */ -/*--------------------------------------------*/ -bool NOMAD::TGP_Model::predict ( NOMAD::Eval_Point & x , bool pred_outside_bnds ) -{ - if ( !_error_str.empty() ) - return false; - - if ( !_model_computed ) { - _error_str = "NOMAD::TGP_Model::compute() has not been called"; - return false; - } - - int i , i0 , ix , m = x.get_m() , nx = x.size(); - - // reset point outputs: - x.set_eval_status ( NOMAD::EVAL_FAIL ); - for ( i = 0 ; i < m ; ++i ) - x.set_bb_output ( i , NOMAD::Double() ); - - // check dimensions: - if ( m != static_cast<int>(_bbot.size()) || - ( nx != _n0 && nx != _n ) ) { - _error_str = "predict error: bad x dimensions"; - return false; - } - - double ZZ , * XX = new double[_n]; - - // set the coordinates and check the bounds: - for ( i = 0 ; i < _n ; ++i ) { - - ix = ( nx == _n0 ) ? _fv_index[i] : i; - - if ( !pred_outside_bnds ) { - i0 = _fv_index[i]; - if ( x[ix] < _lb[i0] || x[ix] > _ub[i0] ) { - delete [] XX; - return false; // this is not an error - } - } - - XX[i] = x[ix].value(); - } - - // predictions (one for each output): - for ( i = 0 ; i < m ; ++i ) - if ( _tgp_models[i] ) { - if ( !_tgp_models[i]->predict ( XX , - _n , - ZZ , - _tgp_rect ) ) { - std::ostringstream oss; - oss << "predict error: problem with model #" << i; - _error_str = oss.str(); - break; - } - x.set_bb_output ( i , ZZ ); - } - - delete [] XX; - - if ( !_error_str.empty() ) { - x.set_eval_status ( NOMAD::EVAL_FAIL ); - return false; - } - - x.set_eval_status ( NOMAD::EVAL_OK ); - return true; -} - -/*-----------------------------------------------------------------*/ -/* this function checks if the p x n matrix X is of full rank by */ -/* applying the Cholesky decomposition to the sym. def. pos. */ -/* nxn matrix X'X */ -/* (static, private) */ -/*-----------------------------------------------------------------*/ -bool NOMAD::TGP_Model::check_full_rank ( double ** X , int p , int n ) { - - int i , j , k , ki , kii , kij , kj , kji , nn12 = n*(n+1)/2; - - // create XTX (X'X): - double * XTX = new double [nn12]; - for ( i = 0 ; i < n ; ++i ) { - ki = i*(i+1)/2; - for ( j = 0 ; j <= i ; ++j ) { - kij = ki + j; - XTX[kij] = 0.0; - for ( k = 0 ; k < p ; ++k ) - XTX[kij] += X[k][i] * X[k][j]; - } - } - - // create chol: - double * chol = new double [nn12] , tmp1 , tmp2 , eps = 1e-10; - - // Choleski decomposition: - for ( i = 0 ; i < n ; ++i ) { - - ki = i*(i+1)/2; - kii = ki+i; - tmp1 = XTX[kii]; - for ( k = 0 ; k < i ; ++k ) - tmp1 -= pow(chol[ki+k],2.0); - if ( fabs ( tmp1 ) <= eps ) { - delete [] XTX; - delete [] chol; - return false; - } - - if ( i == n-1 ) - break; - - tmp1 = sqrt(tmp1); - chol[kii] = tmp1; - - for ( j = i+1 ; j < n ; ++j ) { - kj = j*(j+1)/2; - kji = kj+i; - tmp2 = XTX[kji]; - for ( k = 0 ; k < i ; ++k ) - tmp2 -= chol[ki+k]*chol[kj+k]; - chol[kji] = tmp2/tmp1; - } - } - - delete [] XTX; - delete [] chol; - - return true; -} - -/*----------------------------------------------------------------*/ -/* compute model h and f values given one blackbox output */ -/*----------------------------------------------------------------*/ -void NOMAD::TGP_Model::eval_hf ( const NOMAD::Point & bbo , - const NOMAD::Double & h_min , - NOMAD::hnorm_type h_norm , - NOMAD::Double & h , - NOMAD::Double & f ) const -{ - f.clear(); - h = 0.0; - - int m = bbo.size(); - - if ( m != static_cast<int>(_bbot.size()) ) - throw NOMAD::Exception ( "TGP_Model.cpp" , __LINE__ , - "TGP_Model::eval_hf() called with an invalid bbo argument" ); - - NOMAD::Double bboi; - - for ( int i = 0 ; i < m ; ++i ) { - - bboi = bbo[i]; - - if ( bboi.is_defined() ) { - - if ( _bbot[i] == NOMAD::EB || _bbot[i] == NOMAD::PEB_E ) { - - if ( bboi > h_min ) { - h.clear(); - return; - } - } - - else if ( ( _bbot[i] == NOMAD::FILTER || - _bbot[i] == NOMAD::PB || - _bbot[i] == NOMAD::PEB_P ) ) { - if ( bboi > h_min ) { - switch ( h_norm ) { - case NOMAD::L1: - h += bboi; - break; - case NOMAD::L2: - h += bboi * bboi; - break; - case NOMAD::LINF: - if ( bboi > h ) - h = bboi; - break; - } - } - } - - else if ( _bbot[i] == NOMAD::OBJ ) - f = bboi; - } - - } - - if ( h_norm == NOMAD::L2 ) - h = h.sqrt(); -} - -/*---------------------------------------*/ -/* compute the TGP dparam array */ -/* (static, private) */ -/*---------------------------------------*/ -double * NOMAD::TGP_Model::get_TGP_dparams ( int n ) { - - double * dparams = new double [n*(n+3)+41]; - int i , j , k; - - // tree (p <- c(as.numeric(params$tree))): - dparams[0] = 0.5; - dparams[1] = 2.0; - dparams[2] = n+2; - if ( dparams[2] < 10 ) - dparams[2] = 10; - dparams[3] = 1.0; - dparams[4] = n; - - // params$meanfn == "linear" : - dparams[5] = 0.0; - - // params$bprior == "bflat" : - dparams[6] = 2.0; - - // p <- c(p, as.numeric(params$beta)) : n+1 zeros - k = 6; - for ( i = 0 ; i <= n ; ++i ) - dparams[++k] = 0.0; - - // p <- c(p, as.numeric(params$Wi)) : I_{n+1} - for ( i = 0 ; i <= n ; ++i ) - for ( j = 0 ; j <= n ; ++j ) - dparams[++k] = (i!=j) ? 0.0 : 1.0; - - // p <- c(p, as.numeric(params$s2tau2)): - dparams[++k] = 1.0; - dparams[++k] = 1.0; - - // p <- c(p, as.numeric(params$s2.p)): - dparams[++k] = 5.0; - dparams[++k] = 10.0; - - // p <- c(p, as.numeric(params$s2.lam)): - dparams[++k] = 0.2; - dparams[++k] = 10.0; - - // p <- c(p, as.numeric(params$tau2.p)): - dparams[++k] = 5.0; - dparams[++k] = 10.0; - - // p <- c(p, as.numeric(params$tau2.lam)): - dparams[++k] = 0.2; - dparams[++k] = 0.1; - - // params$corr == "expsep" : - dparams[++k] = 1.0; - - // p <- c(p, as.numeric(params$gd)): - dparams[++k] = 0.1; - dparams[++k] = 0.5; - - // p <- c(p, as.numeric(params$nug.p)): - dparams[++k] = 1.0; - dparams[++k] = 1.0; - dparams[++k] = 1.0; - dparams[++k] = 1.0; - - // if (params$nug.lam[1] == "fixed"), p <- c(p, rep(-1, 4)) : - dparams[++k] = -1.0; - dparams[++k] = -1.0; - dparams[++k] = -1.0; - dparams[++k] = -1.0; - - // p <- c(p, as.numeric(params$gamma)): - dparams[++k] = 0.0; - dparams[++k] = 0.2; - dparams[++k] = 0.7; - - // p <- c(p, as.numeric(params$d.p)): - dparams[++k] = 1.0; - dparams[++k] = 20.0; - dparams[++k] = 10.0; - dparams[++k] = 10.0; - - // if (params$d.lam[1] == "fixed"), p <- c(p, rep(-1, 4)): - dparams[++k] = -1.0; - dparams[++k] = -1.0; - dparams[++k] = -1.0; - dparams[++k] = -1.0; - - return dparams; -} - -/*--------------------------------------------*/ -/* display the interpolation set X */ -/*--------------------------------------------*/ -void NOMAD::TGP_Model::display_X ( const NOMAD::Display & out , - int display_limit ) const -{ - if ( _p == 0 || !_X ) { - out << "no interpolation points" << std::endl; - return; - } - - int i , j; - int m = _bbot.size(); - int i0 = ( display_limit > 0 ) ? _p - display_limit : 0; - NOMAD::Point x(_n) , bbo(m); - - out << NOMAD::open_block ( "interpolation points (X)"); - - if ( i0 > 0 ) - out << "..." << std::endl; - else if ( i0 < 0 ) - i0 = 0; - - for ( i = i0 ; i < _p ; ++i ) { - - for ( j = 0 ; j < _n ; ++j ) - x[j] = _X[i][j]; - - bbo = NOMAD::Point(m); - if ( _tgp_models ) - for ( j = 0 ; j < m ; ++j ) - if ( _tgp_models[j] ) - bbo[j] = (_tgp_models[j]->get_Z())[i]; - - out << "#"; - out.display_int_w ( i , _p ); - out << " x=("; - x.display ( out , " " , 15 , -1 ); - out << " ) f(x)=["; - bbo.display ( out , " " , 15 , -1 ); - out << " ]" << std::endl; - } - - std::ostringstream oss; - oss << "(size=" << _p << ")"; - out << NOMAD::close_block ( oss.str() ) << std::endl; -} - -/*---------------------------------------------------------*/ -/* get the XX points with the largest expected reduction */ -/* in predictive variance, for each output */ -/* (no duplicates) */ -/*---------------------------------------------------------*/ -void NOMAD::TGP_Model::get_Ds2x_points ( std::set<int> & pts_indexes ) const -{ - pts_indexes.clear(); - if ( !_Ds2x || _n_XX == 0 ) - return; - - int i , j , k , m = _bbot.size(); - - for ( i = 0 ; i < m ; ++i ) - if ( _Ds2x[i] ) { - - NOMAD::Double max; - k = -1; - for ( j = 0 ; j < _n_XX ; ++j ) - if ( !max.is_defined() || _Ds2x[i][j] > max ) { - max = _Ds2x[i][j]; - k = j; - } - - if ( k >= 0 ) - pts_indexes.insert ( k ); - } -} - -/*----------------------------------------------------------------------------*/ -/* get the XX points with the largest expected improvement of the objective */ -/*----------------------------------------------------------------------------*/ -void NOMAD::TGP_Model::get_improv_points ( std::list<int> & pts_indexes ) const -{ - pts_indexes.clear(); - if ( !_improv || _n_XX == 0 ) - return; - - int j; - NOMAD::Point * XX_pt; - std::multiset<NOMAD::Model_Sorted_Point> pts; - std::multiset<NOMAD::Model_Sorted_Point>::const_iterator it , end; - - // 1. sort: - for ( j = 0 ; j < _n_XX ; ++j ) { - XX_pt = new NOMAD::Point ( 1 ); - (*XX_pt)[0] = j; - pts.insert ( NOMAD::Model_Sorted_Point ( XX_pt , _improv[j] ) ); - } - - // 2. construct pts_indexes (exclude points with improv >= n_XX): - end = pts.end(); - for ( it = pts.begin() ; it != end ; ++it ) { - if ( it->get_dist() < _n_XX ) - pts_indexes.push_back ( static_cast<int> ( (*it->get_point())[0].value() ) ); - delete it->get_point(); - } -} - -/*--------------------------------------------------------------*/ -/* display the expected improvement of the objective (improv) */ -/* (better ranks are displayed first) */ -/*--------------------------------------------------------------*/ -void NOMAD::TGP_Model::display_improv ( const NOMAD::Display & out , - int display_limit ) const -{ - if ( !_improv || _n_XX == 0 ) { - out << "improv has not been computed" << std::endl; - return; - } - - int j , k; - NOMAD::Point * XX_pt; - std::multiset<NOMAD::Model_Sorted_Point> pts; - std::multiset<NOMAD::Model_Sorted_Point>::const_iterator it , end; - - // 1. sort: - for ( j = 0 ; j < _n_XX ; ++j ) { - - // construct a NOMAD::Point from matrix _XX: - XX_pt = new NOMAD::Point ( _fv ); - for ( k = 0 ; k < _n0 ; ++k ) - if ( _av_index[k] >= 0 ) - (*XX_pt)[k] = _XX[j][_av_index[k]]; - - // insert this point in the sorted list: - pts.insert ( NOMAD::Model_Sorted_Point ( XX_pt , _improv[j] ) ); - } - - // 2. display: - end = pts.end(); - for ( j = 0 , it = pts.begin() ; it != end ; ++it , ++j ) { - - if ( display_limit <= 0 || j < display_limit ) { - out << "x=( "; - it->get_point()->display ( out , " " , 6 , -1 ); - out << " ) improv=" << it->get_dist() << std::endl; - } - - else if ( j == display_limit ) - out << "..." << std::endl; - - delete it->get_point(); - } -} - -/*----------------------------------------------------------------*/ -/* display the expected reduction in predictive variance (Ds2x) */ -/* (larger values are displayed first) */ -/*----------------------------------------------------------------*/ -void NOMAD::TGP_Model::display_Ds2x ( const NOMAD::Display & out , - int display_limit ) const -{ - if ( !_Ds2x || _n_XX == 0 ) { - out << "matrix Ds2x has not been computed" << std::endl; - return; - } - - int i , j , k , m = _bbot.size(); - NOMAD::Point * XX_pt; - std::multiset<NOMAD::Model_Sorted_Point> pts; - std::multiset<NOMAD::Model_Sorted_Point>::const_iterator it , end; - - for ( i = 0 ; i < m ; ++i ) { - - if ( m > 1 ) { - std::ostringstream oss; - oss << "output #" << i; - out << NOMAD::open_block ( oss.str() ); - } - - if ( _Ds2x[i] ) { - - // 1. sort: - for ( j = 0 ; j < _n_XX ; ++j ) { - - // construct a NOMAD::Point from matrix _XX: - XX_pt = new NOMAD::Point ( _fv ); - for ( k = 0 ; k < _n0 ; ++k ) - if ( _av_index[k] >= 0 ) - (*XX_pt)[k] = _XX[j][_av_index[k]]; - - // insert this point in the sorted list: - pts.insert ( NOMAD::Model_Sorted_Point ( XX_pt , -_Ds2x[i][j] ) ); - } - - // 2. display: - end = pts.end(); - for ( j = 0 , it = pts.begin() ; it != end ; ++it , ++j ) { - - if ( display_limit <= 0 || j < display_limit ) { - out << "x=( "; - it->get_point()->display ( out , " " , 6 , -1 ); - out << " ) Ds2x=" << it->get_dist()*-1.0 << std::endl; - } - - else if ( j == display_limit ) - out << "..." << std::endl; - - delete it->get_point(); - } - - pts.clear(); - } - else - out << "NULL" << std::endl; - - if ( m > 1 ) - out.close_block(); - } -} - -/*-------------------------------------------------------*/ -/* display the error stats for the interpolation set X */ -/*-------------------------------------------------------*/ -void NOMAD::TGP_Model::display_X_errors ( const NOMAD::Display & out ) -{ - if ( _p == 0 || !_X ) { - out << "no interpolation points" << std::endl; - return; - } - - int i , j , m = _bbot.size(); - NOMAD::Point min_err(m) , max_err(m) , avg_err(m,0.0) , sd_err(m,0.0); - NOMAD::Eval_Point x ( _n , m ); - double ** err = new double * [_p]; - - for ( i = 0 ; i < _p ; ++i ) { - - err[i] = new double[m]; - - for ( j = 0 ; j < _n ; ++j ) - x[j] = _X[i][j]; - - if ( predict ( x , true ) ) { - - for ( j = 0 ; j < m ; ++j ) - if ( _tgp_models[j] ) { - - // relative error (in %) for point #i and output #j: - err[i][j] = ( x.get_bb_outputs()[j].rel_err((_tgp_models[j]->get_Z())[i]) - * 100.0).value(); - - // out << "f=" << (_tgp_models[j]->get_Z())[i] << " " - // << "m=" << x.get_bb_outputs()[j] << " err=" << err[i][j] - // << std::endl; - - if ( !min_err[j].is_defined() || err[i][j] < min_err[j].value() ) - min_err[j] = err[i][j]; - - if ( !max_err[j].is_defined() || err[i][j] > max_err[j].value() ) - max_err[j] = err[i][j]; - - avg_err[j] += err[i][j]; - } - } - else { - for ( j = 0 ; j <= i ; ++j ) - delete [] err[j]; - delete [] err; - out << "cannot predict interpolation errors (" - << _error_str << ")" << std::endl; - return; - } - } - - for ( j = 0 ; j < m ; ++j ) - if ( _tgp_models[j] ) { - - // compute the median error: - NOMAD::Double med_err; - { - if ( _p == 1 ) - med_err = err[0][j]; - else if ( _p == 2 ) - med_err = ( err[0][j] + err[1][j] ) / 2.0; - - else { - std::multiset<double> sorted_errors; - for ( i = 0 ; i < _p ; ++i ) - sorted_errors.insert ( err[i][j] ); - std::multiset<double>::const_iterator it , end = sorted_errors.end(); - --end; - for ( it = sorted_errors.begin() , i = 0 ; it != end ; ++it , ++i ) { - if ( i == (_p+1)/2-1 ) { - med_err = *it; - if ( _p%2==0 ) { - ++it; - med_err = ( med_err + *it ) / 2.0; - } - break; - } - } - } - } - - // compute the mean and the standard deviation: - avg_err[j] /= _p; - for ( i = 0 ; i < _p ; ++i ) - sd_err[j] += ( avg_err[j] - err[i][j] ).pow2(); - sd_err[j] = (sd_err[j] / _p).sqrt(); - - // display: - if ( m > 1 ) { - std::ostringstream oss; - oss << "output #" << j; - if ( _tgp_models[j]->is_fixed() ) - oss << " (fixed)"; - else if ( _tgp_models[j]->is_binary() ) - oss << " (binary)"; - out << NOMAD::open_block ( oss.str() ); - } - - out << "min : "; - min_err[j].display ( out , "%6.2f" ); - out << std::endl << "max : "; - max_err[j].display ( out , "%6.2f" ); - out << std::endl << "median: "; - med_err.display ( out , "%6.2f" ); - out << std::endl << "mean : "; - avg_err[j].display ( out , "%6.2f" ); - out << std::endl << "sd : "; - sd_err[j].display ( out , "%6.2f" ); - out << std::endl; - - if ( m > 1 ) - out.close_block(); - } - - for ( i = 0 ; i < _p ; ++i ) - delete [] err[i]; - delete [] err; -} - -/*--------------------------------------------*/ -/* display */ -/*--------------------------------------------*/ -void NOMAD::TGP_Model::display ( const NOMAD::Display & out ) const -{ - if ( !_error_str.empty() ) { - out << "error with model" << std::endl; - return; - } - - int i , j; - - // fixed variables: - out << "fixed_var = [ " << _fv << "]" << std::endl; - out << "av_index = "; - if ( _av_index ) { - out << "[ "; - for ( i = 0 ; i < _n0 ; ++i ) - out << _av_index[i] << " "; - out << "]" << std::endl; - } - else - out << "NULL" << std::endl; - out << "fv_index = "; - if ( _fv_index ) { - out << "[ "; - for ( i = 0 ; i < _n ; ++i ) - out << _fv_index[i] << " "; - out << "]" << std::endl; - } - else - out << "NULL" << std::endl; - - // bounds: - out << "lb = [ " << _lb << "]" << std::endl - << "ub = [ " << _ub << "]" << std::endl - << std::endl; - - // display X: - if ( !_X ) - out << "X = NULL" << std::endl; - else { - out << "X = ["; - for ( i = 0 ; i < _p ; ++i ) { - out << "\t"; - for ( j = 0 ; j < _n ; ++j ) - out << std::setw(15) << _X[i][j] << " "; - out << ( (i==_p-1) ? "]" : ";" ) << std::endl; - } - out << "size(X)=" << _p << "x" << _n << std::endl << std::endl; - } - - // display XX: - if ( !_XX ) - out << "XX = NULL" << std::endl; - else { - out << "XX = ["; - for ( i = 0 ; i < _n_XX ; ++i ) { - out << "\t"; - for ( j = 0 ; j < _n ; ++j ) - out << std::setw(15) << _XX[i][j] << " "; - out << ( (i==_n_XX-1) ? "]" : ";" ) << std::endl; - } - out << "size(XX)=" << _n_XX << "x" << _n << std::endl << std::endl; - } - - // display models: - out << std::endl; - if ( _tgp_models ) { - int m = _bbot.size(); - for ( i = 0 ; i < m ; ++i ) { - if ( _tgp_models[i] ) { - std::ostringstream oss; - oss << "model #" << i; - out.open_block ( oss.str() ); - _tgp_models[i]->display ( out ); - out.close_block(); - } - else - out << "model #" << i << ": NULL" << std::endl; - out << std::endl; - } - } - else - out << "no models" << std::endl << std::endl; -} - -/*----------------------------------------------------------------*/ -/* access to the width of the interpolation set */ -/*----------------------------------------------------------------*/ -#ifdef MODEL_STATS -NOMAD::Double NOMAD::TGP_Model::get_Yw ( void ) const -{ - NOMAD::Double Yw , tmp; - for ( int i = 0 ; i < _n0 ; ++i ) { - tmp = _ub[i]-_lb[i]; - if ( !Yw.is_defined() || tmp > Yw ) - Yw = tmp; - } - return Yw; -} -#endif - -#endif diff --git a/src/TGP_Model.hpp b/src/TGP_Model.hpp deleted file mode 100644 index 78cf20ceeb4b0b6bf5d84eeaef61654abd83977b..0000000000000000000000000000000000000000 --- a/src/TGP_Model.hpp +++ /dev/null @@ -1,397 +0,0 @@ -/*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ -/* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ -/* */ -/* funded in part by AFOSR and Exxon Mobil */ -/* */ -/* Author: Sebastien Le Digabel */ -/* */ -/* Contact information: */ -/* Ecole Polytechnique de Montreal - GERAD */ -/* C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */ -/* e-mail: nomad@gerad.ca */ -/* phone : 1-514-340-6053 #6928 */ -/* fax : 1-514-340-5665 */ -/* */ -/* 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 <http://www.gnu.org/licenses/>. */ -/* */ -/* You can find information on the NOMAD software at www.gerad.ca/nomad */ -/*-------------------------------------------------------------------------------------*/ -/** - \file TGP_Model.hpp - \brief TGP (Bayesian treed Gaussian process) model for all outputs (headers) - \author Sebastien Le Digabel - \date 2011-02-07 - \see TGP_Model.cpp -*/ -#ifdef USE_TGP - -#ifndef __TGP_MODEL__ -#define __TGP_MODEL__ - -#include "TGP_Output_Model.hpp" -#include "Model_Sorted_Point.hpp" -#include "Cache.hpp" - -namespace NOMAD { - - /// TGP models for all outputs. - class TGP_Model : private NOMAD::Uncopyable { - - private: - - const NOMAD::Display & _out; ///< Display. - - std::vector<NOMAD::bb_output_type> _bbot; ///< Blackbox output types. - - std::string _error_str; ///< Error string. - - int _p; ///< Number of interpolation points. - - int _n0; ///< Original dimension (all variables). - int _n; ///< Number of free variables (\c n \c <= \c n0). - - int _n_XX; ///< Number of points (rows) in \c XX. - - NOMAD::Point _lb; ///< Lower bounds for \c X (size=\c n0). - NOMAD::Point _ub; ///< Upper bounds for \c X (size=\c n0). - NOMAD::Point _fv; ///< Fixed variables for \c X (size=\c n0). - - int * _av_index; ///< All variables index. - int * _fv_index; ///< Free variables index. - // - // avi[j] in [0;n -1], j in [0;n0-1]; avi[j]=-1: var j fixed - // fvi[j] in [0;n0-1], j in [0;n-1] - // - // example with n0=3 and n=2 (second variable is fixed): - // _av_index: [ 0 -1 1 ] - // _fv_index: [ 0 2 ] - - double ** _X; ///< Interpolation matrix \c X (size = \c p \c x \c n). - - double ** _XX; ///< Points at which evaluate the model (prediction points). - - double ** _Ds2x; ///< Expected reduction in predictive variance (\c Ds2x). - - int * _improv; ///< Expected improvement (ranks). - - bool _model_computed; ///< Flag to check if the model has been computed. - bool _nep_flag; ///< 'Not enought points' (nep) flag. - - NOMAD::TGP_mode_type _tgp_mode; ///< TGP mode (fast, precise, or user). - - NOMAD::TGP_Output_Model ** _tgp_models; ///< TGP models (one for each output). - // - // tgp_models[i] may be NULL if bbot[i] - // is not an objective or a constraint - - double ** _tgp_rect; ///< TGP rectangle (bounds). - - int _usr_BTE[3]; ///< User \c BTE parameters (TGP default: 2000,7000,2). - - bool _tgp_linburn; ///< TGP \c linburn parameter. - - int _usr_pmax; ///< User max number of interpolation points in \c X. - - bool _tgp_verb; ///< Display (\c verb) parameter. - - /// Clear memory. - void clear ( void ); - - /// Filter and sort the intepolation set \c X. - /** - \param X Original interpolation set (typically the cache) -- \b IN. - \param center Center of the model (may be NULL) -- \b IN. - \param filtered_X Filtered and sorted interpolation set -- \b OUT. - \return The number of filtered interpolation points. - */ - int filter_and_sort_X - ( const std::vector<const NOMAD::Eval_Point *> & X , - const NOMAD::Point * center , - std::list<const NOMAD::Eval_Point *> & filtered_X ) const; - - /** - Compute the ranges, check the fixed variables, set the - different indexes, and return the number of free variables. - \param X Filtered and sorted interpolation set -- \b IN. - \param remove_fv Set to \c true to eliminate fixed variables -- \b IN. - \return The number of free variables (member \c _n). - */ - int check_fixed_variables ( const std::list<const NOMAD::Eval_Point *> & X , - bool remove_fv ); - - /// Tests to check if an interpolation point is valid for interpolation. - /** - \param x The interpolation point -- \b IN. - \return A boolean equal to \c true if \c x is valid. - */ - bool test_interpolation_point ( const NOMAD::Eval_Point * x ) const; - - /// Get the limits on the interpolation set size \c p. - /** - \param n Number of free variables -- \b IN. - \param pmin Inf limit on \c p the number of interpolation points -- \b OUT. - \param pmax Sup limit on \c p -- \b OUT. - \return A boolean equal to \c true if the limits are valid. - */ - bool get_p_limits ( int n , int & pmin , int & pmax ); - - /// Get the TGP \c BTE parameters. - /** - \param BTE The BTE parameters -- \b OUT. - \return A boolean equal to \c true if the BTE parameters are valid. - */ - bool get_BTE ( int BTE[3] ); - - /// Compute the TGP \c dparam array. - /** - \param n Dimension -- \b IN. - \return A pointer to the \c dparam array. - */ - static double * get_TGP_dparams ( int n ); - - /// Check if the interpolation matrix is of full rank. - /** - \param X The \c X matrix -- \b IN. - \param p Number of rows -- \b IN. - \param n Number of columns -- \b IN. - \return A boolean equal to \c true if \c X is of full rank. - */ - static bool check_full_rank ( double ** X , int p , int n ); - - public: - - /// Constructor 1/2. - /** - \param n0 Dimension including fixed variables -- \b IN. - \param bbot Blackbox output types -- \b IN. - \param out Display object -- \b IN. - \param mode TGP mode (fast or precise only) -- \b IN. - */ - explicit TGP_Model ( int n0 , - const std::vector<NOMAD::bb_output_type> & bbot , - const NOMAD::Display & out , - NOMAD::TGP_mode_type mode ); - - /// Constructor 2/2 (with no blackbox output types; a value of \c m=1 is taken). - /** - This is the user TGP mode. - \param n0 Dimension including fixed variables -- \b IN. - \param out Display object -- \b IN. - \param BTE TGP \c B, \c T, and \c E parameters -- \b IN. - \param linburn TGP \c linburn parameter -- \b IN. - \param pmax Max number of interpolation points in \c X -- \b IN. - \param verb TGP \c verb parameter -- \b IN. - */ - explicit TGP_Model ( int n0 , - const NOMAD::Display & out , - int BTE[3] , - bool linburn , - int pmax , - bool verb ); - - /// Destructor. - virtual ~TGP_Model ( void ); - - /// Set the interpolation set \c X from a cache. - /** - \param cache Cache of true evaluations -- \b IN. - \param center Center of the model (the incumbent; may be \c NULL) -- \b IN. - \param seed Random seed -- \b IN. - \param remove_fv Set to \c true to eliminate fixed variables -- \b IN. - \return A boolean equal to \c true if no error occured. - */ - bool set_X ( const NOMAD::Cache & cache , - const NOMAD::Point * center , - int seed , - bool remove_fv ); - - /// Set the interpolation set \c X from a set of points. - /** - \param X The set of points -- \b IN. - \param center Center of the model ( may be \c NULL) -- \b IN. - \param seed Random seed -- \b IN. - \param remove_fv Set to \c true to eliminate fixed variables -- \b IN. - \return A boolean equal to \c true if no error occured. - */ - bool set_X ( const std::vector<const NOMAD::Eval_Point *> & X , - const NOMAD::Point * center , - int seed , - bool remove_fv ); - - /// Compute the models (one for each output). - /** - \param XX_pts Prediction points -- \b IN/OUT. - \param compute_Ds2x Flag to activate the Ds2x computation -- \b IN. - \param compute_improv Flag to activate the improv computation -- \b IN. - \param pred_outside_bnds If \c false, no prediction outside bounds -- \b IN. - \return A boolean equal to \c true if the model computation worked. - */ - bool compute ( std::vector<NOMAD::Eval_Point *> & XX_pts , - bool compute_Ds2x , - bool compute_improv , - bool pred_outside_bnds ); - - /// Prediction at one point. - /** - \param x The point (size \c _n or \c _n0) -- \b IN. - \param pred_outside_bnds Set to \c false to not predict outside bounds -- \b IN. - \return A boolean equal to \c true if the prediction worked. - */ - bool predict ( NOMAD::Eval_Point & x , bool pred_outside_bnds ); - - /// Compute model \c h and \c f values given one blackbox output. - /** - \param bbo Blackbox output -- \b IN. - \param h_min Value of \c h_min -- \b IN.. - \param h_norm Norm used to compute \c h -- \b IN.. - \param h Value of \c h -- \b OUT. - \param f Value of \c f -- \b OUT. - */ - void eval_hf ( const NOMAD::Point & bbo , - const NOMAD::Double & h_min , - NOMAD::hnorm_type h_norm , - NOMAD::Double & h , - NOMAD::Double & f ) const; - - /// Get the \c XX points with the largest expected improvement of the objective. - /** - \param pts_index The \c XX points indexes -- \b OUT. - */ - void get_improv_points ( std::list<int> & pts_indexes ) const; - - /// Get the \c XX points with the largest expected reduction in predictive variance. - /** - \param pts_index The \c XX points indexes -- \b OUT. - */ - void get_Ds2x_points ( std::set<int> & pts_indexes ) const; - - /// Get error string. - /** - \return The error string. - */ - const std::string & get_error_str ( void ) const { return _error_str; } - - /// Get \c nep flag (nep=not enough points). - /** - \return The nep flag. - */ - bool get_nep_flag ( void ) const { return _nep_flag; } - - /// Access to the number of interpolation points \c p. - /** - \return The number of interpolation points. - */ - int get_p ( void ) const { return _p; } - - /// Access to the number of free variables \c n. - /** - \return The number of free variables. - */ - int get_n ( void ) const { return _n; } - - /// Access to the total number of variables \c n0. - /** - \return The total number of variables. - */ - int get_n0 ( void ) const { return _n0; } - - /// Access to the lower bounds. - /** - \return The lower bounds. - */ - const NOMAD::Point & get_lb ( void ) const { return _lb; } - - /// Access to the upper bounds. - /** - \return The upper bounds. - */ - const NOMAD::Point & get_ub ( void ) const { return _ub; } - -#ifdef MODEL_STATS - /// Access to the width of the interpolation set \c X (or \c Y). - /** - \return The width of the interpolation set. - */ - NOMAD::Double get_Yw ( void ) const; -#endif - - /// Access to improv. - /** - \param i Index in the \c XX matrix -- \b IN. - \return The improv value of the ith point in \c XX. - */ - int get_improv ( int i ) const - { - return ( _improv == NULL || i < 0 || i >= _n_XX ) ? -1 : _improv[i]; - } - - /// Display the expected reduction in predictive variance (\c Ds2x). - /** - \param out Display -- \b IN. - \param display_limit Max number of pts displayed (-1 for no limit) -- \b IN. - */ - void display_Ds2x ( const NOMAD::Display & out , int display_limit = -1 ) const; - - /// Display the expected improvement ranks (\c improv). - /** - \param out Display -- \b IN. - \param display_limit Max number of pts displayed (-1 for no limit) -- \b IN. - */ - void display_improv ( const NOMAD::Display & out , int display_limit = -1 ) const; - - /// Display error stats for the interpolation set \c X. - /** - \param out Display -- \b IN. - */ - void display_X_errors ( const NOMAD::Display & out ); - - /// Display interpolation set \x X. - /** - \param out Display -- \b IN. - \param display_limit Max number of pts displayed (-1 for no limit) -- \b IN. - */ - void display_X ( const NOMAD::Display & out , int display_limit = -1 ) const; - - /// Default display. - void display ( void ) { display ( _out ); } - - /// Display. - /** - \param out Display -- \b IN. - */ - void display ( const NOMAD::Display & out ) const; - }; - - /// Display a NOMAD::TGP_Model object. - /** - \param out The NOMAD::Display object -- \b IN. - \param s The NOMAD::TGP_Model object to be displayed -- \b IN. - \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::TGP_Model & s ) { - s.display ( out ); - return out; - } -} - -#endif - -#endif diff --git a/src/TGP_Model_Evaluator.cpp b/src/TGP_Model_Evaluator.cpp deleted file mode 100644 index 3edc7c6587e4d318e6a239f15666be2ea3d3703a..0000000000000000000000000000000000000000 --- a/src/TGP_Model_Evaluator.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ -/* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ -/* */ -/* funded in part by AFOSR and Exxon Mobil */ -/* */ -/* Author: Sebastien Le Digabel */ -/* */ -/* Contact information: */ -/* Ecole Polytechnique de Montreal - GERAD */ -/* C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */ -/* e-mail: nomad@gerad.ca */ -/* phone : 1-514-340-6053 #6928 */ -/* fax : 1-514-340-5665 */ -/* */ -/* 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 <http://www.gnu.org/licenses/>. */ -/* */ -/* You can find information on the NOMAD software at www.gerad.ca/nomad */ -/*-------------------------------------------------------------------------------------*/ -/** - \file TGP_Model_Evaluator.cpp - \brief NOMAD::Evaluator subclass for TGP model optimization (implementation) - \author Sebastien Le Digabel - \date 2011-02-17 - \see TGP_Mopel_Evaluator.hpp -*/ - -#ifndef USE_TGP - -int TGP_MODEL_EVALUATOR_DUMMY; // avoids that TGP_Model_Evaluator.o has no symbols with ranlib - -#else - -#include "TGP_Model_Evaluator.hpp" - -/*------------------------------------------------------------------------*/ -/* evaluate the TGP model at a given trial point */ -/*------------------------------------------------------------------------*/ -bool NOMAD::TGP_Model_Evaluator::eval_x ( NOMAD::Eval_Point & x , - const NOMAD::Double & h_max , - bool & count_eval ) const -{ - count_eval = true; - if ( !_model.predict ( x , true ) ) - return false; - return true; -} - -#endif diff --git a/src/TGP_Model_Evaluator.hpp b/src/TGP_Model_Evaluator.hpp deleted file mode 100644 index 2a378f243deaac6a0c4683ffb00ed3085bfda72c..0000000000000000000000000000000000000000 --- a/src/TGP_Model_Evaluator.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ -/* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ -/* */ -/* funded in part by AFOSR and Exxon Mobil */ -/* */ -/* Author: Sebastien Le Digabel */ -/* */ -/* Contact information: */ -/* Ecole Polytechnique de Montreal - GERAD */ -/* C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */ -/* e-mail: nomad@gerad.ca */ -/* phone : 1-514-340-6053 #6928 */ -/* fax : 1-514-340-5665 */ -/* */ -/* 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 <http://www.gnu.org/licenses/>. */ -/* */ -/* You can find information on the NOMAD software at www.gerad.ca/nomad */ -/*-------------------------------------------------------------------------------------*/ -/** - \file TGP_Model_Evaluator.hpp - \brief NOMAD::Evaluator subclass for TGP model optimization (headers) - \author Sebastien Le Digabel - \date 2011-02-17 - \see TGP_Model_Evaluator.cpp -*/ -#ifdef USE_TGP - -#ifndef __TGP_MODEL_EVALUATOR__ -#define __TGP_MODEL_EVALUATOR__ - -#include "Search.hpp" -#include "Evaluator.hpp" - -namespace NOMAD { - - /// NOMAD::Evaluator subclass for quadratic model optimization. - class TGP_Model_Evaluator : public NOMAD::Evaluator { - - private: - -// int _n; ///< Number of variables. -// int _nm1; ///< Number of variables minus one. -// int _m; ///< Number of blackbox outputs. -// double * _x; ///< An evaluation point. -// double ** _alpha; ///< Model parameters. -// bool _model_ready; ///< \c true if model ready to evaluate. - - NOMAD::TGP_Model & _model; ///< The TGP model. - - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - \param model Model -- \b IN. - */ - TGP_Model_Evaluator ( const NOMAD::Parameters & p , - NOMAD::TGP_Model & model ) - : NOMAD::Evaluator ( p ) , - _model ( model ) {} - - /// Destructor. - virtual ~TGP_Model_Evaluator ( void ) {} - - /// Evaluate the blackboxes at a given trial point. - /** - \param x The trial point -- \b IN/OUT. - \param h_max Maximal feasibility value \c h_max -- \b IN. - \param count_eval Flag indicating if the evaluation has to be counted - or not -- \b OUT. - \return A boolean equal to \c false if the evaluation failed. - */ - virtual bool eval_x ( NOMAD::Eval_Point & x , - const NOMAD::Double & h_max , - bool & count_eval ) const; - }; -} - -#endif - -#endif diff --git a/src/TGP_Model_Search.cpp b/src/TGP_Model_Search.cpp deleted file mode 100644 index bf5b6bc80e670f0e13055f065f3b2979f836c41b..0000000000000000000000000000000000000000 --- a/src/TGP_Model_Search.cpp +++ /dev/null @@ -1,1683 +0,0 @@ -/*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ -/* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ -/* */ -/* funded in part by AFOSR and Exxon Mobil */ -/* */ -/* Author: Sebastien Le Digabel */ -/* */ -/* Contact information: */ -/* Ecole Polytechnique de Montreal - GERAD */ -/* C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */ -/* e-mail: nomad@gerad.ca */ -/* phone : 1-514-340-6053 #6928 */ -/* fax : 1-514-340-5665 */ -/* */ -/* 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 <http://www.gnu.org/licenses/>. */ -/* */ -/* You can find information on the NOMAD software at www.gerad.ca/nomad */ -/*-------------------------------------------------------------------------------------*/ -/** - \file TGP_Model_Search.cpp - \brief TGP Model search (implementation) - \author Sebastien Le Digabel - \date 2011-02-17 - \see TGP_Model_Search.hpp -*/ - -#ifndef USE_TGP - -int TGP_MODEL_SEARCH_DUMMY; // avoids that TGP_Model_Search.o has no symbols with ranlib - -#else - -#include "TGP_Model_Search.hpp" - -/*-----------------------------------*/ -/* reset (virtual) */ -/*-----------------------------------*/ -void NOMAD::TGP_Model_Search::reset ( void ) -{ - if ( _model ) - delete _model; - _model = NULL; -} - -/*--------------------------------------------------------*/ -/* delete a list of points: one version for points, and */ -/* one version for evaluation points (static, private) */ -/*--------------------------------------------------------*/ -void NOMAD::TGP_Model_Search::clear_pts ( std::vector<NOMAD::Point *> & pts ) -{ - size_t k , n = pts.size(); - for ( k = 0 ; k < n ; ++k ) - delete pts[k]; - pts.clear(); -} - -void NOMAD::TGP_Model_Search::clear_pts ( std::vector<NOMAD::Eval_Point *> & pts ) -{ - size_t k , n = pts.size(); - for ( k = 0 ; k < n ; ++k ) - delete pts[k]; - pts.clear(); -} - -/*------------------------------------------------------------------*/ -/* the search */ -/*------------------------------------------------------------------*/ -/* Search parameters: */ -/* ------------------ */ -/* */ -/* . MODEL_SEARCH: flag to activate the model search (MS) */ -/* (here its value is NOMAD::TGP_MODEL) */ -/* */ -/* . MODEL_SEARCH_OPTIMISTIC: if true, the direction from the */ -/* model center to the trial point */ -/* is computed and prossibly used */ -/* in the speculative search */ -/* default=yes */ -/* */ -/* . MODEL_SEARCH_PROJ_TO_MESH: project or not to mesh */ -/* default=yes */ -/* */ -/* . MODEL_SEARCH_MAX_TRIAL_PTS: limit on the number of trial */ -/* points for one search */ -/* default=10 */ -/* */ -/* . MODEL_TGP_MODE: TGP mode (FAST or PRECISE) */ -/* default=FAST */ -/* */ -/*------------------------------------------------------------------*/ -void NOMAD::TGP_Model_Search::search ( NOMAD::Mads & mads , - int & nb_search_pts , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - bool & count_search , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ) -{ - new_feas_inc = new_infeas_inc = NULL; - nb_search_pts = 0; - success = NOMAD::UNSUCCESSFUL; - count_search = false; - - _one_search_stats.reset(); - - const NOMAD::Display & out = _p.out(); - NOMAD::dd_type display_degree = out.get_search_dd(); - int display_lim = 15; - - if ( stop ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "TGP_Model_Search::search(): not performed (stop flag is active)" - << std::endl; - return; - } - - // active cache (we accept only true function evaluations): - const NOMAD::Cache & cache = mads.get_cache(); - if ( cache.get_eval_type() != NOMAD::TRUTH ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "TGP_Model_Search::search(): not performed on surrogates" - << std::endl; - return; - } - - // check that there is one objective exactly: - const std::list<int> & index_obj_list = _p.get_index_obj(); - - if ( index_obj_list.empty() ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "TGP_Model_Search::search(): not performed with no objective function" - << std::endl; - return; - } - if ( index_obj_list.size() > 1 ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "TGP_Model_Search::search(): not performed with biobjective" - << std::endl; - return; - } - - // active barrier: - const NOMAD::Barrier & barrier = mads.get_true_barrier(); - - // get the incumbent: - const NOMAD::Eval_Point * incumbent = barrier.get_best_feasible(); - if ( !incumbent ) - incumbent = barrier.get_best_infeasible(); - if ( !incumbent ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "TGP_Model_Search::search(): no incumbent" - << std::endl; - return; - } - - // get and check the signature, and compute the dimension: - NOMAD::Signature * signature = incumbent->get_signature(); - - if ( !signature ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "TGP_Model_Search::search(): no signature" - << std::endl; - return; - } - - int n = signature->get_n(); - - if ( n != incumbent->size() ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "TGP_Model_Search::search(): incompatible signature" - << std::endl; - return; - } - - // initial displays: - if ( display_degree == NOMAD::FULL_DISPLAY ) { - std::ostringstream oss; - oss << NOMAD::MODEL_SEARCH << " #" - << _all_searches_stats.get_MS_nb_searches(); - out << std::endl << NOMAD::open_block ( oss.str() ) << std::endl; - } - - // from this point the search is counted: - count_search = true; - _one_search_stats.add_MS_nb_searches(); - - NOMAD::Point delta_m; - signature->get_mesh()->get_delta(delta_m); - - // initial displays: - if ( display_degree == NOMAD::FULL_DISPLAY ) { -#ifdef TGP_DEBUG - out << "seed : " - << _p.get_seed() << std::endl; -#endif - out << "number of cache points: " << cache.size() << std::endl - << "mesh size parameter : ( " << delta_m << " )" << std::endl - << "incumbent : ( "; - incumbent->NOMAD::Point::display - ( out , " " , 2 , NOMAD::Point::get_display_limit() ); - out << " )" << std::endl; - } - - // construct the model: - NOMAD::Stats & stats = mads.get_stats(); - bool compute_Ds2x; - std::vector<NOMAD::Eval_Point *> XX; - std::string error_str; - - if ( !model_construction ( cache , - *incumbent , - delta_m , - out , - display_degree , - display_lim , - stats , - compute_Ds2x , - XX , - stop , - stop_reason , - error_str ) ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << NOMAD::close_block ( "failure: " + error_str ) - << std::endl; - return; - } - - // trial_pts = oracle_pts + Ds2x_pts + improv_pts - // - // oracle_pts: given by the model optimization - // Ds2x_pts : XX points with the largest expected reduction in predictive variance - // improv_pts: XX points with the largest expected improvement for the objective - - int max_pts = _p.get_model_search_max_trial_pts(); - - /*-----------------------*/ - /* oracle points (1/3) */ - /*-----------------------*/ - std::vector<NOMAD::Point *> oracle_pts; - if ( !create_oracle_pts ( cache , - *incumbent , - delta_m , - out , - display_degree , - display_lim , - XX , - oracle_pts , - stop , - stop_reason ) && stop ) { - - // delete XX and oracle_pts: - NOMAD::TGP_Model_Search::clear_pts ( XX ); - NOMAD::TGP_Model_Search::clear_pts ( oracle_pts ); - - // quit: - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << NOMAD::close_block ( "algorithm stop" ) - << std::endl; - return; - } - - /*---------------------*/ - /* Ds2x points (2/3) */ - /*---------------------*/ - std::vector<NOMAD::Point *> Ds2x_pts; - if ( compute_Ds2x ) - create_Ds2x_pts ( XX , out , display_degree , display_lim , Ds2x_pts ); - - /*-----------------------*/ - /* improv points (3/3) */ - /*-----------------------*/ - std::vector<NOMAD::Point *> improv_pts; - create_improv_pts ( XX , - *incumbent , - max_pts , - out , - display_degree , - display_lim , - improv_pts ); - - // create the complete list of trial points: - // ----------------------------------------- - std::vector<NOMAD::Point *> trial_pts; - create_trial_pts ( oracle_pts , - Ds2x_pts , - improv_pts , - *incumbent , - max_pts , - out , - display_degree , - trial_pts ); - - // evaluator control: - NOMAD::Evaluator_Control & ev_control = mads.get_evaluator_control(); - - // add the trial points to the evaluator control for evaluation: - int i , nop = trial_pts.size(); - for ( i = 0 ; i < nop ; ++i ) - register_point ( *trial_pts[i] , - *signature , - *incumbent , - display_degree , - ev_control ); - - // display the evaluator control list of points: - if ( display_degree == NOMAD::FULL_DISPLAY ) { - out << std::endl << NOMAD::open_block ( "list of trial points" ); - const std::set<NOMAD::Priority_Eval_Point> & lop = ev_control.get_eval_lop(); - std::set<NOMAD::Priority_Eval_Point>::const_iterator it , end = lop.end(); - nop = lop.size(); - for ( it = lop.begin() , i = 0 ; it != end ; ++it , ++i ) { - out << "#"; - out.display_int_w ( i , nop ); - out << " x=( "; - it->get_point()->NOMAD::Point::display ( out , " " , 15 , -1 ); - out << " )" << std::endl; - } - out.close_block(); - } - - // delete XX and the trial points - // (do not delete Ds2x_pts and improv_pts because - // they are XX points, contrary to oracle_pts): - NOMAD::TGP_Model_Search::clear_pts ( XX ); - NOMAD::TGP_Model_Search::clear_pts ( oracle_pts ); - - nb_search_pts = ev_control.get_nb_eval_points(); - - if ( nb_search_pts == 0 ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << "no trial point" << std::endl; - } - - else { - - _one_search_stats.update_MS_max_search_pts ( nb_search_pts ); - - // evaluate the trial points: - // -------------------------- - int bbe = stats.get_bb_eval(); - int sgte_eval = stats.get_sgte_eval (); - int cache_hits = stats.get_cache_hits(); - - new_feas_inc = new_infeas_inc = NULL; - - ev_control.disable_model_eval_sort(); - - std::list<const NOMAD::Eval_Point *> * evaluated_pts = NULL; - if ( display_degree == NOMAD::FULL_DISPLAY ) - evaluated_pts = new std::list<const NOMAD::Eval_Point *>; - - ev_control.eval_list_of_points ( _type , - mads.get_true_barrier() , - mads.get_sgte_barrier() , - mads.get_pareto_front() , - stop , - stop_reason , - new_feas_inc , - new_infeas_inc , - success , - evaluated_pts ); - - // display the prediction error for the evaluated points: - if ( display_degree == NOMAD::FULL_DISPLAY ) { - display_eval_pred_errors ( *evaluated_pts , out ); - delete evaluated_pts; - } - - ev_control.enable_model_eval_sort(); - - // update stats: - _one_search_stats.add_MS_bb_eval ( stats.get_bb_eval () - bbe ); - _one_search_stats.add_MS_sgte_eval ( stats.get_sgte_eval () - sgte_eval ); - _one_search_stats.add_MS_cache_hits ( stats.get_cache_hits() - cache_hits ); - - if ( success == NOMAD::FULL_SUCCESS ) - _one_search_stats.add_MS_success(); - - _one_search_stats.add_MS_pts ( nb_search_pts ); - } - - // update stats objects: - stats.update_model_stats ( _one_search_stats ); - _all_searches_stats.update ( _one_search_stats ); - - // final display: - if ( display_degree == NOMAD::FULL_DISPLAY ) { - std::ostringstream oss; - oss << "end of " << NOMAD::MODEL_SEARCH << " (" << success << ")"; - out << std::endl << NOMAD::close_block ( oss.str() ) << std::endl; - } -} - -/*---------------------------------------------------------------*/ -/* create XX a list of prediction points (private) */ -/*---------------------------------------------------------------*/ -void NOMAD::TGP_Model_Search::set_XX -( const NOMAD::Cache & cache , - int n , - int m , - const NOMAD::Point & incumbent , - const NOMAD::Point & delta_m , - std::vector<NOMAD::Eval_Point *> & XX ) const -{ - // . we begin with 1999 points, filter them to remove points - // that appear more than once or in the cache. - // . then we prune the list to 499 points. - // . we do not begin directly with 500 points because it - // gives more flexibility with the projection. - // . we terminate by adding the incumbent. - // --> we obtain a list of at most 500 prediction points. - - int j , i = 0 , n_XX = 1999; // 2000-1 - bool proj_to_mesh = _p.get_model_search_proj_to_mesh(); - bool remove_pt; - - // XX is made of n_XX-1 LH points inside the model bounds - // (and the incumbent will be added at the end): - NOMAD::LH_Search::LH_points ( n, m, n_XX, _model->get_lb(), _model->get_ub(), XX ); - - while ( i < n_XX ) { - - remove_pt = false; - - // project to the mesh: - if ( proj_to_mesh ) - XX[i]->project_to_mesh ( incumbent , delta_m , _p.get_lb() , _p.get_ub() ); - - // remove if point is in cache: - if ( cache.find ( *XX[i] ) ) - remove_pt = true; - - // check if this point is already in XX - // (may occur only if the point has been projected): - if ( proj_to_mesh && !remove_pt ) { - - if ( incumbent == (*XX[i]) ) - remove_pt = true; - - else - for ( j = 0 ; j < i ; ++j ) - if ( XX[j]->NOMAD::Point::operator == ( *XX[i] ) ) { - remove_pt = true; - break; - } - } - - // remove the point: - if ( remove_pt ) { - delete XX[i]; - --n_XX; - if ( i != n_XX ) - XX[i] = XX[n_XX]; - XX.resize ( n_XX ); - } - else - ++i; - } - - // reduce to 500-1 points (we eliminate randomly): - while ( n_XX >= 500 ) { - - i = rand()%n_XX; - - delete XX[i]; - --n_XX; - if ( i != n_XX ) - XX[i] = XX[n_XX]; - XX.resize(n_XX); - } - - // add the incumbent as the last point of XX: - XX.push_back ( new NOMAD::Eval_Point ( n , m ) ); - XX[n_XX]->NOMAD::Point::operator = ( incumbent ); -} - -/*---------------------------------------------------------------------*/ -/* create the complete list of trial points (oracle + Ds2x + improv) */ -/* (private) */ -/*---------------------------------------------------------------------*/ -void NOMAD::TGP_Model_Search::create_trial_pts -( const std::vector<NOMAD::Point *> & oracle_pts , // IN - const std::vector<NOMAD::Point *> & Ds2x_pts , // IN - const std::vector<NOMAD::Point *> & improv_pts , // IN - const NOMAD::Point & incumbent , // IN - int max_pts , // IN - const NOMAD::Display & out , // IN - NOMAD::dd_type display_degree , // IN - std::vector<NOMAD::Point *> & trial_pts ) const // OUT -{ - bool found; - size_t i , j , - n1 = oracle_pts.size() , - n2 = Ds2x_pts.size () , - n3 = improv_pts.size(); - - std::vector<NOMAD::Point *> l2 , l3; - - // 1. remove duplicates: - // --------------------- - // - // . oracle_pts are not XX points - // . Ds2x_pts and improv_pts are XX points - // . there is no duplicate in each list separately - // - for ( i = 0 ; i < n2 ; ++i ) { - found = false; - - if ( *Ds2x_pts[i] == incumbent ) - found = true; - else { - for ( j = 0 ; j < n1 ; ++j ) - if ( *Ds2x_pts[i] == *oracle_pts[j] ) { - found = true; - break; - } - } - if ( !found ) - l2.push_back ( Ds2x_pts[i] ); - } - - n2 = l2.size(); - - for ( i = 0 ; i < n3 ; ++i ) { - found = false; - if ( *improv_pts[i] == incumbent ) - found = true; - else { - for ( j = 0 ; j < n1 ; ++j ) - if ( *improv_pts[i] == *oracle_pts[j] ) { - found = true; - break; - } - } - if ( !found ) { - for ( j = 0 ; j < n2 ; ++j ) - if ( improv_pts[i] == l2[j] ) { - found = true; - break; - } - } - if ( !found ) - l3.push_back ( improv_pts[i] ); - } - - n3 = l3.size(); - - // 2. construct the list of trial points: - // ------------------------------------ - trial_pts.clear(); - - int nb_pts = static_cast<int> ( n1 + n2 + n3 ); - - // no need to reduce the number of trial points: - if ( max_pts <= 0 || nb_pts <= max_pts ) { - - - // 1. oracle points: - for ( i = 0 ; i < n1 ; ++i ) - trial_pts.push_back ( oracle_pts[i] ); - - // 2, improv points: - for ( i = 0 ; i < n3 ; ++i ) - trial_pts.push_back ( l3[i] ); - - // 3. Ds2x points: - for ( i = 0 ; i < n2 ; ++i ) - trial_pts.push_back ( l2[i] ); - - } - - // reduce the list to max_pts points: - else { - - nb_pts = 0; - - size_t i1 = 0 , i2 = 0 , i3 = 0; - - while ( true ) { - - // one point from the oracle points: - if ( i1 < n1 ) { - trial_pts.push_back ( oracle_pts[i1++] ); - ++nb_pts; - if ( nb_pts == max_pts ) - break; - } - - // two from the improv points: - for ( i = 0 ; i < 2 ; ++i ) { - if ( i3 < n3 ) { - trial_pts.push_back ( l3[i3++] ); - ++nb_pts; - if ( nb_pts == max_pts ) - break; - } - } - if ( nb_pts == max_pts ) - break; - - // one from the Ds2x points: - if ( i2 < n2 ) { - trial_pts.push_back ( l2[i2++] ); - ++nb_pts; - if ( nb_pts == max_pts ) - break; - } - } - } - - // 3. display the list of trial points: - // ------------------------------------ - // if ( display_degree == NOMAD::FULL_DISPLAY ) { - // out.open_block ( "list of trial points (debug)" ); - // n1 = trial_pts.size(); - // for ( i = 0 ; i < n1 ; ++i ) { - // out << "#"; - // out.display_int_w ( i , n1 ); - // out << " x=( " << *trial_pts[i] << " )" << std::endl; - // } - // out.close_block(); - // } -} - -/*---------------------------------------------------------*/ -/* create the list of improv points (private) */ -/*---------------------------------------------------------*/ -void NOMAD::TGP_Model_Search::create_improv_pts -( const std::vector<NOMAD::Eval_Point *> & XX , // IN - const NOMAD::Point & incumbent , // IN - int max_pts , // IN - const NOMAD::Display & out , // IN - NOMAD::dd_type display_degree , // IN - int display_lim , // IN - std::vector<NOMAD::Point *> & improv_pts ) const // OUT -{ - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << NOMAD::open_block ( "improv points construction" ) - << std::endl; - - // reset improv points: - improv_pts.clear(); - - // display improv points directly from the NOMAD::TGP_Model object: -#ifdef TGP_DEBUG - out << NOMAD::open_block ( "expected improvement of the objective (improv)" ); - _model->display_improv ( out , display_lim ); - out << NOMAD::close_block() << std::endl; -#endif - - std::list<int> pts_indexes; - _model->get_improv_points ( pts_indexes ); - - if ( pts_indexes.empty() ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << NOMAD::close_block ( "no improv candidate" ) - << std::endl; - return; - } - - std::list<int>::const_iterator it , end = pts_indexes.end(); - - // with constraints, the list is re-sorted in order to put the - // predicred feasible points first: - if ( _p.has_constraints() ) { - - std::list<int> feas_pts , infeas_pts; - - NOMAD::Double h , f; - const NOMAD::Double & h_min = _p.get_h_min(); - - for ( it = pts_indexes.begin() ; it != end ; ++it ) { - if ( predict ( *XX[*it] , h , f ) && h <= h_min ) - feas_pts.push_back ( *it ); - else - infeas_pts.push_back ( *it ); - } - - pts_indexes.clear(); - - end = feas_pts.end(); - for ( it = feas_pts.begin() ; it != end ; ++it ) - pts_indexes.push_back ( *it ); - - end = infeas_pts.end(); - for ( it = infeas_pts.begin() ; it != end ; ++it ) - pts_indexes.push_back ( *it ); - - end = pts_indexes.end(); - } - - // compute max_index just for the display: - int i , j , max_index = -1 , ni = -1; - - if ( display_degree == NOMAD::FULL_DISPLAY ) { - ni = pts_indexes.size(); - if ( max_pts > 0 && ni > max_pts ) - ni = max_pts; - - for ( it = pts_indexes.begin() ; it != end ; ++it ) { - if ( *it > max_index ) - max_index = *it; - } - } - - // add the points to improv_pts: - bool rejected; - i = j = 0; - for ( it = pts_indexes.begin() ; it != end ; ++it ) { - - // we check the max number of points: - rejected = ( max_pts > 0 && max_pts == i ); - - // we reject the point if it is the incumbent: - if ( !rejected && incumbent == *XX[*it] ) - rejected = true; - - // we add the point: - if ( !rejected ) { - improv_pts.push_back ( XX[*it] ); - ++i; - } - - // display: - if ( display_degree == NOMAD::FULL_DISPLAY ) { - if ( display_lim <= 0 || j < display_lim ) { - if ( rejected ) - out << "rejected candidate "; - else { - out << "improv candidate #"; - out.display_int_w ( i-1 , ni ); - } - out << " (XX point #"; - out.display_int_w ( *it , max_index ); - out << "): x=( "; - XX[*it]->NOMAD::Point::display ( out , " " , 6 , -1 ); - out << " )"; - if ( rejected ) { - if ( max_pts > 0 && max_pts == i ) - out << " (max number of points)"; - else - out << " (candidate==incumbent)"; - } - else - out << " improv=" << _model->get_improv(*it); - out << std::endl; - } - if ( display_lim > 0 && j == display_lim ) - out << "..." << std::endl; - ++j; - } - - // if no display, stop the loop if there is already too many points: - else if ( max_pts > 0 && max_pts == i ) - break; - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << NOMAD::close_block ( "end of improv points construction" ) - << std::endl; -} - -/*------------------------------------------------------------*/ -/* create the list of Ds2x points, the points that maximize */ -/* the expected reduction in predictive variance */ -/* (private) */ -/*------------------------------------------------------------*/ -void NOMAD::TGP_Model_Search::create_Ds2x_pts -( const std::vector<NOMAD::Eval_Point *> & XX , // IN - const NOMAD::Display & out , // IN - NOMAD::dd_type display_degree , // IN - int display_lim , // IN - std::vector<NOMAD::Point *> & Ds2x_pts ) const // OUT -{ - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << NOMAD::open_block ( "Ds2x points construction" ) - << std::endl; - - // reset Ds2x points: - Ds2x_pts.clear(); - - // display Ds2x points directly from the NOMAD::TGP_Model object: -#ifdef TGP_DEBUG - out << NOMAD::open_block ( "expected reduction in predictive variance (Ds2x)" ); - _model->display_Ds2x ( out , display_lim ); - out << NOMAD::close_block() << std::endl; -#endif - - std::set<int> pts_indexes; - _model->get_Ds2x_points ( pts_indexes ); - - if ( pts_indexes.empty() ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << NOMAD::close_block ( "no Ds2x candidate" ) - << std::endl; - return; - } - - std::set<int>::const_iterator it , end = pts_indexes.end(); - int i , max_index = -1 , m = _p.get_bb_nb_outputs() , n_XX = XX.size(); - - if ( display_degree == NOMAD::FULL_DISPLAY ) { - for ( it = pts_indexes.begin() ; it != end ; ++it ) { - if ( *it > max_index ) - max_index = *it; - } - } - - for ( it = pts_indexes.begin() , i = 0 ; it != end ; ++it , ++i ) { - - Ds2x_pts.push_back ( XX[*it] ); - - if ( display_degree == NOMAD::FULL_DISPLAY ) { - out << "Ds2x candidate #"; - out.display_int_w ( i , m ); - out << " (XX point #"; - out.display_int_w ( *it , max_index ); - out << "): x=( "; - XX[*it]->NOMAD::Point::display ( out , " " , 6 , -1 ); - out << " )"; - if ( *it == n_XX - 1 ) - out << " (rejected: candidate==incumbent)"; - out << std::endl; - } - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << NOMAD::close_block ( "end of Ds2x points construction" ) - << std::endl; -} - -/*-------------------------------------------------------------------*/ -/* create a list of oracle points, given by the model optimization */ -/* (private) */ -/*-------------------------------------------------------------------*/ -bool NOMAD::TGP_Model_Search::create_oracle_pts -( const NOMAD::Cache & cache , - const NOMAD::Point & incumbent , - const NOMAD::Point & delta_m , - const NOMAD::Display & out , - NOMAD::dd_type display_degree , - int display_lim , - const std::vector<NOMAD::Eval_Point *> & XX , - std::vector<NOMAD::Point *> & oracle_pts , - bool & stop , - NOMAD::stop_type & stop_reason ) -{ - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << NOMAD::open_block ( "oracle points construction" ) - << std::endl; - - // reset oracle points: - NOMAD::TGP_Model_Search::clear_pts ( oracle_pts ); - - int i , n_XX = XX.size(); - - // starting points selection: - const NOMAD::Eval_Point * x0s[3]; - x0s[0] = x0s[1] = x0s[2] = NULL; - - // open display block for model predictions: -#ifdef TGP_DEBUG - out << NOMAD::open_block ( "TGP predictions (XX+ZZ)"); - int i0 = ( display_lim > 0 ) ? n_XX - display_lim : 0; - if ( i0 > 0 ) - out << "..." << std::endl; -#endif - - NOMAD::Double f_model , h_model; - const NOMAD::Double & h_min = _p.get_h_min(); - NOMAD::hnorm_type h_norm = _p.get_h_norm(); - - for ( i = 0 ; i < n_XX ; ++i ) { - - // compute model h and f values: - _model->eval_hf ( XX[i]->get_bb_outputs() , - h_min , - h_norm , - h_model , - f_model ); - - if ( h_model.is_defined() && f_model.is_defined() ) { - - XX[i]->set_f ( f_model ); - XX[i]->set_h ( h_model ); - - // feasible point: - if ( XX[i]->is_feasible ( h_min ) ) { - if ( !x0s[0] || f_model < x0s[0]->get_f() ) - x0s[0] = XX[i]; - } - - // infeasible point: - else { - if ( !x0s[1] || h_model < x0s[1]->get_h() ) - x0s[1] = XX[i]; - - if ( !x0s[2] || f_model < x0s[2]->get_f() ) - x0s[2] = XX[i]; - } - } - - // display model predictions: -#ifdef TGP_DEBUG - if ( i >= i0 ) { - out << "#"; - out.display_int_w ( i , n_XX ); - out << " x=("; - XX[i]->NOMAD::Point::display ( out , " " , 15 , -1 ); - out << " ) m(x)=["; - XX[i]->get_bb_outputs().display ( out , " " , 15 , -1 ); - out << " ]"; - - if ( h_model.is_defined() && f_model.is_defined() ) - out << " hm=" << h_model << " fm=" << f_model; - else - out << " no model value"; - out << std::endl; - } -#endif - -#ifdef MODEL_STATS - if ( XX[i] && f_model.is_defined() && h_model.is_defined() ) { - XX[i]->set_mod_use ( 1 ); // 1 for model search - XX[i]->set_Yw ( _model->get_Yw () ); - XX[i]->set_nY ( p ); - XX[i]->set_mh ( h_model ); - XX[i]->set_mf ( f_model ); - } -#endif - } - -#ifdef TGP_DEBUG - // close display block for model predictions: - { - std::ostringstream oss; - oss << "(size=" << n_XX << ")"; - out << NOMAD::close_block ( oss.str() ) << std::endl; - } - - // compute and display prediction errors: - out << NOMAD::open_block ( "prediction relative errors on X(%)" ); - _model->display_X_errors ( out ); - out << NOMAD::close_block() << std::endl; - -#endif - - if ( !x0s[0] && !x0s[1] && !x0s[2] ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << NOMAD::close_block ( "oracle points error: no model starting point" ) - << std::endl; - return false; - } - - // display starting points: - if ( display_degree == NOMAD::FULL_DISPLAY ) { - out << std::endl - << NOMAD::open_block ( "model starting points" ); - - for ( i = 0 ; i < 3 ; ++i ) { - - out << "#" << i << ": "; - if ( !x0s[i] ) - out << "NULL" << std::endl; - else { - - out << " x=("; - x0s[i]->NOMAD::Point::display ( out , " " , 15 , -1 ); - out << " ) m(x)=["; - x0s[i]->get_bb_outputs().display ( out , " " , 15 , -1 ); - out << " ]" - << " hm=" << std::setw(15) << x0s[i]->get_h() - << " fm=" << std::setw(15) << x0s[i]->get_f() - << std::endl; - } - } - out << NOMAD::close_block() << std::endl; - } - - // optimize model: - // --------------- - NOMAD::Point * xf = NULL , * xi = NULL; - NOMAD::Clock clock; - - bool optimization_ok = optimize_model ( x0s , - out , - display_degree , - xf , - xi , - stop , - stop_reason ); - - _one_search_stats.add_optimization_time ( clock.get_CPU_time() ); - - if ( stop || !optimization_ok || ( xf == NULL && xi == NULL ) ) { - std::string error_str; - if ( xf == NULL && xi == NULL ) - error_str = "no model optimization solution"; - else { - if ( xf ) delete xf; - if ( xi ) delete xi; - error_str = ( stop ) ? "algorithm stop" : "model optimization error"; - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << NOMAD::close_block ( "oracle points error: " + error_str ) - << std::endl; - return false; - } - - // project and check xf and xi: - if ( xf && !check_oracle_point ( cache , - incumbent , - delta_m , - out , - display_degree , - *xf ) ) { - delete xf; - xf = NULL; - } - - if ( xi && !check_oracle_point ( cache , - incumbent , - delta_m , - out , - display_degree , - *xi ) ) { - delete xi; - xi = NULL; - } - - // add xf and xi in the list of oracle points: - if ( xf ) - oracle_pts.push_back ( xf ); - - if ( xi ) { - - // check that xi != xf: - if ( xf && *xf == *xi ) { - delete xi; - xi = NULL; - } - - if ( xi ) - oracle_pts.push_back ( xi ); - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << NOMAD::close_block ( "end of oracle points construction" ) - << std::endl; - - return true; -} - -/*------------------------------------------------------*/ -/* project and accept or reject an oracle trial point */ -/* (private) */ -/*------------------------------------------------------*/ -bool NOMAD::TGP_Model_Search::check_oracle_point -( const NOMAD::Cache & cache , - const NOMAD::Point & incumbent , - const NOMAD::Point & delta_m , - const NOMAD::Display & out , - NOMAD::dd_type display_degree , - NOMAD::Point & x ) -{ - bool proj_to_mesh = _p.get_model_search_proj_to_mesh(); - - if ( display_degree == NOMAD::FULL_DISPLAY ) { - out << std::endl << "oracle candidate"; - if ( proj_to_mesh ) - out << " (before projection)"; - out << ": ( " << x << " )" << std::endl; - } - - // projection to mesh: - if ( proj_to_mesh ) { - x.project_to_mesh ( incumbent , delta_m , _p.get_lb() , _p.get_ub() ); - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "oracle candidate (after projection) : ( " - << x << " )" << std::endl; - } - - // compare x and incumbent coordinates: - if ( x == incumbent ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "oracle candidate rejected (candidate==incumbent)" << std::endl; - return false; - } - - // two evaluations points are created in order to: - // 1. check if the candidate is in cache - // 2. have a prediction at x and at the incumbent: - int n = x.size() , m = _p.get_bb_nb_outputs(); - - NOMAD::Eval_Point * tk = new NOMAD::Eval_Point ( n , m ); // trial point - tk->Point::operator = ( x ); - - // check if the point is in cache: - if ( cache.find ( *tk ) ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "oracle candidate rejected (found in cache)" << std::endl; - delete tk; - return false; - } - - NOMAD::Eval_Point * ic = new NOMAD::Eval_Point ( n , m ); // incumbent copy - ic->Point::operator = ( incumbent ); - - // model predictions (in order to accept or reject the trial point): - bool pred_error = !_model->predict ( *ic , true ) || // pred_outside_bnds = true - !_model->predict ( *tk , true ); // pred_outside_bnds = true - - const NOMAD::Double & h_min = _p.get_h_min(); - NOMAD::hnorm_type h_norm = _p.get_h_norm(); - - NOMAD::Double h0 , f0; // model values of f and h at the center - NOMAD::Double h1 , f1; // model values of f and h at the trial point - - if ( !pred_error ) - _model->eval_hf ( tk->get_bb_outputs() , h_min , h_norm , h1 , f1 ); - - delete tk; - - if ( pred_error || !h1.is_defined() || !f1.is_defined() ) { - - if ( display_degree == NOMAD::FULL_DISPLAY ) { - if ( pred_error ) - out << "prediction error: oracle candidate rejected"; - else - out << "no model value (EB constraint violated?): oracle candidate rejected"; - out << std::endl; - } - - delete ic; - - return false; - } - - // accept or reject the trial point: - bool accept_point = false; - _model->eval_hf ( ic->get_bb_outputs(), h_min, h_norm, h0, f0 ); - if ( !h0.is_defined() || !f0.is_defined() ) - accept_point = true; - - delete ic; - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl - << "incumbent prediction : h0=" << h0 << " f0=" << f0 << std::endl - << "trial point prediction: h1=" << h1 << " f1=" << f1 << std::endl; - - if ( !accept_point ) - accept_point = (f1 < f0) || (h1 < h0); - - if ( !accept_point ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "oracle candidate rejected" << std::endl; - _one_search_stats.add_MS_rejected(); - return false; - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "oracle candidate accepted" << std::endl; - - return true; -} - -/*--------------------------------------------------------*/ -/* insert a trial point in the evaluator control object */ -/* (private) */ -/*--------------------------------------------------------*/ -void NOMAD::TGP_Model_Search::register_point -( NOMAD::Point x , - NOMAD::Signature & signature , - const NOMAD::Point & incumbent , - NOMAD::dd_type display_degree , - NOMAD::Evaluator_Control & ev_control ) const -{ - int n = x.size(); - - NOMAD::Eval_Point * tk = new NOMAD::Eval_Point ( n , _p.get_bb_nb_outputs() ); - - // if the search is optimistic, a direction is computed (this - // will be used in case of success in the speculative search): - if ( _p.get_model_search_optimistic() ) { - NOMAD::Direction dir ( n , 0.0 , NOMAD::MODEL_SEARCH_DIR ); - dir.Point::operator = ( x - incumbent ); - tk->set_direction ( &dir ); - } - - tk->set_signature ( &signature ); - tk->Point::operator = ( x ); - - // add the new point to the list of search trial points: - ev_control.add_eval_point ( tk , - display_degree , - _p.get_snap_to_bounds() , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() , - NOMAD::Double() ); -#ifdef MODEL_STATS - if ( tk ) { - NOMAD::Double h1 , f1; - if ( _model->predict ( *tk , true ) ) // pred_outside_bnds = true - _model->eval_hf ( tk->get_bb_outputs() , - _p.get_h_min() , - _p.get_h_norm() , - h1 , - f1 ); - if ( h1.is_defined() && f1.is_defined() ) { - tk->set_mod_use ( 1 ); // 1 for model search - tk->set_Yw ( _model->get_Yw() ); - tk->set_nY ( model.get_p () ); - tk->set_mh ( h1 ); - tk->set_mf ( f1 ); - } - } -#endif -} - -/*---------------------------------------------------------------*/ -/* model construction (private) */ -/*---------------------------------------------------------------*/ -bool NOMAD::TGP_Model_Search::model_construction -( const NOMAD::Cache & cache , - const NOMAD::Point & incumbent , - const NOMAD::Point & delta_m , - const NOMAD::Display & out , - NOMAD::dd_type display_degree , - int display_lim , - NOMAD::Stats & stats , - bool & compute_Ds2x , - std::vector<NOMAD::Eval_Point *> & XX , - bool & stop , - NOMAD::stop_type & stop_reason , - std::string & error_str ) -{ - int i , n_XX , n = incumbent.size(); - - compute_Ds2x = false; - - // reset XX: - { - n_XX = XX.size(); - for ( i = 0 ; i < n_XX ; ++i ) - delete XX[i]; - XX.clear(); - n_XX = 0; - } - - error_str.clear(); - - if ( stop ) - return false; - - NOMAD::Clock clock; - - // TGP model creation: - if ( _model ) - delete _model; - - NOMAD::TGP_mode_type tgp_mode = _p.get_model_tgp_mode(); - - _model = new NOMAD::TGP_Model ( n , - _p.get_bb_output_type() , - out , - tgp_mode ); - - // construct interpolation set (X): - // -------------------------------- - if ( !_model->set_X ( cache , - &incumbent , - _p.get_seed() , - true ) ) { // remove_fv = true - - if ( _model->get_nep_flag() ) - _one_search_stats.add_not_enough_pts(); - - stats.update_model_stats ( _one_search_stats ); - _all_searches_stats.update ( _one_search_stats ); - - error_str = _model->get_error_str(); - - delete _model; - _model = NULL; - - return false; - } - - // create the list of prediction points (XX) - // (they are used to get starting points - // and to get IMPROV and DS2X stats): - // ----------------------------------- - set_XX ( cache , - n , - _p.get_bb_output_type().size() , - incumbent , - delta_m , - XX ); - - n_XX = XX.size(); - - // display sets X and XX: - // ---------------------- -#ifdef TGP_DEBUG - - // X: - _model->display_X ( out , display_lim ); - - // XX (only the 10 last points are displayed): - out << NOMAD::open_block ( "prediction points (XX)"); - int i0 = ( display_lim > 0 ) ? n_XX - display_lim : 0; - if ( i0 > 0 ) - out << "..." << std::endl; - else if ( i0 < 0 ) - i0 = 0; - for ( i = i0 ; i < n_XX ; ++i ) { - out << "#"; - out.display_int_w ( i , n_XX ); - out << " x=("; - XX[i]->NOMAD::Point::display ( out , " " , 15 , -1 ); - out << " )" << std::endl; - } - std::ostringstream oss; - oss << "(size=" << n_XX << ")"; - out << NOMAD::close_block ( oss.str() ) << std::endl; -#endif - - // model construction: - // ------------------- - int p = _model->get_p(); // number of points in X - - if ( display_degree == NOMAD::FULL_DISPLAY ) { - out << "TGP model construction (p=" - << p << ") ..."; - out.flush(); - } - - // decide compute_Ds2x flag: - compute_Ds2x = true; - if ( tgp_mode == NOMAD::TGP_PRECISE && n_XX > 100 ) - compute_Ds2x = false; - - if ( !_model->compute ( XX , - compute_Ds2x , - true , // compute_improv = true - false ) ) { // pred_outside_bnds = false - - _one_search_stats.add_construction_error(); - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "... error" << std::endl; - - // delete XX points: - for ( i = 0 ; i < n_XX ; ++i ) - delete XX[i]; - XX.clear(); - n_XX = 0; - - stats.update_model_stats ( _one_search_stats ); - _all_searches_stats.update ( _one_search_stats ); - - error_str = _model->get_error_str(); - - delete _model; - _model = NULL; - - // check if ctrl-c has been pressed: - if ( NOMAD::TGP_Output_Model::get_force_quit() ) { - stop = true; - stop_reason = NOMAD::CTRL_C; - } - - return false; - } - - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << "... OK" << std::endl << std::endl; - - // update model stats: - _one_search_stats.add_construction_time ( clock.get_CPU_time() ); - _one_search_stats.update_nY ( p ); - _one_search_stats.add_nb_truth(); - _one_search_stats.add_nb_TGP(); - - return true; -} - -/*---------------------------------------------------------------*/ -/* optimize a model (private) */ -/*---------------------------------------------------------------*/ -bool NOMAD::TGP_Model_Search::optimize_model -( const NOMAD::Eval_Point * x0s[3] , - const NOMAD::Display & out , - NOMAD::dd_type display_degree , - NOMAD::Point *& xf , - NOMAD::Point *& xi , - bool & stop , - NOMAD::stop_type & stop_reason ) -{ - // reset xf and xi: - if ( xf ) delete xf; xf = NULL; - if ( xi ) delete xi; xi = NULL; - - if ( !_model ) { - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << "model optimization error (no model)" - << std::endl; - return false; - } - - std::string error_str; - bool error = false; - int i , n = _model->get_n0(); - - // model bounds: - const NOMAD::Point & lb = _model->get_lb(); - const NOMAD::Point & ub = _model->get_ub(); - - // initial displays: - if ( display_degree == NOMAD::FULL_DISPLAY ) - out << std::endl << NOMAD::open_block ( "model optimization" ); - - // parameters creation: - NOMAD::Parameters model_param ( out ); - - - // number of variables: - model_param.set_DIMENSION ( n ); - - // blackbox outputs: - model_param.set_BB_OUTPUT_TYPE ( _p.get_bb_output_type() ); - - // barrier parameters: - model_param.set_H_MIN ( _p.get_h_min () ); - model_param.set_H_NORM ( _p.get_h_norm() ); - - // starting points: - for ( i = 0 ; i < 3 ; ++i ) - if ( x0s[i] ) - model_param.set_X0 ( *x0s[i] ); - - // fixed variables: - for ( i = 0 ; i < n ; ++i ) - if ( lb[i] == ub[i] || _p.variable_is_fixed(i) ) - model_param.set_FIXED_VARIABLE(i); - - // no model search and no model ordering: - model_param.set_MODEL_SEARCH ( false ); - model_param.set_MODEL_EVAL_SORT ( false ); - - // display: - model_param.set_DISPLAY_DEGREE ( NOMAD::NO_DISPLAY ); - if ( display_degree == NOMAD::FULL_DISPLAY ) { - - model_param.set_DISPLAY_DEGREE ( NOMAD::NORMAL_DISPLAY ); - // model_param.set_DISPLAY_DEGREE ( NOMAD::FULL_DISPLAY ); - - if ( n <= 5 ) - model_param.set_DISPLAY_STATS ( "bbe mesh_index ( %14.12gsol ) %14.12gobj" ); - else if ( n <= 10 ) - model_param.set_DISPLAY_STATS ( "bbe mesh_index ( sol ) obj" ); - else - model_param.set_DISPLAY_STATS ( "bbe obj" ); - } - // mesh: use isotropic mesh - model_param.set_ANISOTROPIC_MESH ( false ); - model_param.set_MESH_UPDATE_BASIS ( 4.0 ); - model_param.set_MESH_COARSENING_EXPONENT ( 1 ); - model_param.set_MESH_REFINING_EXPONENT ( -1 ); - model_param.set_INITIAL_MESH_INDEX ( 0 ); - - - // maximum number of evaluations (2000 or 10000): - model_param.set_MAX_BB_EVAL - ( ( _p.get_model_tgp_mode() == NOMAD::TGP_PRECISE ) ? 10000 : 2000 ); - - model_param.set_SNAP_TO_BOUNDS ( true ); - - // disable user calls: - model_param.set_USER_CALLS_ENABLED ( false ); - - // set flags: - bool flag_check_bimads , flag_reset_mesh , flag_reset_barriers , flag_p1_active; - NOMAD::Mads::get_flags ( flag_check_bimads , - flag_reset_mesh , - flag_reset_barriers , - flag_p1_active ); - - NOMAD::Mads::set_flag_check_bimads ( true ); - NOMAD::Mads::set_flag_reset_mesh ( true ); - NOMAD::Mads::set_flag_reset_barriers ( true ); - NOMAD::Mads::set_flag_p1_active ( false ); - - // bounds: - model_param.set_LOWER_BOUND ( lb ); - model_param.set_UPPER_BOUND ( ub ); - - try { - - // parameters validation: - model_param.check(); - - // out << "TGP PARAMETERS:" << std::endl << model_param << std::endl; - - // model evaluator creation: - NOMAD::TGP_Model_Evaluator ev ( model_param , *_model ); - - // algorithm creation and execution: - NOMAD::Mads mads ( model_param , &ev ); - NOMAD::stop_type st = mads.run(); - - // check the stopping criterion: - if ( st == NOMAD::CTRL_C || st == NOMAD::MAX_CACHE_MEMORY_REACHED ) { - std::ostringstream oss; - oss << "model optimization: " << st; - error_str = oss.str(); - error = true; - stop = true; - stop_reason = st; - } - - else if ( st == NOMAD::MAX_BB_EVAL_REACHED ) - _one_search_stats.add_MS_max_bbe(); - - // update the stats on the number of model evaluations: - _one_search_stats.update_MS_model_opt ( mads.get_stats().get_bb_eval() ); - - // get the solution(s): - const NOMAD::Eval_Point * best_feas = mads.get_best_feasible (); - const NOMAD::Eval_Point * best_infeas = mads.get_best_infeasible(); - - if ( best_feas ) - xf = new NOMAD::Point ( *best_feas ); - if ( best_infeas ) - xi = new NOMAD::Point ( *best_infeas ); - - if ( !xf && !xi ) { - error = true; - error_str = "optimization error: no solution"; - } - } - catch ( std::exception & e ) { - error = true; - error_str = std::string ( "optimization error: " ) + e.what(); - } - - // reset flags: - NOMAD::Mads::set_flag_check_bimads ( flag_check_bimads ); - NOMAD::Mads::set_flag_reset_mesh ( flag_reset_mesh ); - NOMAD::Mads::set_flag_reset_barriers ( flag_reset_barriers ); - NOMAD::Mads::set_flag_p1_active ( flag_p1_active ); - - // close display block: - if ( display_degree == NOMAD::FULL_DISPLAY ) { - if ( error ) - out.close_block ( error_str ); - else - out.close_block(); - } - - return !error; -} - -/*---------------------------------------------------------*/ -/* display the prediction error for the evaluated points */ -/* (private) */ -/*---------------------------------------------------------*/ -bool NOMAD::TGP_Model_Search::predict ( const NOMAD::Point & x , - NOMAD::Double & h , - NOMAD::Double & f ) const -{ - h.clear(); - f.clear(); - - if ( !_model ) - return false; - - NOMAD::Eval_Point y ( x.size() , _p.get_bb_nb_outputs() ); - y.NOMAD::Point::operator = ( x ); - - if ( _model->predict ( y , true ) ) // pred_outside_bnds = true - _model->eval_hf ( y.get_bb_outputs() , _p.get_h_min() , _p.get_h_norm() , h , f ); - - return ( h.is_defined() && f.is_defined() ); -} - -/*---------------------------------------------------------*/ -/* display the prediction error for the evaluated points */ -/* (private) */ -/*---------------------------------------------------------*/ -void NOMAD::TGP_Model_Search::display_eval_pred_errors -( const std::list<const NOMAD::Eval_Point *> & evaluated_pts , - const NOMAD::Display & out ) -{ - if ( !_model ) - return; - - int i , j = 0; - int nb_pts = evaluated_pts.size() , - n = _model->get_n0() , - m = _p.get_bb_nb_outputs(); - const NOMAD::Double & h_min = _p.get_h_min(); - NOMAD::hnorm_type h_norm = _p.get_h_norm(); - NOMAD::Double h , f , hm , fm , err; - NOMAD::Eval_Point x ( n , m ); - - out << std::endl << NOMAD::open_block ( "evaluated points" ); - std::list<const NOMAD::Eval_Point *>::const_iterator it , end = evaluated_pts.end(); - for ( it = evaluated_pts.begin() ; it != end ; ++it ) { - - if ( !(*it) ) - continue; - - h = (*it)->get_h(); - f = (*it)->get_f(); - - for ( i = 0 ; i < n ; ++i ) - x[i] = (**it)[i]; - - _model->predict ( x , true ); // pred_outside_bnds = true - _model->eval_hf ( x.get_bb_outputs(), h_min , h_norm , hm , fm ); - - out << "#"; - out.display_int_w ( j++ , nb_pts ); - - out << " x=("; - if ( n < 5 ) - (*it)->NOMAD::Point::display ( out , " " , 6 , -1 ); - else - (*it)->NOMAD::Point::display ( out , " " , -1 , 20 ); - out << ")"; - if ( _p.has_constraints() ) { - err = (h.is_defined() && hm.is_defined()) ? h.rel_err(hm) * 100.0 : 100.0; - out << " [h="; - h.display ( out , "%11.3g" ); - out << " hm="; - hm.display ( out , "%11.3g" ); - out << " err_h="; - err.display ( out , "%.2f" ); - out << "%]"; - } - err = (f.is_defined() && fm.is_defined()) ? f.rel_err(fm) * 100.0 : 100.0; - out << " [f="; - f.display ( out , "%11.3g" ); - out << " fm="; - fm.display ( out , "%11.3g" ); - out << " err_f="; - err.display ( out , "%.2f" ); - out << "%]" << std::endl; - } - - out.close_block(); -} - -#endif diff --git a/src/TGP_Model_Search.hpp b/src/TGP_Model_Search.hpp deleted file mode 100644 index c31faf1ed2d83be410b2d997b428b500834677c2..0000000000000000000000000000000000000000 --- a/src/TGP_Model_Search.hpp +++ /dev/null @@ -1,332 +0,0 @@ -/*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ -/* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ -/* */ -/* funded in part by AFOSR and Exxon Mobil */ -/* */ -/* Author: Sebastien Le Digabel */ -/* */ -/* Contact information: */ -/* Ecole Polytechnique de Montreal - GERAD */ -/* C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */ -/* e-mail: nomad@gerad.ca */ -/* phone : 1-514-340-6053 #6928 */ -/* fax : 1-514-340-5665 */ -/* */ -/* 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 <http://www.gnu.org/licenses/>. */ -/* */ -/* You can find information on the NOMAD software at www.gerad.ca/nomad */ -/*-------------------------------------------------------------------------------------*/ -/** - \file TGP_Model_Search.hpp - \brief TGP Model search (headers) - \author Sebastien Le Digabel - \date 2011-02-17 - \see TGP_Model_Search.cpp -*/ -#ifdef USE_TGP - -#ifndef __TGP_MODEL_SEARCH__ -#define __TGP_MODEL_SEARCH__ - -#include "LH_Search.hpp" -#include "TGP_Model_Evaluator.hpp" - -namespace NOMAD { - - /// Model search. - class TGP_Model_Search : public NOMAD::Search , private NOMAD::Uncopyable { - - private: - - NOMAD::TGP_Model * _model; - - NOMAD::Model_Stats _one_search_stats; ///< Stats for one search. - NOMAD::Model_Stats _all_searches_stats; ///< Stats for all searches. - - /// Delete a list of points. - /** - \param pts The points -- \b IN/OUT. - */ - static void clear_pts ( std::vector<NOMAD::Point *> & pts ); - - /// Delete a list of evaluation points. - /** - \param pts The points -- \b IN/OUT. - */ - static void clear_pts ( std::vector<NOMAD::Eval_Point *> & pts ); - - /// Model construction. - /** - \param cache Cache of true evaluations -- \b IN. - \param incumbent The incumbent -- \b IN. - \param delta_m Mesh size parameter -- \b IN. - \param out The NOMAD::Display object -- \b IN. - \param display_degree Display degree -- \b IN. - \param display_lim Max number of pts when sets are displayed -- \b IN. - \param stats Model search stats -- \b IN/OUT. - \param compute_Ds2x Flag to enable/disable Ds2x computation -- \b OUT. - \param XX The set of prediction points -- \b OUT. - \param stop Stop flag -- \b OUT. - \param stop_reason Stop reason -- \b OUT. - \param error_std Error string -- \b OUT. - \return A boolean equal to \c true if the model has been constructed. - */ - bool model_construction ( const NOMAD::Cache & cache , - const NOMAD::Point & incumbent , - const NOMAD::Point & delta_m , - const NOMAD::Display & out , - NOMAD::dd_type display_degree , - int display_lim , - NOMAD::Stats & stats , - bool & compute_Ds2x , - std::vector<NOMAD::Eval_Point *> & XX , - bool & stop , - NOMAD::stop_type & stop_reason , - std::string & error_str ); - - /// Create a list of prediction points. - /** - \param cache Cache of true evaluations -- \b IN. - \param n Number of variables -- \b IN. - \param m Number of outputs -- \b IN. - \param incumbent The incumbent -- \b IN. - \param delta_m Mesh size parameter -- \b IN. - \param XX The set of prediction points -- \b OUT. - */ - void set_XX ( const NOMAD::Cache & cache , - int n , - int m , - const NOMAD::Point & incumbent , - const NOMAD::Point & delta_m , - std::vector<NOMAD::Eval_Point *> & XX ) const; - - /// Create the complete list of trial points (oracle + Ds2x + improv). - /** - \param oracle_pts Oracle points -- \b IN. - \param Ds2x_pts Ds2x points -- \b IN. - \param improv_pts Improv points -- \b IN. - \param incumbent The incumbent -- \b IN. - \param max_pts Max number of trial points -- \b IN. - \param out The NOMAD::Display object -- \b IN. - \param display_degree Display degree -- \b IN. - \param trial_pts The list of trial points -- \b OUT. - */ - void create_trial_pts - ( const std::vector<NOMAD::Point *> & oracle_pts , - const std::vector<NOMAD::Point *> & Ds2x_pts , - const std::vector<NOMAD::Point *> & improv_pts , - const NOMAD::Point & incumbent , - int max_pts , - const NOMAD::Display & out , - NOMAD::dd_type display_degree , - std::vector<NOMAD::Point *> & trial_pts ) const; - - /// Create oracle points by optimizing the model. - /** - \param cache Cache of true evaluations -- \b IN. - \param incumbent The incumbent -- \b IN. - \param delta_m Mesh size parameter -- \b IN. - \param out The NOMAD::Display object -- \b IN. - \param display_degree Display degree -- \b IN. - \param display_lim Max number of pts when sets are displayed -- \b IN. - \param XX The set of prediction points -- \b IN. - \param oracle_pts Oracle candidates points -- \b OUT. - \param stop Stop flag -- \b OUT. - \param stop_reason Stop reason -- \b OUT. - \return A boolean equal to \c true oracle points are proposed. - */ - bool create_oracle_pts - ( const NOMAD::Cache & cache , - const NOMAD::Point & incumbent , - const NOMAD::Point & delta_m , - const NOMAD::Display & out , - NOMAD::dd_type display_degree , - int display_lim , - const std::vector<NOMAD::Eval_Point *> & XX , - std::vector<NOMAD::Point *> & oracle_pts , - bool & stop , - NOMAD::stop_type & stop_reason ); - - /// Model optimization. - /** - \param x0s The three starting points -- \b IN. - \param out The NOMAD::Display object -- \b IN. - \param display_degree Display degree -- \b IN. - \param xf Feasible solution \c xf -- \b OUT. - \param xi Infeasible solution \c xi -- \b OUT. - \param stop Stop flag -- \b OUT. - \param stop_reason Stop reason -- \b OUT. - */ - bool optimize_model ( const NOMAD::Eval_Point * x0s[3] , - const NOMAD::Display & out , - NOMAD::dd_type display_degree , - NOMAD::Point *& xf , - NOMAD::Point *& xi , - bool & stop , - NOMAD::stop_type & stop_reason ); - - /// Project and accept or reject an oracle trial point. - /** - \param cache Cache of true evaluations -- \b IN. - \param incumbent The incumbent -- \b IN. - \param delta_m Mesh size parameter -- \b IN. - \param out The NOMAD::Display object -- \b IN. - \param display_degree Display degree -- \b IN. - \param x The oracle point -- \b IN/OUT. - \return A boolean equal to \c true if the point is accepted. - */ - bool check_oracle_point - ( const NOMAD::Cache & cache , - const NOMAD::Point & incumbent , - const NOMAD::Point & delta_m , - const NOMAD::Display & out , - NOMAD::dd_type display_degree , - NOMAD::Point & x ); - - /// Insert a trial point in the evaluator control object. - /** - \param x The point coordinates -- \b IN. - \param signature Signature -- \b IN. - \param incumbent The incumbent -- \b IN. - \param display_degree Display degree -- \b IN. - \param ev_control The NOMAD::Evaluator_Control object -- \b IN/OUT. - */ - void register_point ( NOMAD::Point x , - NOMAD::Signature & signature , - const NOMAD::Point & incumbent ,, - NOMAD::dd_type display_degree , - NOMAD::Evaluator_Control & ev_control ) const; - - /// Create the list of improv points. - /** - These points (from the set \c XX) maximize - the expected improvement of the objective. - Priority is given to predicted feasible points. - \param XX The set of prediction points -- \b IN. - \param incumbent The incumbent -- \b IN. - \param max_pts Max number of points -- \b IN. - \param out The NOMAD::Display object -- \b IN. - \param display_degree Display degree -- \b IN. - \param display_lim Max number of pts when sets are displayed -- \b IN. - \param Ds2x_pts The list of improv points -- \b OUT. - */ - void create_improv_pts - ( const std::vector<NOMAD::Eval_Point *> & XX , - const NOMAD::Point & incumbent , - int max_pts , - const NOMAD::Display & out , - NOMAD::dd_type display_degree , - int display_lim , - std::vector<NOMAD::Point *> & improv_pts ) const; - - /// Create the list of Ds2x points. - /** - These points (from the set \c XX) maximize the expected reduction in - predictive variance for each output. - \param XX The set of prediction points -- \b IN. - \param out The NOMAD::Display object -- \b IN. - \param display_degree Display degree -- \b IN. - \param display_lim Max number of pts when sets are displayed -- \b IN. - \param Ds2x_pts The list of Ds2x points -- \b OUT. - */ - void create_Ds2x_pts - ( const std::vector<NOMAD::Eval_Point *> & XX , - const NOMAD::Display & out , - NOMAD::dd_type display_degree , - int display_lim , - std::vector<NOMAD::Point *> & Ds2x_pts ) const; - - /// Prediction at one point. - /** - \param x The point -- \b IN. - \param h Value of \c h -- \b OUT. - \param f Value of \c f -- \b OUT. - \return A boolean equal to \c true if the prediction was possible. - */ - bool predict ( const NOMAD::Point & x , - NOMAD::Double & h , - NOMAD::Double & f ) const; - - /// Display the prediction error for the evaluated points. - /** - \param evaluated_pts List of evaluated points -- \b IN. - \param out The NOMAD::Display object -- \b IN. - */ - void display_eval_pred_errors - ( const std::list<const NOMAD::Eval_Point *> & evaluated_pts , - const NOMAD::Display & out ); - - /*----------------------------------------------------------------------*/ - - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - */ - TGP_Model_Search ( NOMAD::Parameters & p ) - : NOMAD::Search ( p , NOMAD::MODEL_SEARCH ) , _model ( NULL ) {} - - /// Destructor. - virtual ~TGP_Model_Search ( void ) { reset(); } - - /// Reset. - virtual void reset ( void ); - - /// The TGP model search. - /** - Based on quadratic regression/MFN interpolation models. - \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. - \param nb_search_pts Number of generated search points -- \b OUT. - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - \param success Type of success -- \b OUT. - \param count_search Count or not the search -- \b OUT. - \param new_feas_inc New feasible incumbent -- \b IN/OUT. - \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. - */ - virtual void search ( NOMAD::Mads & mads , - int & nb_search_pts , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - bool & count_search , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ); - - /// Access to the model. - /** - \return The model. - */ - NOMAD::TGP_Model * get_model ( void ) const { return _model; } - - //// Display stats. - /** - \param out The NOMAD::Display object -- \b IN. - */ - virtual void display ( const NOMAD::Display & out ) const - { - out << _all_searches_stats; - } - }; -} - -#endif -#endif diff --git a/src/TGP_Output_Model.cpp b/src/TGP_Output_Model.cpp deleted file mode 100644 index 55152a1d6ea0194252f2b706ab4a69f9c6f3be1d..0000000000000000000000000000000000000000 --- a/src/TGP_Output_Model.cpp +++ /dev/null @@ -1,486 +0,0 @@ -/*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ -/* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ -/* */ -/* funded in part by AFOSR and Exxon Mobil */ -/* */ -/* Author: Sebastien Le Digabel */ -/* */ -/* Contact information: */ -/* Ecole Polytechnique de Montreal - GERAD */ -/* C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */ -/* e-mail: nomad@gerad.ca */ -/* phone : 1-514-340-6053 #6928 */ -/* fax : 1-514-340-5665 */ -/* */ -/* 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 <http://www.gnu.org/licenses/>. */ -/* */ -/* You can find information on the NOMAD software at www.gerad.ca/nomad */ -/*-------------------------------------------------------------------------------------*/ -/** - \file TGP_Output_Model.cpp - \brief TGP (Bayesian treed Gaussian process) model for one output (implementation) - \author Sebastien Le Digabel - \date 2011-02-07 - \see TGP_Output_Model.hpp -*/ - -#ifndef USE_TGP - -int TGP_OUTPUT_MODEL_DUMMY; // avoids that TGP_Output_Model.o has no symbols with ranlib - -#else - -#include "TGP_Output_Model.hpp" - -/*---------------------------------------------------------*/ -/* NOMAD-TGP callback function (called regularly by TGP) */ -/*---------------------------------------------------------*/ -// SLD -- 2014-09-04 -// void NOMAD::TGP_callback ( bool & TGP_interrupt ) -// { -// if ( NOMAD::TGP_Output_Model::get_force_quit() ) -// TGP_interrupt = true; -// } - -/*-----------------------------------*/ -/* static members initialization */ -/*-----------------------------------*/ -double NOMAD::TGP_Output_Model::_ditemps[7] = - { 1.0 , 0.0 , 0.0 , 1.0 , 1.0 , 0.0 , 1.0 }; - -bool NOMAD::TGP_Output_Model::_force_quit = false; - -/*-----------------------------------*/ -/* constructor */ -/*-----------------------------------*/ -NOMAD::TGP_Output_Model::TGP_Output_Model -( const std::list<const NOMAD::Eval_Point *> & X_pts , - int bbo_index , - int seed , - const NOMAD::Display & out ) - : _out ( out ) , - _p ( X_pts.size() ) , - _Z ( new double[_p] ) , - _Z_is_scaled ( false ) , - _is_binary ( true ) , - _bin_values ( 2 ) , - _is_fixed ( false ) , - _tgp_state ( NULL ) , - _tgp_model ( NULL ) , - _tgp_its ( NULL ) -{ - NOMAD::TGP_Output_Model::_force_quit = false; - - _Z_scaling[0] = _Z_scaling[1] = 0.0; - - std::list<const NOMAD::Eval_Point *>::const_iterator it , end = X_pts.end(); - - NOMAD::Double tmp , Zmin , Zmax , Zsum = 0.0; - int j = 0; - - for ( it = X_pts.begin() ; it != end ; ++it ) { - - // the output value: - tmp = (*it)->get_bb_outputs()[bbo_index]; - _Z[j++] = tmp.value(); - - // Z scaling parameters (1/2): - Zsum += tmp; - if ( !Zmin.is_defined() || tmp < Zmin ) - Zmin = tmp; - if ( !Zmax.is_defined() || tmp > Zmax ) - Zmax = tmp; - - // check if the output is binary: - if ( _is_binary ) { - if ( !_bin_values[0].is_defined() ) - _bin_values[0] = tmp; - else if ( !_bin_values[1].is_defined() && tmp != _bin_values[0] ) - _bin_values[1] = tmp; - else { - if ( tmp != _bin_values[0] && tmp != _bin_values[1] ) - _is_binary = false; - } - } - } - - // Z scaling parameters (1/2): - _Z_scaling[0] = (Zmax - Zmin).value(); - - // the output is fixed: - if ( _Z_scaling[0] == 0.0 ) - _is_fixed = true; - - else { - - _Z_scaling[1] = (Zsum/_p).value() / _Z_scaling[0]; - - if ( !_is_binary ) - _bin_values = NOMAD::Point(2); - - // RNG (random number generator): - int state[] = { 896 , 265 , 371 }; - - // if seed==0, the model will be the same as the one constructed in R, - // with values taken from the R tgp functions for: - // set.seed(0) - // state <- sample(seq(0, 999), 3) - - // otherwise use rand() to get three different integers in [0;999]: - if ( seed != 0 ) { - state[0] = rand()%1000; - while ( state[1] == state[0] ) - state[1] = rand()%1000; - while ( state[2] == state[0] || state[2] == state[1] ) - state[2] = rand()%1000; - } - _tgp_state = newRNGstate ( three2lstate ( state ) ); - - // importance tempering: - _tgp_its = new Temper ( NOMAD::TGP_Output_Model::_ditemps ); - } -} - -/*--------------------------------------------*/ -/* destructor */ -/*--------------------------------------------*/ -NOMAD::TGP_Output_Model::~TGP_Output_Model ( void ) -{ - if ( _Z ) - delete [] _Z; - if ( _tgp_model ) - delete _tgp_model; - if ( _tgp_its ) - delete _tgp_its; - if ( _tgp_state ) - deleteRNGstate ( _tgp_state ); -} - -/*--------------------------------------------*/ -/* compute the model */ -/*--------------------------------------------*/ -void NOMAD::TGP_Output_Model::compute ( double ** X , - double ** XX , - double ** Xsplit , - int n , - int n_XX , - int nsplit , - Params * tgp_params , - double ** tgp_rect , - int * tgp_BTE , - bool tgp_linburn , - bool tgp_verb , - double * ZZ , // OUT - double * Ds2x , // OUT, may be NULL - int * improv ) // OUT, may be NULL -{ - bool compute_Ds2x = ( Ds2x != NULL ); - bool compute_improv = ( improv != NULL ); - - // the output is fixed: - if ( _is_fixed ) { - for ( int j = 0 ; j < n_XX ; ++j ) { - ZZ[j] = _bin_values[0].value(); - if ( compute_Ds2x ) - Ds2x[j] = 0.0; - } - return; - } - - // scale Z: - scale_Z(); - - // construct the TGP model: - _tgp_model = new Model ( tgp_params , - n , - tgp_rect , - 0 , // Id=0 - false , // trace=false - _tgp_state ); - - _tgp_model->Init ( X , - _p , - n , - _Z , - _tgp_its , - NULL , // dtree=NULL - 0 , // ncol=0 - NULL ); // dhier=NULL - - // set the NOMAD-TGP callback function: - // _tgp_model->set_callback ( NOMAD::TGP_callback ); // SLD -- 2014-09-04 - - // TGP verbim (display): -#ifdef TGP_DEBUG - _tgp_model->Outfile ( stdout , 1 ); // set 10 for full display -#else - if ( tgp_verb ) - _tgp_model->Outfile ( stdout , 1 ); - else - _tgp_model->Outfile ( NULL , 0 ); -#endif - - // set the splitting locations (Xsplit): - _tgp_model->set_Xsplit ( Xsplit , nsplit , n ); - - // linear model initialization rounds -B thru 1: - if ( tgp_linburn ) - _tgp_model->Linburn ( tgp_BTE[0] , _tgp_state ); - - // do model rounds 1 thru B (burn in): - _tgp_model->Burnin ( tgp_BTE[0] , _tgp_state ); - - // do the MCMC rounds B,...,T: - Preds * tgp_preds = new_preds ( XX , - n_XX , - 0 , - n , - tgp_rect , - tgp_BTE[1]-tgp_BTE[0] , - false , // pred_n - true , // krige - _tgp_its->IT_ST_or_IS() , - compute_Ds2x , - compute_improv , - false , // sens - tgp_BTE[2] ); - - _tgp_model->Sample ( tgp_preds , tgp_BTE[1]-tgp_BTE[0] , _tgp_state ); - - // if importance tempering, then update the pseudo-prior - // based on the observation counts: - if ( _tgp_its->Numit() > 1 ) - _tgp_its->UpdatePrior ( _tgp_model->update_tprobs() , _tgp_its->Numit() ); - - // copy back the itemps: - _tgp_model->DupItemps ( _tgp_its ); - - // kriging mean: - wmean_of_columns ( ZZ , - tgp_preds->ZZm , - tgp_preds->R , - n_XX , - (_tgp_its->IT_ST_or_IS()) ? tgp_preds->w : NULL ); - - int i; - - // expected reduction in predictive variance (Ds2x): - if ( compute_Ds2x ) { - for ( i = 0 ; i < n_XX ; ++i ) - Ds2x[i] = 0.0; - if ( tgp_preds->Ds2x ) - wmean_of_columns ( Ds2x , - tgp_preds->Ds2x , - tgp_preds->R , - tgp_preds->nn , - (_tgp_its->IT_ST_or_IS()) ? tgp_preds->w : NULL ); - } - - // expected improvement of objective (improv): - if ( compute_improv ) { - - // double * improvec = new double [n_XX]; - // wmean_of_columns ( improvec , - // tgp_preds->improv, - // tgp_preds->R, - // tgp_preds->nn, - // (_tgp_its->IT_ST_or_IS()) ? tgp_preds->w : NULL ); - // for ( i = 0 ; i < n_XX ; ++i ) - // _out << "IMPROVEC[" << i<< "] = " << improvec[i] << std::endl; - // delete [] improvec; - - int *ir = (int*) GetImprovRank ( tgp_preds->R , - tgp_preds->nn , - tgp_preds->improv , - true , // improv=true - tgp_preds->nn , // numirank = n_XX - (_tgp_its->IT_ST_or_IS()) ? tgp_preds->w : NULL ); - - for ( i = 0 ; i < n_XX ; ++i ) { - improv[i] = ir[i]; - if ( improv[i] == 0 ) - improv[i] = n_XX; - } - - free ( ir ); - - // for ( i = 0 ; i < n_XX ; ++i ) - // _out << "RANK[" << i<< "] = " << improv[i] << std::endl; - } - - delete_preds ( tgp_preds ); - -#ifdef TGP_DEBUG - _tgp_model->Outfile ( NULL , 0 ); -#endif - - // unscale Z and ZZ: - unscale_Z ( ZZ , n_XX ); - unscale_Z(); - - // treat binary output: - if ( _is_binary ) - treat_binary_output ( ZZ , n_XX ); - - // disable TGP display: - _tgp_model->Outfile ( NULL , 0 ); -} - -/*--------------------------------------------*/ -/* prediction at one point */ -/*--------------------------------------------*/ -bool NOMAD::TGP_Output_Model::predict ( double * XX , - int n , - double & ZZ , - double ** tgp_rect ) const -{ - if ( _is_fixed ) { - ZZ = _bin_values[0].value(); - return true; - } - - // do the MCMC rounds B,...,T: - Preds * tgp_preds = new_preds ( &XX , - 1 , - 0 , - n , - tgp_rect , - 1 , // instead of T-B - false , // pred_n - true , // krige - _tgp_its->IT_ST_or_IS() , - false , // delta_s2 (flag for Ds2x) - false , // improv - false , // sens - 1 ); // instead of E - - // new TGP function for the one point prediction: - _tgp_model->MAPreplace(); - - // prediction: - _tgp_model->Predict ( tgp_preds , - 1 , // instead of T-B - _tgp_state ); - - // kriging mean: - ZZ = *tgp_preds->ZZm[0]; - // no need to do: - // wmean_of_columns ( &ZZ , - // tgp_preds->ZZm , - // tgp_preds->R , - // 1 , - // (_tgp_its->IT_ST_or_IS()) ? tgp_preds->w : NULL ); - - delete_preds ( tgp_preds ); - - // unscale: - unscale_Z ( &ZZ , 1 ); - - // treat binary output: - if ( _is_binary ) - treat_binary_output ( &ZZ , 1 ); - - return true; -} - -/*--------------------------------------------*/ -/* scale Z or ZZ (private) */ -/*--------------------------------------------*/ -void NOMAD::TGP_Output_Model::scale_Z ( void ) -{ - if ( _Z_is_scaled || _is_fixed ) - return; - scale_Z ( _Z , _p ); - _Z_is_scaled = true; -} - -void NOMAD::TGP_Output_Model::scale_Z ( double * Z , int n ) const -{ - if ( _is_fixed ) - return; - for ( int i = 0 ; i < n ; ++i ) - Z[i] = Z[i] / _Z_scaling[0] - _Z_scaling[1]; -} - -/*--------------------------------------------*/ -/* unscale Z or ZZ (private) */ -/*--------------------------------------------*/ -void NOMAD::TGP_Output_Model::unscale_Z ( void ) -{ - if ( !_Z_is_scaled || _is_fixed ) - return; - unscale_Z ( _Z , _p ); - _Z_is_scaled = false; -} - -void NOMAD::TGP_Output_Model::unscale_Z ( double * Z , int n ) const -{ - if ( _is_fixed ) - return; - for ( int i = 0 ; i < n ; ++i ) - Z[i] = ( Z[i] + _Z_scaling[1] ) * _Z_scaling[0]; -} - -/*--------------------------------------------*/ -/* treat binary output (private) */ -/*--------------------------------------------*/ -void NOMAD::TGP_Output_Model::treat_binary_output ( double * ZZ , int nout ) const -{ - NOMAD::Double d0 , d1; - for ( int j = 0 ; j < nout ; ++j ) { - d0 = (_bin_values[0] - ZZ[j]).abs(); - d1 = (_bin_values[1] - ZZ[j]).abs(); - if ( d0 < d1 ) - ZZ[j] = _bin_values[0].value(); - else - ZZ[j] = _bin_values[1].value(); - } -} - -/*--------------------------------------------*/ -/* display */ -/*--------------------------------------------*/ -void NOMAD::TGP_Output_Model::display ( const NOMAD::Display & out ) const -{ - out << "Z ("; - if ( !_Z_is_scaled ) - out << "un"; - out << "scaled)" << " = [ "; - for ( int i = 0 ; i < _p ; ++i ) { - out << std::setw(15) << _Z[i]; - if ( (i+1)%5 == 0 ) - out << " ;" << std::endl << " "; - else - out << " "; - } - out << "]" << std::endl - << "size(Z)=" << _p << std::endl; - if ( _is_fixed ) - out << "fixed output"; - else if ( _is_binary ) - out << "binary output: values in {" - << _bin_values[0] << "," << _bin_values[1] - << "}"; - out << std::endl - << "Z_scaling=[" << _Z_scaling[0] << "," << _Z_scaling[1] - << "]" << std::endl; -} - -#endif diff --git a/src/TGP_Output_Model.hpp b/src/TGP_Output_Model.hpp deleted file mode 100644 index eaae843cd4fad3d4d14e4c6546e7ea17bdfa32a7..0000000000000000000000000000000000000000 --- a/src/TGP_Output_Model.hpp +++ /dev/null @@ -1,241 +0,0 @@ -/*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ -/* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ -/* */ -/* funded in part by AFOSR and Exxon Mobil */ -/* */ -/* Author: Sebastien Le Digabel */ -/* */ -/* Contact information: */ -/* Ecole Polytechnique de Montreal - GERAD */ -/* C.P. 6079, Succ. Centre-ville, Montreal (Quebec) H3C 3A7 Canada */ -/* e-mail: nomad@gerad.ca */ -/* phone : 1-514-340-6053 #6928 */ -/* fax : 1-514-340-5665 */ -/* */ -/* 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 <http://www.gnu.org/licenses/>. */ -/* */ -/* You can find information on the NOMAD software at www.gerad.ca/nomad */ -/*-------------------------------------------------------------------------------------*/ -/** - \file TGP_Output_Model.hpp - \brief TGP (Bayesian treed Gaussian process) model for one output (headers) - \author Sebastien Le Digabel - \date 2011-02-07 - \see TGP_Output_Model.cpp -*/ -#ifdef USE_TGP - -#ifndef __TGP_OUTPUT_MODEL__ -#define __TGP_OUTPUT_MODEL__ - -#include "Eval_Point.hpp" -#include "tgp.h" - -/*------------------------------*/ -/* TGP C functions prototypes */ -/*------------------------------*/ -extern "C" -{ - unsigned long three2lstate ( int * state ); - void * newRNGstate ( unsigned long s ); - void deleteRNGstate ( void * seed ); - unsigned int * GetImprovRank ( int, int, double **, int, int, double * ); -} - -namespace NOMAD { - - // NOMAD-TGP callback function (called regularly by TGP). - // void TGP_callback ( bool & TGP_interrupt ); // SLD -- 2014-09-04 - - /// TGP models for one output. - class TGP_Output_Model : private NOMAD::Uncopyable { - - private: - - const NOMAD::Display & _out; ///< Display. - - int _p; ///< Number of interpolation points. - - double * _Z; ///< Output vector (size = \c p). - - double _Z_scaling[2]; ///< To scale/unscale \c Z. - bool _Z_is_scaled; ///< If \c Z is scaled or not. - - bool _is_binary; ///< If the output has only two values. - NOMAD::Point _bin_values; ///< Binary output values. - - bool _is_fixed; ///< Only one output value saved in \c bin_values[0]. - - void * _tgp_state; ///< RNG (random number generator). - - Model * _tgp_model; ///< The TGP model. - - Temper * _tgp_its; ///< Importance tempering object. - - static double _ditemps[7]; ///< Importance tempering parameters. - - static bool _force_quit; ///< Flag equal to \c true if ctrl-c is pressed. - - /// Treat binary output. - /** - \param ZZ Output vector -- \b IN/OUT. - \param nout Size of output -- \b IN. - */ - void treat_binary_output ( double * ZZ , int nout ) const; - - /// Scale member \c _Z. - void scale_Z ( void ); - - /// Unscale member \c _Z. - void unscale_Z ( void ); - - /// Scale an output \c Z. - /** - \param Z Output to scale -- \b IN/OUT. - \param n Size of output -- \b IN. - */ - void scale_Z ( double * Z , int n ) const; - - /// Unscale an output \c Z. - /** - \param Z Output to unscale -- \b IN/OUT. - \param n Size of output -- \b IN. - */ - void unscale_Z ( double * Z , int n ) const; - - public: - - /// Constructor. - /** - \param X_pts Interpolation points with output values -- \b IN. - \param bbo_index Output index -- \b IN. - \param seed Random seed (\c 0 to have the same \c R results) -- \b IN. - \param out Display object -- \b IN. - */ - explicit TGP_Output_Model - ( const std::list<const NOMAD::Eval_Point *> & X_pts , - int bbo_index , - int seed , - const NOMAD::Display & out ); - - /// Destructor. - virtual ~TGP_Output_Model ( void ); - - /// Force quit (called by pressing ctrl-c). - static void force_quit ( void ) - { - NOMAD::TGP_Output_Model::_force_quit = true; - } - - /// Access to the \c force_quit flag. - /** - \return The \c force_quit flag. - */ - static bool get_force_quit ( void ) { return NOMAD::TGP_Output_Model::_force_quit; } - - /// Compute the model. - /** - \param X \c X matrix (\c X_pts \c x \c n): interpolation pts -- \b IN. - \param XX \c XX matrix (\c n_XX \c x \c n): prediction points -- \b IN. - \param Xsplit \x Xsplit matrix (\c X plus \c XX) -- \b IN. - \param n Dimension and number of columns of the matrices -- \b IN. - \param n_XX Number of rows of \c XX -- \b IN. - \param nsplit Number of rows of \c Xsplit (\c X_pts \c + \c n_XX) -- \b IN. - \param tgp_params TGP parameters -- \b IN. - \param tgp_rect TGP rectangle -- \b IN. - \param tgp_BTE TGP \c B,\c T, and \c R parameters -- \b IN. - \param tgp_linburn TGP \c linburn parameter -- \b IN. - \param tgp_verb TGP \c verb parameter -- \b IN. - \param ZZ \c ZZ vector (size \c n_XX): prediction values -- \b OUT. - \param Ds2x Expected reduction in predictive var (size \c n_XX) -- \b OUT. - \param improv Expected improvement of the obj. (size \c n_XX) -- \b OUT. - */ - void compute ( double ** X , - double ** XX , - double ** Xsplit , - int n , - int n_XX , - int nsplit , - Params * tgp_params , - double ** tgp_rect , - int * tgp_BTE , - bool tgp_linburn , - bool tgp_verb , - double * ZZ , - double * Ds2x , - int * improv ); - - /// Prediction at one point. - /** - \param XX \c XX matrix (\c n_XX \c x \c n): prediction points -- \b IN. - \param n Dimension and number of columns of the matrices -- \b IN. - \param ZZ \c ZZ vector (size \c n_XX): prediction values -- \b OUT. - \param tgp_rect TGP rectangle -- \b IN. - \return A boolean equal to \c true if the prediction went well. - */ - bool predict ( double * XX , - int n , - double & ZZ , - double ** tgp_rect ) const; - - /// Access to \c Z. - /** - \return The \c Z vector. - */ - const double * get_Z ( void ) const { return _Z; } - - /// Access to the \c fixed flag. - /** - \return The \c fixed flag. - */ - bool is_fixed ( void ) const { return _is_fixed; } - - /// Access to the \c binary flag. - /** - \return The \c binary flag. - */ - bool is_binary ( void ) const { return _is_binary; } - - /// Default display. - void display ( void ) { display ( _out ); } - - /// Display. - /** - \param out Display -- \b IN. - */ - void display ( const NOMAD::Display & out ) const; - }; - - /// Display a NOMAD::TGP_Output_Model object. - /** - \param out The NOMAD::Display object -- \b IN. - \param s The NOMAD::TGP_Output_Model object to be displayed -- \b IN. - \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::TGP_Output_Model & s ) { - s.display ( out ); - return out; - } - -} - -#endif -#endif diff --git a/src/Uncopyable.hpp b/src/Uncopyable.hpp index 64065a3b9a4927d4f17a24f8b753fb7a19c5ff1a..5b2dc8639b57ca88d7eb0ecf3c488519e5e6ab77 100644 --- a/src/Uncopyable.hpp +++ b/src/Uncopyable.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ diff --git a/src/VNS_Search.cpp b/src/VNS_Search.cpp index 508057a6d60c40b6ce0f9e0eb5bce2e630aca079..647dd6c4d1b7badaa8050f2cbcdd3ff59106da9d 100644 --- a/src/VNS_Search.cpp +++ b/src/VNS_Search.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -129,7 +136,7 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , out.close_block ( "end of VNS search (no signature)" ); return; } - + int n = signature->get_n(); if ( n != x->size() ) { @@ -143,9 +150,11 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , signature->get_one_direction ( dir , _k - 1); + NOMAD::Point xp(n); + for (int i = 0 ; i < n ; ++i ) + xp[i] = ( (_p.get_bb_input_type())[i]==NOMAD::BINARY && dir[i]==1.0 && (*x)[i]==1.0 ) ? 0.0 : xp[i] = (*x)[i] + dir[i]; + - // shaking: construct x': - NOMAD::Point xp = *x + dir; // shaking: the perturbation is tried twice with dir and -dir // (in case x == x + dir after snapping) @@ -179,7 +188,11 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , // Current mesh indices const NOMAD::Point old_mesh_indices = signature->get_mesh()->get_mesh_indices ( ); + // Current min mesh size const NOMAD::Point old_delta_min = signature->get_mesh()->get_min_mesh_size(); + // Current min poll size + const NOMAD::Point old_Delta_min = signature->get_mesh()->get_min_poll_size(); + // stats: @@ -187,7 +200,7 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , // current number of blackbox evaluations: int bbe = stats.get_bb_eval(); - int blk_eva = stats.get_block_eval(); + int blk_eva = stats.get_block_eval(); int sgte_eval = stats.get_sgte_eval(); int mads_iterations = stats.get_iterations(); bool has_sgte = _p.has_sgte(); @@ -196,17 +209,17 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , if ( display_degree == NOMAD::FULL_DISPLAY ) { out << " it = " << mads_iterations << std::endl - << " bbe = " << bbe << std::endl - << " blk_eva = " << blk_eva << std::endl; + << " bbe = " << bbe << std::endl + << " blk_eva = " << blk_eva << std::endl; if ( has_sgte ) out << " sgte_eval = " << sgte_eval << std::endl; out << "mesh_indices = ( " << old_mesh_indices << " ) " << std::endl - << " k = " << _k << std::endl - << " kmax = " << _k_max << std::endl - << " x = ( "; + << " k = " << _k << std::endl + << " kmax = " << _k_max << std::endl + << " x = ( "; x->Point::display ( out , " " , 5 , _p.get_point_display_limit() ); out << " ) f=" << x->get_f() << " h=" << x->get_h() << std::endl - << " dir = ( "; + << " dir = ( "; dir.Point::display ( out , " " , 5 , _p.get_point_display_limit() ); out << " ) |dir|="; NOMAD::Double norm = dir.norm(); @@ -215,7 +228,7 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , xp.display ( out , " " , 5 , _p.get_point_display_limit() ); out << " )" << std::endl << std::endl; out << "bb_eval (before+VNS only) objective_value" - << std::endl << std::endl; + << std::endl << std::endl; } // save parameters that are going to be modified: @@ -252,6 +265,7 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , bool old_uce = _p.get_user_calls_enabled(); bool old_epe = _p.get_extended_poll_enabled(); const std::vector<NOMAD::bb_output_type> old_bbot = _p.get_bb_output_type(); + int old_max_eval_intensification = _p.get_max_eval_intensification(); // save list of starting points: std::string x0_cache_file = _p.get_x0_cache_file(); @@ -263,10 +277,14 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , x0s.push_back ( new Point ( *x0s_tmp[k] ) ); } + if ( _p.get_display_degree() == NOMAD::FULL_DISPLAY ) + _p.set_DISPLAY_DEGREE ( NOMAD::NORMAL_DISPLAY ); + else if ( _p.get_display_degree() == NOMAD::NORMAL_DISPLAY ) + _p.set_DISPLAY_DEGREE ( NOMAD::MINIMAL_DISPLAY ); + + // modify parameters: // ------------------ - _p.set_DISPLAY_DEGREE(NOMAD::NO_DISPLAY); - _p.set_SOLUTION_FILE ( "" ); _p.set_LH_SEARCH ( 0 , 0 ); _p.set_VNS_SEARCH ( false ); @@ -293,7 +311,7 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , _p.set_DISPLAY_STATS ( NOMAD::itos(sgte_eval) + "+SGTE OBJ (VNS--surrogate)" ); else { - std::list<std::string> ds = old_ds; + std::list<std::string> ds = old_ds; std::list<std::string>::iterator it = ds.begin(); std::list<std::string>::const_iterator end = ds.end(); std::string s_bbe = NOMAD::itos(bbe) + "+"; @@ -317,7 +335,7 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , std::list<std::string>::iterator it = sf.begin(); std::list<std::string>::const_iterator end = sf.end(); std::string s_bbe = NOMAD::itos(bbe) + "+"; - std::string s_blk = NOMAD::itos(blk_eva) + "+"; + std::string s_blk = NOMAD::itos(blk_eva) + "+"; while ( it != end ) { if ( *it == "BBE" ) @@ -327,17 +345,9 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , ++it; } sf.push_back ( " (VNS)" ); - - _p.set_STATS_FILE( old_stats_file_name, sf); + _p.set_STATS_FILE ( old_stats_file_name , sf ); } - - // Mesh size at current mads iterate can be used as termination criterion for vns search. - // Mesh indices are reinitialized during p.check() - NOMAD::Point delta=signature->get_mesh()->get_delta ( ); - signature->get_mesh()->set_min_mesh_sizes( delta ); - - // X0: _p.set_EXTERN_SIGNATURE ( signature ); _p.set_X0 ( xp ); @@ -348,6 +358,12 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , else _p.set_MAX_BB_EVAL ( old_max_bbe - bbe ); + // MAX_EVAL_INTENSIFICATION + if ( old_max_eval_intensification > 0 && _p.get_intensification_type() == NOMAD::POLL_ONLY ) + _p.set_MAX_EVAL_INTENSIFICATION ( 0 ); + + + // MAX_SGTE_EVAL: if ( old_max_sgte_eval > 0 ) _p.set_MAX_SGTE_EVAL ( old_max_sgte_eval - sgte_eval ); @@ -379,11 +395,24 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , _p.set_STOP_IF_FEASIBLE ( false ); } + // The mesh size before starting vns search + // Mesh indices, mesh size and poll size are reinitialized during p.check() + NOMAD::Point delta=signature->get_mesh()->get_delta ( ); + NOMAD::Point Delta=signature->get_mesh()->get_Delta ( ); + // check the parameters: _p.check ( false , // remove_history_file = false false , // remove_solution_file = false false ); // remove_stats_file = false + // Mesh and poll sizes at current mads iterate can be used as termination criterion for vns search (the mesh object may set min mesh size to initial mesh size if necessary). + signature->get_mesh()->set_min_mesh_sizes( delta ); + signature->get_mesh()->set_min_poll_sizes( Delta ); + + // Modified dimension after extern signature is set + int modified_dimension = _p.get_dimension(); + + // Evaluator_Control: NOMAD::Evaluator_Control & ev_control = mads.get_evaluator_control(); @@ -445,6 +474,12 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , } else if ( !x0_cache_file.empty() ) _p.set_X0 ( x0_cache_file ); + + if ( x0s.size() !=0 && x0s[0]->size() != modified_dimension ) + { + _p.reset_X0(); + _p.set_X0 ( *x ); + } } // restore other saved parameters: @@ -473,17 +508,18 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , _p.set_MAX_TIME ( old_max_time ); _p.set_SGTE_EVAL_SORT ( old_ses ); _p.set_OPT_ONLY_SGTE ( opt_only_sgte ); - _p.set_BB_OUTPUT_TYPE ( old_bbot ); + _p.set_BB_OUTPUT_TYPE ( old_bbot ); + _p.set_MAX_EVAL_INTENSIFICATION ( old_max_eval_intensification ); _p.check ( false , // remove_history_file = false false , // remove_solution_file = false false ); // remove_stats_file = false - // restore min mesh sizes and mesh indices + // Needed because mesh reinitialized during p.check() signature->get_mesh()->set_min_mesh_sizes( old_delta_min ); - signature->get_mesh()->set_mesh_indices( old_mesh_indices ); // Needed because mesh indices reinitialized during p.check() - + signature->get_mesh()->set_min_poll_sizes( old_Delta_min ); + signature->get_mesh()->set_mesh_indices( old_mesh_indices ); // surrogate evaluations: perform only one true evaluation: if ( has_sgte && !opt_only_sgte ) @@ -606,7 +642,7 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , // ( active_barrier.check_PEB_constraints() ): if ( _p.get_barrier_type() == NOMAD::PEB_P ) ( ( _p.get_opt_only_sgte() ) ? sgte_barrier : true_barrier ).check_PEB_constraints ( *new_infeas_inc , display_degree==NOMAD::FULL_DISPLAY ); - } + } // number of search points and success: if ( opt_only_sgte ) @@ -622,8 +658,16 @@ void NOMAD::VNS_Search::search ( NOMAD::Mads & mads , // solution file: if ( bf ) + { ev_control.write_solution_file ( *bf ); + } + if ( new_feas_inc && display_degree > NOMAD::NO_DISPLAY && display_degree < NOMAD::FULL_DISPLAY ) + { + std::list<std::string> ds = old_ds; + ds.push_back ( " (VNS)" ); + ev_control.display_stats(false, out, ds , new_feas_inc , true , NULL ); + } } // final display: diff --git a/src/VNS_Search.hpp b/src/VNS_Search.hpp index f74a3fe859c20ad61f25e7e99e03470c13a109fc..e966c3f27628f1b635039b721ce37800824003e4 100644 --- a/src/VNS_Search.hpp +++ b/src/VNS_Search.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file VNS_Search.hpp - \brief VNS search (headers) - \author Sebastien Le Digabel - \date 2010-04-12 - \see VNS_Search.cpp -*/ + \file VNS_Search.hpp + \brief VNS search (headers) + \author Sebastien Le Digabel + \date 2010-04-12 + \see VNS_Search.cpp + */ #ifndef __VNS_SEARCH__ #define __VNS_SEARCH__ @@ -47,57 +54,57 @@ #include "Search.hpp" namespace NOMAD { - - /// Variable Neighborhood Search (VNS) search. - class VNS_Search : public NOMAD::Search , private NOMAD::Uncopyable { - - private: - - int _k; ///< VNS neighborhood parameter. - int _k_max; ///< Maximum value of \c _k. - const NOMAD::Eval_Point * _old_x; ///< Previous reference point (updates \c _k). - - public: - - /// Constructor. - /** - \param p Parameters -- \b IN. - */ - VNS_Search ( NOMAD::Parameters & p ) - : NOMAD::Search ( p , NOMAD::VNS_SEARCH ) , - _k ( 1 ) , - _k_max ( 1 ) , - _old_x ( NULL ) {} - - /// Destructor. - virtual ~VNS_Search ( void ) {} - - /// Reset. - virtual void reset ( void ); - - /// The VNS search. - /** - Principle: x --[shaking(k)]--> x' --[descent]--> x'' . - \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. - \param nb_search_pts Number of generated search points -- \b OUT. - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - \param success Type of success -- \b OUT. - \param count_search Count or not the search -- \b OUT. - \param new_feas_inc New feasible incumbent -- \b IN/OUT. - \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. - */ - virtual void search ( NOMAD::Mads & mads , - int & nb_search_pts , - bool & stop , - NOMAD::stop_type & stop_reason , - NOMAD::success_type & success , - bool & count_search , - const NOMAD::Eval_Point *& new_feas_inc , - const NOMAD::Eval_Point *& new_infeas_inc ); - - }; + /// Variable Neighborhood Search (VNS) search. + class VNS_Search : public NOMAD::Search , private NOMAD::Uncopyable { + + private: + + int _k; ///< VNS neighborhood parameter. + int _k_max; ///< Maximum value of \c _k. + const NOMAD::Eval_Point * _old_x; ///< Previous reference point (updates \c _k). + + + public: + + /// Constructor. + /** + \param p Parameters -- \b IN. + */ + VNS_Search ( NOMAD::Parameters & p ) + : NOMAD::Search ( p , NOMAD::VNS_SEARCH ) , + _k ( 1 ) , + _k_max ( 1 ) , + _old_x ( NULL ) {} + + /// Destructor. + virtual ~VNS_Search ( void ) {} + + /// Reset. + virtual void reset ( void ); + + /// The VNS search. + /** + Principle: x --[shaking(k)]--> x' --[descent]--> x'' . + \param mads NOMAD::Mads object invoking this search -- \b IN/OUT. + \param nb_search_pts Number of generated search points -- \b OUT. + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + \param success Type of success -- \b OUT. + \param count_search Count or not the search -- \b OUT. + \param new_feas_inc New feasible incumbent -- \b IN/OUT. + \param new_infeas_inc New infeasible incumbent -- \b IN/OUT. + */ + virtual void search ( NOMAD::Mads & mads , + int & nb_search_pts , + bool & stop , + NOMAD::stop_type & stop_reason , + NOMAD::success_type & success , + bool & count_search , + const NOMAD::Eval_Point *& new_feas_inc , + const NOMAD::Eval_Point *& new_infeas_inc ); + + }; } #endif diff --git a/src/Variable_Group.cpp b/src/Variable_Group.cpp index c177fec114bb511a039f08b356dd2e893432a3de..6c198f1900d198532ce645e07641d09a80f62ad1 100644 --- a/src/Variable_Group.cpp +++ b/src/Variable_Group.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -45,11 +52,10 @@ /*-------------------------------------------------------------*/ /* check (also removes fixed variables from the group) */ /*-------------------------------------------------------------*/ -bool NOMAD::Variable_Group::check -( const NOMAD::Point & fixed_vars , - const std::vector<NOMAD::bb_input_type> & bbit , - std::vector<bool> * in_group , - bool & mod ) +bool NOMAD::Variable_Group::check( const NOMAD::Point & fixed_vars , + const std::vector<NOMAD::bb_input_type> & bbit , + std::vector<bool> * in_group , + bool & mod ) { // initial checks: @@ -141,15 +147,17 @@ bool NOMAD::Variable_Group::check /*---------------------------------------------------------*/ /* compute the directions */ /*---------------------------------------------------------*/ -void NOMAD::Variable_Group::get_directions ( std::list<NOMAD::Direction> & dirs , - NOMAD::poll_type poll , - const NOMAD::OrthogonalMesh & mesh ) +void NOMAD::Variable_Group::get_directions ( std::list<NOMAD::Direction> & dirs , + NOMAD::poll_type poll , + const NOMAD::OrthogonalMesh & mesh ) { - - _directions->compute ( dirs , - poll , + // vectors are of size nc : + // ------------------------ + _directions->compute ( dirs , + poll , mesh ); return; + } /*---------------------------------------------------------*/ @@ -166,7 +174,8 @@ bool NOMAD::Variable_Group::operator < ( const NOMAD::Variable_Group & vg ) cons std::set<int>::const_iterator it1 , it2 = vg._var_indexes.begin() , end = _var_indexes.end(); - for ( it1 = _var_indexes.begin() ; it1 != end ; ++it1 , ++it2 ) { + for ( it1 = _var_indexes.begin() ; it1 != end ; ++it1 , ++it2 ) + { if ( *it1 < *it2 ) return true; if ( *it1 > *it2 ) diff --git a/src/Variable_Group.hpp b/src/Variable_Group.hpp index 70f60544af43e840948cc06375097c49c3e5de9d..beee30517ce4d2a04b8bcb6b4d378e10ffc9dba9 100644 --- a/src/Variable_Group.hpp +++ b/src/Variable_Group.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -118,7 +125,7 @@ namespace NOMAD { bool check ( const NOMAD::Point & fixed_vars , const std::vector<NOMAD::bb_input_type> & bbit , std::vector<bool> * in_group , - bool & mod ); + bool & mod ); /// Check if the directions are Ortho-MADS directions. /** @@ -126,7 +133,6 @@ namespace NOMAD { */ bool is_orthomads ( void ) const { return _directions->is_orthomads(); } - /// Access to the variable indexes. /** \return The variable indexes. @@ -151,15 +157,16 @@ namespace NOMAD { return _directions->get_sec_poll_dir_types(); } + /// Access to the directions. /** - \param dirs List of directions -- \b OUT. - \param poll Type of poll (primary or secondary) -- \b IN. - \param mesh Mesh -- \b IN. + \param dirs List of directions -- \b OUT. + \param poll Type of poll (primary or secondary) -- \b IN. + \param mesh Mesh -- \b IN. */ - void get_directions ( std::list<NOMAD::Direction> & dirs , - NOMAD::poll_type poll , - const NOMAD::OrthogonalMesh & mesh ); + void get_directions ( std::list<NOMAD::Direction> & dirs , + NOMAD::poll_type poll , + const NOMAD::OrthogonalMesh & mesh ); /// Access to one direction for a given mesh. @@ -193,7 +200,8 @@ namespace NOMAD { \return The NOMAD::Display object. */ inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::Variable_Group & vg ) { + const NOMAD::Variable_Group & vg ) + { vg.display ( out ); return out; } @@ -202,9 +210,11 @@ namespace NOMAD { /** Used with \c set<Variable_Group*,VG_Comp> in class NOMAD::Parameters. */ - struct VG_Comp { + struct VG_Comp + { /// Comparison between two NOMAD::Variable_Group objects. - bool operator() ( const Variable_Group * vg1 , const Variable_Group * vg2 ) const { + bool operator() ( const Variable_Group * vg1 , const Variable_Group * vg2 ) const + { return (*vg1 < *vg2); } }; diff --git a/src/XMesh.cpp b/src/XMesh.cpp index 926ddac8f88c68c40524df03a8e63a1cbb19a1cd..f19078df3e5870d121207d9ced8b93b8137b9ef0 100644 --- a/src/XMesh.cpp +++ b/src/XMesh.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -36,7 +43,7 @@ /** \file XMesh.cpp \brief Class for the MADS xmesh (implementation) - \author Christophe Tribes + \author Christophe Tribes \date 2014-07 \see XMesh.hpp */ @@ -48,79 +55,63 @@ /* init the XMesh */ /*-----------------------------------------------------------*/ void NOMAD::XMesh::init ( ) -{ - bool chkMesh = _delta_min.is_defined(); - bool chkPoll = _Delta_min_is_defined; - _n = _delta_0.size(); - - - if ( !_Delta_0.is_complete() ) - throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , - "NOMAD::XMesh::init(): Delta_0 has undefined values" ); - if ( _delta_0.size() != _Delta_0.size() ) - throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , - "NOMAD::XMesh::init(): delta_0 and Delta_0 have different sizes" ); - - if ( !_delta_0.is_complete() ) - throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , - "NOMAD::XMesh::init(): delta_0 has undefined values" ); - - if ( chkMesh && _delta_min.size() != _n ) - throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , - "NOMAD::XMesh::init(): delta_0 and delta_min have different sizes" ); - - if ( chkPoll && _Delta_min.size() != _n ) - throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , - "NOMAD::XMesh::init(): delta_0 and Delta_min have different sizes" ); - +{ + if ( _limit_mesh_index >0 ) - throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , - "NOMAD::XMesh::XMesh(): limit mesh index must be <=0 " ); - - - _r.resize( _n ); - _r_max.resize( _n ); - _r_min.resize( _n ); - - for ( int k = 0 ; k < _n ; ++k ) - { - _r[k]=0; - _r_max[k]=0; - _r_min[k]=0; - } - - + throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , + "NOMAD::XMesh::XMesh(): limit mesh index must be <=0 " ); + + // The delta_0 depends on Delta_0 and the problem dimension + _delta_0=_Delta_0; + _delta_0*=pow(_n_free_variables,-0.5); + + + _r.resize( _n ); + _r_max.resize( _n ); + _r_min.resize( _n ); + + for ( int k = 0 ; k < _n ; ++k ) + { + _r[k]=0; + _r_max[k]=0; + _r_min[k]=0; + + } + + } /*-----------------------------------------------------------*/ /* Update the provided mesh indices (the Mesh is unchanged). */ /*-----------------------------------------------------------*/ -void NOMAD::XMesh::update ( NOMAD::success_type success , NOMAD::Point & mesh_indices, const NOMAD::Direction *dir ) const +void NOMAD::XMesh::update ( NOMAD::success_type success , + NOMAD::Point & mesh_indices, + const NOMAD::Direction *dir ) const { - - if ( mesh_indices.is_defined() ) - { - - if ( dir && dir->size() != mesh_indices.size() ) - throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , - "NOMAD::XMesh::update(): mesh_indices and dir have different sizes" ); - - for (int i=0; i < mesh_indices.size() ; i++) - { - if ( success == NOMAD::FULL_SUCCESS ) - { - - if ( (*dir)[i] !=0.0) - mesh_indices[i] += _coarsening_step; - - if ( mesh_indices[i] > -NOMAD::XL_LIMITS ) - mesh_indices[i] = -NOMAD::XL_LIMITS; - } - else if ( success == NOMAD::UNSUCCESSFUL ) - mesh_indices[i] += _refining_step; - } - } + + if ( mesh_indices.is_defined() ) + { + + if ( dir && dir->size() != mesh_indices.size() ) + throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , + "NOMAD::XMesh::update(): mesh_indices and dir have different sizes" ); + + for (int i=0; i < mesh_indices.size() ; i++) + { + if ( success == NOMAD::FULL_SUCCESS ) + { + + if ( (*dir)[i] !=0.0) + mesh_indices[i] += _coarsening_step; + + if ( mesh_indices[i] > -NOMAD::XL_LIMITS ) + mesh_indices[i] = -NOMAD::XL_LIMITS; + } + else if ( success == NOMAD::UNSUCCESSFUL ) + mesh_indices[i] += _refining_step; + } + } } @@ -128,24 +119,26 @@ void NOMAD::XMesh::update ( NOMAD::success_type success , NOMAD::Point & mesh_in /*-----------------------------------------------------------*/ /* update the XMesh */ /*-----------------------------------------------------------*/ -void NOMAD::XMesh::update ( NOMAD::success_type success , const NOMAD::Direction * dir) +void NOMAD::XMesh::update ( NOMAD::success_type success , const NOMAD::Direction * dir) // , const NOMAD::OrthogonalMesh *mesh ) { - // defaults: - // full success: r^k_j = r^k_j + 1 if (dir_k != 0 and anistropic_mesh) and r^k_j remains the same if dir_k=0 - // failure : r^k_j = r^k_j - 1 - - - if ( dir && dir->size() != _n ) - throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , - "NOMAD::XMesh::update(): delta_0 and dir have different sizes" ); - - - if ( success == NOMAD::FULL_SUCCESS ) - { - // Evaluate ||d||_inf - NOMAD::Double norm_inf=0; + // defaults: + // full success: r^k_j = r^k_j + 1 if (dir_k != 0 and anistropic_mesh) and r^k_j remains the same if dir_k=0 + // failure : r^k_j = r^k_j - 1 + + // Granularity is only used to block Delta from decreasing but mesh indices are updated + + + if ( dir && dir->size() != _n ) + throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , + "NOMAD::XMesh::update(): delta_0 and dir have different sizes" ); + + + if ( success == NOMAD::FULL_SUCCESS ) + { + // Evaluate ||d||_inf + NOMAD::Double norm_inf=0; NOMAD::Point delta=NOMAD::OrthogonalMesh::get_delta(); - + if ( _anisotropic_mesh ) { for (int i=0; i < _n; i++) @@ -162,42 +155,42 @@ void NOMAD::XMesh::update ( NOMAD::success_type success , const NOMAD::Direction for (int j=0; j < _n; j++) if ( _r[j] > max_index ) max_index=_r[j]; - - - // Update mesh indices for coordinates with |dir_j|>1/n_free_variables ||dir||_inf or mesh index >=-2 - for (int i=0; i < _n; i++) - { + + + // Update mesh indices for coordinates with |dir_j|>1/n_free_variables ||dir||_inf or mesh index >=-2 + for (int i=0; i < _n; i++) + { if ( ! dir || (*dir)[i].abs()/delta[i] > norm_inf/_n_free_variables || _r[i] >=-2 ) - { - _r[i] += _coarsening_step; - - if (_r[i] > -NOMAD::XL_LIMITS ) - _r[i] = -NOMAD::XL_LIMITS; - - if ( _r[i] > _r_max[i] ) - _r_max[i] = _r[i]; - - } - } - - - // Udate mesh indices for coordinates with |dir_l| < 1/n_free_variables ||dir||_inf and mesh index < 2*max_mesh_index - for (int l=0; l < _n; l++) - { - if ( dir && _r[l] < -2 && (*dir)[l].abs()/delta[l] <= norm_inf/_n_free_variables && _r[l] < 2*max_index ) - _r[l]+= _coarsening_step; - } - - } - else if ( success == NOMAD::UNSUCCESSFUL ) - for (int i=0; i< _n; i++) - { - _r[i] += _refining_step; - - if ( _r[i] < _r_min[i] ) - _r_min[i] = _r[i]; - - } + { + _r[i] += _coarsening_step; + + if (_r[i] > -NOMAD::XL_LIMITS ) + _r[i] = -NOMAD::XL_LIMITS; + + if ( _r[i] > _r_max[i] ) + _r_max[i] = _r[i]; + + } + } + + + // Udate mesh indices for coordinates with |dir_l| < 1/n_free_variables ||dir||_inf and mesh index < 2*max_mesh_index + for (int l=0; l < _n; l++) + { + if ( dir && _r[l] < -2 && (*dir)[l].abs()/delta[l] <= norm_inf/_n_free_variables && _r[l] < 2*max_index ) + _r[l]+= _coarsening_step; + } + + } + else if ( success == NOMAD::UNSUCCESSFUL ) + for (int i=0; i< _n; i++) + { + _r[i] += _refining_step; + + if ( _r[i] < _r_min[i] ) + _r_min[i] = _r[i]; + + } } @@ -206,21 +199,21 @@ void NOMAD::XMesh::update ( NOMAD::success_type success , const NOMAD::Direction /*-----------------------------------------------------------*/ void NOMAD::XMesh::display ( const NOMAD::Display & out ) const { - out << "n : " << _n << std::endl - << "tau : " << _update_basis << std::endl - << "poll coarsening exponent: " << _coarsening_step << std::endl - << "poll refining exponent : " << _refining_step << std::endl; + out << "n : " << _n << std::endl + << "tau : " << _update_basis << std::endl + << "poll coarsening exponent: " << _coarsening_step << std::endl + << "poll refining exponent : " << _refining_step << std::endl; out << "minimal mesh size : "; - if ( _delta_min.is_defined() ) - out << "(" << _delta_min << " )" << std::endl; - else - out << "none"; - out << std::endl - << "minimal poll size : "; - if ( _Delta_min_is_defined ) - out << "( " << _Delta_min << " )" << std::endl; - else - out << "none"; + if ( _delta_min.is_defined() ) + out << "(" << _delta_min << " )" << std::endl; + else + out << "none"; + out << std::endl + << "minimal poll size : "; + if ( _Delta_min_is_defined ) + out << "( " << _Delta_min << " )" << std::endl; + else + out << "none"; out << std::endl << "initial poll size : "; if (_Delta_0.is_defined()) @@ -235,7 +228,7 @@ void NOMAD::XMesh::display ( const NOMAD::Display & out ) const else out <<"( none )" << std::endl; - out << std::endl; + out << std::endl; } @@ -244,58 +237,57 @@ void NOMAD::XMesh::display ( const NOMAD::Display & out ) const /* and on the minimal mesh size */ /*----------------------------------------------------------*/ void NOMAD::XMesh::check_min_mesh_sizes ( bool & stop , - NOMAD::stop_type & stop_reason ) const + NOMAD::stop_type & stop_reason ) const { - if ( stop ) - return; - - // Coarse mesh stopping criterion - stop=false; + if ( stop ) + return; - for (int i=0;i<_n;i++) + // Coarse mesh stopping criterion + stop=false; + + for (int i=0;i<_n;i++) if ( _r[i] > -NOMAD::XL_LIMITS ) - { - stop = true; - break; - } - - if (stop) - { - stop_reason = NOMAD::XL_LIMITS_REACHED; - return; - } - - stop=true; - + { + stop = true; + break; + } + + if (stop) + { + stop_reason = NOMAD::XL_LIMITS_REACHED; + return; + } + + stop=true; // Fine mesh stopping criterion // All mesh indices must < _limit_mesh_index to trigger this stopping criterion - for (int i=0;i<_n;i++) - { - if ( _r[i] >= _limit_mesh_index ) - { - stop = false; - break; - } - } - if (stop) - { - stop_reason = NOMAD::XL_LIMITS_REACHED; - return; - } - - // 2. Delta^k (poll size) tests: - if ( check_min_poll_size_criterion ( ) ) - { - stop = true; - stop_reason = NOMAD::DELTA_P_MIN_REACHED; - } - - // 3. delta^k (mesh size) tests: - if ( check_min_mesh_size_criterion ( ) ) - { - stop = true; - stop_reason = NOMAD::DELTA_M_MIN_REACHED; - } + for (int i=0;i<_n;i++) + { + if ( _r[i] >= _limit_mesh_index ) + { + stop = false; + break; + } + } + if (stop) + { + stop_reason = NOMAD::XL_LIMITS_REACHED; + return; + } + + // 2. Delta^k (poll size) tests: + if ( check_min_poll_size_criterion ( ) ) + { + stop = true; + stop_reason = NOMAD::DELTA_P_MIN_REACHED; + } + + // 3. delta^k (mesh size) tests: + if ( check_min_mesh_size_criterion ( ) ) + { + stop = true; + stop_reason = NOMAD::DELTA_M_MIN_REACHED; + } } /*-----------------------------------------------------------*/ @@ -303,11 +295,11 @@ void NOMAD::XMesh::check_min_mesh_sizes ( bool & stop , /*-----------------------------------------------------------*/ bool NOMAD::XMesh::check_min_poll_size_criterion ( ) const { - if ( !_Delta_min_is_defined ) - return false; - - NOMAD::Point Delta; - return get_Delta ( Delta ); + if ( !_Delta_min_is_defined ) + return false; + + NOMAD::Point Delta; + return get_Delta ( Delta ); } /*-----------------------------------------------------------*/ @@ -315,118 +307,103 @@ bool NOMAD::XMesh::check_min_poll_size_criterion ( ) const /*-----------------------------------------------------------*/ bool NOMAD::XMesh::check_min_mesh_size_criterion ( ) const { - if ( !_delta_min.is_defined() ) - return false; - - NOMAD::Point delta; - return get_delta ( delta ); + if ( !_delta_min.is_defined() ) + return false; + + NOMAD::Point delta; + return get_delta ( delta ); } /*--------------------------------------------------------------*/ -/* get delta (mesh size parameter) */ -/* delta^k = delta^0 \tau ^min{0,2*r^k} */ +/* get delta (mesh size parameter) */ +/* delta^k = delta^0 \tau ^min{0,2*r^k} */ /*--------------------------------------------------------------*/ /* the function also returns true if ALL delta[i] < delta_min */ -/*----------------------------------------------------------------*/ +/*--------------------------------------------------------------*/ bool NOMAD::XMesh::get_delta ( NOMAD::Point & delta ) const { - - delta.resize(_n); + + delta.resize(_n); bool delta_min_is_defined=_delta_min.is_defined(); - + bool stop = true; - - // delta^k = power_of_beta * delta^0: - for ( int i = 0 ; i < _n ; ++i ) - { - NOMAD::Double power_of_beta - = pow ( _update_basis.value() , ( (_r[i] >= 0) ? 0 : 2*_r[i].value() ) ); - - delta[i] = _delta_0[i] * power_of_beta; - - if ( delta_min_is_defined && _delta_min[i].is_defined() && delta[i] >= _delta_min[i] ) + + // delta^k = power_of_beta * delta^0: + for ( int i = 0 ; i < _n ; ++i ) + { + delta[i] = get_delta( i ); + + if ( stop && delta_min_is_defined && _delta_min[i].is_defined() && delta[i] >= _delta_min[i] ) stop = false; - } - - return stop; + } + + return stop; } /*--------------------------------------------------------------*/ -/* get delta (mesh size parameter) */ -/* delta^k = delta^0 \tau ^min{0,2*r^k} */ +/* get delta (mesh size parameter) */ +/* delta^k = delta^0 \beta ^min{0,2*r^k} */ /*--------------------------------------------------------------*/ NOMAD::Double NOMAD::XMesh::get_delta ( int i ) const { // delta^k = power_of_beta * delta^0: NOMAD::Double power_of_beta = pow ( _update_basis.value() , ( (_r[i] >= 0) ? 0 : 2*_r[i].value() ) ); - + return _delta_0[i] * power_of_beta; } -/*--------------------------------------------------------------*/ -/* get Delta (poll size parameter) */ -/* Delta^k = Delta^0 \tau ^{r^k} */ -/*--------------------------------------------------------------*/ -/* the function also returns true if all values are < Delta_min */ -/*----------------------------------------------------------------*/ +/*---------------------------------------------------------------*/ +/* get Delta (poll size parameter) */ +/* Delta^k = Delta^0 \beta ^{r^k} */ +/*---------------------------------------------------------------*/ +/* the function also returns true if all values are < Delta_min */ +/*---------------------------------------------------------------*/ bool NOMAD::XMesh::get_Delta ( NOMAD::Point & Delta ) const { - - bool stop = true; - + + bool stop = true; Delta.resize(_n); - - // delta^k = power_of_tau * delta^0: - for ( int i = 0 ; i < _n ; ++i ) - { - Delta[i] = _Delta_0[i] * pow( _update_basis.value() , _r[i].value() ); - - if ( !_Delta_min_is_complete || Delta[i] >= _Delta_min[i] ) - stop = false; + + // delta^k = power_of_tau * delta^0: + for ( int i = 0 ; i < _n ; ++i ) + { + Delta[i] = get_Delta( i ); - if ( _Delta_min_is_defined && _Delta_min[i].is_defined() && Delta[i] < _Delta_min[i] ) - Delta[i]=_Delta_min[i]; - - } - - return stop; + if ( stop && ! _fixed_variables[i].is_defined() && ( !_Delta_min_is_complete || Delta[i] >= _Delta_min[i] ) ) + stop = false; + } + + return stop; } /*--------------------------------------------------------------*/ /* get Delta_i (poll size parameter) */ -/* Delta^k = Delta^0 \tau ^{r^k} */ -/*--------------------------------------------------------------*/ -/* the function returns Delta >= Delta_min */ +/* Delta^k = Delta^0 \beta ^{r^k} */ /*--------------------------------------------------------------*/ NOMAD::Double NOMAD::XMesh::get_Delta ( int i ) const { - NOMAD::Double Delta = _Delta_0[i] * pow( _update_basis.value() , _r[i].value() ); - if ( _Delta_min_is_defined && _Delta_min[i].is_defined() && Delta < _Delta_min[i] ) - Delta=_Delta_min[i]; - - return Delta; + } bool NOMAD::XMesh::is_finest ( ) const { - - for ( int i = 0 ; i < _n ; ++i ) - { - if ( _r[i] > _r_min[i] ) - return false; - } - return true; + for ( int i = 0 ; i < _n ; ++i ) + { + if ( _r[i] > _r_min[i] ) + return false; + } + return true; } @@ -437,17 +414,17 @@ void NOMAD::XMesh::set_mesh_indices ( const NOMAD::Point & r ) { if ( r.size() != _n ) - throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , + throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , "NOMAD::XMesh::set_mesh_indices(): dimension of provided mesh indices must be consistent with their previous dimension" ); - - _r=r; - for ( int i = 0 ; i < _n ; ++i ) - { - if ( r[i] > _r_max[i] ) - _r_max[i] = r[i]; - if ( r[i] < _r_min[i] ) - _r_min[i] = r[i]; - } + + _r=r; + for ( int i = 0 ; i < _n ; ++i ) + { + if ( r[i] > _r_max[i] ) + _r_max[i] = r[i]; + if ( r[i] < _r_min[i] ) + _r_min[i] = r[i]; + } } @@ -456,6 +433,7 @@ void NOMAD::XMesh::set_mesh_indices ( const NOMAD::Point & r ) /*-----------------------------------------------------------*/ void NOMAD::XMesh::set_limit_mesh_index ( int l ) { + _limit_mesh_index=l; } @@ -465,16 +443,20 @@ void NOMAD::XMesh::set_limit_mesh_index ( int l ) /*-----------------------------------------------------------*/ /* scale and project on the mesh */ /*-----------------------------------------------------------*/ -NOMAD::Double NOMAD::XMesh::scale_and_project(int i, const NOMAD::Double & l) const +NOMAD::Double NOMAD::XMesh::scale_and_project(int i, const NOMAD::Double & l, bool round_up) const { + NOMAD::Double delta = get_delta( i ); NOMAD::Double Delta = get_Delta( i ); - if ( i<=_n && delta.is_defined() && Delta.is_defined() ) { + NOMAD::Double d = Delta / delta * l; - return d.NOMAD::Double::round()*delta; + if ( ! round_up ) + return ( d < 0.0 ? -std::floor(.5-d.value()) : std::floor(.5+d.value()) ) * delta; + else + return d.NOMAD::Double::ceil()*delta; } else throw NOMAD::Exception ( "XMesh.cpp" , __LINE__ , @@ -486,26 +468,29 @@ NOMAD::Double NOMAD::XMesh::scale_and_project(int i, const NOMAD::Double & l) co NOMAD::Point NOMAD::XMesh::get_mesh_ratio_if_success ( void ) const { - - try - { - NOMAD::Point ratio( _n ); - for (int i=0 ; i < _n ; i++) - { - NOMAD::Double power_of_tau - = pow ( _update_basis.value() , ( (_r[i] >= 0) ? 0 : 2*_r[i].value() ) ); - - NOMAD::Double power_of_tau_if_success - = pow ( _update_basis.value() , ( (_r[i] + _coarsening_step >= 0) ? 0 : 2*(_r[i].value() + _coarsening_step) ) ); - - ratio[i] = power_of_tau_if_success/power_of_tau; - - } - - return ratio; - } - catch ( NOMAD::Double::Invalid_Value & ) - { - return NOMAD::Point( _n,-1 ); - } + + try + { + NOMAD::Point ratio( _n ); + for (int i=0 ; i < _n ; i++) + { + NOMAD::Double power_of_tau + = pow ( _update_basis.value() , ( (_r[i] >= 0) ? 0 : 2*_r[i].value() ) ); + + NOMAD::Double power_of_tau_if_success + = pow ( _update_basis.value() , ( (_r[i] + _coarsening_step >= 0) ? 0 : 2*(_r[i].value() + _coarsening_step) ) ); + + ratio[i] = power_of_tau_if_success/power_of_tau; + + } + + return ratio; + } + catch ( NOMAD::Double::Invalid_Value & ) + { + return NOMAD::Point( _n,-1 ); + } } + + + diff --git a/src/XMesh.hpp b/src/XMesh.hpp index e29262cd6d15a4b969ea6deeaa38ea2ec28fbe38..f3450fe40fc920c019db1e607484ba807a954d4f 100644 --- a/src/XMesh.hpp +++ b/src/XMesh.hpp @@ -1,7 +1,7 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ +/* Copyright (C) 2001-2015 Mark Abramson - Brigham Young University, Provo */ /* Charles Audet - Ecole Polytechnique, Montreal */ /* Gilles Couture - Ecole Polytechnique, Montreal */ /* John Dennis - Rice University, Houston */ @@ -46,38 +46,35 @@ #include "OrthogonalMesh.hpp" namespace NOMAD { - - /// Class for the MADS Xmesh. - /** + + /// Class for the MADS Xmesh. + /** - The Xmesh in NOMAD is defined with the basic directions and the - mesh size parameter delta^k for each coordinate. - */ - - class XMesh : public NOMAD::OrthogonalMesh { - - /*--------------------------------------------------------------*/ - private: - - NOMAD::Point _r; // Mesh index per coordinate. - NOMAD::Point _r_min; - NOMAD::Point _r_max; - bool _anisotropic_mesh; - - - - /*--------------------------------------------------------------*/ - - /// Private affectation operator. - /** - \param m The right-hand side object -- \b IN. - */ - const XMesh & operator = ( const XMesh & m ); - - /// Check the minimal poll size criterion. - bool check_min_poll_size_criterion ( ) const; - - /// Check the minimal mesh size criterion. - bool check_min_mesh_size_criterion ( ) const; + mesh size parameter delta^k for each coordinate. + */ + + class XMesh : public NOMAD::OrthogonalMesh { + + /*--------------------------------------------------------------*/ + private: + + NOMAD::Point _r; // Mesh index per coordinate. + NOMAD::Point _r_min; + NOMAD::Point _r_max; + + /*--------------------------------------------------------------*/ + + /// Private affectation operator. + /** + \param m The right-hand side object -- \b IN. + */ + const XMesh & operator = ( const XMesh & m ); + + /// Check the minimal poll size criterion. + bool check_min_poll_size_criterion ( ) const; + + /// Check the minimal mesh size criterion. + bool check_min_mesh_size_criterion ( ) const; /// Access to the mesh size parameter delta^k. @@ -85,7 +82,7 @@ namespace NOMAD { \return delta The mesh size parameter delta^k -- \b OUT. \param i The index of the mesh size */ - NOMAD::Double get_delta ( int i ) const ; + inline NOMAD::Double get_delta ( int i ) const ; /// Access to the poll size parameter Delta^k. @@ -93,215 +90,207 @@ namespace NOMAD { \return Delta The poll size parameter Delta^k -- \b OUT. \param i The index of the poll size */ - NOMAD::Double get_Delta ( int i ) const ; - - void init ( ); - - public: - - /// Constructor. - /** - \param anistropic_mesh Use anisotropic mesh or not -- \b IN. - \param Delta_0 Initial poll size Delta^0 -- \b IN. - \param Delta_min Minimal poll size Delta^min (may be undefined) -- \b IN. - \param delta_min Minimal mesh size delta^min (may be undefined) -- \b IN. - \param poll_update_basis Poll update basis (b); default=2 -- \b IN. - \param poll_coarsening_step Poll coarsening step (w+); default=1 -- \b IN. - \param poll_refining_step Poll refining step (w-); default=-1 -- \b IN. + inline NOMAD::Double get_Delta ( int i ) const ; + + void init ( ); + + public: + + /// Constructor. + /** + \param anisotropic_mesh Use anisotropic mesh or not -- \b IN. + \param Delta_0 Initial poll size Delta^0 -- \b IN. + \param Delta_min Minimal poll size Delta^min (may be undefined) -- \b IN. + \param delta_min Minimal mesh size delta^min (may be undefined) -- \b IN. + \param poll_update_basis Poll update basis (b); default=2 -- \b IN. + \param poll_coarsening_step Poll coarsening step (w+); default=1 -- \b IN. + \param poll_refining_step Poll refining step (w-); default=-1 -- \b IN. \param fixed_variables Fixed variables -- \b IN. \param limit_min_mesh_index Limit mesh index (<0) -- \b IN. - */ - XMesh (bool anisotropic_mesh, + */ + XMesh (bool anisotropic_mesh, const NOMAD::Point & Delta_0 , - const NOMAD::Point & Delta_min , - const NOMAD::Point & delta_min , + const NOMAD::Point & Delta_min , + const NOMAD::Point & delta_min , const NOMAD::Point & fixed_variables, - NOMAD::Double poll_update_basis=2.0, - int poll_coarsening_step=1, - int poll_refining_step=-1 , + NOMAD::Double poll_update_basis=2.0, + int poll_coarsening_step=1, + int poll_refining_step=-1 , int limit_min_mesh_index=NOMAD::XL_LIMITS ) - : NOMAD::OrthogonalMesh ( Delta_0, - Delta_min, - delta_min, + : NOMAD::OrthogonalMesh ( anisotropic_mesh, + Delta_0, + Delta_min, + delta_min, fixed_variables, - poll_update_basis, - poll_coarsening_step, - poll_refining_step , - limit_min_mesh_index ), - _anisotropic_mesh ( anisotropic_mesh ){ init();} - - - - - /// Copy constructor. - /** - \param m The copied object -- \b IN. - */ - XMesh ( const XMesh & m ) - : OrthogonalMesh ( m ) , - _r ( m._r ), - _r_min ( m._r_min ), - _r_max ( m._r_max ), - _anisotropic_mesh ( m._anisotropic_mesh ){} - - /// Destructor. - ~XMesh ( void ) + NOMAD::Point(), + poll_update_basis, + poll_coarsening_step, + poll_refining_step , + limit_min_mesh_index ) { init();} + + + + + /// Copy constructor. + /** + \param m The copied object -- \b IN. + */ + XMesh ( const XMesh & m ) + : OrthogonalMesh ( m ) , + _r ( m._r ), + _r_min ( m._r_min ), + _r_max ( m._r_max ) { init(); } + + /// Destructor. + ~XMesh ( void ) { _delta_0.clear(); _Delta_0.clear(); _delta_min.clear(); _Delta_min.clear(); } - - - /// Access to the mesh size parameter delta^k for earch coordinate. - /** - - It is a NOMAD::Point of size \c nc the number of free variables. - \param delta The mesh size parameter delta^k -- \b OUT. - -- \b optional (default = the current mesh index ell_k.) - \return A boolean equal to \c true if all values are - strictly inferior than the associated minimal - mesh size delta_min (stopping criterion MIN_MESH_SIZE). - */ - bool get_delta ( NOMAD::Point & delta ) const ; - - /// Access to the largest mesh size for earch coordinate. - /** - \return delta_max - */ - NOMAD::Point get_delta_max ( void ) const { return _delta_0;} - - - /// Access to the poll size Delta^k for each coordinate. - /** - - It is a NOMAD::Point of size \c nc the number of free variables. - \param Delta The poll size parameter Delta^k -- \b OUT. - \return A boolean equal to \c true if all values are - strictly inferior than the associated minimal - poll size Delta_min - (stopping criterion MIN_POLL_SIZE). - */ - bool get_Delta ( NOMAD::Point & Delta) const ; - - - /// Update the provided mesh indices (the Mesh is unchanged). - /** - \param success Type of success of the iteration -- \b IN. - \param mesh_indices The mesh indices before and after the update -- \b IN/OUT. - \param dir The direction that is considered (opt) -- \b IN. - */ - void update ( NOMAD::success_type success , NOMAD::Point & mesh_indices, const NOMAD::Direction *dir=NULL ) const ; - - - /// Test if mesh finer than initial. - /** - \return True if mesh size is smaller than initial mesh size for all components; False otherwise. - */ - bool is_finer_than_initial (void) const {return true;} - - - - /// Update the XMesh (poll and mesh sizes). - /** - \param success Type of success of the iteration -- \b IN. - \param dir Direction of the iteration -- \b IN. - */ - void update ( NOMAD::success_type success, const NOMAD::Direction * dir=NULL); - - /// Reset the mesh to its original size (mesh indices). - void reset ( void ) { init() ;} - - - /// Display. - /** - \param out The NOMAD::Display object -- \b IN. - */ - void display ( const NOMAD::Display & out ) const; - - /// Test if r < r_min so far for all coordinates. - /** - \return True if mesh is the finest so far, False otherwise. - */ - bool is_finest ( void ) const; - - - /// Scale and project the ith component of a vector on the mesh - /** - \param i The vector component number -- \b IN. - \param l The vector component value -- \b IN. - \return The ith component of a vector after mesh scaling and projection - */ - NOMAD::Double scale_and_project(int i, const NOMAD::Double & l) const ; - - - /// Check the stopping conditions on the minimal poll and mesh sizes. - /** - \param stop Stop flag -- \b IN/OUT. - \param stop_reason Stop reason -- \b OUT. - */ - void check_min_mesh_sizes ( bool & stop , - NOMAD::stop_type & stop_reason ) const; - - /// Access to the mesh indices per coordinate. - /** - \return A point with the mesh index for each coordinate. - */ - const NOMAD::Point get_mesh_indices ( void ) const { return _r; } - - /// Access to the min mesh indices reached so far. - /** - \return A point with the mesh index for each coordinate. - */ - const NOMAD::Point get_min_mesh_indices ( void ) const { return _r_min; } - - - /// Access to the max mesh indices reached so far. - /** - \return A point with the mesh index for each coordinate. - */ - const NOMAD::Point get_max_mesh_indices ( void ) const { return _r_max; } - - - /// Manually set the mesh index. - /** - \param r The mesh index provided as a point -- \b IN. - */ - void set_mesh_indices ( const NOMAD::Point & r ); - + /// Access to the mesh size parameter delta^k for earch coordinate. + /** + - It is a NOMAD::Point of size \c nc the number of free variables. + \param delta The mesh size parameter delta^k -- \b OUT. + \return A boolean equal to \c true if all values are + strictly inferior than the associated minimal + mesh size delta_min (stopping criterion MIN_MESH_SIZE). + */ + bool get_delta ( NOMAD::Point & delta ) const ; - /// Manually set the limit mesh index (termination criterion). - /** - \param l The limit mesh index for all coordinates -- \b IN. - */ - void set_limit_mesh_index ( int l ); - - - /// Access to the mesh ratios after a success - /** - \return A point with the ratio for each coordinate - */ - NOMAD::Point get_mesh_ratio_if_success ( void ) const; - - - - }; - - /// Display a NOMAD::XMesh object. - /** + /// Access to the largest mesh size for earch coordinate. + /** + \return delta_max + */ + NOMAD::Point get_delta_max ( void ) const { return _delta_0;} + + + /// Access to the poll size Delta^k for each coordinate. + /** + - It is a NOMAD::Point of size \c nc the number of free variables. + \param Delta The poll size parameter Delta^k -- \b OUT. + \return A boolean equal to \c true if all values are + strictly inferior than the associated minimal + poll size Delta_min + (stopping criterion MIN_POLL_SIZE). + */ + bool get_Delta ( NOMAD::Point & Delta) const ; + + + /// Update the provided mesh indices (the Mesh is unchanged). + /** + \param success Type of success of the iteration -- \b IN. + \param mesh_indices The mesh indices before and after the update -- \b IN/OUT. + \param dir The direction that is considered (opt) -- \b IN. + */ + void update ( NOMAD::success_type success , NOMAD::Point & mesh_indices, const NOMAD::Direction *dir=NULL ) const ; + + + /// Update the XMesh (poll and mesh sizes). + /** + \param success Type of success of the iteration -- \b IN. + \param dir Direction of the iteration -- \b IN. + */ + void update ( NOMAD::success_type success, const NOMAD::Direction * dir=NULL); + + /// Reset the mesh to its original size (mesh indices). + void reset ( void ) { init() ;} + + + /// Display. + /** + \param out The NOMAD::Display object -- \b IN. + */ + void display ( const NOMAD::Display & out ) const; + + /// Test if r < r_min so far for all coordinates. + /** + \return True if mesh is the finest so far, False otherwise. + */ + bool is_finest ( void ) const; + + + /// Scale and project the ith component of a vector on the mesh + /** + \param i The vector component number -- \b IN. + \param l The vector component value -- \b IN. + \param round_up A flag to round or not -- \b IN. + \return The ith component of a vector after mesh scaling and projection + */ + NOMAD::Double scale_and_project(int i, const NOMAD::Double & l , bool round_up ) const ; + + + /// Check the stopping conditions on the minimal poll and mesh sizes. + /** + \param stop Stop flag -- \b IN/OUT. + \param stop_reason Stop reason -- \b OUT. + */ + void check_min_mesh_sizes ( bool & stop , + NOMAD::stop_type & stop_reason ) const; + + /// Access to the mesh indices per coordinate. + /** + \return A point with the mesh index for each coordinate. + */ + const NOMAD::Point get_mesh_indices ( void ) const { return _r; } + + /// Access to the min mesh indices reached so far. + /** + \return A point with the mesh index for each coordinate. + */ + const NOMAD::Point get_min_mesh_indices ( void ) const { return _r_min; } + + + /// Access to the max mesh indices reached so far. + /** + \return A point with the mesh index for each coordinate. + */ + const NOMAD::Point get_max_mesh_indices ( void ) const { return _r_max; } + + + /// Manually set the mesh index. + /** + \param r The mesh index provided as a point -- \b IN. + */ + void set_mesh_indices ( const NOMAD::Point & r ); + + + + /// Manually set the limit mesh index (termination criterion). + /** + \param l The limit mesh index for all coordinates -- \b IN. + */ + void set_limit_mesh_index ( int l ); + + + + /// Access to the mesh ratios after a success + /** + \return A point with the ratio for each coordinate + */ + NOMAD::Point get_mesh_ratio_if_success ( void ) const; + + + + }; + + /// Display a NOMAD::XMesh object. + /** \param out The NOMAD::Display object -- \b IN. \param m The NOMAD::XMesh object to be displayed -- \b IN. \return The NOMAD::Display object. - */ - inline const NOMAD::Display & operator << ( const NOMAD::Display & out , - const NOMAD::XMesh & m ) - { - m.display ( out ); - return out; - } - + */ + inline const NOMAD::Display & operator << ( const NOMAD::Display & out , + const NOMAD::XMesh & m ) + { + m.display ( out ); + return out; + } + } #endif diff --git a/src/defines.hpp b/src/defines.hpp index 511f75e36db545a2bc277e5cbbbf0d0f9ae09382..d1078f3714c44f1535b0ad02169c949cd0509148 100644 --- a/src/defines.hpp +++ b/src/defines.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -53,7 +60,7 @@ // #define R_VERSION // defined for the R version only // Matlab version OPTI style (if not defined than GERAD style) -// #define OPTI_VERSION +// #define OPTI_VERSION // Define in order to display debug information //#define DEBUG @@ -61,27 +68,20 @@ // define in order to display memory debug information: //#define MEMORY_DEBUG -// define in order to display TGP information. -// #define TGP_DEBUG - -// #define USE_TGP is defined in the makefile #ifdef DEBUG #ifndef MEMORY_DEBUG #define MEMORY_DEBUG -#ifndef TGP_DEBUG -#define TGP_DEBUG -#endif #endif #endif -// CASE Linux using gnu compiler +// CASE Linux using gnu compiler #ifdef __gnu_linux__ #define GCC_X #endif -// CASE OSX using gnu compiler +// CASE OSX using gnu compiler #ifdef __APPLE__ #ifdef __GNUC__ #define GCC_X @@ -102,10 +102,10 @@ #pragma warning(disable:4996) #endif -// For NOMAD random number generator +// For NOMAD random number generator #if !defined(UINT32_MAX) typedef unsigned int uint32_t; -#define UINT32_MAX 0xffffffff +#define UINT32_MAX 0xffffffff #endif // to display model stats for each evaluation at @@ -125,24 +125,16 @@ typedef unsigned int uint32_t; namespace NOMAD { /// Current version: - const std::string BASE_VERSION = "3.7.2"; + const std::string BASE_VERSION = "3.7.3"; #ifdef R_VERSION const std::string VERSION = BASE_VERSION + ".R"; #else #ifdef USE_MPI -#ifdef USE_TGP - const std::string VERSION = BASE_VERSION + ".TGP" + ".MPI"; -#else const std::string VERSION = BASE_VERSION + ".MPI"; -#endif -#else -#ifdef USE_TGP - const std::string VERSION = BASE_VERSION + ".TGP"; #else const std::string VERSION = BASE_VERSION; #endif -#endif #endif // Directory separator, plus LGPL and user guide files @@ -197,12 +189,11 @@ namespace NOMAD { // Old static Mesh index constants const int L_LIMITS = 50; ///< Limits for the smesh index values const int UNDEFINED_L = L_LIMITS+1; ///< Undefined value for the smesh index - + // xmesh index constants const int XL_LIMITS = -50; ///< Limits for the xmesh index values const int UNDEFINED_XL = XL_LIMITS-1; ///< Undefined value for the xmesh index - /// Default epsilon used by NOMAD::Double /** Use Parameters::set_EPSILON(), or parameter EPSILON, or NOMAD::Double::set_epsilon() to change it @@ -228,6 +219,9 @@ namespace NOMAD { const double LOG10 = 2.30258509299; const double INF = std::numeric_limits<double>::max(); ///< Infinity + const double P_INF_INT = std::numeric_limits<int>::max(); ///< plus infinity for int + const double M_INF_INT = std::numeric_limits<int>::min(); ///< minus infinity for int + const double D_INT_MAX = UINT32_MAX; ///< The UINT32_MAX constant as a \c double @@ -235,7 +229,7 @@ namespace NOMAD { const double SVD_EPS = 1e-13; ///< Epsilon for SVD const int SVD_MAX_MPN = 1500; ///< Matrix maximal size (\c m+n ) const double SVD_MAX_COND = NOMAD::INF; ///< Max. acceptable cond. number - + /// Default value for parameter POINT_DISPLAY_LIMIT /** Use Parameters::set_POINT_DISPLAY_LIMIT() or parameter POINT_DISPLAY_LIMIT or Point::set_display_limit() to change it */ @@ -246,7 +240,7 @@ namespace NOMAD { const int DISPLAY_PRECISION_BB = 15; ///< Display precision for blackboxes /// Constant for blackbox files #1. - const std::string BLACKBOX_INPUT_FILE_PREFIX = "nomad"; + const std::string BLACKBOX_INPUT_FILE_PREFIX = "nomad"; /// Constant for blackbox files #2. const std::string BLACKBOX_INPUT_FILE_EXT = "input"; @@ -261,7 +255,7 @@ namespace NOMAD { enum dd_type { NO_DISPLAY , ///< No display - MINIMAL_DISPLAY, ///< Minimal dispay + MINIMAL_DISPLAY, ///< Minimal dispay NORMAL_DISPLAY , ///< Normal display FULL_DISPLAY ///< Full display }; @@ -342,16 +336,15 @@ namespace NOMAD { enum model_type { QUADRATIC_MODEL , ///< Quadratic model - TGP_MODEL , ///< TGP model NO_MODEL ///< No models }; - /// TGP mode - enum TGP_mode_type + enum intensification_type { - TGP_FAST , ///< TGP fast mode. - TGP_PRECISE , ///< TGP precise mode. - TGP_USER ///< TGP user mode. + NO_INTENSIFICATION , + POLL_ONLY , ///< Poll intensification only + SEARCH_ONLY , ///< Search intensification only + POLL_AND_SEARCH }; /// Success type of an iteration @@ -389,6 +382,7 @@ namespace NOMAD { L_MIN_REACHED , ///< Min mesh index L_LIMITS_REACHED , ///< Mesh index limits XL_LIMITS_REACHED , ///< Mesh index limits + GL_LIMITS_REACHED , ///< Mesh index limits MAX_TIME_REACHED , ///< Max time MAX_BB_EVAL_REACHED , ///< Max number of blackbox evaluations MAX_SGTE_EVAL_REACHED , ///< Max number of surrogate evaluations @@ -424,8 +418,9 @@ namespace NOMAD { NO_DIRECTION , ///< No direction ORTHO_1 , ///< OrthoMADS 1 ORTHO_2 , ///< OrthoMADS 2 - ORTHO_NP1_QUAD , ///< OrthoMADS n+1 use Quad model to determine n+1-th direction + ORTHO_NP1_QUAD , ///< OrthoMADS n+1 use Quad model to determine n+1-th direction ORTHO_NP1_NEG , ///< OrthoMADS n+1 use negative sum of n first directions to determine n+1-th direction + ORTHO_NP1_UNI , ///< OrthoMADS n+1 uniform directions DYN_ADDED , ///< Dynamic addition (n+1-th direction added for ORTHO n+1) ORTHO_2N , ///< OrthoMADS 2n LT_1 , ///< LT-MADS 1 @@ -471,7 +466,7 @@ namespace NOMAD { // (keep in first position) DS_SIM_BBE , ///< Number of simulated bb evaluations DS_BBE , ///< Number of bb evaluations - DS_BLK_EVA , ///< Number of block evaluation calls + DS_BLK_EVA , ///< Number of block evaluation calls DS_SGTE , ///< Number of surrogate evaluations DS_BBO , ///< All blackbox outputs DS_EVAL , ///< Number of evaluations @@ -506,6 +501,13 @@ namespace NOMAD { UNDEFINED_STATUS ///< Undefined evaluation status }; + enum mesh_type + { + XMESH , /// Anisotropic (eXtensible) mesh + SMESH , /// Isotropic Standard mesh + NO_MESH_TYPE + }; + } #endif diff --git a/src/nomad.cpp b/src/nomad.cpp index 250c2a3d743175f4ceb0ee2409ebe888d49927db..e97307cadeb2ac5fce82b40fa59ec7df7132fdf3 100644 --- a/src/nomad.cpp +++ b/src/nomad.cpp @@ -1,16 +1,21 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ /* */ -/* Author: Sebastien Le Digabel */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -140,6 +145,7 @@ int main ( int argc , char ** argv ) if ( p.get_display_degree() > NOMAD::MINIMAL_DISPLAY) NOMAD::display_info ( out ); + // parameters display: if ( NOMAD::Slave::is_master() && p.get_display_degree() == NOMAD::FULL_DISPLAY ) @@ -285,18 +291,24 @@ void NOMAD::display_info ( const NOMAD::Display & out ) if ( !NOMAD::Slave::is_master() ) return; #endif - NOMAD::display_version ( out ); - out << NOMAD::open_block ( "Copyright (C) 2001-2015" ) - << "Mark A. Abramson - The Boeing Company" << std::endl + out << std::endl << "NOMAD - version " + << NOMAD::VERSION + << NOMAD::open_block(" has been created by") << "Charles Audet - Ecole Polytechnique de Montreal" << std::endl - << "Gilles Couture - Ecole Polytechnique de Montreal" << std::endl - << "John E. Dennis, Jr. - Rice University" << std::endl << "Sebastien Le Digabel - Ecole Polytechnique de Montreal" << std::endl << "Christophe Tribes - Ecole Polytechnique de Montreal" << std::endl << NOMAD::close_block() << std::endl - << "Funded in part by AFOSR and Exxon Mobil." << std::endl + << "The copyright of NOMAD - version " + << NOMAD::VERSION + << NOMAD::open_block(" is owned by") + << "Sebastien Le Digabel - Ecole Polytechnique de Montreal" << std::endl + << "Christophe Tribes - Ecole Polytechnique de Montreal" << std::endl + << NOMAD::close_block() + << std::endl << "NOMAD version 3 is a new version of Nomad v1 and v2, it has been funded by AFOSR and Exxon Mobil." << std::endl + << "Nomad v1 and v2 were created and developed by Mark A. Abramson from The Boeing Company, Charles Audet and Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from Rice University, and were funded by AFOSR and Exxon Mobil." << std::endl << std::endl + << "Download : www.gerad.ca/nomad" << std::endl << "License : \'" << NOMAD::LGPL_FILE << "\'" << std::endl << "User guide: \'" << NOMAD::USER_GUIDE_FILE << "\'" << std::endl << "Examples : \'" << NOMAD::EXAMPLES_DIR << "\'" << std::endl @@ -304,8 +316,16 @@ void NOMAD::display_info ( const NOMAD::Display & out ) << std::endl << "Please report bugs to nomad@gerad.ca" << std::endl; + out << endl << "Seed: "<< NOMAD::RNG::get_seed()<<endl; } + + + + + + + /*------------------------------------------*/ /* display NOMAD usage */ /*------------------------------------------*/ @@ -321,7 +341,7 @@ void NOMAD::display_usage ( char* exeName, const NOMAD::Display & out ) << "Developer help : " << exeName << " -d keyword(s) (or 'all')" << std::endl << "Version : " << exeName << " -v" << std::endl << "Usage : " << exeName << " -u" << std::endl - << std::endl; + << std::endl; #else out << std::endl << "Run NOMAD : " << exeName << " parameters_file" << std::endl @@ -330,6 +350,6 @@ void NOMAD::display_usage ( char* exeName, const NOMAD::Display & out ) << "Developer help : " << exeName << " -d keyword(s) (or 'all')" << std::endl << "Version : " << exeName << " -v" << std::endl << "Usage : " << exeName << " -u" << std::endl - << std::endl; + << std::endl; #endif } diff --git a/src/nomad.hpp b/src/nomad.hpp index 580117703c945c1e9fe73ec345473d384a48b9b6..6b6f9687b808d169e9e544d13c4b14600f818f1b 100644 --- a/src/nomad.hpp +++ b/src/nomad.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -65,7 +72,7 @@ namespace NOMAD { \param out A NOMAD::Display object -- \b IN. */ void display_usage ( char* exeName, const NOMAD::Display & out ); - void display_usage ( const NOMAD::Display & out ); + void display_usage ( const NOMAD::Display & out ); #ifdef MEMORY_DEBUG /// Display NOMAD most important structures in memory. diff --git a/src/utils.cpp b/src/utils.cpp index 199400fa5e4f6a8341424377e4be09911385017c..1392dfed022f212cf9ec7d73e09bf53943c10a45 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file utils.cpp - \brief Utility functions - \author Sebastien Le Digabel - \date 2010-03-23 - \see utils.hpp -*/ + \file utils.cpp + \brief Utility functions + \author Sebastien Le Digabel + \date 2010-03-23 + \see utils.hpp + */ #include "utils.hpp" /*---------------------------------------------------------------*/ @@ -47,24 +54,27 @@ /*---------------------------------------------------------------*/ void NOMAD::construct_primes ( int n , int * primes ) { - bool is_prime; - double kk; - int i = 0 , k = 2 , j; - while ( true ) { - is_prime = true; - kk = sqrt ( static_cast<double>(k) ); - for ( j = 2 ; j <= kk ; ++j ) - if ( k%j==0 ) { - is_prime = false; - break; - } - if ( is_prime ) { - primes[i++] = k; - if ( i==n ) - break; + bool is_prime; + double kk; + int i = 0 , k = 2 , j; + while ( true ) + { + is_prime = true; + kk = sqrt ( static_cast<double>(k) ); + for ( j = 2 ; j <= kk ; ++j ) + if ( k%j==0 ) + { + is_prime = false; + break; + } + if ( is_prime ) + { + primes[i++] = k; + if ( i==n ) + break; + } + ++k; } - ++k; - } } /*--------------------------------------------*/ @@ -72,14 +82,15 @@ void NOMAD::construct_primes ( int n , int * primes ) /*--------------------------------------------*/ void NOMAD::get_words ( const std::string & sentence , std::list<std::string> & words ) { - std::string s; - std::istringstream in ( sentence ); - while ( true ) { - in >> s; - if ( in.fail() ) - break; - words.push_back ( s ); - } + std::string s; + std::istringstream in ( sentence ); + while ( true ) + { + in >> s; + if ( in.fail() ) + break; + words.push_back ( s ); + } } /*---------------------------------------------------------------*/ @@ -88,9 +99,9 @@ void NOMAD::get_words ( const std::string & sentence , std::list<std::string> & int NOMAD::get_pid ( void ) { #ifdef _MSC_VER - return _getpid(); + return _getpid(); #else - return getpid(); + return getpid(); #endif } @@ -100,7 +111,7 @@ int NOMAD::get_pid ( void ) void NOMAD::begin ( int argc , char ** argv ) { #ifdef USE_MPI - MPI_Init ( &argc , &argv ); + MPI_Init ( &argc , &argv ); #endif } @@ -110,7 +121,7 @@ void NOMAD::begin ( int argc , char ** argv ) void NOMAD::end ( void ) { #ifdef USE_MPI - MPI_Finalize(); + MPI_Finalize(); #endif } @@ -120,10 +131,10 @@ void NOMAD::end ( void ) bool NOMAD::check_exe_file ( const std::string & file_name ) { #ifdef WINDOWS - // don't check on Windows: - return true; + // don't check on Windows: + return true; #else - return ( access ( file_name.c_str() , X_OK ) == 0 ); + return ( access ( file_name.c_str() , X_OK ) == 0 ); #endif } @@ -133,9 +144,9 @@ bool NOMAD::check_exe_file ( const std::string & file_name ) bool NOMAD::check_read_file ( const std::string & file_name ) { #ifdef _MSC_VER - return ( _access ( file_name.c_str() , 4 ) == 0 ); + return ( _access ( file_name.c_str() , 4 ) == 0 ); #else - return ( access ( file_name.c_str() , R_OK ) == 0 ); + return ( access ( file_name.c_str() , R_OK ) == 0 ); #endif } @@ -144,9 +155,9 @@ bool NOMAD::check_read_file ( const std::string & file_name ) /*-----------------------------------------------------------------*/ std::string NOMAD::itos ( int i ) { - std::ostringstream oss; - oss << i; - return oss.str(); + std::ostringstream oss; + oss << i; + return oss.str(); } /*-----------------------------------------------------------------*/ @@ -160,14 +171,48 @@ std::string NOMAD::itos ( size_t i ) } +/*-----------------------------------------------------------------*/ +/* NOMAD::deblank */ +/*-----------------------------------------------------------------*/ +void NOMAD::deblank ( std::string & s ) +{ + // Remove leading spaces + while ( (s.length()) && (s.at(0)==' ') ) + { + s.erase(0,1); + } + // Remove trailing spaces + size_t i = s.length(); + while ( (i>0) && (s.at(i-1)==' ') ) + { + s.erase(i-1,1); + i--; + } + // Remove double spaces + i=1; + while (i+2<s.length()) + { + if ( (s.at(i)==' ') && (s.at(i+1)==' ') ) + { + s.erase(i,1); + } + else + { + i++; + } + } +} + + + /*-----------------------------------------------------------------*/ /* NOMAD::toupper - 1/2 */ /*-----------------------------------------------------------------*/ void NOMAD::toupper ( std::string & s ) { - size_t ns = s.size(); - for ( size_t i = 0 ; i < ns ; ++i ) - s[i] = std::toupper(s[i]); + size_t ns = s.size(); + for ( size_t i = 0 ; i < ns ; ++i ) + s[i] = std::toupper(s[i]); } /*-----------------------------------------------------------------*/ @@ -175,10 +220,10 @@ void NOMAD::toupper ( std::string & s ) /*-----------------------------------------------------------------*/ void NOMAD::toupper ( std::list<std::string> & ls ) { - std::list<std::string>::iterator it; - std::list<std::string>::const_iterator end = ls.end(); - for ( it = ls.begin() ; it != end ; ++it ) - NOMAD::toupper ( *it ); + std::list<std::string>::iterator it; + std::list<std::string>::const_iterator end = ls.end(); + for ( it = ls.begin() ; it != end ; ++it ) + NOMAD::toupper ( *it ); } /*-----------------------------------------------------------------*/ @@ -186,35 +231,38 @@ void NOMAD::toupper ( std::list<std::string> & ls ) /*-----------------------------------------------------------------*/ bool NOMAD::atoi ( const std::string & s , int & i ) { - i = -1; - if ( s.empty() ) - return false; - - size_t n = s.size(); - - if ( s[0] == '-' ) { - if ( n > 1 && s[1] == '-' ) - return false; - std::string ss = s; - ss.erase(ss.begin()); - if ( NOMAD::atoi ( ss , i ) ) { - i = -i; - return true; + i = -1; + if ( s.empty() ) + return false; + + size_t n = s.size(); + + if ( s[0] == '-' ) + { + if ( n > 1 && s[1] == '-' ) + return false; + std::string ss = s; + ss.erase(ss.begin()); + if ( NOMAD::atoi ( ss , i ) ) + { + i = -i; + return true; + } + return false; } - return false; - } - - for ( size_t k = 0 ; k < n ; ++k ) - if ( !isdigit(s[k]) ) - return false; - i = std::atoi(s.c_str()); - return true; + + for ( size_t k = 0 ; k < n ; ++k ) + if ( !isdigit(s[k]) ) + return false; + i = std::atoi(s.c_str()); + return true; } -bool NOMAD::atoi ( char c , int & i ) { - std::string s = "-"; - s[0] = c; - return NOMAD::atoi(s,i); +bool NOMAD::atoi ( char c , int & i ) +{ + std::string s = "-"; + s[0] = c; + return NOMAD::atoi(s,i); } /*-------------------------------------------------------------------*/ @@ -222,11 +270,11 @@ bool NOMAD::atoi ( char c , int & i ) { /*-------------------------------------------------------------------*/ bool NOMAD::bbot_is_constraint ( NOMAD::bb_output_type bbot ) { - return ( bbot == NOMAD::EB || - bbot == NOMAD::PB || - bbot == NOMAD::PEB_P || - bbot == NOMAD::PEB_E || - bbot == NOMAD::FILTER ); + return ( bbot == NOMAD::EB || + bbot == NOMAD::PB || + bbot == NOMAD::PEB_P || + bbot == NOMAD::PEB_E || + bbot == NOMAD::FILTER ); } /*-----------------------------------------------------------------------*/ @@ -234,16 +282,16 @@ bool NOMAD::bbot_is_constraint ( NOMAD::bb_output_type bbot ) /*-----------------------------------------------------------------------*/ bool NOMAD::dir_is_mads ( NOMAD::direction_type dt ) { - return (dt == NOMAD::ORTHO_1 || - dt == NOMAD::ORTHO_2 || - dt == NOMAD::ORTHO_NP1_QUAD || - dt == NOMAD::ORTHO_NP1_NEG || - dt == NOMAD::DYN_ADDED || - dt == NOMAD::ORTHO_2N || - dt == NOMAD::LT_1 || - dt == NOMAD::LT_2 || - dt == NOMAD::LT_2N || - dt == NOMAD::LT_NP1 ); + return (dt == NOMAD::ORTHO_1 || + dt == NOMAD::ORTHO_2 || + dt == NOMAD::ORTHO_NP1_QUAD || + dt == NOMAD::ORTHO_NP1_NEG || + dt == NOMAD::DYN_ADDED || + dt == NOMAD::ORTHO_2N || + dt == NOMAD::LT_1 || + dt == NOMAD::LT_2 || + dt == NOMAD::LT_2N || + dt == NOMAD::LT_NP1 ); } /*----------------------------------------------------------------------*/ @@ -251,13 +299,13 @@ bool NOMAD::dir_is_mads ( NOMAD::direction_type dt ) /*----------------------------------------------------------------------*/ bool NOMAD::dir_is_gps ( NOMAD::direction_type dt ) { - return ( dt == NOMAD::GPS_BINARY || - dt == NOMAD::GPS_2N_STATIC || - dt == NOMAD::GPS_2N_RAND || - dt == NOMAD::GPS_NP1_STATIC_UNIFORM || - dt == NOMAD::GPS_NP1_STATIC || - dt == NOMAD::GPS_NP1_RAND_UNIFORM || - dt == NOMAD::GPS_NP1_RAND ); + return ( dt == NOMAD::GPS_BINARY || + dt == NOMAD::GPS_2N_STATIC || + dt == NOMAD::GPS_2N_RAND || + dt == NOMAD::GPS_NP1_STATIC_UNIFORM || + dt == NOMAD::GPS_NP1_STATIC || + dt == NOMAD::GPS_NP1_RAND_UNIFORM || + dt == NOMAD::GPS_NP1_RAND ); } /*--------------------------------------------------------------------------*/ @@ -265,10 +313,10 @@ bool NOMAD::dir_is_gps ( NOMAD::direction_type dt ) /*--------------------------------------------------------------------------*/ bool NOMAD::dir_is_ltmads ( NOMAD::direction_type dt ) { - return ( dt == NOMAD::LT_1 || - dt == NOMAD::LT_2 || - dt == NOMAD::LT_2N || - dt == NOMAD::LT_NP1 ); + return ( dt == NOMAD::LT_1 || + dt == NOMAD::LT_2 || + dt == NOMAD::LT_2N || + dt == NOMAD::LT_NP1 ); } /*-------------------------------------------------------------------------*/ @@ -276,13 +324,13 @@ bool NOMAD::dir_is_ltmads ( NOMAD::direction_type dt ) /*-------------------------------------------------------------------------*/ bool NOMAD::dir_is_random ( NOMAD::direction_type dt ) { - return ( dt == NOMAD::GPS_NP1_RAND || - dt == NOMAD::GPS_NP1_RAND_UNIFORM || - dt == NOMAD::GPS_2N_RAND || - dt == NOMAD::LT_1 || - dt == NOMAD::LT_2 || - dt == NOMAD::LT_2N || - dt == NOMAD::LT_NP1 ); + return ( dt == NOMAD::GPS_NP1_RAND || + dt == NOMAD::GPS_NP1_RAND_UNIFORM || + dt == NOMAD::GPS_2N_RAND || + dt == NOMAD::LT_1 || + dt == NOMAD::LT_2 || + dt == NOMAD::LT_2N || + dt == NOMAD::LT_NP1 ); } /*-----------------------------------------------------------------------------*/ @@ -290,11 +338,12 @@ bool NOMAD::dir_is_random ( NOMAD::direction_type dt ) /*-----------------------------------------------------------------------------*/ bool NOMAD::dir_is_orthomads ( NOMAD::direction_type dt ) { - return (dt == NOMAD::ORTHO_1 || - dt == NOMAD::ORTHO_2 || - dt == NOMAD::ORTHO_NP1_QUAD || - dt == NOMAD::ORTHO_NP1_NEG || - dt == NOMAD::ORTHO_2N ); + return (dt == NOMAD::ORTHO_1 || + dt == NOMAD::ORTHO_2 || + dt == NOMAD::ORTHO_NP1_QUAD || + dt == NOMAD::ORTHO_NP1_NEG || + dt == NOMAD::ORTHO_NP1_UNI || + dt == NOMAD::ORTHO_2N ); } /*---------------------------------------------------------------------*/ @@ -303,11 +352,11 @@ bool NOMAD::dir_is_orthomads ( NOMAD::direction_type dt ) /*---------------------------------------------------------------------*/ bool NOMAD::dirs_have_orthomads ( const std::set<NOMAD::direction_type> & dir_types ) { - std::set<NOMAD::direction_type>::const_iterator it , end = dir_types.end(); - for ( it = dir_types.begin() ; it != end ; ++it ) - if ( NOMAD::dir_is_orthomads (*it) ) - return true; - return false; + std::set<NOMAD::direction_type>::const_iterator it , end = dir_types.end(); + for ( it = dir_types.begin() ; it != end ; ++it ) + if ( NOMAD::dir_is_orthomads (*it) ) + return true; + return false; } /*---------------------------------------------------------------------*/ @@ -316,11 +365,11 @@ bool NOMAD::dirs_have_orthomads ( const std::set<NOMAD::direction_type> & dir_ty /*---------------------------------------------------------------------*/ bool NOMAD::dirs_have_orthomads_np1( const std::set<NOMAD::direction_type> & dir_types ) { - std::set<NOMAD::direction_type>::const_iterator it , end = dir_types.end(); - for ( it = dir_types.begin() ; it != end ; ++it ) - if ( (*it)==NOMAD::ORTHO_NP1_QUAD || (*it)==NOMAD::ORTHO_NP1_NEG) - return true; - return false; + std::set<NOMAD::direction_type>::const_iterator it , end = dir_types.end(); + for ( it = dir_types.begin() ; it != end ; ++it ) + if ( (*it)==NOMAD::ORTHO_NP1_QUAD || (*it)==NOMAD::ORTHO_NP1_NEG || (*it)==NOMAD::ORTHO_NP1_UNI ) + return true; + return false; } /*---------------------------------------------------*/ @@ -328,11 +377,11 @@ bool NOMAD::dirs_have_orthomads_np1( const std::set<NOMAD::direction_type> & dir /*---------------------------------------------------*/ bool NOMAD::string_find ( const std::string & s , const std::list<std::string> & ls ) { - std::list<std::string>::const_iterator it , end = ls.end(); - for ( it = ls.begin() ; it != end ; ++it ) - if ( NOMAD::string_find ( s , *it ) ) - return true; - return false; + std::list<std::string>::const_iterator it , end = ls.end(); + for ( it = ls.begin() ; it != end ; ++it ) + if ( NOMAD::string_find ( s , *it ) ) + return true; + return false; } /*---------------------------------------------------*/ @@ -340,7 +389,7 @@ bool NOMAD::string_find ( const std::string & s , const std::list<std::string> & /*---------------------------------------------------*/ bool NOMAD::string_find ( const std::string & s1 , const std::string & s2 ) { - return ( s1.find(s2) < s1.size() ); + return ( s1.find(s2) < s1.size() ); } /*--------------------------------------------------------------------------*/ @@ -348,11 +397,11 @@ bool NOMAD::string_find ( const std::string & s1 , const std::string & s2 ) /*--------------------------------------------------------------------------*/ bool NOMAD::string_match ( const std::string & s , const std::list<std::string> & ls ) { - std::list<std::string>::const_iterator it , end = ls.end(); - for ( it = ls.begin() ; it != end ; ++it ) - if ( s.compare(*it) == 0 ) - return true; - return false; + std::list<std::string>::const_iterator it , end = ls.end(); + for ( it = ls.begin() ; it != end ; ++it ) + if ( s.compare(*it) == 0 ) + return true; + return false; } @@ -360,186 +409,213 @@ bool NOMAD::string_match ( const std::string & s , const std::list<std::string> /* interpret a list of strings as a direction type */ /*-----------------------------------------------------------------*/ bool NOMAD::strings_to_direction_type ( const std::list<std::string> & ls , - NOMAD::direction_type & dt ) + NOMAD::direction_type & dt ) { - - dt = NOMAD::UNDEFINED_DIRECTION; - - if ( ls.empty() || ls.size() > 4 ) - return false; - - std::list<std::string>::const_iterator it = ls.begin() , end = ls.end(); - std::string s = *it; - NOMAD::toupper ( s ); - - // no direction: - if ( s == "NONE" ) { - dt = NOMAD::NO_DIRECTION; - return true; - } - - // Ortho-MADS with 1, 2, n+1 (plus QUAD or NEG), or 2n directions: - if ( s == "ORTHO" ) - { - ++it; - if ( it == end ) - { - dt = NOMAD::ORTHO_NP1_QUAD; // Default for ORTHO - return true; - } - if ( *it == "1" ) - { - dt = NOMAD::ORTHO_1; - return true; - } - if ( *it == "2" ) - { - dt = NOMAD::ORTHO_2; - return true; - } - s = *it; - NOMAD::toupper ( s ); - if ( s == "2N" ) - { - dt = NOMAD::ORTHO_2N; - return true; - } - if ( s == "N+1" ) - { - ++it; - if (it==end) - { - dt = NOMAD::ORTHO_NP1_QUAD; // Default for ORTHO N+1 - return true; - } - s = *it; - NOMAD::toupper ( s ); - if ( s=="QUAD" ) - { - dt= NOMAD::ORTHO_NP1_QUAD; - return true; - } - if ( s=="NEG" ) - { - dt=NOMAD::ORTHO_NP1_NEG; - return true; - } - - } - - return false; - } - - // LT-MADS with 1, 2 or 2n directions: - if ( s == "LT" ) { - ++it; - if ( it == end ) { - dt = NOMAD::LT_2N; - return true; - } - if ( *it == "1" ) { - dt = NOMAD::LT_1; - return true; - } - if ( *it == "2" ) { - dt = NOMAD::LT_2; - return true; - } - s = *it; - NOMAD::toupper ( s ); - if ( s == "N+1" ) { - dt = NOMAD::LT_NP1; - return true; - } - if ( s == "2N" ) { - dt = NOMAD::LT_2N; - return true; - } - return false; - } - - // GPS: - if ( s == "GPS" ) { - ++it; - if ( it == end ) { - dt = NOMAD::GPS_2N_STATIC; - return true; - } - s = *it; - NOMAD::toupper ( s ); - - // GPS for binary variables: - if ( s == "BINARY" || s == "BIN" ) { - dt = NOMAD::GPS_BINARY; - return true; - } - - // GPS, n+1 directions: - if ( s == "N+1" ) { - ++it; - if ( it == end ) { - dt = NOMAD::GPS_NP1_STATIC; - return true; - } - s = *it; - NOMAD::toupper ( s ); - - // GPS, n+1, static: - if ( s == "STATIC" ) { - ++it; - if ( it == end ) { - dt = NOMAD::GPS_NP1_STATIC; - return true; - } - s = *it; - NOMAD::toupper ( s ); - if ( s == "UNIFORM" ) { - dt = NOMAD::GPS_NP1_STATIC_UNIFORM; - return true; - } - return false; - } - - // GPS, n+1, random: - if ( s == "RAND" || s == "RANDOM" ) { - ++it; - if ( it == end ) { - dt = NOMAD::GPS_NP1_RAND; - return true; - } - s = *it; - NOMAD::toupper ( s ); - if ( s == "UNIFORM" ) { - dt = NOMAD::GPS_NP1_RAND_UNIFORM; - return true; - } - return false; - } - return false; - } - - // 2n directions: - if ( s == "2N" ) { - ++it; - if ( it == end ) { - dt = NOMAD::GPS_2N_STATIC; - return true; - } - s = *it; - NOMAD::toupper ( s ); - if ( s == "STATIC" ) { - dt = NOMAD::GPS_2N_STATIC; - return true; - } - if ( s == "RAND" || s == "RANDOM" ) { - dt = NOMAD::GPS_2N_RAND; - return true; - } - return false; - } - return false; - } - return false; + + dt = NOMAD::UNDEFINED_DIRECTION; + + if ( ls.empty() || ls.size() > 4 ) + return false; + + std::list<std::string>::const_iterator it = ls.begin() , end = ls.end(); + std::string s = *it; + NOMAD::toupper ( s ); + + // no direction: + if ( s == "NONE" ) + { + dt = NOMAD::NO_DIRECTION; + return true; + } + + // Ortho-MADS with 1, 2, n+1 (plus QUAD or NEG), or 2n directions: + if ( s == "ORTHO" ) + { + ++it; + if ( it == end ) + { + dt = NOMAD::ORTHO_NP1_QUAD; // Default for ORTHO + return true; + } + if ( *it == "1" ) + { + dt = NOMAD::ORTHO_1; + return true; + } + if ( *it == "2" ) + { + dt = NOMAD::ORTHO_2; + return true; + } + s = *it; + NOMAD::toupper ( s ); + if ( s == "2N" ) + { + dt = NOMAD::ORTHO_2N; + return true; + } + if ( s == "N+1" ) + { + ++it; + if (it==end) + { + dt = NOMAD::ORTHO_NP1_QUAD; // Default for ORTHO N+1 + return true; + } + s = *it; + NOMAD::toupper ( s ); + if ( s=="QUAD" ) + { + dt= NOMAD::ORTHO_NP1_QUAD; + return true; + } + if ( s=="NEG" ) + { + dt=NOMAD::ORTHO_NP1_NEG; + return true; + } + if ( s=="UNI" ) + { + dt=NOMAD::ORTHO_NP1_UNI; + return true; + } + + } + + return false; + } + + // LT-MADS with 1, 2 or 2n directions: + if ( s == "LT" ) + { + ++it; + if ( it == end ) + { + dt = NOMAD::LT_2N; + return true; + } + if ( *it == "1" ) + { + dt = NOMAD::LT_1; + return true; + } + if ( *it == "2" ) + { + dt = NOMAD::LT_2; + return true; + } + s = *it; + NOMAD::toupper ( s ); + if ( s == "N+1" ) + { + dt = NOMAD::LT_NP1; + return true; + } + if ( s == "2N" ) + { + dt = NOMAD::LT_2N; + return true; + } + return false; + } + + // GPS: + if ( s == "GPS" ) + { + ++it; + if ( it == end ) + { + dt = NOMAD::GPS_2N_STATIC; + return true; + } + s = *it; + NOMAD::toupper ( s ); + + // GPS for binary variables: + if ( s == "BINARY" || s == "BIN" ) + { + dt = NOMAD::GPS_BINARY; + return true; + } + + // GPS, n+1 directions: + if ( s == "N+1" ) + { + ++it; + if ( it == end ) + { + dt = NOMAD::GPS_NP1_STATIC; + return true; + } + s = *it; + NOMAD::toupper ( s ); + + // GPS, n+1, static: + if ( s == "STATIC" ) + { + ++it; + if ( it == end ) + { + dt = NOMAD::GPS_NP1_STATIC; + return true; + } + s = *it; + NOMAD::toupper ( s ); + if ( s == "UNIFORM" ) + { + dt = NOMAD::GPS_NP1_STATIC_UNIFORM; + return true; + } + return false; + } + + // GPS, n+1, random: + if ( s == "RAND" || s == "RANDOM" ) + { + ++it; + if ( it == end ) + { + dt = NOMAD::GPS_NP1_RAND; + return true; + } + s = *it; + NOMAD::toupper ( s ); + if ( s == "UNIFORM" ) + { + dt = NOMAD::GPS_NP1_RAND_UNIFORM; + return true; + } + return false; + } + return false; + } + + // 2n directions: + if ( s == "2N" ) + { + ++it; + if ( it == end ) + { + dt = NOMAD::GPS_2N_STATIC; + return true; + } + s = *it; + NOMAD::toupper ( s ); + if ( s == "STATIC" ) + { + dt = NOMAD::GPS_2N_STATIC; + return true; + } + if ( s == "RAND" || s == "RANDOM" ) + { + dt = NOMAD::GPS_2N_RAND; + return true; + } + return false; + } + return false; + } + return false; } /*---------------------------------------*/ @@ -547,172 +623,195 @@ bool NOMAD::strings_to_direction_type ( const std::list<std::string> & ls , /*---------------------------------------*/ bool NOMAD::string_to_hnorm_type ( const std::string & s , NOMAD::hnorm_type & hn ) { - std::string ss = s; - NOMAD::toupper(ss); - if ( ss == "L1" ) { - hn = NOMAD::L1; - return true; - } - if ( ss == "L2" ) { - hn = NOMAD::L2; - return true; - } - if ( ss == "LINF" ) { - hn = NOMAD::LINF; - return true; - } - return false; -} - -/*-----------------------------------------*/ -/* convert a string into a TGP_mode_type */ -/*-----------------------------------------*/ -bool NOMAD::string_to_TGP_mode_type ( const std::string & s , NOMAD::TGP_mode_type & m ) -{ - std::string ss = s; - NOMAD::toupper(ss); - if ( ss == "FAST" ) { - m = NOMAD::TGP_FAST; - return true; - } - if ( ss == "PRECISE" ) { - m = NOMAD::TGP_PRECISE; - return true; - } - if ( ss == "USER" ) { - m = NOMAD::TGP_USER; - return true; - } - return false; + std::string ss = s; + NOMAD::toupper(ss); + if ( ss == "L1" ) + { + hn = NOMAD::L1; + return true; + } + if ( ss == "L2" ) + { + hn = NOMAD::L2; + return true; + } + if ( ss == "LINF" ) + { + hn = NOMAD::LINF; + return true; + } + return false; } /*--------------------------------------------------*/ /* convert a string into a multi_formulation_type */ /*--------------------------------------------------*/ bool NOMAD::string_to_multi_formulation_type ( const std::string & s , - NOMAD::multi_formulation_type & mft ) + NOMAD::multi_formulation_type & mft ) { - std::string ss = s; - NOMAD::toupper(ss); - if ( ss == "NORMALIZED" ) { - mft = NOMAD::NORMALIZED; - return true; - } - if ( ss == "PRODUCT" ) { - mft = NOMAD::PRODUCT; - return true; - } - if ( ss == "DIST_L1" ) { - mft = NOMAD::DIST_L1; - return true; - } - if ( ss == "DIST_L2" ) { - mft = NOMAD::DIST_L2; - return true; - } - if ( ss == "DIST_LINF" ) { - mft = NOMAD::DIST_LINF; - return true; - } - return false; + std::string ss = s; + NOMAD::toupper(ss); + if ( ss == "NORMALIZED" ) + { + mft = NOMAD::NORMALIZED; + return true; + } + if ( ss == "PRODUCT" ) + { + mft = NOMAD::PRODUCT; + return true; + } + if ( ss == "DIST_L1" ) + { + mft = NOMAD::DIST_L1; + return true; + } + if ( ss == "DIST_L2" ) + { + mft = NOMAD::DIST_L2; + return true; + } + if ( ss == "DIST_LINF" ) + { + mft = NOMAD::DIST_LINF; + return true; + } + return false; } /*-------------------------------------------*/ /* convert a string into a bb_output_type */ /*-------------------------------------------*/ bool NOMAD::string_to_bb_output_type ( const std::string & s , - NOMAD::bb_output_type & bbot ) + NOMAD::bb_output_type & bbot ) { - std::string ss = s; - NOMAD::toupper(ss); - - if ( ss == "OBJ" ) { - bbot = NOMAD::OBJ; - return true; - } - if ( ss == "EB" ) { - bbot = NOMAD::EB; - return true; - } - if ( ss == "PB" || ss == "CSTR" ) { - bbot = NOMAD::PB; - return true; - } - if ( ss == "PEB" ) { - bbot = NOMAD::PEB_P; - return true; - } - if ( ss == "F" ) { - bbot = NOMAD::FILTER; - return true; - } - if ( ss == "STAT_AVG" ) { - bbot = NOMAD::STAT_AVG; - return true; - } - if ( ss == "STAT_SUM" ) { - bbot = NOMAD::STAT_SUM; - return true; - } - if ( ss == "CNT_EVAL" ) { - bbot = NOMAD::CNT_EVAL; - return true; - } - if ( ss == "NOTHING" || ss == "-" ) { - bbot = NOMAD::UNDEFINED_BBO; - return true; - } - return false; + std::string ss = s; + NOMAD::toupper(ss); + + if ( ss == "OBJ" ) + { + bbot = NOMAD::OBJ; + return true; + } + if ( ss == "EB" ) + { + bbot = NOMAD::EB; + return true; + } + if ( ss == "PB" || ss == "CSTR" ) + { + bbot = NOMAD::PB; + return true; + } + if ( ss == "PEB" ) + { + bbot = NOMAD::PEB_P; + return true; + } + if ( ss == "F" ) + { + bbot = NOMAD::FILTER; + return true; + } + if ( ss == "STAT_AVG" ) + { + bbot = NOMAD::STAT_AVG; + return true; + } + if ( ss == "STAT_SUM" ) + { + bbot = NOMAD::STAT_SUM; + return true; + } + if ( ss == "CNT_EVAL" ) + { + bbot = NOMAD::CNT_EVAL; + return true; + } + if ( ss == "NOTHING" || ss == "-" ) + { + bbot = NOMAD::UNDEFINED_BBO; + return true; + } + return false; } /*-----------------------------------------------------------------*/ /* convert a string into a bb_input_type */ /*-----------------------------------------------------------------*/ bool NOMAD::string_to_bb_input_type ( const std::string & s , - NOMAD::bb_input_type & bbit ) + NOMAD::bb_input_type & bbit ) { - std::string ss = s; - NOMAD::toupper ( ss ); - if ( ss=="R" || ss=="REAL" ) { - bbit = NOMAD::CONTINUOUS; - return true; - } - if ( ss=="C" || ss=="CAT" ) { - bbit = NOMAD::CATEGORICAL; - return true; - } - if ( ss=="B" || ss=="BIN" ) { - bbit = NOMAD::BINARY; - return true; - } - if ( ss=="I" || ss=="INT" ) { - bbit = NOMAD::INTEGER; - return true; - } - return false; + std::string ss = s; + NOMAD::toupper ( ss ); + if ( ss=="R" || ss=="REAL" ) + { + bbit = NOMAD::CONTINUOUS; + return true; + } + if ( ss=="C" || ss=="CAT" ) + { + bbit = NOMAD::CATEGORICAL; + return true; + } + if ( ss=="B" || ss=="BIN" ) + { + bbit = NOMAD::BINARY; + return true; + } + if ( ss=="I" || ss=="INT" ) + { + bbit = NOMAD::INTEGER; + return true; + } + return false; } /*-----------------------------------------------------------------*/ /* convert a string into a model_type */ /*-----------------------------------------------------------------*/ bool NOMAD::string_to_model_type ( const std::string & s , - NOMAD::model_type & mt ) + NOMAD::model_type & mt ) { - std::string ss = s; - NOMAD::toupper ( ss ); - if ( ss=="TGP" || ss=="TGP_MODEL" ) { - mt = NOMAD::TGP_MODEL; - return true; - } - if ( ss=="QUADRATIC" || ss=="QUADRATIC_MODEL" ) { - mt = NOMAD::QUADRATIC_MODEL; - return true; - } + std::string ss = s; + NOMAD::toupper ( ss ); - mt = NOMAD::NO_MODEL; - return false; + if ( ss=="QUADRATIC" || ss=="QUADRATIC_MODEL" ) + { + mt = NOMAD::QUADRATIC_MODEL; + return true; + } + + + mt = NOMAD::NO_MODEL; + return false; } +/*-----------------------------------------------------------------*/ +/* convert a string into a mesh_type */ +/*-----------------------------------------------------------------*/ +bool NOMAD::string_to_mesh_type ( const std::string & s , + NOMAD::mesh_type & mt ) +{ + std::string ss = s; + NOMAD::toupper ( ss ); + if ( ss=="XMESH" || ss=="X" ) + { + mt = NOMAD::XMESH; + return true; + } + if ( ss=="SMESH" || ss=="S" ) + { + mt = NOMAD::SMESH; + return true; + } + + mt = NOMAD::NO_MESH_TYPE; + return false; +} + + + /*----------------------------------------------------------------------*/ /* convert a string in {"YES","NO","Y","N"} to a bool */ /* value of return: -1: error */ @@ -721,131 +820,137 @@ bool NOMAD::string_to_model_type ( const std::string & s , /*----------------------------------------------------------------------*/ int NOMAD::string_to_bool ( const std::string & ss ) { - std::string s = ss; - NOMAD::toupper ( s ); - if ( s=="Y" || s=="YES" || s=="1" || s=="TRUE" ) - return 1; - if ( s=="N" || s=="NO" || s=="0" || s=="FALSE" ) - return 0; - return -1; + std::string s = ss; + NOMAD::toupper ( s ); + if ( s=="Y" || s=="YES" || s=="1" || s=="TRUE" ) + return 1; + if ( s=="N" || s=="NO" || s=="0" || s=="FALSE" ) + return 0; + return -1; } /*---------------------------------------------------*/ /* convert a string 'i-j' to the integers i and j */ /*---------------------------------------------------*/ bool NOMAD::string_to_index_range ( const std::string & s , - int & i , - int & j , - int * n , - bool check_order ) + int & i , + int & j , + int * n , + bool check_order ) { - if ( s.empty() ) - return false; - - if ( s == "*" ) { - if ( !n ) - return false; - i = 0; - j = *n-1; - return true; - } - - if ( s[0] == '-' ) { - - size_t ns = s.size(); - if ( ns > 1 && s[1] == '-' ) - return false; + if ( s.empty() ) + return false; - std::string ss = s; - ss.erase ( ss.begin() ); - - if ( NOMAD::string_to_index_range ( ss , i , j , n , false ) ) { - i = -i; - return true; + if ( s == "*" ) + { + if ( !n ) + return false; + i = 0; + j = *n-1; + return true; } - return false; - } - - std::istringstream in (s); - std::string s1; - - getline ( in , s1 , '-' ); - - if (in.fail()) - return false; - - size_t k , n1 = s1.size(); - - if ( n1 >= s.size() - 1 ) { - for ( k = 0 ; k < n1 ; ++k ) - if (!isdigit(s1[k])) - return false; - if ( !NOMAD::atoi ( s1 , i ) ) - return false; - if ( n1 == s.size() ) { - j = i; - return true; + + if ( s[0] == '-' ) + { + + size_t ns = s.size(); + if ( ns > 1 && s[1] == '-' ) + return false; + + std::string ss = s; + ss.erase ( ss.begin() ); + + if ( NOMAD::string_to_index_range ( ss , i , j , n , false ) ) + { + i = -i; + return true; + } + return false; } - if (n) { - j = *n-1; - return true; + + std::istringstream in (s); + std::string s1; + + getline ( in , s1 , '-' ); + + if (in.fail()) + return false; + + size_t k , n1 = s1.size(); + + if ( n1 >= s.size() - 1 ) + { + for ( k = 0 ; k < n1 ; ++k ) + if (!isdigit(s1[k])) + return false; + if ( !NOMAD::atoi ( s1 , i ) ) + return false; + if ( n1 == s.size() ) + { + j = i; + return true; + } + if (n) + { + j = *n-1; + return true; + } + return false; } - return false; - } - - std::string s2; - getline (in, s2); - - if (in.fail()) - return false; - - size_t n2 = s2.size(); - for ( k = 0 ; k < n2 ; ++k ) - if ( !isdigit(s2[k]) ) - return false; - - if ( !NOMAD::atoi ( s1, i ) || !NOMAD::atoi ( s2 , j ) ) - return false; - - return !check_order || i <= j; + + std::string s2; + getline (in, s2); + + if (in.fail()) + return false; + + size_t n2 = s2.size(); + for ( k = 0 ; k < n2 ; ++k ) + if ( !isdigit(s2[k]) ) + return false; + + if ( !NOMAD::atoi ( s1, i ) || !NOMAD::atoi ( s2 , j ) ) + return false; + + return !check_order || i <= j; } int NOMAD::get_rank(double ** M, - size_t m, - size_t n) + size_t m, + size_t n) { - double * W = new double [n]; - double ** V = new double *[n]; - for (size_t i = 0 ; i < n ; ++i ) - { - V[i]=new double [n]; - } - - std::string error_msg; - NOMAD::SVD_decomposition ( error_msg , M , W , V , static_cast<int>(m) , static_cast<int>(n) ); - - for (size_t i=0;i<n;++i) - delete [] V[i]; - delete [] V; - - - if (! error_msg.empty()) - { - delete [] W; - return -1; - } - - int rank=0; - for (size_t i=0;i<n;i++) - { - if (fabs(W[i])>NOMAD::SVD_EPS) - rank++; - } - - delete [] W; - return rank; - + double * W = new double [n]; + double ** V = new double *[n]; + for (size_t i = 0 ; i < n ; ++i ) + { + V[i]=new double [n]; + } + + std::string error_msg; + NOMAD::SVD_decomposition ( error_msg , M , W , V , static_cast<int>(m) , static_cast<int>(n) ); + + for (size_t i=0;i<n;++i) + delete [] V[i]; + delete [] V; + + + if (! error_msg.empty()) + { + delete [] W; + return -1; + } + + int rank=0; + for (size_t i=0;i<n;i++) + { + if (fabs(W[i])>NOMAD::SVD_EPS) + rank++; + } + + delete [] W; + return rank; + } @@ -873,293 +978,311 @@ int NOMAD::get_rank(double ** M, /* V is given, not V' */ /* */ /*--------------------------------------------------------------*/ +/* 2011-08-16 -- BUG REPORT (found by Etienne Duclos) */ +/* */ +/* the -Wall option gave a warning when nm was not initialized */ +/* */ +/* Solution: initialize nm = 0 */ +/* */ +/*--------------------------------------------------------------*/ bool NOMAD::SVD_decomposition ( std::string & error_msg , - double ** M , - double * W , - double ** V , - int m , - int n , - int max_mpn ) // default=1500 + double ** M , + double * W , + double ** V , + int m , + int n , + int max_mpn ) // default=1500 { - error_msg.clear(); - - if ( max_mpn > 0 && m+n > max_mpn ) { - error_msg = "SVD_decomposition() error: m+n > " + NOMAD::itos ( max_mpn ); - return false; - } - - double * rv1 = new double[n]; - double scale = 0.0; - double g = 0.0; - double norm = 0.0; - - int nm1 = n - 1; - - bool flag; - int i , j , k , l , its , jj , nm = 0; - double s , f , h , tmp , c , x , y , z , absf , absg , absh; - - const int NITER = 30; - - // Initialization W and V - for (i=0; i < n; ++i) - { - W[i]=0.0; - for (j=0; j < n ; ++j) - V[i][j]=0.0; - } - - // Householder reduction to bidiagonal form: - for ( i = 0 ; i < n ; ++i ) - { - l = i + 1; - rv1[i] = scale * g; - g = s = scale = 0.0; - if ( i < m ) - { - for ( k = i ; k < m ; ++k ) - scale += fabs ( M[k][i] ); - if ( scale ) { - for ( k = i ; k < m ; ++k ) - { - M[k][i] /= scale; - s += M[k][i] * M[k][i]; - } - f = M[i][i]; - g = ( f >= 0.0 ) ? -fabs(sqrt(s)) : fabs(sqrt(s)); - h = f * g - s; - M[i][i] = f - g; - for ( j = l ; j < n ; ++j ) { - for ( s = 0.0 , k = i ; k < m ; ++k ) - s += M[k][i] * M[k][j]; - f = s / h; - for ( k = i ; k < m ; ++k ) - M[k][j] += f * M[k][i]; - } - for ( k = i ; k < m ; ++k ) - M[k][i] *= scale; - } - } - W[i] = scale * g; - g = s = scale = 0.0; - if ( i < m && i != nm1 ) - { - for ( k = l ; k < n ; ++k ) - scale += fabs ( M[i][k] ); - if ( scale ) - { - for ( k = l ; k < n ; ++k ) - { - M[i][k] /= scale; - s += M[i][k] * M[i][k]; - } - f = M[i][l]; - g = ( f >= 0.0 ) ? -fabs(sqrt(s)) : fabs(sqrt(s)); - h = f * g - s; - M[i][l] = f - g; - for ( k = l ; k < n ; ++k ) - rv1[k] = M[i][k] / h; - for ( j = l ; j < m ; ++j ) { - for ( s=0.0,k=l ; k < n ; ++k ) - s += M[j][k] * M[i][k]; - for ( k=l ; k < n ; ++k ) - M[j][k] += s * rv1[k]; - } - for ( k = l ; k < n ; ++k ) - M[i][k] *= scale; - } - } - tmp = fabs ( W[i] ) + fabs ( rv1[i] ); - norm = ( norm > tmp ) ? norm : tmp; - } - - // accumulation of right-hand transformations: - for ( i = nm1 ; i >= 0 ; --i ) - { - if ( i < nm1 ) - { - if ( g ) - { - for ( j = l ; j < n ; ++j ) - V[j][i] = ( M[i][j] / M[i][l] ) / g; - for ( j = l ; j < n ; ++j ) { - for ( s = 0.0 , k = l ; k < n ; ++k ) - s += M[i][k] * V[k][j]; - for ( k = l ; k < n ; ++k ) - V[k][j] += s * V[k][i]; - } - } - for ( j = l ; j < n ; ++j ) - V[i][j] = V[j][i] = 0.0; - } - V[i][i] = 1.0; - g = rv1[i]; - l = i; - } - - // accumulation of left-hand transformations: - for ( i = ( ( m < n ) ? m : n ) - 1 ; i >= 0 ; --i ) - { - l = i + 1; - g = W[i]; - for ( j = l ; j < n ; ++j ) - M[i][j] = 0.0; - if ( g ) { - g = 1.0 / g; - for ( j = l ; j < n ; ++j ) - { - for ( s = 0.0 , k = l ; k < m ; ++k ) - s += M[k][i] * M[k][j]; - f = ( s / M[i][i] ) * g; - for ( k = i ; k < m ; ++k ) - M[k][j] += f * M[k][i]; - } - for ( j = i ; j < m ; ++j ) - M[j][i] *= g; - } - else - for ( j = i ; j < m ; ++j ) - M[j][i] = 0.0; - ++M[i][i]; - } - - // diagonalization of the bidiagonal form: - for ( k = nm1 ; k >= 0 ; --k ) - { - for ( its = 1 ; its <= NITER ; its++ ) - { - flag = true; - for ( l = k ; l >= 0 ; l-- ) - { - nm = l - 1; - if ( nm < 0 || fabs ( rv1[l]) + norm == norm ) - { - flag = false; - break; - } - if ( fabs ( W[nm] ) + norm == norm ) - break; - } - if ( flag ) - { - c = 0.0; - s = 1.0; - for ( i = l ; i <= k ; i++ ) - { - f = s * rv1[i]; - rv1[i] = c * rv1[i]; - if ( fabs(f) + norm == norm ) - break; - g = W[i]; - - absf = fabs(f); - absg = fabs(g); - h = ( absf > absg ) ? - absf * sqrt ( 1.0 + pow ( absg/absf , 2.0 ) ) : - ( ( absg==0 ) ? 0.0 : absg * sqrt ( 1.0 + pow ( absf/absg , 2.0 ) ) ); - - W[i] = h; - h = 1.0 / h; - c = g * h; - s = -f * h; - for ( j = 0 ; j < m ; ++j ) { - y = M[j][nm]; - z = M[j][ i]; - M[j][nm] = y * c + z * s; - M[j][ i] = z * c - y * s; - } - } - } - z = W[k]; - if ( l == k) { - if ( z < 0.0 ) { - W[k] = -z; - for ( j = 0 ; j < n ; j++ ) - V[j][k] = -V[j][k]; - } - break; // this 'break' is always active if k==0 - } - if ( its == NITER ) - { - error_msg = "SVD_decomposition() error: no convergence in " + - NOMAD::itos ( NITER ) + " iterations"; - delete [] rv1; - return false; - } - x = W[l]; - nm = k - 1; - y = W[nm]; - g = rv1[nm]; - h = rv1[k]; - f = ( (y-z) * (y+z) + (g-h) * (g+h) ) / ( 2.0 * h * y ); - - absf = fabs(f); - g = ( absf > 1.0 ) ? - absf * sqrt ( 1.0 + pow ( 1.0/absf , 2.0 ) ) : - sqrt ( 1.0 + pow ( absf , 2.0 ) ); - - f = ( (x-z) * (x+z) + - h * ( ( y / ( f + ( (f >= 0)? fabs(g) : -fabs(g) ) ) ) - h ) ) / x; - c = s = 1.0; - - for ( j = l ; j <= nm ; ++j ) { - i = j + 1; - g = rv1[i]; - y = W[i]; - h = s * g; - g = c * g; - - absf = fabs(f); - absh = fabs(h); - z = ( absf > absh ) ? - absf * sqrt ( 1.0 + pow ( absh/absf , 2.0 ) ) : - ( ( absh==0 ) ? 0.0 : absh * sqrt ( 1.0 + pow ( absf/absh , 2.0 ) ) ); - - rv1[j] = z; - c = f / z; - s = h / z; - f = x * c + g * s; - g = g * c - x * s; - h = y * s; - y *= c; - for ( jj = 0 ; jj < n ; ++jj ) - { - x = V[jj][j]; - z = V[jj][i]; - V[jj][j] = x * c + z * s; - V[jj][i] = z * c - x * s; - } - - absf = fabs(f); - absh = fabs(h); - z = ( absf > absh ) ? - absf * sqrt ( 1.0 + pow ( absh/absf , 2.0 ) ) : - ( ( absh==0 ) ? 0.0 : absh * sqrt ( 1.0 + pow ( absf/absh , 2.0 ) ) ); - - W[j] = z; - - if ( z ) - { - z = 1.0 / z; - c = f * z; - s = h * z; - } - f = c * g + s * y; - x = c * y - s * g; - for ( jj = 0 ; jj < m ; ++jj ) - { - y = M[jj][j]; - z = M[jj][i]; - M[jj][j] = y * c + z * s; - M[jj][i] = z * c - y * s; - } - } - rv1[l] = 0.0; - rv1[k] = f; - W [k] = x; - } - } - - delete [] rv1; - return true; + error_msg.clear(); + + if ( max_mpn > 0 && m+n > max_mpn ) + { + error_msg = "SVD_decomposition() error: m+n > " + NOMAD::itos ( max_mpn ); + return false; + } + + double * rv1 = new double[n]; + double scale = 0.0; + double g = 0.0; + double norm = 0.0; + + int nm1 = n - 1; + + bool flag; + int i , j , k , l , its , jj , nm = 0; + double s , f , h , tmp , c , x , y , z , absf , absg , absh; + + const int NITER = 30; + + // Initialization W and V + for (i=0; i < n; ++i) + { + W[i]=0.0; + for (j=0; j < n ; ++j) + V[i][j]=0.0; + } + + // Householder reduction to bidiagonal form: + for ( i = 0 ; i < n ; ++i ) + { + l = i + 1; + rv1[i] = scale * g; + g = s = scale = 0.0; + if ( i < m ) + { + for ( k = i ; k < m ; ++k ) + scale += fabs ( M[k][i] ); + if ( scale ) + { + for ( k = i ; k < m ; ++k ) + { + M[k][i] /= scale; + s += M[k][i] * M[k][i]; + } + f = M[i][i]; + g = ( f >= 0.0 ) ? -fabs(sqrt(s)) : fabs(sqrt(s)); + h = f * g - s; + M[i][i] = f - g; + for ( j = l ; j < n ; ++j ) + { + for ( s = 0.0 , k = i ; k < m ; ++k ) + s += M[k][i] * M[k][j]; + f = s / h; + for ( k = i ; k < m ; ++k ) + M[k][j] += f * M[k][i]; + } + for ( k = i ; k < m ; ++k ) + M[k][i] *= scale; + } + } + W[i] = scale * g; + g = s = scale = 0.0; + if ( i < m && i != nm1 ) + { + for ( k = l ; k < n ; ++k ) + scale += fabs ( M[i][k] ); + if ( scale ) + { + for ( k = l ; k < n ; ++k ) + { + M[i][k] /= scale; + s += M[i][k] * M[i][k]; + } + f = M[i][l]; + g = ( f >= 0.0 ) ? -fabs(sqrt(s)) : fabs(sqrt(s)); + h = f * g - s; + M[i][l] = f - g; + for ( k = l ; k < n ; ++k ) + rv1[k] = M[i][k] / h; + for ( j = l ; j < m ; ++j ) + { + for ( s=0.0,k=l ; k < n ; ++k ) + s += M[j][k] * M[i][k]; + for ( k=l ; k < n ; ++k ) + M[j][k] += s * rv1[k]; + } + for ( k = l ; k < n ; ++k ) + M[i][k] *= scale; + } + } + tmp = fabs ( W[i] ) + fabs ( rv1[i] ); + norm = ( norm > tmp ) ? norm : tmp; + } + + // accumulation of right-hand transformations: + l=0; + for ( i = nm1 ; i >= 0 ; --i ) + { + if ( i < nm1 ) + { + if ( g ) + { + for ( j = l ; j < n ; ++j ) + V[j][i] = ( M[i][j] / M[i][l] ) / g; + for ( j = l ; j < n ; ++j ) + { + for ( s = 0.0 , k = l ; k < n ; ++k ) + s += M[i][k] * V[k][j]; + for ( k = l ; k < n ; ++k ) + V[k][j] += s * V[k][i]; + } + } + for ( j = l ; j < n ; ++j ) + V[i][j] = V[j][i] = 0.0; + } + V[i][i] = 1.0; + g = rv1[i]; + l = i; + } + + // accumulation of left-hand transformations: + for ( i = ( ( m < n ) ? m : n ) - 1 ; i >= 0 ; --i ) + { + l = i + 1; + g = W[i]; + for ( j = l ; j < n ; ++j ) + M[i][j] = 0.0; + if ( g ) + { + g = 1.0 / g; + for ( j = l ; j < n ; ++j ) + { + for ( s = 0.0 , k = l ; k < m ; ++k ) + s += M[k][i] * M[k][j]; + f = ( s / M[i][i] ) * g; + for ( k = i ; k < m ; ++k ) + M[k][j] += f * M[k][i]; + } + for ( j = i ; j < m ; ++j ) + M[j][i] *= g; + } + else + for ( j = i ; j < m ; ++j ) + M[j][i] = 0.0; + ++M[i][i]; + } + + // diagonalization of the bidiagonal form: + for ( k = nm1 ; k >= 0 ; --k ) + { + for ( its = 1 ; its <= NITER ; its++ ) + { + flag = true; + for ( l = k ; l >= 0 ; l-- ) + { + nm = l - 1; + if ( nm < 0 || fabs ( rv1[l]) + norm == norm ) + { + flag = false; + break; + } + if ( fabs ( W[nm] ) + norm == norm ) + break; + } + if ( flag ) + { + c = 0.0; + s = 1.0; + for ( i = l ; i <= k ; i++ ) + { + f = s * rv1[i]; + rv1[i] = c * rv1[i]; + if ( fabs(f) + norm == norm ) + break; + g = W[i]; + + absf = fabs(f); + absg = fabs(g); + h = ( absf > absg ) ? + absf * sqrt ( 1.0 + pow ( absg/absf , 2.0 ) ) : + ( ( absg==0 ) ? 0.0 : absg * sqrt ( 1.0 + pow ( absf/absg , 2.0 ) ) ); + + W[i] = h; + h = 1.0 / h; + c = g * h; + s = -f * h; + for ( j = 0 ; j < m ; ++j ) + { + y = M[j][nm]; + z = M[j][ i]; + M[j][nm] = y * c + z * s; + M[j][ i] = z * c - y * s; + } + } + } + z = W[k]; + if ( l == k) + { + if ( z < 0.0 ) + { + W[k] = -z; + for ( j = 0 ; j < n ; j++ ) + V[j][k] = -V[j][k]; + } + break; // this 'break' is always active if k==0 + } + if ( its == NITER ) + { + error_msg = "SVD_decomposition() error: no convergence in " + + NOMAD::itos ( NITER ) + " iterations"; + delete [] rv1; + return false; + } + x = W[l]; + nm = k - 1; + y = W[nm]; + g = rv1[nm]; + h = rv1[k]; + f = ( (y-z) * (y+z) + (g-h) * (g+h) ) / ( 2.0 * h * y ); + + absf = fabs(f); + g = ( absf > 1.0 ) ? + absf * sqrt ( 1.0 + pow ( 1.0/absf , 2.0 ) ) : + sqrt ( 1.0 + pow ( absf , 2.0 ) ); + + f = ( (x-z) * (x+z) + + h * ( ( y / ( f + ( (f >= 0)? fabs(g) : -fabs(g) ) ) ) - h ) ) / x; + c = s = 1.0; + + for ( j = l ; j <= nm ; ++j ) + { + i = j + 1; + g = rv1[i]; + y = W[i]; + h = s * g; + g = c * g; + + absf = fabs(f); + absh = fabs(h); + z = ( absf > absh ) ? + absf * sqrt ( 1.0 + pow ( absh/absf , 2.0 ) ) : + ( ( absh==0 ) ? 0.0 : absh * sqrt ( 1.0 + pow ( absf/absh , 2.0 ) ) ); + + rv1[j] = z; + c = f / z; + s = h / z; + f = x * c + g * s; + g = g * c - x * s; + h = y * s; + y *= c; + for ( jj = 0 ; jj < n ; ++jj ) + { + x = V[jj][j]; + z = V[jj][i]; + V[jj][j] = x * c + z * s; + V[jj][i] = z * c - x * s; + } + + absf = fabs(f); + absh = fabs(h); + z = ( absf > absh ) ? + absf * sqrt ( 1.0 + pow ( absh/absf , 2.0 ) ) : + ( ( absh==0 ) ? 0.0 : absh * sqrt ( 1.0 + pow ( absf/absh , 2.0 ) ) ); + + W[j] = z; + + if ( z ) + { + z = 1.0 / z; + c = f * z; + s = h * z; + } + f = c * g + s * y; + x = c * y - s * g; + for ( jj = 0 ; jj < m ; ++jj ) + { + y = M[jj][j]; + z = M[jj][i]; + M[jj][j] = y * c + z * s; + M[jj][i] = z * c - y * s; + } + } + rv1[l] = 0.0; + rv1[k] = f; + W [k] = x; + } + } + + delete [] rv1; + return true; } diff --git a/src/utils.hpp b/src/utils.hpp index 0fd19d580d5305ef5a1b9fcb7b85c5a0861dc674..8496a7074b6a51d93a2968447f79d2e290e7af86 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -1,16 +1,23 @@ /*-------------------------------------------------------------------------------------*/ -/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.2 */ +/* NOMAD - Nonlinear Optimization by Mesh Adaptive Direct search - version 3.7.3 */ /* */ -/* Copyright (C) 2001-2015 Mark Abramson - the Boeing Company, Seattle */ -/* Charles Audet - Ecole Polytechnique, Montreal */ -/* Gilles Couture - Ecole Polytechnique, Montreal */ -/* John Dennis - Rice University, Houston */ -/* Sebastien Le Digabel - Ecole Polytechnique, Montreal */ -/* Christophe Tribes - Ecole Polytechnique, Montreal */ /* */ -/* funded in part by AFOSR and Exxon Mobil */ +/* NOMAD - version 3.7.3 has been created by */ +/* Charles Audet - Ecole Polytechnique de Montreal */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* The copyright of NOMAD - version 3.7.3 is owned by */ +/* Sebastien Le Digabel - Ecole Polytechnique de Montreal */ +/* Christophe Tribes - Ecole Polytechnique de Montreal */ +/* */ +/* NOMAD v3 has been funded by AFOSR and Exxon Mobil. */ +/* */ +/* NOMAD v3 is a new version of Nomad v1 and v2. Nomad v1 and v2 were created and */ +/* developed by Mark A. Abramson from The Boeing Company, Charles Audet and */ +/* Gilles Couture from Ecole Polytechnique de Montreal, and John E. Dennis Jr. from */ +/* Rice University, and were funded by AFOSR and Exxon Mobil. */ /* */ -/* Author: Sebastien Le Digabel */ /* */ /* Contact information: */ /* Ecole Polytechnique de Montreal - GERAD */ @@ -34,12 +41,12 @@ /* You can find information on the NOMAD software at www.gerad.ca/nomad */ /*-------------------------------------------------------------------------------------*/ /** - \file utils.hpp - \brief Utility functions (headers) - \author Sebastien Le Digabel - \date 2010-03-23 - \see utils.cpp -*/ + \file utils.hpp + \brief Utility functions (headers) + \author Sebastien Le Digabel + \date 2010-03-23 + \see utils.cpp + */ #ifndef __UTILS__ #define __UTILS__ @@ -66,225 +73,226 @@ namespace NOMAD { - - /// Convert a string into a NOMAD::bb_input_type. - /** + + /// Convert a string into a NOMAD::bb_input_type. + /** \param s The string -- \b IN. \param bbit The NOMAD::bb_input_type -- \b OUT. \return A boolean equal to \c true if the conversion was possible. - */ - bool string_to_bb_input_type ( const std::string & s , NOMAD::bb_input_type & bbit ); - - /// Convert a string into a NOMAD::bb_output_type. - /** + */ + bool string_to_bb_input_type ( const std::string & s , NOMAD::bb_input_type & bbit ); + + /// Convert a string into a NOMAD::bb_output_type. + /** \param s The string -- \b IN. \param bbot The NOMAD::bb_output_type -- \b OUT. \return A boolean equal to \c true if the conversion was possible. - */ - bool string_to_bb_output_type ( const std::string & s , NOMAD::bb_output_type & bbot ); - - /// Convert a string into a NOMAD::hnorm_type. - /** + */ + bool string_to_bb_output_type ( const std::string & s , NOMAD::bb_output_type & bbot ); + + /// Convert a string into a NOMAD::hnorm_type. + /** \param s The string -- \b IN. \param hn The NOMAD::hnorm_type -- \b OUT. \return A boolean equal to \c true if the conversion was possible. - */ - bool string_to_hnorm_type ( const std::string & s , NOMAD::hnorm_type & hn ); - - /// Convert a string into a NOMAD::TGP_mode_type. - /** - \param s The string -- \b IN. - \param m The NOMAD::TGP_mode_type -- \b OUT. - \return A boolean equal to \c true if the conversion was possible. - */ - bool string_to_TGP_mode_type ( const std::string & s , NOMAD::TGP_mode_type & m ); - - /// Convert a string into a multi_formulation_type. - /** + */ + bool string_to_hnorm_type ( const std::string & s , NOMAD::hnorm_type & hn ); + + /// Convert a string into a multi_formulation_type. + /** \param s The string -- \b IN. \param mft The NOMAD::multi_formulation_type -- \b OUT. \return A boolean equal to \c true if the conversion was possible. - */ - bool string_to_multi_formulation_type ( const std::string & s , - NOMAD::multi_formulation_type & mft ); - - /// Convert a string with format "i-j" into two integers i and j. - /** + */ + bool string_to_multi_formulation_type ( const std::string & s , + NOMAD::multi_formulation_type & mft ); + + /// Convert a string with format "i-j" into two integers i and j. + /** If s=="*" and if n is defined, then i=0 and j=*n-1. - + \param s The string -- \b IN. \param i The first integer \c i -- \b OUT. \param j The second integer \c j -- \b OUT. \param n Number of variables; use \c NULL if unknown - -- \b IN -- \b optional (default = \c NULL). + -- \b IN -- \b optional (default = \c NULL). \param check_order A boolean indicating if \c i and \c j are to be compared - -- \b IN -- \b optional (default = \c true). + -- \b IN -- \b optional (default = \c true). \return A boolean equal to \c true if the conversion was possible. - */ - bool string_to_index_range ( const std::string & s , - int & i , - int & j , - int * n = NULL , - bool check_order = true ); - - - /// Convert a string in {"QUADRATIC","TGP"} to a \c NOMAD::model_type. - /** + */ + bool string_to_index_range ( const std::string & s , + int & i , + int & j , + int * n = NULL , + bool check_order = true ); + + /// Convert a string in {"QUADRATIC"} to a \c NOMAD::model_type. + /** \param s The string -- \b IN. \param mt The NOMAD::model_type -- \b OUT. \return A boolean equal to \c true if the conversion was possible. - */ - bool string_to_model_type ( const std::string & s , NOMAD::model_type & mt ); + */ + bool string_to_model_type ( const std::string & s , NOMAD::model_type & mt ); + - /// Convert a string in {"YES","NO","Y","N","0","1","TRUE","FALSE"} to a boolean. - /** + /// Convert a string in {"XMESH","SMESH"} to a \c NOMAD::mesh_type. + /** + \param s The string -- \b IN. + \param mt The NOMAD::mesh_type -- \b OUT. + \return A boolean equal to \c true if the conversion was possible. + */ + bool string_to_mesh_type ( const std::string & s , NOMAD::mesh_type & mt ); + + + /// Convert a string in {"YES","NO","Y","N","0","1","TRUE","FALSE"} to a boolean. + /** \param s The string -- \b IN. \return An integer equal to \c 0 for \c false, \c 1 for \c true, - and \c -1 if the conversion failed. - */ - int string_to_bool ( const std::string & s ); - - /// Interpret a list of strings as a direction type. - /** + and \c -1 if the conversion failed. + */ + int string_to_bool ( const std::string & s ); + + /// Interpret a list of strings as a direction type. + /** \param ls The list of strings -- \b IN. \param dt The NOMAD::direction_type -- \b OUT. \return A boolean equal to \c true if the conversion was possible. - */ - bool strings_to_direction_type ( const std::list<std::string> & ls , - NOMAD::direction_type & dt ); - - /// If a NOMAD::bb_output_type variable corresponds to a constraint. - /** + */ + bool strings_to_direction_type ( const std::list<std::string> & ls , + NOMAD::direction_type & dt ); + + /// If a NOMAD::bb_output_type variable corresponds to a constraint. + /** \param bbot The NOMAD::bb_output_type -- \b IN. \return A boolean equal to \c true if \c bbot corresponds to a constraint. - */ - bool bbot_is_constraint ( NOMAD::bb_output_type bbot ); - - /// If a NOMAD::direction_type variable corresponds to a MADS direction. - /** + */ + bool bbot_is_constraint ( NOMAD::bb_output_type bbot ); + + /// If a NOMAD::direction_type variable corresponds to a MADS direction. + /** \param dt The NOMAD::direction_type -- \b IN. \return A boolean equal to \c true if \c dt corresponds to a MADS direction. - */ - bool dir_is_mads ( NOMAD::direction_type dt ); - - /// If a NOMAD::direction_type variable corresponds to a GPS direction. - /** + */ + bool dir_is_mads ( NOMAD::direction_type dt ); + + /// If a NOMAD::direction_type variable corresponds to a GPS direction. + /** \param dt The NOMAD::direction_type -- \b IN. \return A boolean equal to \c true if \c dt corresponds to a GPS direction. - */ - bool dir_is_gps ( NOMAD::direction_type dt ); - - /// If a NOMAD::direction_type variable corresponds to a LT-MADS direction. - /** + */ + bool dir_is_gps ( NOMAD::direction_type dt ); + + /// If a NOMAD::direction_type variable corresponds to a LT-MADS direction. + /** \param dt The NOMAD::direction_type -- \b IN. \return A boolean equal to \c true if \c dt corresponds to a LT-MADS direction. - */ - bool dir_is_ltmads ( NOMAD::direction_type dt ); - - /// If a NOMAD::direction_type variable corresponds to a random direction. - /** + */ + bool dir_is_ltmads ( NOMAD::direction_type dt ); + + /// If a NOMAD::direction_type variable corresponds to a random direction. + /** \param dt The NOMAD::direction_type -- \b IN. \return A boolean equal to \c true if \c dt corresponds to a random direction. - */ - bool dir_is_random ( NOMAD::direction_type dt ); - - - /// If a NOMAD::direction_type variable corresponds to a Ortho-MADS direction. - /** + */ + bool dir_is_random ( NOMAD::direction_type dt ); + + + /// If a NOMAD::direction_type variable corresponds to a Ortho-MADS direction. + /** \param dt The NOMAD::direction_type -- \b IN. \return A boolean equal to \c true if \c dt corresponds to a Ortho-MADS direction. - */ - bool dir_is_orthomads ( NOMAD::direction_type dt ); - - /// If a NOMAD::direction_type variable corresponds to a Ortho-MADS direction using XMesh. - /** + */ + bool dir_is_orthomads ( NOMAD::direction_type dt ); + + /// If a NOMAD::direction_type variable corresponds to a Ortho-MADS direction using XMesh. + /** \param dt The NOMAD::direction_type -- \b IN. \return A boolean equal to \c true if \c dt corresponds to a Ortho-MADS direction using XMesh. - */ - bool dir_is_orthomads_xmesh ( NOMAD::direction_type dt ); - - /// Check if a set of directions include Ortho-MADS direction. - /** + */ + bool dir_is_orthomads_xmesh ( NOMAD::direction_type dt ); + + /// Check if a set of directions include Ortho-MADS direction. + /** \param dir_types Set of direction types -- \b IN. \return A boolean equal to \c true if at least one direction in the set is of type Ortho-MADS. - */ - bool dirs_have_orthomads ( const std::set<NOMAD::direction_type> & dir_types ); - - /// Check if a set of directions include Ortho-MADS direction using XMesh. - /** + */ + bool dirs_have_orthomads ( const std::set<NOMAD::direction_type> & dir_types ); + + /// Check if a set of directions include Ortho-MADS direction using XMesh. + /** \param dir_types Set of direction types -- \b IN. \return A boolean equal to \c true if at least one direction in the set is of type Ortho-MADS+XMesh. - */ - bool dirs_have_orthomads_xmesh ( const std::set<NOMAD::direction_type> & dir_types ); - - - /// Check if a set of direction types include Ortho-MADS N+1 direction. - /** + */ + bool dirs_have_orthomads_xmesh ( const std::set<NOMAD::direction_type> & dir_types ); + + + /// Check if a set of direction types include Ortho-MADS N+1 direction. + /** \param dir_types Set of direction types -- \b IN. \return A boolean equal to \c true if at least one direction in the set is of type Ortho-MADS N+1. - */ - bool dirs_have_orthomads_np1 ( const std::set<NOMAD::direction_type> & dir_types ); - - - /// Construct the n first prime numbers. - /** + */ + bool dirs_have_orthomads_np1 ( const std::set<NOMAD::direction_type> & dir_types ); + + + /// Construct the n first prime numbers. + /** \param n The integer \c n-- \b IN. \param primes An integer array of size \c n for the prime numbers; - must be previously allocated -- \b OUT. - */ - void construct_primes ( int n , int * primes ); - - /// Decompose a string (sentence) into a list of strings (words). - /** + must be previously allocated -- \b OUT. + */ + void construct_primes ( int n , int * primes ); + + /// Decompose a string (sentence) into a list of strings (words). + /** \param sentence The sentence -- \b IN. \param words The words -- \b OUT. - */ - void get_words ( const std::string & sentence , std::list<std::string> & words ); - - /// Check if a file exists and is executable. - /** + */ + void get_words ( const std::string & sentence , std::list<std::string> & words ); + + /// Check if a file exists and is executable. + /** \param file_name A string corresponding to a file name -- \b IN. \return A boolean equal to \c true if the file is executable. - */ - bool check_exe_file ( const std::string & file_name ); - - /// Check if a file exists and is readable. - /** + */ + bool check_exe_file ( const std::string & file_name ); + + /// Check if a file exists and is readable. + /** \param file_name A string corresponding to a file name -- \b IN. \return A boolean equal to \c true if the file exists and is readable. - */ - bool check_read_file ( const std::string & file_name ); - - /// Get the process id (pid); useful for unique random seeds. - /** + */ + bool check_read_file ( const std::string & file_name ); + + /// Get the process id (pid); useful for unique random seeds. + /** \return An integer corresponding to the pid. - */ - int get_pid ( void ); - - /// Called at the beginning of NOMAD. - /** + */ + int get_pid ( void ); + + /// Called at the beginning of NOMAD. + /** \param argc Number of command line arguments. \param argv Command line arguments. - */ - void begin ( int argc , char ** argv ); - - /// Called at the end of NOMAD. - void end ( void ); - - - /// Transform an integer into a string. - /** + */ + void begin ( int argc , char ** argv ); + + /// Called at the end of NOMAD. + void end ( void ); + + + /// Transform an integer into a string. + /** \param i The integer -- \b IN. \return The string. - */ - std::string itos ( int i ); - + */ + std::string itos ( int i ); + /// Transform a unsigned long (size_t) into a string. /** @@ -292,63 +300,71 @@ namespace NOMAD { \return The string. */ std::string itos ( size_t i ); - - /// Put a string into upper cases. - /** + /// Remove leading, trailing and double spaces in a string. + /** \param s The string -- \b IN/OUT. - */ - void toupper ( std::string & s ); - - /// Put a list of strings into upper cases. - /** + */ + void deblank ( std::string & s ); + + + + + /// Put a string into upper cases. + /** + \param s The string -- \b IN/OUT. + */ + void toupper ( std::string & s ); + + /// Put a list of strings into upper cases. + /** \param ls The list of strings -- \b IN/OUT. - */ - void toupper ( std::list<std::string> & ls ); - - /// Convert a string into an integer. - /** + */ + void toupper ( std::list<std::string> & ls ); + + /// Convert a string into an integer. + /** \param s The string -- \b IN. \param i The integer -- \b OUT. \return A boolean equal to \c true if the conversion was possible. - */ - bool atoi ( const std::string & s , int & i ); - - /// Convert a character into an integer. - /** + */ + bool atoi ( const std::string & s , int & i ); + + /// Convert a character into an integer. + /** \param c The character -- \b IN. \param i The integer -- \b OUT. \return A boolean equal to \c true if the conversion was possible. - */ - bool atoi ( char c , int & i ); - - /// Search a list of string inside a string. - /** + */ + bool atoi ( char c , int & i ); + + /// Search a list of string inside a string. + /** \param s The string -- \b IN. \param ls The list of strings -- \b IN. \return A boolean equal to \c true if one of the string of ls is in s. - */ - bool string_find ( const std::string & s , const std::list<std::string> & ls ); - - /// Search a string into another string. - /** + */ + bool string_find ( const std::string & s , const std::list<std::string> & ls ); + + /// Search a string into another string. + /** \param s1 A string -- \b IN. \param s2 A string -- \b IN. \return A boolean equal to \c true if \c s2 is in \c s1. - */ - bool string_find ( const std::string & s1 , const std::string & s2 ); - - /// Search if a string matches an element in a list of string. - /** + */ + bool string_find ( const std::string & s1 , const std::string & s2 ); + + /// Search if a string matches an element in a list of string. + /** \param s A string -- \b IN. \param ls A list of strings -- \b IN. \return A boolean equal to \c true if \c s matches an element in \c ls. - */ - bool string_match ( const std::string & s , const std::list<std::string> & ls ); - - - /// SVD decomposition. - /** + */ + bool string_match ( const std::string & s , const std::list<std::string> & ls ); + + + /// SVD decomposition. + /** - The \c mxn \c M matrix is decomposed into \c M=U.W.V'. \param error_msg Error message when the function returns \c false -- \b OUT. \param M The input \c mxn matrix; Will be replaced by \c U -- \b IN/OUT. @@ -357,31 +373,30 @@ namespace NOMAD { \param m Number of rows in M -- \b IN. \param n Number of columns in M -- \b IN. \param max_mpn Maximum allowed value for \c m+n; ignored if \c <=0 -- \b IN - -- \b optional (default = \c 1500). + -- \b optional (default = \c 1500). \return A boolean equal to \c true if the decomposition worked. - */ - bool SVD_decomposition ( std::string & error_msg , - double ** M , - double * W , - double ** V , - int m , - int n , - int max_mpn = 1500 ); - - - // Get rank of a matrix using SVD decomposition - /** + */ + bool SVD_decomposition ( std::string & error_msg , + double ** M , + double * W , + double ** V , + int m , + int n , + int max_mpn = 1500 ); + + + // Get rank of a matrix using SVD decomposition + /** - The \c mxn \c M matrix is decomposed into \c M=U.W.V'. The rank equals the size of W - \param M The input \c mxn matrix -- \b IN. + \param M The input \c mxn matrix -- \b IN. \param m Number of rows in M -- \b IN. \param n Number of columns in M -- \b IN. \return The rank>0 if the decomposition worked else 0. - */ - int get_rank(double **M, - size_t m, - size_t n); - - + */ + int get_rank(double **M, + size_t m, + size_t n); + } #endif diff --git a/tools/COOP-MADS/makefile b/tools/COOP-MADS/makefile index 56ef9d250e489d35560a0d450ab563f78f7859ee..0c3c6f00b21695e42331aa27bcd99e496bcdf55e 100644 --- a/tools/COOP-MADS/makefile +++ b/tools/COOP-MADS/makefile @@ -1,17 +1,24 @@ -EXE = coopmads.exe -COMPILATOR = mpic++ -SUNAME = $(shell uname) -OSS=$(findstring MINGW32,$(SUNAME)) -ifneq "$(strip $(OSS))" "" -COMPILATOR = g++ +UNAME := $(shell uname) + +EXE = coopmads.exe + +COMPILATOR = mpic++ +COMPILATOR_OPTIONS = -ansi -O2 + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = -DUSE_MPI +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi endif -COMPILATOR_OPTIONS = -ansi -O2 -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lm -lmpi -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -OBJS = main.o Cache_Server.o +LDLIBS = -lm -lnomad -lmpi + +INCLUDE = -I$(NOMAD_HOME)/src -I. +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +OBJS = main.o Cache_Server.o ifndef NOMAD_HOME define ECHO_NOMAD @@ -20,20 +27,21 @@ define ECHO_NOMAD endef endif -$(EXE): $(OBJS) $(L1) +$(EXE): $(OBJS) $(ECHO_NOMAD) - $(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif main.o: main.cpp + $(ECHO_NOMAD) $(COMPILE) main.cpp Cache_Server.o: Cache_Server.cpp Cache_Server.hpp $(ECHO_NOMAD) $(COMPILE) Cache_Server.cpp - -$(L1): ; - $(ECHO_NOMAD) - + clean: @echo "cleaning obj files" @rm -f $(OBJS) @@ -44,4 +52,4 @@ del: @echo "cleaning obj files" @rm -f $(OBJS) @echo "cleaning exe file" - @rm -f $(EXE) + @rm -f $(EXE) \ No newline at end of file diff --git a/tools/COOP-MADS/problems/G2_10/runExample.log b/tools/COOP-MADS/problems/G2_10/runExample.log index 133b63da0c5310eabc004c8305250b10c0580d87..b591c857b0190342b4c75b232360add3f4718b4b 100644 --- a/tools/COOP-MADS/problems/G2_10/runExample.log +++ b/tools/COOP-MADS/problems/G2_10/runExample.log @@ -2,22 +2,19 @@ TIME BBE OBJ 0 1 -0.001746040966254643 -0 2 -0.08743509125381764 -0 3 -0.09502614738887308 -0 12 -0.1241414508378795 -0 13 -0.1243880456661476 -0 14 -0.1282392319163835 -0 17 -0.1473005317907833 -0 35 -0.150183285112481 -0 46 -0.1572895785336448 -0 65 -0.194312112152985 -1 99 -0.215523726538665 -2 100 -0.215523726538665 +0 2 -0.08528561640409191 +0 4 -0.1217773504383107 +0 5 -0.1279124163911427 +0 9 -0.1683898819115072 +0 15 -0.1736961324904976 +0 25 -0.1977471952080628 +0 33 -0.2013413195042891 +0 34 -0.2200888366995143 +0 39 -0.256670797710581 +1 101 -0.256670797710581 -evaluations : 100 +evaluations : 101 multiple evaluations : 0 -cache hits : 1374 -cache search points : 26 -best feasible solution: x=( 9 8 6 3 6 3.5 3 3 5 3 ) F(x)=[ -3674159.25 -25.5 -0.215523726538665 ] h=0 f=-0.215523726538665 -best infeas. sol. #1 : x=( 6 10 8.5 8.5 7.5 0 5.5 0.5 6.5 3.5 ) F(x)=[ 0.75 -18.5 -0.1232423970453351 ] h=0.75 f=-0.1232423970453351 -best infeas. sol. #2 : x=( 5.5 9 9.5 2.5 6.5 1 0 2 5.5 5 ) F(x)=[ 0.75 -28.5 -0.1303069434264795 ] h=0.75 f=-0.1303069434264795 +cache hits : 1449 +cache search points : 18 +best feasible solution: x=( 1 7 3 3 3 7 3 3 3 3 ) F(x)=[ -107162.25 -39 -0.256670797710581 ] h=0 f=-0.256670797710581 diff --git a/tools/COOP-MADS/problems/RHEOLOGY/runExample.log b/tools/COOP-MADS/problems/RHEOLOGY/runExample.log index 3342d27408b5917f424fdd31ab4f7ab1b6fe1015..5b831784955dea07eb07faaa63e47f27b63937e6 100644 --- a/tools/COOP-MADS/problems/RHEOLOGY/runExample.log +++ b/tools/COOP-MADS/problems/RHEOLOGY/runExample.log @@ -2,121 +2,122 @@ TIME BBE OBJ 0 1 409.067422156616 -0 2 407.173143113625 -0 7 326.103515990633 -0 42 325.623426986692 -0 59 295.895440816156 -0 72 293.4555631559 -0 90 279.968263515696 -0 139 275.288266367226 -0 187 275.132352128014 -0 209 275.075795191333 -0 210 274.976333696773 -0 241 274.933105934363 -0 250 274.790628310616 -0 270 274.36972472876 -0 289 274.275563955637 -0 326 274.268484588901 -0 338 274.064933108817 -1 386 274.062269914507 -1 387 274.054281384837 -1 391 274.049026282641 -1 401 273.920837770762 -1 404 273.508720307709 -1 424 273.331822600277 -1 428 273.234004939865 -1 445 272.832477208338 -1 467 272.636358518916 -1 485 272.016936191517 -1 522 271.675223302068 -1 528 271.458245294985 -1 563 271.409843575617 -1 566 271.294040864725 -1 575 271.203751307945 -1 580 270.867285707472 -1 582 270.135910598837 -1 584 268.624704712738 -1 586 264.655640417888 -1 626 264.547329099114 -1 629 264.369411744322 -1 636 259.186132611454 -1 670 259.111109366001 -1 694 258.526885252145 -1 737 258.461782617644 -1 741 258.254128487816 -2 743 257.637827815885 -2 751 257.487467885692 -2 763 256.062079426438 -2 784 255.55667512634 -2 822 255.301356122905 -2 827 255.062123107245 -2 852 254.969793840294 -2 872 254.961280633716 -2 874 254.872629390701 -2 892 254.11730737943 -2 901 252.429482703112 -2 913 247.734161777393 -2 943 246.281383367226 -2 950 244.871940734504 -2 955 243.687522298512 -2 968 240.313783391124 -2 994 225.924186834258 -2 1027 225.375287811551 -2 1030 223.59959141347 -2 1033 214.372939666438 -2 1075 212.392129645385 -2 1079 202.458511181126 -3 1118 201.385729843192 -3 1121 200.414479846749 -3 1122 197.265532908615 -3 1130 196.484237748458 -3 1143 195.363761230687 -3 1150 194.180926892312 -3 1164 186.886694594438 -3 1229 186.775564288857 -3 1235 185.543088875516 -3 1247 184.315879020582 -3 1250 183.591281538454 -3 1251 180.585581615803 -3 1252 176.910717859633 -3 1256 151.835774047001 -3 1288 151.049164181499 -3 1289 143.621877654316 -3 1298 138.52428369358 -3 1300 130.977242901418 -3 1304 100.267474292617 -3 1325 99.71006688112919 -3 1363 94.56656135601661 -3 1379 79.3308117287512 -3 1411 62.8192798819504 -4 1413 57.1236275580665 -4 1433 45.5493739549428 -4 1482 44.5241434513005 -4 1485 42.8758586335358 -4 1494 40.173767108364 -4 1520 35.9160626502317 -4 1541 35.4706065363053 -4 1625 35.3985432229957 -4 1626 34.7705213812039 -4 1648 33.7365638550162 -4 1654 33.2736870837588 -4 1721 33.1821599854517 -4 1756 33.1640101150454 -4 1759 33.1094860838809 -5 1772 33.0242678796706 -5 1817 32.9941537610489 -5 1827 32.993685905707 -5 1860 32.9805924282463 -5 1912 32.9797736631138 -5 1936 32.979572485373 -5 1941 32.9794989828924 -5 1943 32.978674947399 -5 1980 32.9781395291375 -5 1983 32.9779413611568 -5 2001 32.9779413611568 +0 5 322.714672991286 +0 11 265.453635576699 +0 59 253.700379372787 +0 86 253.508031417864 +0 118 253.201633640789 +0 135 252.358093402554 +0 160 251.197472707471 +1 182 251.197301214826 +1 190 251.07713195817 +1 207 250.997447369686 +1 234 250.863129878857 +1 239 250.348565958289 +1 259 250.085055415213 +1 263 249.552570436516 +1 265 248.815865880956 +1 301 247.44992060398 +1 331 247.112498030273 +1 334 246.811892550734 +1 370 246.500086500941 +1 387 246.419187625588 +1 391 245.966804212317 +1 401 245.796743257507 +1 425 245.525068769592 +1 475 245.218533633366 +1 486 244.90846223392 +1 493 244.849644072153 +1 546 244.676306494478 +2 565 244.582999118234 +2 586 244.575839696815 +2 594 244.378107909394 +2 595 243.796461173388 +2 598 241.642674855193 +2 619 240.954865563714 +2 620 239.095740614928 +2 630 239.042233330649 +2 663 238.392177294901 +2 687 237.14673675086 +2 698 236.447365897648 +2 720 236.114659332555 +2 739 235.691225738535 +2 761 234.102484883206 +2 764 229.340323724089 +2 767 216.522605525348 +2 771 196.963059945103 +2 787 196.847112442146 +2 788 196.509148264238 +2 859 196.472844306831 +2 860 195.917100202077 +2 877 195.52911433773 +2 894 195.32691063284 +2 909 194.6659700126 +3 954 193.250827222827 +3 956 192.675360163547 +3 960 191.754551114895 +3 963 187.293158675319 +3 965 173.11436821721 +3 992 168.278990026847 +3 996 168.241191748863 +3 997 164.093855182351 +3 1027 154.594844826658 +3 1046 146.464758975961 +3 1048 145.102201089468 +3 1062 109.906215853184 +3 1069 106.774234762506 +3 1074 95.0780580563132 +3 1108 69.93773412990249 +3 1134 67.7573780014974 +3 1157 61.2885209600909 +3 1200 60.431575681709 +3 1204 60.4294769846275 +3 1206 58.3738847038617 +3 1222 56.6121681907407 +3 1237 55.9551830235949 +3 1252 48.9988231468474 +4 1292 45.6702759695433 +4 1343 43.8079499580428 +4 1352 42.9716585947603 +4 1360 42.0929043227586 +4 1376 39.949447504498 +4 1399 39.4932283554129 +4 1402 39.2287376352352 +4 1427 38.9784559612383 +4 1450 38.2078899027391 +4 1462 36.2656269613614 +4 1464 35.580177483812 +4 1498 33.7818737227238 +4 1535 33.4939643479363 +4 1543 33.0918450456313 +4 1606 33.0590338343981 +4 1609 33.0200589300374 +4 1638 33.0156952097848 +4 1641 33.0026037040469 +5 1655 32.9969719389035 +5 1686 32.9957520259869 +5 1750 32.9878641371004 +5 1783 32.9850410001756 +5 1838 32.9838371886284 +5 1865 32.9837327800898 +5 1870 32.9825522627429 +5 1873 32.9806229180508 +5 1875 32.9758135809074 +5 1878 32.9685718485421 +5 1889 32.9678022774788 +5 1893 32.9662494690148 +5 1894 32.965099452368 +5 1896 32.9646828629751 +5 1898 32.9561254938631 +5 1953 32.9557769687585 +5 1956 32.9547315431167 +5 1957 32.953487367693 +6 1985 32.9499524280818 +6 2000 32.9469957498619 +6 2001 32.9469957498619 evaluations : 2001 multiple evaluations : 0 -cache hits : 258 -cache search points : 221 -best feasible solution: x=( 5.167878504178415 3.051154465074881 9.460783454109679 ) F(x)=[ 32.9779413611568 ] h=0 f=32.9779413611568 +cache hits : 436 +cache search points : 220 +best feasible solution: x=( 5.168634764722022 3.052322762740134 9.462490982212969 ) F(x)=[ 32.9469957498619 ] h=0 f=32.9469957498619 diff --git a/tools/COOP-MADS/readme.txt b/tools/COOP-MADS/readme.txt index 44a9a0e220ecfffc2a331404f00bab77addc7149..f28b904af165b035a96e9751206d5f48a80b69ac 100644 --- a/tools/COOP-MADS/readme.txt +++ b/tools/COOP-MADS/readme.txt @@ -1,3 +1,5 @@ +Procedure for Unix/Linux/mac OSX + 1- Set the NOMAD_HOME environment variable 2- Compile with the command make 3- Go to one of the problem directory diff --git a/tools/PSD-MADS/makefile b/tools/PSD-MADS/makefile index ffc34f7c4f58310cf0fe1e68e004bc51e0806f10..ab23da419da28885beec4717a9704220d94be3c0 100644 --- a/tools/PSD-MADS/makefile +++ b/tools/PSD-MADS/makefile @@ -1,17 +1,25 @@ -EXE = psdmads.exe -COMPILATOR = mpic++ -SUNAME = $(shell uname) -OSS=$(findstring MINGW32,$(SUNAME)) -ifneq "$(strip $(OSS))" "" -COMPILATOR = g++ +UNAME := $(shell uname) + +EXE = psdmads.exe +COMPILATOR = mpic++ + +COMPILATOR_OPTIONS = -ansi -O2 + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi endif -COMPILATOR_OPTIONS = -ansi -O2 -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lm -lmpi -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -OBJS = main.o Cache_Server.o Master_Slaves.o + +LDLIBS = -lm -lnomad -lmpi + +INCLUDE = -I$(NOMAD_HOME)/src -I. +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +OBJS = main.o Cache_Server.o Master_Slaves.o ifndef NOMAD_HOME define ECHO_NOMAD @@ -20,11 +28,15 @@ define ECHO_NOMAD endef endif -$(EXE): $(OBJS) $(L1) +$(EXE): $(OBJS) $(ECHO_NOMAD) - $(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) + $(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif main.o: main.cpp Master_Slaves.o + $(ECHO_NOMAD) $(COMPILE) main.cpp Master_Slaves.o: Master_Slaves.cpp Master_Slaves.hpp Cache_Server.o @@ -35,9 +47,6 @@ Cache_Server.o: Cache_Server.cpp Cache_Server.hpp $(ECHO_NOMAD) $(COMPILE) Cache_Server.cpp -$(L1): ; - $(ECHO_NOMAD) - clean: @echo "cleaning obj files" @rm -f $(OBJS) @@ -48,4 +57,4 @@ del: @echo "cleaning obj files" @rm -f $(OBJS) @echo "cleaning exe file" - @rm -f $(EXE) \ No newline at end of file + @rm -f $(EXE) diff --git a/tools/PSD-MADS/problems/G2_10/runExample.log b/tools/PSD-MADS/problems/G2_10/runExample.log index 77b68db660e5c30ebd7a26f52105769fccedf6ac..2065ff7b4820b00ab44406bd7e81355c8aa1d335 100644 --- a/tools/PSD-MADS/problems/G2_10/runExample.log +++ b/tools/PSD-MADS/problems/G2_10/runExample.log @@ -1,34 +1,44 @@ - + +mpirun -np 4 ../../psdmads.exe param.txt 20 3 > runExample.log + TIME BBE OBJ 0 1 -0.001746040966254643 0 2 -0.1020265638285207 0 6 -0.1441632798005752 -0 15 -0.1542510749518172 -0 22 -0.1577316768630335 -0 37 -0.183989373943974 -0 38 -0.2020008666180557 -0 39 -0.2129271506181529 -0 40 -0.2361644054928127 -1 75 -0.2374148796747058 -1 94 -0.2603035160235741 -1 116 -0.2684048733308141 -2 174 -0.2821001936977113 -3 212 -0.2866228068210581 -4 298 -0.2898075435824587 -4 322 -0.316703796586124 -5 350 -0.338651875099582 -6 412 -0.3480692693344858 -7 506 -0.4056438193796689 -8 550 -0.4404750660164174 -9 598 -0.4453605848005951 -11 758 -0.4502266934808508 -12 780 -0.4606308402126712 -12 794 -0.4678396551609023 -12 804 -0.4864410201396533 -13 836 -0.5028952047514585 -15 961 -0.513267791679749 -29 1001 -0.513267791679749 -evaluations: 1001 -cache hits : 14460 -best feasible solution: x=( 3.125 3.125 3.25 1.5 2.375 0.25 2.625 0.125 0.5 0.875 ) F(x)=[ -3.307846963405609 -57.25 -0.513267791679749 ] h=0 f=-0.513267791679749 +0 19 -0.1479342881281465 +0 25 -0.1841215568617915 +0 28 -0.1849197713114521 +0 38 -0.1916931712633913 +0 40 -0.2227632234775169 +0 87 -0.2412462955044069 +1 95 -0.2527350956716981 +1 114 -0.2704851250098481 +1 128 -0.2717551757304079 +1 153 -0.2878109208445224 +1 157 -0.3235573809157189 +1 168 -0.3308416194351365 +2 209 -0.3537076003988114 +2 216 -0.3785183934692382 +2 226 -0.3932656382622645 +2 235 -0.397226624873137 +2 269 -0.4026098831965045 +2 279 -0.402851775010626 +2 302 -0.4131889647727121 +3 315 -0.4304862626819641 +3 318 -0.4558590836833153 +3 336 -0.4848732170447992 +4 497 -0.4924809666931201 +4 525 -0.5119819323392423 +5 553 -0.5173948676971726 +5 618 -0.6229712809770065 +5 626 -0.6535294804372643 +6 711 -0.6729611996573323 +6 717 -0.6878450704721685 +6 722 -0.693572111946147 +7 838 -0.7163568681615147 +8 902 -0.7202155341278618 +23 1000 -0.7202155341278618 +evaluations: 1000 +cache hits : 7323 +best feasible solution: x=( 3.078125 3.109375 2.9765625 2.9296875 0.71875 0.453125 0.3359375 0.375 0.3828125 0.578125 ) F(x)=[ -0.007860294779722617 -60.0625 -0.7202155341278618 ] h=0 f=-0.7202155341278618 diff --git a/tools/PSD-MADS/readme.txt b/tools/PSD-MADS/readme.txt index 62a9c97ee365d9537a7acb164dd978be2012d5e5..fc125f1652e20ce6aa03745f9ae90611dfce1f31 100644 --- a/tools/PSD-MADS/readme.txt +++ b/tools/PSD-MADS/readme.txt @@ -1,3 +1,5 @@ +Procedure for Unix/Linux/mac OSX + 1- Set the NOMAD_HOME environment variable 2- Compile with the command make 3- Go to one of the problem directory diff --git a/tools/PSD-MADS_library_mode/makefile b/tools/PSD-MADS_library_mode/makefile index ffc34f7c4f58310cf0fe1e68e004bc51e0806f10..29093ff34ef10379669beb941518f254a3a30874 100644 --- a/tools/PSD-MADS_library_mode/makefile +++ b/tools/PSD-MADS_library_mode/makefile @@ -1,17 +1,24 @@ -EXE = psdmads.exe -COMPILATOR = mpic++ -SUNAME = $(shell uname) -OSS=$(findstring MINGW32,$(SUNAME)) -ifneq "$(strip $(OSS))" "" -COMPILATOR = g++ +UNAME := $(shell uname) + +EXE = psdmads.exe + +COMPILATOR = mpic++ +COMPILATOR_OPTIONS = -ansi -O2 + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi endif -COMPILATOR_OPTIONS = -ansi -O2 -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lm -lmpi -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -OBJS = main.o Cache_Server.o Master_Slaves.o +LDLIBS = -lm -lnomad + +INCLUDE = -I$(NOMAD_HOME)/src -I. +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +OBJS = main.o Cache_Server.o Master_Slaves.o ifndef NOMAD_HOME define ECHO_NOMAD @@ -20,11 +27,15 @@ define ECHO_NOMAD endef endif -$(EXE): $(OBJS) $(L1) +$(EXE): $(OBJS) $(ECHO_NOMAD) - $(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) + $(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif main.o: main.cpp Master_Slaves.o + $(ECHO_NOMAD) $(COMPILE) main.cpp Master_Slaves.o: Master_Slaves.cpp Master_Slaves.hpp Cache_Server.o @@ -34,9 +45,6 @@ Master_Slaves.o: Master_Slaves.cpp Master_Slaves.hpp Cache_Server.o Cache_Server.o: Cache_Server.cpp Cache_Server.hpp $(ECHO_NOMAD) $(COMPILE) Cache_Server.cpp - -$(L1): ; - $(ECHO_NOMAD) clean: @echo "cleaning obj files" diff --git a/tools/SENSITIVITY/cache_inspect/makefile b/tools/SENSITIVITY/cache_inspect/makefile index 70e3082a1f20a952cf31947e3dbe42261d2bdc15..87af1472a2ee18be03de2f9ea6185171378c0d8f 100644 --- a/tools/SENSITIVITY/cache_inspect/makefile +++ b/tools/SENSITIVITY/cache_inspect/makefile @@ -1,28 +1,35 @@ -EXE = cache_inspect -COMPILATOR = g++ -COMPILATOR_OPTIONS = -ansi -Wall -O2 -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lc -lm -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -OBJS = cache_inspect.o +UNAME := $(shell uname) + +EXE = cache_inspect.exe +COMPILATOR = g++ +COMPILATOR_OPTIONS = -ansi -Wall -O2 + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif + +LDLIBS = -lm -lnomad + +INCLUDE = -I$(NOMAD_HOME)/src -I. +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c +OBJS = cache_inspect.o $(EXE): $(OBJS) - $(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) + $(ECHO_NOMAD) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif -cache_inspect.o: cache_inspect.cpp $(L1) - $(COMPILE) cache_inspect.cpp -mpi: COMPILATOR = mpic++ -mpi: EXE = cache_inspect_MPI -mpi: L1 = $(NOMAD_HOME)/lib/nomad.MPI.a -mpi: LIBS = $(L1) -lc -lm -mpi: COMPILATOR_OPTIONS += -DUSE_MPI -mpi: clean $(OBJS) - @echo " building the MPI version ..." - @echo " exe file : "$(EXE) - @$(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) - @strip $(EXE) +cache_inspect.o: cache_inspect.cpp + $(ECHO_NOMAD) + $(COMPILE) cache_inspect.cpp clean: @echo " cleaning obj files" diff --git a/tools/SENSITIVITY/detailed_analysis/makefile b/tools/SENSITIVITY/detailed_analysis/makefile index b067cc7b954c2f469e204c011e0d0cee69f80241..a9115acedecd7b91c53651b7be75e761e6b0fd8c 100644 --- a/tools/SENSITIVITY/detailed_analysis/makefile +++ b/tools/SENSITIVITY/detailed_analysis/makefile @@ -1,28 +1,38 @@ -EXE = detailed_analysis.exe -COMPILATOR = g++ -COMPILATOR_OPTIONS = -ansi -Wall -O2 -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lc -lm -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -OBJS = detailed_analysis.o +UNAME := $(shell uname) + +EXE = detailed_analysis.exe + +COMPILATOR = g++ +COMPILATOR_OPTIONS = -ansi -Wall -O2 + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif + +LDLIBS = -lm -lnomad + +INCLUDE = -I$(NOMAD_HOME)/src -I. + +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c + +OBJS = detailed_analysis.o $(EXE): $(OBJS) - $(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) + $(ECHO_NOMAD) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif -detailed_analysis.o: detailed_analysis.cpp $(L1) - $(COMPILE) detailed_analysis.cpp -mpi: COMPILATOR = mpic++ -mpi: EXE = detailed_analysis_MPI.exe -mpi: L1 = $(NOMAD_HOME)/lib/nomad.MPI.a -mpi: LIBS = $(L1) -lc -lm -mpi: COMPILATOR_OPTIONS += -DUSE_MPI -mpi: clean $(OBJS) - @echo " building the MPI version ..." - @echo " exe file : "$(EXE) - @$(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) - @strip $(EXE) +detailed_analysis.o: detailed_analysis.cpp + $(ECHO_NOMAD) + $(COMPILE) detailed_analysis.cpp clean: @echo " cleaning obj files" diff --git a/utils/DisplayCacheFile/Readme.txt b/utils/DisplayCacheFile/Readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..ad6122c91e5aa255fb46b789c9d4946fc205fcf7 --- /dev/null +++ b/utils/DisplayCacheFile/Readme.txt @@ -0,0 +1,20 @@ +A cache file from a different run of the same problem can be reused in a later optimization or to continue an optimization. +The code can display a binary cache file whose name is provided as first argument. + +Please note that binary cache files must be from the same OS. The provided cache.bin file has been created under OSX. + +1- Using the OS (linux and OSX) command line + +- On the command line execute the make command + +- Execute ./displayCache.exe cache.bin + +2- Using Matlab environment + +- If not already done, setup the mex Matlab External Interface with the command mex -setup at the command prompt. Please refer to Matlab documentation for details. + +- Change the Current Folder to %NOMAD_HOME%/utils/DisplayCacheFile + +- Run the command build.m + +- Run the command displayM(‘cache.bin’) diff --git a/utils/DisplayCacheFile/build.m b/utils/DisplayCacheFile/build.m new file mode 100644 index 0000000000000000000000000000000000000000..a23f2823b47c4cae88998f7e39a120b4c12e5133 --- /dev/null +++ b/utils/DisplayCacheFile/build.m @@ -0,0 +1,87 @@ +%% GERAD NOMAD Build for Matlab + +% This file will help you compile NOMAD for use with MATLAB. + +% To recompile you will need to get / do the following: + +% 1) Get NOMAD +% NOMAD is available from https://www.gerad.ca/nomad +% Complete the download form then download the latest version. Define the +% $NOMAD_HOME environment variable. + +% 2) Start Matlab and go into $NOMAD_HOME/examples/interfaces/Matlab_Mex +% The NOMAD MEX Interface is a simple MEX interface written to use NOMAD. + +% 3) Compile the MEX File +% The code below will build the NOMAD MEX file and set the Matlab path. + +clear nomad + +% Default library names +nameLibNomad = 'libnomad.so'; + +% Default update LDFLAGS +updateLDFLAGS= ''; + +% Current directory +cdir = cd; + +% Check and set nomad_home and create variables for path +clear nomad_home nomad_src; +nomad_home = getenv('NOMAD_HOME'); + + +if ( length(nomad_home)<1 ) +% Get a default directory for NOMAD_HOME +cd .. +cd .. +nomad_home = cd; + +if ( ~ exist(nomad_home,'dir') ) +error('The default NOMAD_HOME directory does not exist. Please provide a correct value for the NOMAD_HOME variables with the command setenv(''NOMAD_HOME'',ARG1)'); +end + +setenv('NOMAD_HOME',nomad_home); +warning('The NOMAD_HOME variable is set with its default value %s. The default can be replaced by using the command setenv(''NOMAD_HOME'',ARG1)! before runner the GERAD_NOMAD_build command.',nomad_home); +cd(cdir); +end +nomad_src=[nomad_home filesep 'src' filesep]; +nomad_lib=[nomad_home filesep 'lib' filesep]; +nomad_bin=[nomad_home filesep 'bin' filesep]; + +switch(computer) +case 'PCWIN' +libdir = ' -Lwin32\'; +nameLibNomad = 'nomad.dll'; +case 'PCWIN64' +libdir = ' -Lwin64\'; +nameLibNomad = 'nomad.dll'; +case 'GLNX86' +libdir = 'glnx86/'; +updateLDFLAGS = 'LDFLAGS=''$LDFLAGS -Wl,-rpath,''''$ORIGIN/../lib/'''' '' '; +case 'GLNXA64' +libdir = 'glnxa64/'; +updateLDFLAGS = 'LDFLAGS=''$LDFLAGS -Wl,-rpath,''''$ORIGIN/../lib/'''' '' '; +case 'MACI64' +libdir = 'maci64/'; +end + +%Get NOMAD Libraries +post = [' -I. -I' nomad_src ' -lm -lut -lnomad -L ' nomad_lib ' -output displayCacheM']; + +%Compile & Move +pre = ['mex -v -largeArrayDims ' updateLDFLAGS ' displayCacheM.cpp ' ]; + +try + eval([pre post]) + if ( strcmp(computer,'MACI64') ) + install_cmd = ['install_name_tool -change libnomad.so ' nomad_lib 'libnomad.so displayCacheM.mexmaci64' ]; + system(install_cmd); + end + clear nomad_home nomad_src cdir post pre libdir; + fprintf('Done!\n'); +catch ME + clear nomad_home nomad_src cdir post pre libdir; + error('opti:nomad','Error Compiling NOMAD!\n%s',ME.message); +end +fprintf('------------------------------------------------\n'); diff --git a/utils/DisplayCacheFile/cache1.bin b/utils/DisplayCacheFile/cache1.bin new file mode 100644 index 0000000000000000000000000000000000000000..d2bc763560c37723713a363869fd2c1189d04184 Binary files /dev/null and b/utils/DisplayCacheFile/cache1.bin differ diff --git a/utils/DisplayCacheFile/displayCache.cpp b/utils/DisplayCacheFile/displayCache.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ccc601003fe3629e978d3ab1eb663344bba6f9c5 --- /dev/null +++ b/utils/DisplayCacheFile/displayCache.cpp @@ -0,0 +1,66 @@ +/*-----------------------------------------------------*/ +/* how to use the NOMAD library with a user function */ +/*-----------------------------------------------------*/ +#include "nomad.hpp" +using namespace std; +// using namespace NOMAD; avoids putting NOMAD:: everywhere + + +/*------------------------------------------*/ +/* NOMAD main function */ +/*------------------------------------------*/ +int main ( int argc , char ** argv ) +{ + + // display: + NOMAD::Display out ( std::cout ); + out.precision ( NOMAD::DISPLAY_PRECISION_STD ); + + try + { + + // NOMAD initializations: + NOMAD::begin ( argc , argv ); + + if ( argc != 2 ) + { + out << "\n Provide a cache file name on the commande line" <<endl; + return EXIT_FAILURE; + } + + // parameters file: + std::string cache_file_name = argv[1]; + + NOMAD::Display out ( std::cout ); + out.precision ( NOMAD::DISPLAY_PRECISION_STD ); + + // parameters creation: + NOMAD::Cache cache1 ( out ); + + cache1.load(cache_file_name); + + const NOMAD::Eval_Point * cur = cache1.begin(); + int nb = cache1.size(); + int cnt = 0; + while ( cur ) + { + out << "point "; + out.display_int_w ( ++cnt , nb ); + out << "/" << nb << ": "; + cur->display_eval ( out , false ); + out << " obj=" << cur->get_f() << std::endl; + + cur = cache1.next(); + } + out.close_block(); + + + } + catch ( exception & e ) + { + cerr << "\n Cache display triggered an exception (" << e.what() << ")\n\n"; + } + + + return EXIT_SUCCESS; +} diff --git a/utils/DisplayCacheFile/displayCacheM.cpp b/utils/DisplayCacheFile/displayCacheM.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a431e77ba407fbd8e80f61d9eb4cbe284bbdbeaa --- /dev/null +++ b/utils/DisplayCacheFile/displayCacheM.cpp @@ -0,0 +1,89 @@ +/*-----------------------------------------------------*/ +/* Merge cache files from NOMAD */ +/*-----------------------------------------------------*/ +#include "mex.h" +#include "nomad.hpp" + +using namespace std; +// using namespace NOMAD; avoids putting NOMAD:: everywhere + + +struct printfbuf : std::streambuf { +public: + //Constructor + printfbuf() + { + setp(m_buffer, m_buffer + s_size - 2); + } +private: + enum { s_size = 1024 }; //not sure on this size + char m_buffer[s_size]; + int_type overflow(int_type c) + { + if (!traits_type::eq_int_type(c, traits_type::eof())) { + *pptr() = traits_type::to_char_type(c); + pbump(1); + } + return sync() != -1 ? traits_type::not_eof(c) : traits_type::eof(); + } + + int sync() { + *pptr() = 0; + mexPrintf(pbase()); + mexEvalString("drawnow;"); + setp(m_buffer, m_buffer + s_size - 2); + return 0; + } + }; + +// Main Entry Function +// ----------------------------------------------------------------- +void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) +{ + // display: + + + try + { + + if( nrhs != 1 || !mxIsChar(prhs[0]) ) + mexErrMsgTxt("You must supply the name of a cache file for display \n"); + + + char *cache_file_name_1 = NULL; + cache_file_name_1 = mxArrayToString(prhs[0]); + + printfbuf buf; + std::streambuf *cout_sbuf = std::cout.rdbuf(); //keep existing buffer + std::cout.rdbuf(&buf); //redirect buffer + + NOMAD::Display out ( std::cout ); + out.precision ( NOMAD::DISPLAY_PRECISION_STD ); + + // parameters creation: + NOMAD::Cache cache1 ( out ); + + cache1.load(cache_file_name_1); + + const NOMAD::Eval_Point * cur = cache1.begin(); + int nb = cache1.size(); + int cnt = 0; + while ( cur ) + { + out << "point "; + out.display_int_w ( ++cnt , nb ); + out << "/" << nb << ": "; + cur->display_eval ( out , false ); + out << std::endl; + cur = cache1.next(); + } + out.close_block(); + + + } + catch ( exception & e ) + { + cerr << "\n Cache display triggered an exception (" << e.what() << ")\n\n"; + } + +} diff --git a/utils/DisplayCacheFile/makefile b/utils/DisplayCacheFile/makefile new file mode 100644 index 0000000000000000000000000000000000000000..195338a268cb490019c55b41325520de0b5f8a20 --- /dev/null +++ b/utils/DisplayCacheFile/makefile @@ -0,0 +1,60 @@ +UNAME := $(shell uname) + +EXE = displayCache.exe + +COMPILATOR = g++ +COMPILATOR_OPTIONS = -O2 -ansi + +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,’$(LIB_DIR)’ +CXXFLAGS += -ansi +endif + +LDLIBS = -lm -lnomad + +INCLUDE = -I$(NOMAD_HOME)/src -I. +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c + +OBJS = displayCache.o + +ifndef NOMAD_HOME +define ECHO_NOMAD + @echo Please set NOMAD_HOME environment variable! + @false +endef +endif + + +$(EXE): $(OBJS) + $(ECHO_NOMAD) + @echo " building the executable "$(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif + + +displayCache.o: displayCache.cpp + $(ECHO_NOMAD) + @$(COMPILE) displayCache.cpp + + +all: $(EXE) + +clean: ; + @echo " cleaning obj files" + @rm -f $(OBJS) + +del: ; + @echo " cleaning trash files" + @rm -f core *~ + @echo " cleaning obj files" + @rm -f $(OBJS) + @echo " cleaning exe file" + @rm -f $(EXE) + + diff --git a/utils/MergeCacheFiles/build.m b/utils/MergeCacheFiles/build.m index 5017f5c810df31eeffe0b8e35cafc806a2a55aa6..9a1ce337401bb6723428f4b765a8ad0814cd9d0d 100644 --- a/utils/MergeCacheFiles/build.m +++ b/utils/MergeCacheFiles/build.m @@ -1,68 +1,83 @@ %% GERAD NOMAD Build for Matlab -% This file will help you compile NOMAD for use with MATLAB. +% This file will help you compile NOMAD for use with MATLAB. % To recompile you will need to get / do the following: % 1) Get NOMAD -% NOMAD is available from http://www.gerad.ca/NOMAD/PHP_Forms/Download.php. +% NOMAD is available from https://www.gerad.ca/nomad % Complete the download form then download the latest version. Define the % $NOMAD_HOME environment variable. -% 2) NOMAD MEX Interface +% 2) Start Matlab and go into $NOMAD_HOME/examples/interfaces/Matlab_Mex % The NOMAD MEX Interface is a simple MEX interface written to use NOMAD. % 3) Compile the MEX File -% The code below will build the NOMAD MEX file. Once you have completed all the -% above steps, simply run this file to compile NOMAD! You MUST BE in the -% base directory of OPTI! +% The code below will build the NOMAD MEX file and set the Matlab path. clear nomad +% Default library names +nameLibNomad = 'libnomad.so'; + +% Default update LDFLAGS +updateLDFLAGS= ''; + +% Current directory +cdir = cd; + +% Check and set nomad_home and create variables for path +clear nomad_home nomad_src; +nomad_home = getenv('NOMAD_HOME'); + + +if ( length(nomad_home)<1 ) +% Get a default directory for NOMAD_HOME +cd .. +cd .. +nomad_home = cd; + +if ( ~ exist(nomad_home,'dir') ) +error('The default NOMAD_HOME directory does not exist. Please provide a correct value for the NOMAD_HOME variables with the command setenv(''NOMAD_HOME'',ARG1)'); +end + +setenv('NOMAD_HOME',nomad_home); +warning('The NOMAD_HOME variable is set with its default value %s. The default can be replaced by using the command setenv(''NOMAD_HOME'',ARG1)! before runner the GERAD_NOMAD_build command.',nomad_home); +cd(cdir); +end +nomad_src=[nomad_home filesep 'src' filesep]; +nomad_lib=[nomad_home filesep 'lib' filesep]; +nomad_bin=[nomad_home filesep 'bin' filesep]; + switch(computer) case 'PCWIN' libdir = ' -Lwin32\'; -case 'PCWIN64' -libdir = ' -Lwin64\'; +nameLibNomad = 'nomad.dll'; +case 'PCWIN64' +libdir = ' -Lwin64\'; +nameLibNomad = 'nomad.dll'; case 'GLNX86' libdir = 'glnx86/'; +updateLDFLAGS = 'LDFLAGS=''$LDFLAGS -Wl,-rpath,''''$ORIGIN/../lib/'''' '' '; case 'GLNXA64' libdir = 'glnxa64/'; +updateLDFLAGS = 'LDFLAGS=''$LDFLAGS -Wl,-rpath,''''$ORIGIN/../lib/'''' '' '; case 'MACI64' libdir = 'maci64/'; end -clear nomad_home nomad_src; - - -fprintf('\n------------------------------------------------\n'); -fprintf('NOMAD CACHE MERGE BUILD \n\n'); - -nomad_home = getenv('NOMAD_HOME'); -if (length(nomad_home)<1) - error('opti:nomad','Please set NOMAD_HOME variables properly with the command setenv(''NOMAD_HOME'',ARG1)!'); -end -nomad_src=[nomad_home filesep 'src' filesep]; - - %Get NOMAD Libraries -post = [' -I. -I' nomad_src ' -lm -lut -output mergeM']; +post = [' -I. -I' nomad_src ' -lm -lut -lnomad -L ' nomad_lib ' -output mergeM']; %Compile & Move -pre = ['mex -v -largeArrayDims mergeM.cpp ' nomad_src 'Parameters.cpp ' nomad_src 'Barrier.cpp ' nomad_src 'Cache.cpp '... -nomad_src 'Cache_File_Point.cpp ' nomad_src 'Cache_Point.cpp ' nomad_src 'Cache_Search.cpp ' nomad_src 'Clock.cpp '... -nomad_src 'Direction.cpp ' nomad_src 'Directions.cpp ' nomad_src 'Display.cpp '... -nomad_src 'Double.cpp ' nomad_src 'Eval_Point.cpp ' nomad_src 'Evaluator.cpp ' nomad_src 'Evaluator_Control.cpp ' nomad_src 'Exception.cpp '... -nomad_src 'Extended_Poll.cpp ' nomad_src 'L_Curve.cpp ' nomad_src 'LH_Search.cpp ' nomad_src 'OrthogonalMesh.cpp ' nomad_src 'Mads.cpp ' nomad_src 'Model_Sorted_Point.cpp '... -nomad_src 'Model_Stats.cpp ' nomad_src 'Multi_Obj_Evaluator.cpp ' nomad_src 'Parameter_Entries.cpp '... -nomad_src 'Parameter_Entry.cpp ' nomad_src 'Pareto_Front.cpp ' nomad_src 'Pareto_Point.cpp ' nomad_src 'Phase_One_Evaluator.cpp '... -nomad_src 'Phase_One_Search.cpp ' nomad_src 'Point.cpp ' nomad_src 'Priority_Eval_Point.cpp ' nomad_src 'Quad_Model.cpp '... -nomad_src 'Quad_Model_Evaluator.cpp ' nomad_src 'Quad_Model_Search.cpp ' nomad_src 'Random_Pickup.cpp ' nomad_src 'RNG.cpp '... -nomad_src 'Signature.cpp ' nomad_src 'Slave.cpp ' nomad_src 'SMesh.cpp ' nomad_src 'Speculative_Search.cpp ' nomad_src 'Stats.cpp ' nomad_src 'utils.cpp '... -nomad_src 'Variable_Group.cpp ' nomad_src 'VNS_Search.cpp ' nomad_src 'XMesh.cpp']; +pre = ['mex -v -largeArrayDims ' updateLDFLAGS ' mergeM.cpp ' ]; try eval([pre post]) + if ( strcmp(computer,'MACI64') ) + install_cmd = ['install_name_tool -change libnomad.so ' nomad_lib 'libnomad.so mergeM.mexmaci64' ]; + system(install_cmd); + end clear nomad_home nomad_src cdir post pre libdir; fprintf('Done!\n'); catch ME diff --git a/utils/MergeCacheFiles/makefile b/utils/MergeCacheFiles/makefile index 965ba8105a4bf8fc936f37c522be06d3a831d0de..d86324c0c554d81a6b005bc16a6f6f37811cd31a 100644 --- a/utils/MergeCacheFiles/makefile +++ b/utils/MergeCacheFiles/makefile @@ -1,14 +1,25 @@ -EXE = merge.exe +UNAME := $(shell uname) -COMPILATOR = g++ +EXE = merge.exe -COMPILATOR_OPTIONS = -O2 -ansi -L1 = $(NOMAD_HOME)/lib/nomad.a -LIBS = $(L1) -lm -INCLUDE = -I$(NOMAD_HOME)/src -I. -COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c -OBJS = merge.o +COMPILATOR = g++ +COMPILATOR_OPTIONS = -O2 -ansi +LIB_DIR = $(NOMAD_HOME)/lib +LIB_NOMAD = libnomad.so + +CXXFLAGS = +ifeq ($(UNAME), Linux) +CXXFLAGS += -Wl,-rpath,'$(LIB_DIR)' +CXXFLAGS += -ansi +endif + +LDLIBS = -lm -lnomad + +INCLUDE = -I$(NOMAD_HOME)/src -I. +COMPILE = $(COMPILATOR) $(COMPILATOR_OPTIONS) $(INCLUDE) -c + +OBJS = merge.o ifndef NOMAD_HOME define ECHO_NOMAD @@ -18,33 +29,34 @@ endef endif -$(EXE): $(L1) $(OBJS) +$(EXE): $(OBJS) $(ECHO_NOMAD) @echo " building the scalar version ..." @echo " exe file : "$(EXE) - @$(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS) - @strip $(EXE) + @$(COMPILATOR) -o $(EXE) $(OBJS) $(LDLIBS) $(CXXFLAGS) -L$(LIB_DIR) +ifeq ($(UNAME), Darwin) + @install_name_tool -change $(LIB_NOMAD) $(NOMAD_HOME)/lib/$(LIB_NOMAD) $(EXE) +endif + merge.o: merge.cpp $(ECHO_NOMAD) @$(COMPILE) merge.cpp -$(L1) $(L1_MPI): ; - $(ECHO_NOMAD) -all: $(EXE) $(EXE_MPI) +all: $(EXE) clean: ; @echo " cleaning obj files" - @rm -f $(OBJS) $(OBJS_MPI) + @rm -f $(OBJS) del: ; @echo " cleaning trash files" @rm -f core *~ @echo " cleaning obj files" - @rm -f $(OBJS) $(OBJS_MPI) + @rm -f $(OBJS) @echo " cleaning exe file" - @rm -f $(EXE) $(EXE_MPI) + @rm -f $(EXE) diff --git a/utils/Run_TestSuite/readme.txt b/utils/Run_TestSuite/readme.txt index b99438f0531bd5743ceaed6c656580637fa88d84..d1205a489efd1808afc92c840b346e8d95e285d6 100644 --- a/utils/Run_TestSuite/readme.txt +++ b/utils/Run_TestSuite/readme.txt @@ -1,3 +1,5 @@ +The test script is for OSX and Linux only + 1- Set the NOMAD_HOME environment variable 2- Execute the perl script (perl ./runNomadAll_parallel.pl 4) 3- Check the execution logs if necessary \ No newline at end of file diff --git a/utils/Run_TestSuite/runNomadAll_parallel.pl b/utils/Run_TestSuite/runNomadAll_parallel.pl index f7be08fd0492c1c81cc8b1367a1081405220cb9c..dd90b38b949b46b47ba9e2cea8660392ade1e3b9 100755 --- a/utils/Run_TestSuite/runNomadAll_parallel.pl +++ b/utils/Run_TestSuite/runNomadAll_parallel.pl @@ -34,7 +34,7 @@ if ( grep(/MINGW/,<aComRes>) ){ $MPIcommand="mpirun -n"; # version OSX and linux } -my $keySearch=" Error | error | error: | Exception | NOMAD::Exception | Failed | Arrêt | Stop"; +my $keySearch=" Erreur | Error | error | error: | Exception | NOMAD::Exception | Failed | Arrêt | Stop"; my $nombre_de_jobs_en_parallele:shared; if ( ! exists $ARGV[0]) { @@ -78,8 +78,8 @@ my @list = ( # ["cd $ENV{NOMAD_HOME}/examples/interfaces/CUTEr ; sleep 10 ; if [ ! -e bb ] ; then ./compile 2>&1 ; fi ; $MPIcommand 3 $ENV{NOMAD_HOME}/bin/$nomadMPI_EXE parameters.txt 2>&1 "], # ["cd $ENV{NOMAD_HOME}/examples/interfaces/DLL/single_obj ; if [ -e nomad_for_dll ] ; then rm -f nomad_for_dll ; fi ; echo ; make 2>&1; ./nomad_for_dll parameters.txt 2>&1"], # ["cd $ENV{NOMAD_HOME}/examples/interfaces/DLL/bi_obj ; if [ -e nomad_for_dll ] ; then rm -f nomad_for_dll ; fi ; echo ; make clean 2>&1 ; make 2>&1; ./nomad_for_dll parameters.txt 2>&1"], -# ["cd $ENV{NOMAD_HOME}/examples/interfaces/FORTRAN/example1 ; if [ -e test ] ; then rm -f test ; fi ; make clean 2>&1 ; make 2>&1; ./test 2>&1"], -# ["cd $ENV{NOMAD_HOME}/examples/interfaces/FORTRAN/example2 ; if [ -e test ] ; then rm -f test ; fi ; make clean 2>&1 ; make 2>&1; ./test 2>&1"], +# ["cd $ENV{NOMAD_HOME}/examples/interfaces/FORTRAN/example1 ; if [ -e test.exe ] ; then rm -f test.exe ; fi ; make clean 2>&1 ; make 2>&1; ./test.exe 2>&1"], +# ["cd $ENV{NOMAD_HOME}/examples/interfaces/FORTRAN/example2 ; if [ -e test.exe ] ; then rm -f test.exe ; fi ; make clean 2>&1 ; make 2>&1; ./test.exe 2>&1"], ["cd $ENV{NOMAD_HOME}/tools/COOP-MADS ; if [ -e coopmads.exe ] ; then rm -f *.exe *.o ; fi ; make 2>&1 ; cd problems/G2_10 ; g++ -o bb.exe bb.cpp 2>&1; $MPIcommand 3 ../../coopmads.exe param.txt 2>&1"], ["cd $ENV{NOMAD_HOME}/tools/COOP-MADS ; sleep 10 ; if [ ! -e coopmads.exe ] ; then make 2>&1 ; fi ; cd problems/RHEOLOGY ; g++ -o bb.exe bb.cpp 2>&1; $MPIcommand 3 ../../coopmads.exe param.txt 2>&1"], ["cd $ENV{NOMAD_HOME}/tools/PSD-MADS ; if [ -e psdmads.exe ] ; then rm -f *.exe *.o ; fi ; make 2>&1 ; cd problems/G2_20 ; g++ -o bb.exe bb.cpp 2>&1; $MPIcommand 6 ../../psdmads.exe param.txt 50 5 2>&1"] @@ -127,7 +127,7 @@ sub RunProblem($$$$$){ print WRITE_LOG "Path to problem: $Path[1] \n Command: $Problem[$nmax] ; Managed as process $index \n"; open(LOG,"$command |") or die "Can't run program: $!\n"; if ($? != 0) { - print "Echec d'exécution de la commande $! du process $index \n"; + print "Failed execution: command $! du process $index \n"; $$failed_ref++; $fail=0; } @@ -135,7 +135,7 @@ sub RunProblem($$$$$){ @lines = <LOG>; foreach $line (@lines){ if (my @foo = grep(/$keySearch/, $line) ) { - print "????????? Probleme a l'execution de la commande du process $index :\n -----> @foo\n"; + print "????????? Problem executing command of process $index:\n -----> @foo\n"; print WRITE_LOG " !!!!!!!!!!!!!!! @foo \n "; $$failed_ref++; $fail=0; @@ -183,13 +183,13 @@ sub CompileNOMAD($$$){ print WRITE_LOG "Path: $Path[1] \n Command: $Problem[1] ; Managed as process $index \n"; open(LOG,"$command |") or die "Can't run program: $!\n"; if ($? != 0) { - print "Echec d'exécution de la compilation de NOMAD par la commande $! process $index \n"; + print "Failed compilation of NOMAD: command $! process $index \n"; $$failed=0; } else { while (<LOG>){ if (my @foo = grep(/error/, $_) ) { - print "??????? Probleme a la compilation de NOMAD dans le process $index:\n -----> @foo\n"; + print "??????? Problem encountered when compiling NOMAD in process $index:\n -----> @foo\n"; print WRITE_LOG " -----> @foo \n "; $$failed=0; last; @@ -213,44 +213,42 @@ sub CompileNOMAD($$$){ ##################################### # nettoie les fichiers de log print "########################################################\n"; -print "On nettoie les anciens fichiers de log \n"; +print "Cleaning old log files\n"; system ("rm -f log*.txt"); # démarre la compilation de nomad my $failedCompileNOMAD=1; my $thrNOMAD = threads->create("CompileNOMAD",($NOMADcompilations[0],1,\$failedCompileNOMAD)); ### Version parallele -#CompileNOMAD($NOMADcompilations[0],1,\$failedCompileNOMAD); ### Version scalaire print "########################################################\n"; -print "La compilation de NOMAD (non mpi) vient de commencer \n"; +print "NOMAD compilation (not mpi) started \n"; # démarre la compilation de nomad_mpi my $failedCompileNOMAD_MPI=1; my $thrNOMAD_MPI = threads->create("CompileNOMAD",($NOMADcompilations[1],2,\$failedCompileNOMAD_MPI)); ### Version parallele -#CompileNOMAD($NOMADcompilations[1],2,\$failedCompileNOMAD_MPI); ### Version scalaire -print "La compilation de NOMAD (mpi) vient de commencer \n"; +print "NOMAD compilation (mpi) started\n"; $thrNOMAD->join(); $thrNOMAD_MPI->join(); if ($failedCompileNOMAD==0){ - print "La compilation de NOMAD (non mpi) a echoue. On s'arrete la! \n"; + print "NOMAD compilation (not mpi) failed. Stopping here! \n"; } if ($failedCompileNOMAD_MPI==0){ - print "La compilation de NOMAD (mpi) a echoue. On s'arrete la! \n"; + print "NOMAD compilation (mpi) failed. Stoppinf here! \n"; } if ($failedCompileNOMAD==0 or $failedCompileNOMAD_MPI==0){ exit 0; } -print "Les compilations de nomad ont réussi \n"; +print "NOMAD compilation(s) success\n"; print "########################################################\n\n"; print "########################################################\n"; -print "Démarrage des executions en parallele pour les problemes \n"; +print "Starting parallel executions of problems \n"; print "########################################################\n"; @@ -265,7 +263,7 @@ while ($started < scalar @list ){ $semaphoreProblems->down(); # si le sémaphore est a 0, le processus principal va se bloquer en attendant une nouvelle place - print "Creation du job $started\n"; + print "Creating job $started\n"; my $thr = threads->create("RunProblem", ( $aRefToAListOfCommands, $started, @@ -281,24 +279,36 @@ while ($started < scalar @list ){ # $thr->join(); } +print "########################################################\n"; + # attend les derniers jobs +my $cpt_Prev = $cpt; +print "\n $cpt jobs completed for $started jobs started, patience!\n"; +# Disable buffering +$| = 1; while ($cpt < $started){ - print "Seul $cpt jobs finis sur $started, on patiente!\n"; + print "."; + if ( $cpt > $cpt_Prev) { + print "\n $cpt jobs completed for $started jobs started, patience!\n"; + } + $cpt_Prev = $cpt; sleep(3); } -print "$cpt jobs lances, $failed échoués, sur les ".scalar @list." prévus\n"; +print "\n $cpt jobs started, $failed jobs failed, ".scalar @list." jobs to be done\n"; + +print "########################################################\n"; if ($failed !=0) { print "-----> Check the readme file for the failed problem(s)!!! \n"; } -print "On combine tous les logs en un seul\n"; +print "All logs are combined in a single log file\n"; my $i=0; -open (LOGALL, '>', "logAll.txt") or die("impossible d'ecrire dans le fichier logAll.txt, $!"); +open (LOGALL, '>', "logAll.txt") or die("Not able to write in logAll.txt, $!"); while ($i < scalar @list ){ # incrémente le compteur $i++; - open (LOGI, '<', "log$i.txt") or die("Impossible de lire log$i.txt, $!\n"); + open (LOGI, '<', "log$i.txt") or die("Cannot read file log$i.txt, $!\n"); print LOGALL "*********************************************************\n"; while (my $Ligne = <LOGI> ) { print LOGALL $Ligne;