/*------------------------------------------------------------------*/ 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); }
/*-----------------------------------------------------------------------*/ 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; }