Select Git revision
test_properties.py
Forked from
finesse / pykat
Source project has a limited visibility.
user_search.cpp 5.65 KiB
/*-------------------------------------------------------------------------------------*/
/* 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 ,