コード例 #1
0
ファイル: Barrier.cpp プロジェクト: berndbischl/R-Package-crs
/*---------------------------------------------------------*/
NOMAD::success_type NOMAD::Barrier::insert_feasible ( const NOMAD::Eval_Point & x )
{
  if ( !_best_feasible || ( x.get_f().value() < _best_feasible->get_f().value() ) ) {
    _best_feasible = &x;
    return NOMAD::FULL_SUCCESS;
  }
  return NOMAD::UNSUCCESSFUL;
}
コード例 #2
0
/*---------------------------------------------------------*/
NOMAD::success_type NOMAD::Barrier::insert_infeasible ( const NOMAD::Eval_Point & x )
{
    const NOMAD::Eval_Point * old_bi = get_best_infeasible();
    
    // filter insertion:
    // -----------------
    bool insert;
    filter_insertion ( x , insert );
    
    // 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 ( bi->get_h().value() < old_bi->get_h().value() )
                return NOMAD::FULL_SUCCESS;
            if ( insert )
                return NOMAD::PARTIAL_SUCCESS;
            return NOMAD::UNSUCCESSFUL;
        }
        return NOMAD::FULL_SUCCESS;
    }
    
    // progressive barrier:
    // --------------------
    
    // with PEB constraints, we remember all points that we tried to insert:
    if ( _p.get_barrier_type() == NOMAD::PEB_P )
        _peb_lop.push_back ( &x );
    
    // first infeasible successes are considered as partial successes
    // (improving iterations)
    if ( !_ref )
        return NOMAD::PARTIAL_SUCCESS;
    
    double hx = x.get_h().value();
    double fx = x.get_f().value();
    double hr = _ref->get_h().value();
    double fr = _ref->get_f().value();
    
    // failure:
    if ( hx > hr || ( hx == hr && fx >= fr ) )
        return NOMAD::UNSUCCESSFUL;
    
    // partial success:
    if ( fx > fr )
        return NOMAD::PARTIAL_SUCCESS;
    
    // full success:
    return NOMAD::FULL_SUCCESS;
}
コード例 #3
0
/*---------------------------------------------------------*/
NOMAD::success_type NOMAD::Barrier::insert_feasible ( const NOMAD::Eval_Point & x )
{

    Double fx;
    Double fx_bf;
    if ( _p.get_robust_mads() )
    {
        if ( x.get_smoothing_status() != NOMAD::SMOOTHING_OK )
            return NOMAD::UNSUCCESSFUL;
        
        if ( _best_feasible )
            fx_bf = _best_feasible->get_fsmooth();
        else
        {
            _best_feasible = &x;
            return NOMAD::FULL_SUCCESS;
        }
        fx = x.get_fsmooth();
    }
    else
    {
        if ( _best_feasible )
            fx_bf = _best_feasible->get_f();
        else
        {
            _best_feasible = &x;
            return NOMAD::FULL_SUCCESS;
        }
        
        fx= x.get_f();

    }
    if ( !fx.is_defined() || ! fx_bf.is_defined() )
        throw NOMAD::Exception ( __FILE__ , __LINE__ ,
                                "insert_feasible(): one point has no f value" );
    
    if ( fx.value() < fx_bf.value() )
    {
        _best_feasible = &x;
        return NOMAD::FULL_SUCCESS;
    }
    
    
    
        
    
    return NOMAD::UNSUCCESSFUL;
}
コード例 #4
0
/*---------------------------------------------------------*/
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;
}