本文整理汇总了C++中nomad::Eval_Point::get_tag方法的典型用法代码示例。如果您正苦于以下问题:C++ Eval_Point::get_tag方法的具体用法?C++ Eval_Point::get_tag怎么用?C++ Eval_Point::get_tag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nomad::Eval_Point
的用法示例。
在下文中一共展示了Eval_Point::get_tag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Insert_Error
/*---------------------------------------------------------*/
void NOMAD::Barrier::insert ( const NOMAD::Eval_Point & x )
{
// we compare the eval types (_SGTE_ or _TRUTH_) of x and *this:
if ( x.get_eval_type() != _eval_type )
throw Barrier::Insert_Error ( "Barrier.cpp" , __LINE__ ,
"insertion of an Eval_Point into the bad Barrier object" );
// basic check:
if ( !x.is_eval_ok() )
{
_one_eval_succ = NOMAD::UNSUCCESSFUL;
return;
}
// pre-filter: if tag(x) is already in the pre-filter,
// then return _UNSUCCESSFUL_:
size_t size_before = _prefilter.size();
_prefilter.insert ( x.get_tag() );
if ( _prefilter.size() == size_before )
{
_one_eval_succ = NOMAD::UNSUCCESSFUL;
return;
}
// insertion in _all_inserted:
_all_inserted.push_back ( &x );
// other checks:
const NOMAD::Double & h = x.get_h();
if ( !x.is_EB_ok () ||
!x.get_f().is_defined () ||
!h.is_defined () ||
h.value() > _h_max.value() )
{
_one_eval_succ = NOMAD::UNSUCCESSFUL;
return;
}
// insert_feasible or insert_infeasible:
_one_eval_succ = ( x.is_feasible ( _p.get_h_min() ) ) ?
insert_feasible ( x ) : insert_infeasible(x);
if ( _one_eval_succ > _success )
_success = _one_eval_succ;
}
示例2: if
//.........这里部分代码省略.........
// pts contains n points of dimension p: each of these points contains
// p different values for each variable:
NOMAD::Point ** pts = new NOMAD::Point * [n];
// creation of p search points:
for ( int k = 0 ; k < p ; ++k )
{
x = new NOMAD::Eval_Point ( n , m );
x->set_signature ( signature );
for ( i = 0 ; i < n ; ++i )
{
if ( k==0 )
{
if ( fixed_variables[i].is_defined() )
pts[i] = new NOMAD::Point ( p , fixed_variables[i] );
else if ( bbit[i] == NOMAD::CATEGORICAL )
{
pts[i] = new NOMAD::Point ( p , (*ref)[i] );
}
else
{
pts[i] = new NOMAD::Point ( p );
if ( !_initial_search )
delta_i = delta[i];
values_for_var_i ( p ,
delta_i ,
delta_max[i] ,
bbit [i] ,
lb [i] ,
ub [i] ,
*pts [i] );
}
}
(*x)[i] = (*pts[i])[k];
if ( k == pm1 )
delete pts[i];
}
if ( display_degree == NOMAD::FULL_DISPLAY )
{
out << "LH point #" << x->get_tag()
<< ": ( ";
x->Point::display ( out , " " , 2 , NOMAD::Point::get_display_limit() );
out << " )" << std::endl;
}
// add the new point to the ordered list of search trial points:
ev_control.add_eval_point ( x ,
display_degree ,
false , // snap_to_bounds = false
NOMAD::Double() ,
NOMAD::Double() ,
NOMAD::Double() ,
NOMAD::Double() );
}
delete [] pts;
nb_search_pts = ev_control.get_nb_eval_points();
// eval_list_of_points:
// --------------------
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 );
_p.get_display_stats();
// restore stats style
_p.set_DISPLAY_STATS ( old_ds );
_p.check ( false , // remove_history_file = false
false , // remove_solution_file = false
false ); // remove_stats_file = false
// final displays:
if ( display_degree == NOMAD::FULL_DISPLAY )
{
std::ostringstream oss;
oss << "end of LH search (" << success << ")";
out << std::endl << NOMAD::close_block ( oss.str() ) << std::endl;
}
}
示例3: Exception
//.........这里部分代码省略.........
const NOMAD::Direction * dir = x[i]->get_direction();
if ( dir && ( dir->is_mads() || dir->get_type()==NOMAD::MODEL_SEARCH_DIR ) ) {
// get the x_k's signature:
signature = x[i]->get_signature();
if ( !signature )
throw NOMAD::Exception ( "Speculative_Search.cpp" , __LINE__ ,
"Speculative_Search::search(): could not get the signature" );
xkm1 = *x[i] - *dir;
lk = lkm1 = *x[i]->get_mesh_index();
NOMAD::Mesh::update ( NOMAD::FULL_SUCCESS , lk );
n = signature->get_n();
delta_m_k = NOMAD::Point ( n );
delta_m_km1 = NOMAD::Point ( n );
factor = NOMAD::Point ( n );
signature->get_mesh().get_delta_m ( delta_m_k , lk );
signature->get_mesh().get_delta_m ( delta_m_km1 , lkm1 );
// multiplicative factor: takes into account the fact that
// the direction contains \Delta^m_k:
try {
// factor = delta_m_k / delta_m_km1 :
for ( int k = 0 ; k < n ; ++k ) {
if ( delta_m_k[k].is_defined() && delta_m_km1[k].is_defined() &&
delta_m_k[k].value() != 0.0 && delta_m_km1[k].value() != 0.0 )
factor[k] = delta_m_k[k] / delta_m_km1[k];
else
factor[k] = 0.0;
}
}
catch ( NOMAD::Double::Invalid_Value & ) {
if ( display_degree == NOMAD::FULL_DISPLAY )
out << "could not compute " << _type << " point: stop" << std::endl
<< NOMAD::close_block ( "end of speculative search" );
stop = true;
stop_reason = NOMAD::MESH_PREC_REACHED;
return;
}
if ( lkm1 <= 0 )
factor *= NOMAD::Mesh::get_mesh_update_basis();
// speculative search point:
NOMAD::Direction new_dir ( n , 0.0 , dir->get_type() );
new_dir.Point::operator = ( factor * *dir );
sk = new NOMAD::Eval_Point;
sk->set ( n , _p.get_bb_nb_outputs() );
sk->set_signature ( signature );
sk->set_direction ( &new_dir );
sk->set_mesh_index ( &lk );
sk->Point::operator = ( xkm1 + new_dir );
if ( display_degree == NOMAD::FULL_DISPLAY ) {
out << "trial point #" << sk->get_tag()
<< ": ( ";
sk->Point::display ( out ," " , 2 , NOMAD::Point::get_display_limit() );
out << " )" << std::endl;
}
// add the new point to the list of search trial points:
ev_control.add_eval_point ( sk ,
display_degree ,
_p.get_snap_to_bounds() ,
NOMAD::Double() ,
NOMAD::Double() ,
NOMAD::Double() ,
NOMAD::Double() );
}
}
}
nb_search_pts = ev_control.get_nb_eval_points();
// eval_list_of_points:
// --------------------
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 );
if ( display_degree == NOMAD::FULL_DISPLAY ) {
std::ostringstream oss;
oss << "end of speculative search (" << success << ")";
out << NOMAD::close_block ( oss.str() ) << std::endl;
}
}
示例4: Exception
/*-------------------------------------------------------------------*/
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;
#else
_p.out() << "command=\'" << cmd << "\'" << std::endl;
//.........这里部分代码省略.........