/*---------------------------------------------------------*/
bool NOMAD::LH_Search::LH_points ( int                                n   ,
                                  int                                m   ,
                                  int                                p   ,
                                  const NOMAD::Point               & lb  ,
                                  const NOMAD::Point               & ub  ,
                                  std::vector<NOMAD::Eval_Point *> & pts   )
{
    if ( n <= 0           ||
        p <= 0           ||
        !lb.is_defined() ||
        !ub.is_defined() ||
        lb.size() != n   ||
        ub.size() != n      )
        return false;
    
    for ( size_t j = 0 ; j < pts.size() ; ++j )
        delete pts[j];
    pts.clear();
    
    NOMAD::Eval_Point     * x;
    int                     i;
    int                     pm1 = p-1;
    NOMAD::Random_Pickup ** rps = new NOMAD::Random_Pickup *[n];
    
    for ( int k = 0 ; k < p ; ++k )
    {
        x = new NOMAD::Eval_Point ( n , m );
        for ( i = 0 ; i < n ; ++i )
        {
            if ( k==0 )
                rps[i] = new NOMAD::Random_Pickup(p);
            (*x)[i] = lb[i] +
            (ub[i]-lb[i]) *
            ( rps[i]->pickup() + NOMAD::RNG::rand()/(1.0+NOMAD::D_INT_MAX)) / p;
            if ( k==pm1 )
                delete rps[i];
        }
        pts.push_back(x);
    }
    
    delete [] rps;
    
    return true;
}
Example #2
0
NOMAD::Double NOMAD::SMesh::scale_and_project(int i, NOMAD::Double l) const
{
    
    NOMAD::Point delta;
    NOMAD::Point Delta;
    get_delta ( delta );
    get_Delta ( Delta );
    
    
    if ( delta.is_defined() && Delta.is_defined() && i <= _n)
    {
        NOMAD::Double d= Delta[i] / delta[i] * l;
        return d.NOMAD::Double::round()*delta[i];
    }
    else
        throw NOMAD::Exception ( "SMesh.cpp" , __LINE__ ,
                                "Mesh scaling and projection cannot be performed!" );
    
}
Example #3
0
/*-----------------------------------------------------------*/
void NOMAD::SMesh::set_mesh_indices ( const NOMAD::Point & r )
{
    if (!r.is_defined())
        _mesh_index=0;
    else
        _mesh_index=r[0].NOMAD::Double::round();
    
    if ( _mesh_index > _max_mesh_index )
        _max_mesh_index = _mesh_index;
    if ( _mesh_index < _min_mesh_index )
        _min_mesh_index = _mesh_index;
}
Example #4
0
/*-----------------------------------------------------------*/
void NOMAD::SMesh::update ( NOMAD::success_type success , NOMAD::Point & mesh_indices, const NOMAD::Direction *dir ) const
{
    
    if ( mesh_indices.is_defined() )
    {
        for (int i=0; i < mesh_indices.size() ; i++)
        {
            if ( success == NOMAD::FULL_SUCCESS )
            {
                mesh_indices[i] -= _coarsening_step;
                if ( mesh_indices[i] < -NOMAD::L_LIMITS )
                    mesh_indices[i] = -NOMAD::L_LIMITS;
            }
            else if ( success == NOMAD::UNSUCCESSFUL )
                mesh_indices[i] -= _refining_step;
        }
    }
}