Esempio n. 1
0
/*------------------------------------------*/
int main ( int argc , char ** argv ) {

  // display:
  Display out ( cout );
  out.precision ( DISPLAY_PRECISION_STD );

  // NOMAD initializations:
  begin ( argc , argv );

  try {

    // parameters creation:
    Parameters p ( out );

    p.set_DIMENSION (5);             // number of variables

    vector<bb_output_type> bbot (3); // definition of
    bbot[0] = OBJ;                   // output types
    bbot[1] = OBJ;
    bbot[2] = EB;
    p.set_BB_OUTPUT_TYPE ( bbot );

    p.set_X0 ( Point ( 5 , 0.0 ) );  // starting point

    p.set_LOWER_BOUND ( Point ( 5 , -6.0 ) ); // all var. >= -6
    Point ub ( 5 );                           // x_4 and x_5 have no bounds
    ub[0] = 5.0;                              // x_1 <= 5
    ub[1] = 6.0;                              // x_2 <= 6
    ub[2] = 7.0;                              // x_3 <= 7
    p.set_UPPER_BOUND ( ub );

    p.set_MULTI_OVERALL_BB_EVAL (100); // the algorithm terminates after
                                       // 100 black-box evaluations

    // p.set_TMP_DIR ("/tmp");      // directory for
                                    // temporary files

    // parameters validation:
    p.check();

    // custom evaluator creation:
    My_Evaluator ev   ( p );

    // algorithm creation and execution:
    Mads mads ( p , &ev );
    mads.multi_run();
  }
  catch ( exception & e ) {
    cerr << "\nNOMAD has been interrupted (" << e.what() << ")\n\n";
  }

  Slave::stop_slaves ( out );
  end();

  return EXIT_SUCCESS;
}
Esempio n. 2
0
/*------------------------------------------*/
int main ( int argc , char ** argv ) {

  // display:
  Display out ( std::cout );
  out.precision ( DISPLAY_PRECISION_STD );

  // NOMAD initializations:
  begin ( argc , argv );

  try {

    // usage:
    if ( argc < 2 ) {
      display_usage ( cerr );
      return EXIT_SUCCESS;
    }

    // parameters file:
    string param_file_name = argv[1];
    string opt             = param_file_name;
    NOMAD::toupper(opt);

    // display version if option '-v' has been specified:
    if ( opt == "-V" ) {
      display_version ( out );
      return EXIT_SUCCESS;
    }

    // display info if option '-i' has been specified:
    if ( opt == "-I" || opt == "-INFO" ) {
      display_info  ( out );
      display_usage ( out );
      return EXIT_SUCCESS;
    }
    
    // parameters creation:
    Parameters p ( out );

    // display help on parameters if option '-h' has been specified:
    if ( opt == "-H" || opt == "-HELP" ) {
      p.help( (argc>2) ? argv[2] : "all" );
      return EXIT_SUCCESS;
    }

    // read parameters file:
    p.read ( param_file_name );

    // parameters check:
    p.check();

    // display NOMAD info:
    if ( p.get_display_degree() > 1 )
      display_info ( out );

    // parameters display:
    if ( p.get_display_degree() > 2 )
      out << endl << "parameters:" << endl << p << endl;

    // single-objective:
    if ( p.get_nb_obj() == 1 ) {

      // custom evaluator:
      My_Evaluator ev ( p );

      // algorithm creation and execution:
      Mads mads ( p , &ev );
      mads.run();

      // plot the last point:
      const Eval_Point * bf = mads.get_best_feasible();
      if ( bf )
	ev.plot_success ( mads.get_stats().get_bb_eval() , bf->get_f() );
    }

    // bi-objective:
    else {

      // custom evaluator:
      My_Multi_Obj_Evaluator ev ( p );

      // algorithm creation and execution:
      Mads mads ( p , &ev );
      mads.multi_run();
    }


  }
  catch ( exception & e ) {
    cerr << "\nNOMAD has been interrupted (" << e.what() << ")\n\n";
  }

  GUI_wait();


  Slave::stop_slaves ( out );
  end();

  return EXIT_SUCCESS;
}