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

Function zero_bounded_variables

dlib/optimization/optimization.h:398–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396
397 template <typename T, typename U, typename V>
398 T zero_bounded_variables (
399 const double eps,
400 T vect,
401 const T& x,
402 const T& gradient,
403 const U& x_lower,
404 const V& x_upper
405 )
406 {
407 for (long i = 0; i < gradient.size(); ++i)
408 {
409 const double tol = eps*std::abs(x(i));
410 // if x(i) is an active bound constraint
411 if (x_lower(i)+tol >= x(i) && gradient(i) > 0)
412 vect(i) = 0;
413 else if (x_upper(i)-tol <= x(i) && gradient(i) < 0)
414 vect(i) = 0;
415 }
416 return vect;
417 }
418
419// ----------------------------------------------------------------------------------------
420

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