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
918bbd5d
Commit
918bbd5d
authored
Jun 19, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a max runtime option to the oca solver.
parent
d3006ab3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
optimization_oca.h
dlib/optimization/optimization_oca.h
+20
-0
optimization_oca_abstract.h
dlib/optimization/optimization_oca_abstract.h
+20
-0
No files found.
dlib/optimization/optimization_oca.h
View file @
918bbd5d
...
...
@@ -9,6 +9,7 @@
#include "optimization_solve_qp_using_smo.h"
#include <vector>
#include "../sequence.h"
#include <chrono>
// ----------------------------------------------------------------------------------------
...
...
@@ -88,6 +89,19 @@ namespace dlib
unsigned
long
get_subproblem_max_iterations
(
)
const
{
return
sub_max_iter
;
}
void
set_max_runtime
(
const
std
::
chrono
::
nanoseconds
&
max_runtime_
)
{
max_runtime
=
max_runtime_
;
}
std
::
chrono
::
nanoseconds
get_max_runtime
(
)
const
{
return
max_runtime
;
}
void
set_inactive_plane_threshold
(
unsigned
long
inactive_thresh_
)
...
...
@@ -249,6 +263,8 @@ namespace dlib
const
double
prior_norm
=
have_prior
?
0
.
5
*
dot
(
prior
,
prior
)
:
0
;
const
auto
time_to_stop
=
std
::
chrono
::
steady_clock
::
now
()
+
max_runtime
;
unsigned
long
counter
=
0
;
while
(
true
)
{
...
...
@@ -297,6 +313,8 @@ namespace dlib
{
break
;
}
if
(
std
::
chrono
::
steady_clock
::
now
()
>=
time_to_stop
)
break
;
// compute kernel matrix for all the planes
K
.
swap
(
Ktmp
);
...
...
@@ -398,6 +416,8 @@ namespace dlib
unsigned
long
sub_max_iter
;
unsigned
long
inactive_thresh
;
std
::
chrono
::
nanoseconds
max_runtime
=
std
::
chrono
::
hours
(
24
*
356
*
290
);
// 290 years
};
}
...
...
dlib/optimization/optimization_oca_abstract.h
View file @
918bbd5d
...
...
@@ -3,6 +3,8 @@
#undef DLIB_OPTIMIZATION_OCA_ABsTRACT_Hh_
#ifdef DLIB_OPTIMIZATION_OCA_ABsTRACT_Hh_
#include <chrono>
// ----------------------------------------------------------------------------------------
namespace
dlib
...
...
@@ -131,6 +133,8 @@ namespace dlib
- get_subproblem_epsilon() == 1e-2
- get_subproblem_max_iterations() == 50000
- get_inactive_plane_threshold() == 20
- get_max_runtime() == std::chrono::hours(24*356*290)
(i.e. 290 years, so basically forever)
WHAT THIS OBJECT REPRESENTS
This object is a tool for solving the optimization problem defined above
...
...
@@ -324,6 +328,22 @@ namespace dlib
inactivity required before a cutting plane is removed.
!*/
void
set_max_runtime
(
const
std
::
chrono
::
nanoseconds
&
max_runtime
)
const
;
/*!
ensures
- #get_max_runtime() == max_runtime
!*/
std
::
chrono
::
nanoseconds
get_max_runtime
(
)
const
;
/*!
ensures
- returns the maximum amount of time we will let the solver run before
making it terminate.
!*/
};
}
...
...
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