Skip to content
Snippets Groups Projects
Commit 6f7429e1 authored by Miroslav Shaltev's avatar Miroslav Shaltev
Browse files

initial commit using version 3.6.1

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 1471 additions and 0 deletions
0.000003386085788 , 1.008728922870000
0.000019670074741 , 1.007008946530000
0.000043321197788 , 1.003346798220000
0.000055146759311 , 1.001515713100000
0.000412202423374 , 1.000168579010000
0.026361299103100 , 0.999417828419000
0.037298799103100 , 0.971193297624000
0.049798799103100 , 0.952888513699000
0.057516694610900 , 0.939627014162000
0.058066011017100 , 0.939279825502000
0.059530854767100 , 0.938397674429000
0.062298799103100 , 0.936476038312000
0.070016694610900 , 0.926328031323000
0.070566011017100 , 0.926257348515000
0.072030854767100 , 0.926146239956000
0.074798799103100 , 0.925810984616000
0.077923799103100 , 0.924446768097000
0.079391694610900 , 0.921354188974000
0.082516694610900 , 0.920899117277000
0.487737184651000 , 0.910745455889000
0.487949281819000 , 0.909694407586000
0.488112550862000 , 0.908345982011000
0.488274675496000 , 0.906790979940000
0.488286501057000 , 0.904377988162000
0.488469606526000 , 0.902246153443000
0.489763551839000 , 0.885184702360000
0.490129762776000 , 0.882461841268000
0.490862184651000 , 0.871479999785000
0.491237550862000 , 0.868932146461000
0.491411501057000 , 0.864889414962000
0.491594606526000 , 0.862684681619000
0.494060426839000 , 0.834070197321000
0.495622926839000 , 0.830423802060000
0.497185426839000 , 0.792646115782000
0.498747926839000 , 0.788649180792000
0.500310426839000 , 0.750496780197000
0.501872926839000 , 0.746268489973000
0.503044801839000 , 0.734519523596000
0.503435426839000 , 0.707861697574000
0.504997926839000 , 0.703524372925000
0.508122926839000 , 0.660664615203000
0.511247926839000 , 0.617940596443000
0.512810426839000 , 0.579516317365000
0.515935426839000 , 0.537428151222000
0.528435426839000 , 0.475053320715000
0.533122926839000 , 0.343799077427000
0.545622926839000 , 0.227570694550000
0.548747926839000 , 0.205183552171000
0.551872926839000 , 0.185794223390000
0.554997926839000 , 0.169538118935000
0.556169801839000 , 0.168710185983000
0.558122926839000 , 0.156532011729000
0.561247926839000 , 0.146873085688000
0.767497926839000 , 0.111738954878000
0.770622926839000 , 0.051986336888700
0.773747926839000 , -0.005857658718170
0.790935426839000 , -0.176915342991000
0.795622926839000 , -0.329837896871000
0.815935426839000 , -0.349422398496000
0.820622926839000 , -0.448016426790000
######################################
# Deb, Discontinuous, alpha=2, q=4 #
######################################
DIMENSION 2
display_degree 4
TMP_DIR /tmp
BB_EXE bb.exe
BB_OUTPUT_TYPE OBJ OBJ
x0 ( 0.51 0.51 )
#vns_search yes
#initial_mesh_size r0.01
lower_bound * 0.0
upper_bound * 1.0
DIRECTION_TYPE ORTHO
#MAX_BB_EVAL 5
MULTI_OVERALL_BB_EVAL 500
#MULTI_NB_MADS_RUNS 0
#MULTI_USE_DELTA_CRIT yes
# f1_min f1_max f2_min f2_max
MULTI_F_BOUNDS 0.0 2.0 -1.0 10.0
ADD_SEED_TO_FILE_NAMES no
STATS_FILE front.txt OBJ,
#HISTORY_FILE history.txt
This example illustrates an application of the NOMAD library in order to graphically represent the outputs of an execution. It must not be considered as a graphical user interface of the code, as it is very simple and incomplete for such a purpose. The objective of this example is simply to illustrate a library usage of NOMAD and some links that can be made with another language such as JAVA.
The example has been developed by Quentin Reynaud from ISIMA. It has been tested on a MAC with the C++ and JAVA compilers included in the XCODE package.
The example is composed of two programs: The first is a JAVA application that runs in background and periodically checks NOMAD outputs in order to draw them. The other program uses the NOMAD library in order to optimize single or bi-objective problems and to communicate outputs to the JAVA application.
Open a console, and from the plot directory, go to GUI/src. Compile the JAVA code with the command 'javac *.java'. This generates .class files that you have to move in plot/GUI/bin. Go to this last directory, and execute the JAVA application in the background with the command 'java Prog'.
To execute the NOMAD code associated with the JAVA graphical interface, go to the plot directory and compile with 'make' (NOMAD must be installed and the $NOMAD_HOME environment variable must be defined).
This generates the executable file 'nomad_plot.exe', and you can run it on the two test problems located in the plot/problems directory.
For examples, type './nomad_plot.exe ./problems/01/param_single_obj.txt' to execute on a single-objective problem. Try also the bi-objective version of the same problem with the parameters file param_bi_obj, or 02 instead of 01 for another bi-objective execution. Black-box executables must have been compiled beforehand with command 'g++ -o bb.exe bb.cpp'.
\ No newline at end of file
Explication programme java
Le main est situé dans la classe Prog.
Prog :
On attend de trouver le fichier init qui est créé par le c++, puis on crée la fenêtre ( le fichier init contient 0 ou 1 selon qu'on soit en simple ou bi-objectif).
Ensuite on attend de trouver le fichier in.txt qui contient les coordonnées du ou des nouveaux points.
Une fois qu'elles sont lues on renomme ce fichier en out.txt (pour que le c++ sache qu'il peut envoyer les suivants).
Les points lus sont ajoutés dans des vecteurs de points.
Une fois que les nouveaux points sont ajoutés on met à jour la fenêtre.
Fenetre :
La fenêtre est une JFrame, dont les settings de base ne devraient pas te poser de problèmes...
On a laissé la possibilité à l'utilisateur de spécifier une résolution initiale dans le fichier résolution. Sinon la fenetre est en 600 par 400.
Graph :
C'est un Jpanel à l'intérieur duquel on dessine tout.
Le constructeur est surchargé, selon qu'on soit au moment de la création de la fenetre (il faut dessiner un repère vide), en mode simple objectif(il faut ajouter un point), ou bi-objectif(on ajoute un ensemble de points).
Une fois que l'ajout a été effectué on se sert de la méthode calcul qui calcule le système de coordonnées (selon les points présents).
Puis on re dessine la fenetre (pour que le ou les nouveaux points soient présents et que le nouveau système de coordonnée soit mis en place).
Dans le cas du bi-objectif, il faut également trouver les points "extrêmes", c'est-à-dire les points dont les ordonnées ou abscisses sont les plus grande/petite, afin de connaitre la distance que notre système de coordonnées doit pouvoir couvrir.
La méthode calcul : longue et fastidieuse.
La méthode arrondi : une méthode inutile, mais je n'ai pas trouvé comment faire autrement. Elle sert uniquement lors de l'affichage des coordonnées le long des axes. Si je n'arrondis pas les nombres avec cette méthode il ne s'affichent pas correctement (1,9997 au lieu de 2.0 par exemple).
PaintComponent :
C'est lui qui gère tout l'affichage du JPanel, et donc de la fenêtre.
Il trace les axes, leurs noms(sous forme d'images), les graduations des axes, les flèches au bout des axes, les valeurs des graduations, les points, les zones permettant l'affichage de la petite boite d'information, et la fonction en escalier.
Cette méthode est appelé lors de chaque dessin de la fenêtre.
Zone :
Permet de repérer l'arrivée de la souris dans la zone, et son départ. Lors de son arrivée elle déclenche l'affichage de la petite boite de dialogue indiquant les coordonnées du point, et sa coloration en rouge.
Voilà, c'est un peu rapide, j'espère que ça te suffira :o)
quentin
600
400
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++
endif
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 = restart.o
OBJS_MPI = restart_MPI.o
ifndef NOMAD_HOME
define ECHO_NOMAD
@echo Please set NOMAD_HOME environment variable!
@false
endef
endif
$(EXE): $(L1) $(OBJS)
$(ECHO_NOMAD)
@echo " building the scalar version ..."
@echo " exe file : "$(EXE)
@$(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS)
@strip $(EXE)
$(EXE_MPI): $(L1_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)
restart.o: restart.cpp
$(ECHO_NOMAD)
@$(COMPILE) restart.cpp
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)
clean: ;
@echo " cleaning obj files"
@rm -f $(OBJS) $(OBJS_MPI)
del: ;
@echo " cleaning trash files"
@rm -f core *~
@echo " cleaning obj files"
@rm -f $(OBJS) $(OBJS_MPI)
@echo " cleaning exe file"
@rm -f $(EXE) $(EXE_MPI)
/*--------------------------------------------------------------------------*/
/* example of a program that makes NOMAD restarts after failed iterations */
/*--------------------------------------------------------------------------*/
#include "nomad.hpp"
using namespace std;
using namespace NOMAD;
/*----------------------------------------*/
/* the problem */
/*----------------------------------------*/
class My_Evaluator : public Evaluator {
private:
double _mesh_update_basis;
int _initial_mesh_index;
int _mesh_index;
Point _initial_mesh_size;
public:
My_Evaluator ( const Parameters & p ) :
Evaluator ( p ) ,
_mesh_update_basis ( p.get_mesh_update_basis().value() ) ,
_initial_mesh_index ( p.get_initial_mesh_index() ) ,
_mesh_index ( _initial_mesh_index ) ,
_initial_mesh_size ( p.get_initial_mesh_size() ) {}
~My_Evaluator ( void ) {}
int get_mesh_index ( void ) const { return _mesh_index; }
void get_mesh_size ( Point & mesh_size ) const
{
Mesh::get_delta_m ( mesh_size ,
_initial_mesh_size ,
_mesh_update_basis ,
_initial_mesh_index ,
_mesh_index );
}
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
{
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 )
{
_mesh_index = Mesh::get_mesh_index();
if ( success == UNSUCCESSFUL )
stop = true;
}
/*------------------------------------------*/
/* NOMAD main function */
/*------------------------------------------*/
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 ( FULL_DISPLAY );
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();
// 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 < 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);
// initial mesh:
p.set_INITIAL_MESH_INDEX ( ev.get_mesh_index() );
Point initial_mesh_size;
ev.get_mesh_size ( initial_mesh_size );
p.set_INITIAL_MESH_SIZE ( initial_mesh_size );
// parameters validation:
p.check();
// reset the Mads object:
mads.reset ( true , true );
}
// 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;
}
MADS run #0 {
MADS run {
BBE ( SOL ) OBJ
2 ( 1.1000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 ) 275.2281000000 (PhaseOne)
3 ( 4.4000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 ) 0.0000000000 (PhaseOne)
3 ( 4.4000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 ) 0.0000000000
9 ( 4.4000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 ) 0.0000000000
} end of run (terminated by the user inside Evaluator::update_iteration())
blackbox evaluations : 9
best feasible solution : ( 4.4 0 0 0 0 ) h=0 f=0
}
MADS run #1 {
MADS run {
BBE ( SOL ) OBJ
9 ( 4.4000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 ) 0.0000000000
15 ( 4.4000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 ) 0.0000000000
} end of run (terminated by the user inside Evaluator::update_iteration())
blackbox evaluations : 15
best feasible solution : ( 4.4 0 0 0 0 ) h=0 f=0
}
MADS run #2 {
MADS run {
BBE ( SOL ) OBJ
15 ( 4.4000000000 -0.6000000000 0.0000000000 0.0000000000 0.0000000000 ) 0.0000000000
16 ( 4.5375000000 -0.1500000000 0.4875000000 0.7500000000 -1.5000000000 ) -1.5000000000
23 ( 4.5375000000 -0.1500000000 0.4875000000 0.7500000000 -1.5000000000 ) -1.5000000000
} end of run (terminated by the user inside Evaluator::update_iteration())
blackbox evaluations : 23
best feasible solution : ( 4.5375 -0.15 0.4875 0.75 -1.5 ) h=0 f=-1.5
}
MADS run #3 {
MADS run {
BBE ( SOL ) OBJ
23 ( 4.5375000000 -0.7500000000 0.4875000000 0.7500000000 -1.5000000000 ) -1.5000000000
30 ( 4.1250000000 -0.9750000000 0.3250000000 0.7500000000 -2.2500000000 ) -2.2500000000
38 ( 4.1250000000 -0.9750000000 0.3250000000 0.7500000000 -2.2500000000 ) -2.2500000000
} end of run (terminated by the user inside Evaluator::update_iteration())
blackbox evaluations : 38
best feasible solution : ( 4.125 -0.975 0.325 0.75 -2.25 ) h=0 f=-2.25
}
MADS run #4 {
MADS run {
BBE ( SOL ) OBJ
38 ( 3.5750000000 -0.9750000000 0.3250000000 0.7500000000 -2.2500000000 ) -2.2500000000
44 ( 3.5750000000 -0.9750000000 0.3250000000 0.7500000000 -2.2500000000 ) -2.2500000000
} end of run (terminated by the user inside Evaluator::update_iteration())
blackbox evaluations : 44
best feasible solution : ( 3.575 -0.975 0.325 0.75 -2.25 ) h=0 f=-2.25
}
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++
endif
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 = user_search.o
OBJS_MPI = user_search_MPI.o
ifndef NOMAD_HOME
define ECHO_NOMAD
@echo Please set NOMAD_HOME environment variable!
@false
endef
endif
$(EXE): $(L1) $(OBJS)
$(ECHO_NOMAD)
@echo " building the scalar version ..."
@echo " exe file : "$(EXE)
@$(COMPILATOR) -o $(EXE) $(OBJS) $(LIBS) $(COMPILATOR_OPTIONS)
@strip $(EXE)
$(EXE_MPI): $(L1_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)
user_search.o: user_search.cpp
$(ECHO_NOMAD)
@$(COMPILE) user_search.cpp
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)
clean: ;
@echo " cleaning obj files"
@rm -f $(OBJS) $(OBJS_MPI)
del: ;
@echo " cleaning trash files"
@rm -f core *~
@echo " cleaning obj files"
@rm -f $(OBJS) $(OBJS_MPI)
@echo " cleaning exe file"
@rm -f $(EXE) $(EXE_MPI)
MADS search {
user search {
list of points evaluation (user search) {
evaluation 1/1 {
point #1 ( 0.132741232 )
user search dominating point #1 {
x = ( 0.132741232 )
F(x) = [ 0.26237486 ]
h = 0
f = 0.26237486
}
}
} end of evaluations
} end of user search (dominating)
} end of search
MADS search {
user search {
list of points evaluation (user search) {
evaluation 1/1 {
point #2 ( 0.061929856 )
user search dominating point #2 {
x = ( 0.061929856 )
F(x) = [ 0.1235432615 ]
h = 0
f = 0.1235432615
}
}
} end of evaluations
} end of user search (dominating)
} end of search
MADS search {
user search {
list of points evaluation (user search) {
evaluation 1/1 {
point #3 ( 0.052807552 )
user search dominating point #3 {
x = ( 0.052807552 )
F(x) = [ 0.1054188653 ]
h = 0
f = 0.1054188653
}
}
} end of evaluations
} end of user search (dominating)
} end of search
MADS search {
user search {
list of points evaluation (user search) {
evaluation 1/1 {
point #4 ( 0.003343488002 )
user search dominating point #4 {
x = ( 0.003343488002 )
F(x) = [ 0.006686926169 ]
h = 0
f = 0.006686926169
}
}
} end of evaluations
} end of user search (dominating)
} end of search
MADS search {
user search {
list of points evaluation (user search) {
evaluation 1/1 {
point #5 ( 0.003046400592 )
user search dominating point #5 {
x = ( 0.003046400592 )
F(x) = [ 0.006092763488 ]
h = 0
f = 0.006092763488
}
}
} end of evaluations
} end of user search (dominating)
} end of search
MADS search {
user search {
list of points evaluation (user search) {
evaluation 1/1 {
point #6 ( 0.002265794838 )
user search dominating point #6 {
x = ( 0.002265794838 )
F(x) = [ 0.004531574165 ]
h = 0
f = 0.004531574165
}
}
} end of evaluations
} end of user search (dominating)
} end of search
MADS search {
user search {
list of points evaluation (user search) {
evaluation 1/1 {
point #7 ( 0.001481318181 )
user search dominating point #7 {
x = ( 0.001481318181 )
F(x) = [ 0.002962632027 ]
h = 0
f = 0.002962632027
}
}
} end of evaluations
} end of user search (dominating)
} end of search
MADS search {
user search {
list of points evaluation (user search) {
evaluation 1/1 {
point #8 ( 0.001371090082 )
user search dominating point #8 {
x = ( 0.001371090082 )
F(x) = [ 0.002742176728 ]
h = 0
f = 0.002742176728
}
}
} end of evaluations
} end of user search (dominating)
} end of search
MADS search {
user search {
list of points evaluation (user search) {
evaluation 1/1 {
point #9 ( 0.0008957599348 )
user search dominating point #9 {
x = ( 0.0008957599348 )
F(x) = [ 0.001791518911 ]
h = 0
f = 0.001791518911
}
}
} end of evaluations
} end of user search (dominating)
} end of search
/*-------------------------------------------------------------------------------------*/
/* example of a user search for the periodic function f(x)=sin(2x) */
/*-------------------------------------------------------------------------------------*/
#include "nomad.hpp"
using namespace std;
using namespace NOMAD;
const double PI = 3.141592654;
/*------------------------------------------------*/
/* The problem */
/*------------------------------------------------*/
/* n=1, m=1 */
/* the periodic function f(x)=sin(2x) */
/*------------------------------------------------*/
class My_Evaluator : public Evaluator {
public:
// ctor:
My_Evaluator ( const Parameters & p ) :
Evaluator ( p ) {}
// dtor:
~My_Evaluator ( void ) {}
// evaluation of a point:
bool eval_x ( Eval_Point & x ,
const NOMAD::Double & h_max ,
bool & count_eval ) const {
x.set_bb_output ( 0 , sin ( 2*x[0].value() ) );
count_eval = true;
return true;
}
};
/*------------------------------------------------*/
/* user search */
/*------------------------------------------------*/
class My_Search : public Search {
public:
// ctor:
My_Search ( Parameters & p )
: Search ( p , USER_SEARCH ) {}
// dtor:
~My_Search ( void ) {}
// the search:
void search ( Mads & mads ,
int & nb_search_pts ,
bool & stop ,
stop_type & stop_reason ,
success_type & success ,
bool & count_search ,
const Eval_Point *& new_feas_inc ,
const Eval_Point *& new_infeas_inc );
};
/*-------------------*/
/* the user search */
/*-------------------*/
void My_Search::search ( Mads & mads ,
int & nb_search_pts ,
bool & stop ,
stop_type & stop_reason ,
success_type & success ,
bool & count_search ,
const Eval_Point *& new_feas_inc ,
const Eval_Point *& new_infeas_inc ) {
nb_search_pts = 0;
success = UNSUCCESSFUL;
count_search = false;
// current feasible incumbent:
const Eval_Point * feas_inc = mads.get_best_feasible();
if ( !feas_inc )
return;
// xk:
double xk = (*feas_inc)[0].value();
if ( xk < 0 )
return;
// get a signature:
Signature * signature = feas_inc->get_signature();
if ( !signature )
return;
// count the search:
count_search = true;
// construct the search point (tk = qk.xk - 1):
Eval_Point * tk = new Eval_Point;
tk->set ( 1 , 1 );
tk->set_signature ( signature );
(*tk)[0] = static_cast<int>(ceil(1.0/xk)) * xk - 1.0;
// Evaluator_Control:
Evaluator_Control & ev_control = mads.get_evaluator_control();
// add the new point to the ordered list of search trial points:
ev_control.add_eval_point ( tk ,
_p.out().get_search_dd() ,
false ,
Double() ,
Double() ,
Double() ,
Double() );
nb_search_pts = 1;
// evaluation:
new_feas_inc = new_infeas_inc = NULL;
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 );
}
/*------------------------------------------*/
/* NOMAD main function */
/*------------------------------------------*/
int main ( int argc , char ** argv ) {
// NOMAD initializations:
begin ( argc , argv );
// display:
Display out ( std::cout );
out.precision ( DISPLAY_PRECISION_STD );
// parameters creation:
Parameters p ( out );
p.set_DIMENSION (1); // number of variables
vector<bb_output_type> bbot (1); // definition of
bbot[0] = OBJ; // output types
p.set_BB_OUTPUT_TYPE ( bbot );
p.set_X0 ( Point ( 1 , PI-3.0 ) ); // starting point
p.set_LOWER_BOUND ( Point ( 1 , -PI/2.0 ) );
p.set_UPPER_BOUND ( Point ( 1 , PI/2.0 ) );
p.set_SPECULATIVE_SEARCH ( false );
p.set_INITIAL_MESH_SIZE ( 1.0 );
p.set_MESH_UPDATE_BASIS ( 2.0 );
p.set_MESH_COARSENING_EXPONENT ( 0 );
p.set_DISPLAY_DEGREE ( "0300" ); // display only the search step
p.set_DISPLAY_STATS ( "bbe sol obj" );
p.set_MAX_BB_EVAL ( 10 );
// parameters validation:
p.check();
// custom evaluator creation:
My_Evaluator ev ( p );
// algorithm creation:
Mads mads ( p , &ev );
// user search:
My_Search my_search ( p );
mads.set_user_search ( &my_search );
// algorithm execution:
mads.run();
Slave::stop_slaves ( out );
end();
return EXIT_SUCCESS;
}
// Deb Discontinuous, alpha=2, q=4
#include <cmath>
#include <string>
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
#define ALPHA 2.0
#define Q 4.0
#define PIT2 6.2831853071796
int main ( int argc , char ** argv ) {
double x1 , x2;
if ( argc == 2 ) {
ifstream in ( argv[1] );
in >> x1 >> x2;
if ( in.fail() ) {
cout << 1e20 << " " << 1e20 << endl;
in.close();
return 1;
}
in.close();
}
else if ( argc == 3 ) {
x1 = atof(argv[1]);
x2 = atof(argv[2]);
}
else {
cout << 1e20 << " " << 1e20 << endl;
return 1;
}
double f1 = x1;
double g = 1 + 10.0 * x2;
double f1g = f1 / g;
double f2 = g - g * pow(f1g,ALPHA) - f1 * sin ( PIT2 * Q * f1 );
cout.precision(12);
cout << f1 << " " << f2 << endl;
return 0;
}
######################################
# Deb, Discontinuous, alpha=2, q=4 #
######################################
DIMENSION 2
DISPLAY_DEGREE 2
BB_EXE bb.exe
BB_OUTPUT_TYPE OBJ OBJ
x0 ( 0.51 0.51 )
lower_bound * 0.0
upper_bound * 1.0
MULTI_OVERALL_BB_EVAL 500
# ADD_SEED_TO_FILE_NAMES no
# STATS_FILE front.txt OBJ
# HISTORY_FILE history.txt
DISPLAY_STATS BBE ( SOL ) OBJ
# TMP_DIR /tmp # indicates a repertory where
# temporary files are put
# (increases performance by ~100%
# if you're working on a network
# account and if TMP_DIR is on a
# local disk)
fid = fopen ( 'front.txt','r');
X=fscanf(fid,'%f%f');
fclose(fid);
X=reshape(X,2,length(X)/2);
X=X';
hold on;
% 1 - x - x^2 * sin(8 Pi x)
x=(0:0.0001:1);
fx = 1 - x.^2 - x .* sin(8 .* 3.1415926 .* x);
plot( x , fx , 'b-' );
plot( X(:,1) , X(:,2) , 'rx' );
axis([0 1 -1 9]);
hold off;
\ No newline at end of file
NOMAD - version 3.6.1 - www.gerad.ca/nomad
Copyright (C) 2001-2013 {
Mark A. Abramson - The Boeing Company
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.
License : '$NOMAD_HOME/src/lgpl.txt'
User guide: '$NOMAD_HOME/doc/user_guide.pdf'
Examples : '$NOMAD_HOME/examples'
Tools : '$NOMAD_HOME/tools'
Please report bugs to nomad@gerad.ca
multi-MADS run {
MADS run 1 ...... OK [bb eval= 64] [overall bb eval= 64] [# dominant pts= 5] [# new pts= 5] [f1=0 f2=8.036326991]
MADS run 2 ...... OK [bb eval= 32] [overall bb eval= 96] [# dominant pts= 12] [# new pts= 7] [f1=0.5676487984 f2=0.1148721239]
MADS run 3 ...... OK [bb eval= 32] [overall bb eval= 128] [# dominant pts= 15] [# new pts= 3] [f1=0 f2=1]
MADS run 4 ...... OK [bb eval= 32] [overall bb eval= 160] [# dominant pts= 25] [# new pts= 10] [f1=0.08125 f2=0.9210041574]
MADS run 5 ...... OK [bb eval= 32] [overall bb eval= 192] [# dominant pts= 37] [# new pts= 12] [f1=0.5164769234 f2=0.5254339031]
MADS run 6 ...... OK [bb eval= 32] [overall bb eval= 224] [# dominant pts= 51] [# new pts= 14] [f1=0.4954991402 f2=0.8104114832]
MADS run 7 ...... OK [bb eval= 32] [overall bb eval= 256] [# dominant pts= 58] [# new pts= 7] [f1=0.4887608589 f2=0.8973446571]
MADS run 8 ...... OK [bb eval= 32] [overall bb eval= 288] [# dominant pts= 65] [# new pts= 7] [f1=0.4876866402 f2=0.9106878852]
MADS run 9 ...... OK [bb eval= 32] [overall bb eval= 320] [# dominant pts= 71] [# new pts= 6] [f1=0.08327636719 f2=0.9208860571]
MADS run 10 ...... OK [bb eval= 32] [overall bb eval= 352] [# dominant pts= 77] [# new pts= 6] [f1=0.08300170898 f2=0.9208857342]
MADS run 11 ...... OK [bb eval= 32] [overall bb eval= 384] [# dominant pts= 83] [# new pts= 6] [f1=0.08300170898 f2=0.9208857342]
MADS run 12 ...... OK [bb eval= 32] [overall bb eval= 416] [# dominant pts= 93] [# new pts= 10] [f1=0.4872792305 f2=0.9157055455]
MADS run 13 ...... OK [bb eval= 32] [overall bb eval= 448] [# dominant pts= 100] [# new pts= 7] [f1=0.487021357 f2=0.9188689839]
MADS run 14 ...... OK [bb eval= 32] [overall bb eval= 480] [# dominant pts= 108] [# new pts= 8] [f1=0.4869359077 f2=0.9202170697]
MADS run 15 ...... OK [bb eval= 20] [overall bb eval= 500] [# dominant pts= 112] [# new pts= 4] [f1=0.08319091797 f2=0.9208854025]
} end of run (max number of bb evaluations)
blackbox evaluations : 500
number of MADS runs : 15
Pareto front {
BBE ( 0.0000000000 0.0000000000 ) 0.0000000000 1.0000000000
BBE ( 0.0000962840 0.0000000000 ) 0.0000962840 0.9999997577
BBE ( 0.0003906250 0.0000000000 ) 0.0003906250 0.9999960125
BBE ( 0.0031250000 0.0000000000 ) 0.0031250000 0.9997450497
BBE ( 0.0046875000 0.0000000000 ) 0.0046875000 0.9994270708
BBE ( 0.0250000000 0.0000000000 ) 0.0250000000 0.9846803687
BBE ( 0.0500000000 0.0000000000 ) 0.0500000000 0.9499471742
BBE ( 0.0546875000 0.0000000000 ) 0.0546875000 0.9433725823
BBE ( 0.0580017090 0.0000000000 ) 0.0580017090 0.9390043666
BBE ( 0.0582763672 0.0000000000 ) 0.0582763672 0.9386555226
BBE ( 0.0593750000 0.0000000000 ) 0.0593750000 0.9372826427
BBE ( 0.0625000000 0.0000000000 ) 0.0625000000 0.9335937500
BBE ( 0.0687500000 0.0000000000 ) 0.0687500000 0.9273698641
BBE ( 0.0705017090 0.0000000000 ) 0.0705017090 0.9259486581
BBE ( 0.0707763672 0.0000000000 ) 0.0707763672 0.9257399750
BBE ( 0.0718750000 0.0000000000 ) 0.0718750000 0.9249448963
BBE ( 0.0734375000 0.0000000000 ) 0.0734375000 0.9239266272
BBE ( 0.0750000000 0.0000000000 ) 0.0750000000 0.9230457613
BBE ( 0.0765625000 0.0000000000 ) 0.0765625000 0.9223079094
BBE ( 0.0767517090 0.0000000000 ) 0.0767517090 0.9222285264
BBE ( 0.0770263672 0.0000000000 ) 0.0770263672 0.9221171830
BBE ( 0.0781250000 0.0000000000 ) 0.0781250000 0.9217183959
BBE ( 0.0796875000 0.0000000000 ) 0.0796875000 0.9212822432
BBE ( 0.0798767090 0.0000000000 ) 0.0798767090 0.9212400670
BBE ( 0.0799804688 0.0000000000 ) 0.0799804688 0.9212179253
BBE ( 0.0800781250 0.0000000000 ) 0.0800781250 0.9211977263
BBE ( 0.0801513672 0.0000000000 ) 0.0801513672 0.9211829851
BBE ( 0.0812500000 0.0000000000 ) 0.0812500000 0.9210041574
BBE ( 0.0817016602 0.0000000000 ) 0.0817016602 0.9209538533
BBE ( 0.0818115234 0.0000000000 ) 0.0818115234 0.9209436812
BBE ( 0.0821777344 0.0000000000 ) 0.0821777344 0.9209156366
BBE ( 0.0825134277 0.0000000000 ) 0.0825134277 0.9208978855
BBE ( 0.0825927734 0.0000000000 ) 0.0825927734 0.9208948063
BBE ( 0.0827270508 0.0000000000 ) 0.0827270508 0.9208905705
BBE ( 0.0828674316 0.0000000000 ) 0.0828674316 0.9208874553
BBE ( 0.0830017090 0.0000000000 ) 0.0830017090 0.9208857342
BBE ( 0.0830135345 0.0000000000 ) 0.0830135345 0.9208856417
BBE ( 0.0830490112 0.0000000000 ) 0.0830490112 0.9208854215
BBE ( 0.0831909180 0.0000000000 ) 0.0831909180 0.9208854025
BBE ( 0.4868870796 0.0000000000 ) 0.4868870796 0.9205123238
BBE ( 0.4868992866 0.0000061035 ) 0.4868992866 0.9204385441
BBE ( 0.4869359077 0.0000244141 ) 0.4869359077 0.9202170697
BBE ( 0.4870213570 0.0000000000 ) 0.4870213570 0.9188689839
BBE ( 0.4870335640 0.0000061035 ) 0.4870335640 0.9187949686
BBE ( 0.4871007027 0.0000000000 ) 0.4871007027 0.9178966625
BBE ( 0.4871129097 0.0000000000 ) 0.4871129097 0.9177469920
BBE ( 0.4871617378 0.0000000000 ) 0.4871617378 0.9171480902
BBE ( 0.4872052254 0.0000177383 ) 0.4872052254 0.9168338789
BBE ( 0.4872288765 0.0000000000 ) 0.4872288765 0.9163240271
BBE ( 0.4872777046 0.0000000000 ) 0.4872777046 0.9157242928
BBE ( 0.4872792305 0.0000000000 ) 0.4872792305 0.9157055455
BBE ( 0.4872960152 0.0000000000 ) 0.4872960152 0.9154993024
BBE ( 0.4873021187 0.0000030518 ) 0.4873021187 0.9154620588
BBE ( 0.4873078407 0.0000000000 ) 0.4873078407 0.9153539700
BBE ( 0.4873631538 0.0000000000 ) 0.4873631538 0.9146739180
BBE ( 0.4874119820 0.0000000000 ) 0.4874119820 0.9140732253
BBE ( 0.4876378120 0.0000000000 ) 0.4876378120 0.9112905197
BBE ( 0.4876866402 0.0000000000 ) 0.4876866402 0.9106878852
BBE ( 0.4880589546 0.0003417969 ) 0.4880589546 0.9103109499
BBE ( 0.4880772652 0.0000000000 ) 0.4880772652 0.9058545422
BBE ( 0.4884251655 0.0000000000 ) 0.4884251655 0.9015317160
BBE ( 0.4887608589 0.0000000000 ) 0.4887608589 0.8973446571
BBE ( 0.4888585152 0.0000000000 ) 0.4888585152 0.8961237074
BBE ( 0.4892491402 0.0000000000 ) 0.4892491402 0.8912270369
BBE ( 0.4892796577 0.0000000000 ) 0.4892796577 0.8908436249
BBE ( 0.4895237984 0.0000000000 ) 0.4895237984 0.8877718960
BBE ( 0.4898655952 0.0000000000 ) 0.4898655952 0.8834583797
BBE ( 0.4899144234 0.0000000000 ) 0.4899144234 0.8828409301
BBE ( 0.4900120796 0.0000000000 ) 0.4900120796 0.8816051142
BBE ( 0.4901463570 0.0000000000 ) 0.4901463570 0.8799038821
BBE ( 0.4904210152 0.0000000000 ) 0.4904210152 0.8764169969
BBE ( 0.4908116402 0.0000000000 ) 0.4908116402 0.8714417071
BBE ( 0.4910862984 0.0000000000 ) 0.4910862984 0.8679322951
BBE ( 0.4915745796 0.0000000000 ) 0.4915745796 0.8616710988
BBE ( 0.4917088570 0.0000000000 ) 0.4917088570 0.8599443688
BBE ( 0.4919835152 0.0000000000 ) 0.4919835152 0.8564059578
BBE ( 0.4926487984 0.0000000000 ) 0.4926487984 0.8477999690
BBE ( 0.4927464546 0.0000000000 ) 0.4927464546 0.8465326082
BBE ( 0.4942112984 0.0000000000 ) 0.4942112984 0.8274026124
BBE ( 0.4946751655 0.0000000000 ) 0.4946751655 0.8213002814
BBE ( 0.4951146187 0.0002746582 ) 0.4951146187 0.8189185849
BBE ( 0.4954991402 0.0000000000 ) 0.4954991402 0.8104114832
BBE ( 0.4957737984 0.0000000000 ) 0.4957737984 0.8067685071
BBE ( 0.4961155952 0.0000000000 ) 0.4961155952 0.8022260697
BBE ( 0.4961644234 0.0000000000 ) 0.4961644234 0.8015763555
BBE ( 0.4969456734 0.0003417969 ) 0.4969456734 0.7954140614
BBE ( 0.4988987984 0.0000000000 ) 0.4988987984 0.7649058572
BBE ( 0.5001866402 0.0000000000 ) 0.5001866402 0.7474670688
BBE ( 0.5004612984 0.0000000000 ) 0.5004612984 0.7437364245
BBE ( 0.5035862984 0.0000000000 ) 0.5035862984 0.7010722736
BBE ( 0.5055394234 0.0000000000 ) 0.5055394234 0.6742753824
BBE ( 0.5098362984 0.0000000000 ) 0.5098362984 0.6153085893
BBE ( 0.5118870796 0.0000000000 ) 0.5118870796 0.5873076456
BBE ( 0.5120213570 0.0000000000 ) 0.5120213570 0.5854800910
BBE ( 0.5122960152 0.0000000000 ) 0.5122960152 0.5817445301
BBE ( 0.5129612984 0.0000000000 ) 0.5129612984 0.5727116847
BBE ( 0.5133519234 0.0000000000 ) 0.5133519234 0.5674189894
BBE ( 0.5145237984 0.0000000000 ) 0.5145237984 0.5515953642
BBE ( 0.5160862984 0.0000000000 ) 0.5160862984 0.5306427628
BBE ( 0.5164769234 0.0000000000 ) 0.5164769234 0.5254339031
BBE ( 0.5168675484 0.0000000000 ) 0.5168675484 0.5202377465
BBE ( 0.5176487984 0.0000000000 ) 0.5176487984 0.5098855127
BBE ( 0.5207737984 0.0000000000 ) 0.5207737984 0.4690828690
BBE ( 0.5289769234 0.0000000000 ) 0.5289769234 0.3681074167
BBE ( 0.5410862984 0.0000000000 ) 0.5410862984 0.2426270547
BBE ( 0.5457737984 0.0000000000 ) 0.5457737984 0.2038744975
BBE ( 0.5535862984 0.0000000000 ) 0.5535862984 0.1537894775
BBE ( 0.5551487984 0.0000000000 ) 0.5551487984 0.1461090174
BBE ( 0.5582737984 0.0000000000 ) 0.5582737984 0.1332027875
BBE ( 0.5645237984 0.0000000000 ) 0.5645237984 0.1175191667
BBE ( 0.5660862984 0.0000000000 ) 0.5660862984 0.1157579047
BBE ( 0.5676487984 0.0000000000 ) 0.5676487984 0.1148721239
}
number of Pareto points: 112
#include <cmath>
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int main ( int argc , char ** argv ) {
double f = 1e20, c1 = 1e20 , c2 = 1e20;
double x[5];
if ( argc >= 2 ) {
c1 = 0.0 , c2 = 0.0;
ifstream in ( argv[1] );
for ( int i = 0 ; i < 5 ; i++ ) {
in >> x[i];
c1 += pow ( x[i]-1 , 2 );
c2 += pow ( x[i]+1 , 2 );
}
f = x[4];
if ( in.fail() )
f = c1 = c2 = 1e20;
else {
c1 = c1 - 25;
c2 = 25 - c2;
}
in.close();
}
cout << f << " " << c1 << " " << c2 << endl;
return 0;
}
DIMENSION 5 # number of variables
BB_EXE bb.exe # 'bb.exe' is a program that
BB_OUTPUT_TYPE OBJ PB EB # takes in argument the name of
# a text file containing 5
# values, and that displays 3
# values that correspond to the
# objective function value (OBJ),
# and two constraints values g1
# and g2 with g1 <= 0 and
# g2 <= 0; 'PB' and 'EB'
# correspond to constraints that
# are treated by the Progressive
# and Extreme Barrier approaches
# (all constraint-handling
# options are described in the
# detailed parameters list)
X0 ( 0 0 0 0 0 ) # starting point
LOWER_BOUND * -6 # all variables are >= -6
UPPER_BOUND ( 5 6 7 - - ) # x_1 <= 5, x_2 <= 6, x_3 <= 7
# x_4 and x_5 have no bounds
MAX_BB_EVAL 100 # the algorithm terminates when
# 100 black-box evaluations have
# been made
# TMP_DIR /tmp # indicates a directory where
# temporary files are put
# (increases performance by ~100%
# if you're working on a network
# account and if TMP_DIR is on a
# local disk)
DISPLAY_DEGREE 2
# DISPLAY_ALL_EVAL yes
DISPLAY_STATS BBE ( SOL ) OBJ # Display the number of evaluation (BBE),
# the current solution ( SOL ) and the objective
# STATS_FILE test.txt BBE ( SOL ) OBJ
NOMAD - version 3.6.1 - www.gerad.ca/nomad
Copyright (C) 2001-2013 {
Mark A. Abramson - The Boeing Company
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.
License : '$NOMAD_HOME/src/lgpl.txt'
User guide: '$NOMAD_HOME/doc/user_guide.pdf'
Examples : '$NOMAD_HOME/examples'
Tools : '$NOMAD_HOME/tools'
Please report bugs to nomad@gerad.ca
MADS run {
BBE ( SOL ) OBJ
2 ( 1.1000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 ) 275.2281000000 (PhaseOne)
3 ( 4.4000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 ) 0.0000000000 (PhaseOne)
3 ( 4.4000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 ) 0.0000000000
11 ( 4.6750000000 0.9000000000 0.9750000000 1.5000000000 -1.5000000000 ) -1.5000000000
55 ( 1.6500000000 1.8000000000 1.9500000000 -1.5000000000 -3.0000000000 ) -3.0000000000
100 ( 1.6500000000 1.8000000000 1.9500000000 -1.5000000000 -3.0000000000 ) -3.0000000000
} end of run (max number of blackbox evaluations)
blackbox evaluations : 100
best infeasible solution (min. violation): ( 1.65 1.8 2.6 -1.5 -3 ) h=0.8725 f=-3
best feasible solution : ( 1.65 1.8 1.95 -1.5 -3 ) h=0 f=-3
1 2 3 4 5
/*-----------------------------------------------------*/
/* how to use the NOMAD library with a user function */
/* (bi-objective version) */
/*-----------------------------------------------------*/
#include "nomad.hpp"
using namespace std;
using namespace NOMAD;
/*----------------------------------------*/
/* The problem */
/*----------------------------------------*/
class My_Evaluator : public Multi_Obj_Evaluator {
public:
My_Evaluator ( const Parameters & p ) :
Multi_Obj_Evaluator ( p ) {}
~My_Evaluator ( void ) {}
bool eval_x ( Eval_Point & x ,
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 1
x.set_bb_output ( 1 , c1-25 ); // objective 2
x.set_bb_output ( 2 , 25-c2 ); // constraint 1
count_eval = true; // count a black-box evaluation
return true; // the evaluation succeeded
}
};
/*------------------------------------------*/
/* NOMAD main function */
/*------------------------------------------*/
int main ( int argc , char ** argv ) {
// display:
Display out ( cout );
out.precision ( DISPLAY_PRECISION_STD );
// NOMAD initializations:
begin ( argc , argv );
try {
// 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] = OBJ;
bbot[2] = EB;
p.set_BB_OUTPUT_TYPE ( bbot );
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_MULTI_OVERALL_BB_EVAL (100); // the algorithm terminates after
// 100 black-box evaluations
// p.set_TMP_DIR ("/tmp"); // directory for
// temporary files
// parameters validation:
p.check();
// custom evaluator creation:
My_Evaluator ev ( p );
// algorithm creation and execution:
Mads mads ( p , &ev );
mads.multi_run();
}
catch ( exception & e ) {
cerr << "\nNOMAD has been interrupted (" << e.what() << ")\n\n";
}
Slave::stop_slaves ( out );
end();
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment