Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
c75bbc7d
Commit
c75bbc7d
authored
Sep 14, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a version of poly_min_extrap() that uses a 2nd degree model.
parent
aaeb52ba
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
0 deletions
+50
-0
optimization_line_search.h
dlib/optimization/optimization_line_search.h
+18
-0
optimization_line_search_abstract.h
dlib/optimization/optimization_line_search_abstract.h
+16
-0
optimization.cpp
dlib/test/optimization.cpp
+16
-0
No files found.
dlib/optimization/optimization_line_search.h
View file @
c75bbc7d
...
...
@@ -193,6 +193,24 @@ namespace dlib
return
put_in_range
(
0
,
1
,
x
);
}
// ----------------------------------------------------------------------------------------
inline
double
poly_min_extrap
(
double
f0
,
double
d0
,
double
f1
)
{
const
double
temp
=
2
*
(
f1
-
f0
-
d0
);
if
(
std
::
abs
(
temp
)
<=
d0
*
std
::
numeric_limits
<
double
>::
epsilon
())
return
0
.
5
;
const
double
alpha
=
-
d0
/
temp
;
// now make sure the minimum is within the allowed range of (0,1)
return
put_in_range
(
0
,
1
,
alpha
);
}
// ----------------------------------------------------------------------------------------
inline
double
lagrange_poly_min_extrap
(
...
...
dlib/optimization/optimization_line_search_abstract.h
View file @
c75bbc7d
...
...
@@ -103,6 +103,22 @@ namespace dlib
- returns the point in the range [0,1] that minimizes the polynomial c(x)
!*/
// ----------------------------------------------------------------------------------------
inline
double
poly_min_extrap
(
double
f0
,
double
d0
,
double
f1
);
/*!
ensures
- let c(x) be a 2nd degree polynomial such that:
- c(0) == f0
- c(1) == f1
- derivative of c(x) at x==0 is d0
- returns the point in the range [0,1] that minimizes the polynomial c(x)
!*/
// ----------------------------------------------------------------------------------------
inline
double
lagrange_poly_min_extrap
(
...
...
dlib/test/optimization.cpp
View file @
c75bbc7d
...
...
@@ -917,6 +917,21 @@ namespace
}
void
test_poly_min_extract_2nd
()
{
double
off
;
off
=
0.0
;
DLIB_TEST
(
std
::
abs
(
poly_min_extrap
(
off
*
off
,
-
2
*
off
,
(
1
-
off
)
*
(
1
-
off
))
-
off
)
<
1e-13
);
off
=
0.1
;
DLIB_TEST
(
std
::
abs
(
poly_min_extrap
(
off
*
off
,
-
2
*
off
,
(
1
-
off
)
*
(
1
-
off
))
-
off
)
<
1e-13
);
off
=
0.2
;
DLIB_TEST
(
std
::
abs
(
poly_min_extrap
(
off
*
off
,
-
2
*
off
,
(
1
-
off
)
*
(
1
-
off
))
-
off
)
<
1e-13
);
off
=
0.3
;
DLIB_TEST
(
std
::
abs
(
poly_min_extrap
(
off
*
off
,
-
2
*
off
,
(
1
-
off
)
*
(
1
-
off
))
-
off
)
<
1e-13
);
off
=
0.4
;
DLIB_TEST
(
std
::
abs
(
poly_min_extrap
(
off
*
off
,
-
2
*
off
,
(
1
-
off
)
*
(
1
-
off
))
-
off
)
<
1e-13
);
off
=
0.5
;
DLIB_TEST
(
std
::
abs
(
poly_min_extrap
(
off
*
off
,
-
2
*
off
,
(
1
-
off
)
*
(
1
-
off
))
-
off
)
<
1e-13
);
off
=
0.6
;
DLIB_TEST
(
std
::
abs
(
poly_min_extrap
(
off
*
off
,
-
2
*
off
,
(
1
-
off
)
*
(
1
-
off
))
-
off
)
<
1e-13
);
off
=
0.8
;
DLIB_TEST
(
std
::
abs
(
poly_min_extrap
(
off
*
off
,
-
2
*
off
,
(
1
-
off
)
*
(
1
-
off
))
-
off
)
<
1e-13
);
off
=
0.9
;
DLIB_TEST
(
std
::
abs
(
poly_min_extrap
(
off
*
off
,
-
2
*
off
,
(
1
-
off
)
*
(
1
-
off
))
-
off
)
<
1e-13
);
off
=
1.0
;
DLIB_TEST
(
std
::
abs
(
poly_min_extrap
(
off
*
off
,
-
2
*
off
,
(
1
-
off
)
*
(
1
-
off
))
-
off
)
<
1e-13
);
}
class
optimization_tester
:
public
tester
{
...
...
@@ -930,6 +945,7 @@ namespace
void
perform_test
(
)
{
test_poly_min_extract_2nd
();
optimization_test
();
}
}
a
;
...
...
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