Commit 913e03a8 authored by Konstantinos Chatzilygeroudis's avatar Konstantinos Chatzilygeroudis
Browse files

Added xtol_rel in NLOpt and Cmaes

parent 20772425
......@@ -71,11 +71,18 @@ namespace limbo {
BO_PARAM(double, max_fun_evals, -1);
/// @ingroup opt_defaults
/// threshold based on the difference in value of a fixed number
/// of trials: if different to -1, it enables the tolerance criteria
/// of trials: if bigger than 0, it enables the tolerance criteria
/// for stopping based in the history of rewards.
BO_PARAM(double, fun_tolerance, -1);
/// @ingroup opt_defaults
/// function value target: if different to -1, enables the function
/// tolerance for convergence: stop when an optimization step (or an
/// estimate of the optimum) changes all the parameter values by
/// less than tol multiplied by the absolute value of the parameter
/// value.
/// IGNORED if negative
BO_PARAM(double, xrel_tolerance, -1);
/// @ingroup opt_defaults
/// function value target: if bigger than 0, enables the function
/// target criteria for stopping if the performance is greater than this value.
BO_PARAM(double, fun_target, -1);
/// @ingroup opt_defaults
......@@ -216,7 +223,7 @@ namespace limbo {
// max iteration is here only for security
cmaparams.set_max_iter(100000);
if (Params::opt_cmaes::fun_tolerance() == -1) {
if (Params::opt_cmaes::fun_tolerance() < 0) {
// we do not know if what is the actual maximum / minimum of the function
// therefore we deactivate this stopping criterion
cmaparams.set_stopping_criteria(FTARGET, false);
......@@ -228,7 +235,7 @@ namespace limbo {
}
// we allow to set the ftarget parameter
if (Params::opt_cmaes::fun_target() != -1) {
if (Params::opt_cmaes::fun_target() > 0) {
cmaparams.set_stopping_criteria(FTARGET, true);
cmaparams.set_ftarget(-Params::opt_cmaes::fun_target());
}
......@@ -237,8 +244,12 @@ namespace limbo {
cmaparams.set_stopping_criteria(EQUALFUNVALS, true);
cmaparams.set_stopping_criteria(MAXFEVALS, true);
// enable additional criterias to stop
// enable additional criteria to stop
cmaparams.set_stopping_criteria(TOLX, true);
// set different tolerance if available
if (Params::opt_cmaes::xrel_tolerance() > 0) {
cmaparams.set_xtolerance(Params::opt_cmaes::xrel_tolerance());
}
cmaparams.set_stopping_criteria(CONDITIONCOV, true);
// enable or disable different parameters
......
......@@ -69,8 +69,15 @@ namespace limbo {
/// estimate of the optimum) changes the objective function value by
/// less than tol multiplied by the absolute value of the function
/// value.
/// IGNORED if negative (no tolerance, only maximum iteration)
/// IGNORED if negative
BO_PARAM(double, fun_tolerance, -1);
/// @ingroup opt_defaults
/// tolerance for convergence: stop when an optimization step (or an
/// estimate of the optimum) changes all the parameter values by
/// less than tol multiplied by the absolute value of the parameter
/// value.
/// IGNORED if negative
BO_PARAM(double, xrel_tolerance, -1);
};
}
namespace opt {
......@@ -119,6 +126,7 @@ namespace limbo {
opt.set_maxeval(Params::opt_nloptgrad::iterations());
opt.set_ftol_rel(Params::opt_nloptgrad::fun_tolerance());
opt.set_xtol_rel(Params::opt_nloptgrad::xrel_tolerance());
if (bounded) {
opt.set_lower_bounds(std::vector<double>(dim, 0));
......
......@@ -69,8 +69,15 @@ namespace limbo {
/// estimate of the optimum) changes the objective function value by
/// less than tol multiplied by the absolute value of the function
/// value.
/// IGNORED if negative (no tolerance, only maximum iteration)
/// IGNORED if negative
BO_PARAM(double, fun_tolerance, -1);
/// @ingroup opt_defaults
/// tolerance for convergence: stop when an optimization step (or an
/// estimate of the optimum) changes all the parameter values by
/// less than tol multiplied by the absolute value of the parameter
/// value.
/// IGNORED if negative
BO_PARAM(double, xrel_tolerance, -1);
};
}
namespace opt {
......@@ -136,6 +143,7 @@ namespace limbo {
opt.set_maxeval(Params::opt_nloptnograd::iterations());
opt.set_ftol_rel(Params::opt_nloptnograd::fun_tolerance());
opt.set_xtol_rel(Params::opt_nloptnograd::xrel_tolerance());
if (bounded) {
opt.set_lower_bounds(std::vector<double>(dim, 0));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment