SPEC-2513 Fixes to enable w4459 (#1107)
* fixing w4459 * Fixes for nounity * putting OLD_APARAM_USER in a common place to avoid duplicated declarations
This commit is contained in:
@@ -27,6 +27,6 @@ namespace NumericalMethods::Optimization
|
||||
const double epsilon = 1e-7;
|
||||
|
||||
// values recommended in Nocedal and Wright for constants in the Wolfe conditions for satisfactory solution improvement
|
||||
const double c1 = 1e-4;
|
||||
const double c2 = 0.9;
|
||||
const double WolfeConditionsC1 = 1e-4;
|
||||
const double WolfeConditionsC2 = 0.9;
|
||||
} // namespace NumericalMethods::Optimization
|
||||
|
||||
@@ -162,16 +162,16 @@ namespace NumericalMethods::Optimization
|
||||
{
|
||||
// if the value of f corresponding to alpha1 isn't sufficiently small compared to f at x0,
|
||||
// then the interval [alpha0 ... alpha1] must bracket a suitable point.
|
||||
if ((f_alpha1 > f_x0 + c1 * alpha1 * df_x0) || (iteration > 0 && f_alpha1 > f_alpha0))
|
||||
if ((f_alpha1 > f_x0 + WolfeConditionsC1 * alpha1 * df_x0) || (iteration > 0 && f_alpha1 > f_alpha0))
|
||||
{
|
||||
return SelectStepSizeFromInterval(alpha0, alpha1, f_alpha0, f_alpha1, df_alpha0,
|
||||
f, x0, searchDirection, f_x0, df_x0, c1, c2);
|
||||
f, x0, searchDirection, f_x0, df_x0, WolfeConditionsC1, WolfeConditionsC2);
|
||||
}
|
||||
|
||||
// otherwise, if the derivative corresponding to alpha1 is large enough, alpha1 already
|
||||
// satisfies the Wolfe conditions and so return alpha1.
|
||||
double df_alpha1 = DirectionalDerivative(f, x0 + alpha1 * searchDirection, searchDirection);
|
||||
if (fabs(df_alpha1) <= -c2 * df_x0)
|
||||
if (fabs(df_alpha1) <= -WolfeConditionsC2 * df_x0)
|
||||
{
|
||||
LineSearchResult result;
|
||||
result.m_outcome = LineSearchOutcome::Success;
|
||||
@@ -184,7 +184,7 @@ namespace NumericalMethods::Optimization
|
||||
if (df_alpha1 >= 0.0)
|
||||
{
|
||||
return SelectStepSizeFromInterval(alpha1, alpha0, f_alpha1, f_alpha0, df_alpha1,
|
||||
f, x0, searchDirection, f_x0, df_x0, c1, c2);
|
||||
f, x0, searchDirection, f_x0, df_x0, WolfeConditionsC1, WolfeConditionsC2);
|
||||
}
|
||||
|
||||
// haven't found an interval which is guaranteed to bracket a suitable point,
|
||||
|
||||
Reference in New Issue
Block a user