Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
211f98b5
Commit
211f98b5
authored
Sep 22, 2013
by
Davis King
Browse files
Tweaked find_min_box_constrained() so that the user can easily reuse
computations done in f() when computing der().
parent
bfcae263
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
dlib/optimization/optimization_abstract.h
dlib/optimization/optimization_abstract.h
+8
-0
dlib/optimization/optimization_line_search.h
dlib/optimization/optimization_line_search.h
+4
-3
dlib/optimization/optimization_line_search_abstract.h
dlib/optimization/optimization_line_search_abstract.h
+5
-1
No files found.
dlib/optimization/optimization_abstract.h
View file @
211f98b5
...
@@ -330,6 +330,10 @@ namespace dlib
...
@@ -330,6 +330,10 @@ namespace dlib
- returns f(#x).
- returns f(#x).
- When calling f() and der(), the input passed to them will always be inside
- When calling f() and der(), the input passed to them will always be inside
the box constraints defined by x_lower and x_upper.
the box constraints defined by x_lower and x_upper.
- When calling der(x), it will always be the case that the last call to f() was
made with the same x value. This means that you can reuse any intermediate
results from the previous call to f(x) inside der(x) rather than recomputing
them inside der(x).
!*/
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -419,6 +423,10 @@ namespace dlib
...
@@ -419,6 +423,10 @@ namespace dlib
- returns f(#x).
- returns f(#x).
- When calling f() and der(), the input passed to them will always be inside
- When calling f() and der(), the input passed to them will always be inside
the box constraints defined by x_lower and x_upper.
the box constraints defined by x_lower and x_upper.
- When calling der(x), it will always be the case that the last call to f() was
made with the same x value. This means that you can reuse any intermediate
results from the previous call to f(x) inside der(x) rather than recomputing
them inside der(x).
- Note that this function solves the maximization problem by converting it
- Note that this function solves the maximization problem by converting it
into a minimization problem. Therefore, the values of f and its derivative
into a minimization problem. Therefore, the values of f and its derivative
reported to the stopping strategy will be negated. That is, stop_strategy
reported to the stopping strategy will be negated. That is, stop_strategy
...
...
dlib/optimization/optimization_line_search.h
View file @
211f98b5
...
@@ -452,10 +452,12 @@ namespace dlib
...
@@ -452,10 +452,12 @@ namespace dlib
if
(
d0
>
0
&&
alpha
>
0
)
if
(
d0
>
0
&&
alpha
>
0
)
alpha
*=
-
1
;
alpha
*=
-
1
;
for
(
unsigned
long
iter
=
0
;
iter
<
max_iter
;
++
iter
)
unsigned
long
iter
=
0
;
while
(
true
)
{
{
++
max_iter
;
const
double
val
=
f
(
alpha
);
const
double
val
=
f
(
alpha
);
if
(
val
<=
f0
+
alpha
*
rho
*
d0
)
if
(
val
<=
f0
+
alpha
*
rho
*
d0
||
iter
>=
max_iter
)
{
{
return
alpha
;
return
alpha
;
}
}
...
@@ -472,7 +474,6 @@ namespace dlib
...
@@ -472,7 +474,6 @@ namespace dlib
alpha
*=
step
;
alpha
*=
step
;
}
}
}
}
return
alpha
;
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/optimization/optimization_line_search_abstract.h
View file @
211f98b5
...
@@ -217,10 +217,14 @@ namespace dlib
...
@@ -217,10 +217,14 @@ namespace dlib
rule to decide when the search can stop.
rule to decide when the search can stop.
- rho == the parameter of the sufficient decrease condition.
- rho == the parameter of the sufficient decrease condition.
- max_iter == the maximum number of iterations allowable. After this many
- max_iter == the maximum number of iterations allowable. After this many
evaluations of f() line_search() is guaranteed to terminate.
evaluations of f()
backtracking_
line_search() is guaranteed to terminate.
- The line search starts with the input alpha value and then backtracks until
- The line search starts with the input alpha value and then backtracks until
it finds a good enough alpha value. Once found, it returns the alpha value
it finds a good enough alpha value. Once found, it returns the alpha value
such that f(alpha) is significantly closer to the minimum of f than f(0).
such that f(alpha) is significantly closer to the minimum of f than f(0).
- The returned value of alpha will always be the last value of alpha which was
passed to f(). That is, it will always be the case that the last call to f()
made by backtracking_line_search() was f(alpha) where alpha is the return
value from this function.
!*/
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment