MCPcopy Create free account
hub / github.com/davisking/dlib / gap_step_assign_bounded_variables

Function gap_step_assign_bounded_variables

dlib/optimization/optimization.h:422–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420
421 template <typename T, typename U, typename V>
422 T gap_step_assign_bounded_variables (
423 const double eps,
424 T vect,
425 const T& x,
426 const T& gradient,
427 const U& x_lower,
428 const V& x_upper
429 )
430 {
431 for (long i = 0; i < gradient.size(); ++i)
432 {
433 const double tol = eps*std::abs(x(i));
434 // If x(i) is an active bound constraint then we should set its search
435 // direction such that a single step along the direction either does nothing or
436 // closes the gap of size tol before hitting the bound exactly.
437 if (x_lower(i)+tol >= x(i) && gradient(i) > 0)
438 vect(i) = x_lower(i)-x(i);
439 else if (x_upper(i)-tol <= x(i) && gradient(i) < 0)
440 vect(i) = x_upper(i)-x(i);
441 }
442 return vect;
443 }
444
445// ----------------------------------------------------------------------------------------
446

Callers 2

find_min_box_constrainedFunction · 0.85
find_max_box_constrainedFunction · 0.85

Calls 3

absFunction · 0.85
xFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected