Download NOMAD User Guide

Transcript
52
How to use NOMAD
bool eval_x ( NOMAD::Eval_Point
& x
,
const NOMAD::Double & h_max
,
bool
& count_eval
) const;
Figure 4.4: Prototype of method NOMAD::Evaluator::eval_x(). A non-const version is also
available.
method NOMAD::Eval_Point::set_bb_output() (x.set_bb_output(0,v) to set the objective function value to v if the objective has been defined at the first position). Constraints must
be represented by values cj for a constraint cj ≤ 0. Please refer to files Eval_Point.hpp and
Point.hpp for details about the classes defining NOMAD vectors.
The second argument, the real h_max (in), corresponds to the current value of the barrier hmax
parameter. It is not used in this example but it may be used to interrupt an expensive evaluation
if the constraint violation value h grows larger than hmax . See [20] for the definition of h and
hmax and of the Progressive Barrier method for handling constraints. Please refer to
Section 6.1 for description of parameters hmax and hmin .
The third argument, count_eval (out), needs to be set to true if the evaluation counts as
a blackbox evaluation, and false otherwise (for example, if the user interrupts an evaluation
with the hmax criterion before it costs some expensive computations, then set count_eval to
false).
Finally, note that the call to eval_x() inside the NOMAD code is inserted into a try block.
This means that if an error is detected inside the eval_x() function, an exception should be
thrown. The choice for the type of this exception is left to the user, but NOMAD::Exception is
available (see Exception.*pp). If an exception is thrown by the user-defined function, then the
associated evaluation is tagged as a failure and not counted unless the user explicitely set the
flag count_eval to true. Additionally, the user-defined function can test on whether CTRL-C
has been pressed by using the method NOMAD::Evaluator::get_force_quit(). This allows
managing the termination of a costly black-box evaluation within eval_x().
The virtual method NOMAD::Evaluator::update_success() can also be subclassed in the
My_Evaluator class. The corresponding derived method will be automatically invoked every
time a new improvement is made. Note that the automatic calls to this method can be enabled/disabled with NOMAD::Evaluator_Control::set_call_user_update_success().