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
b5467d0f
Commit
b5467d0f
authored
Oct 01, 2011
by
Davis King
Browse files
Optimized the trust region solver a little bit.
parent
1a2a524a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
4 deletions
+24
-4
dlib/optimization/optimization_trust_region.h
dlib/optimization/optimization_trust_region.h
+24
-4
No files found.
dlib/optimization/optimization_trust_region.h
View file @
b5467d0f
...
@@ -108,14 +108,32 @@ namespace dlib
...
@@ -108,14 +108,32 @@ namespace dlib
continue
;
continue
;
}
}
using
namespace
blas_bindings
;
p
=
-
gg
;
p
=
-
gg
;
// Solve RR'*p = -g for p.
// Solve RR'*p = -g for p.
using
namespace
blas_bindings
;
// Solve R*q = -g for q where q = R'*p.
// Solve R*q = -g for q where q = R'*p.
if
(
R
.
nr
()
==
2
)
{
p
(
0
)
=
p
(
0
)
/
R
(
0
,
0
);
p
(
1
)
=
(
p
(
1
)
-
R
(
1
,
0
)
*
p
(
0
))
/
R
(
1
,
1
);
}
else
{
triangular_solver
(
CblasLeft
,
CblasLower
,
CblasNoTrans
,
CblasNonUnit
,
R
,
p
);
triangular_solver
(
CblasLeft
,
CblasLower
,
CblasNoTrans
,
CblasNonUnit
,
R
,
p
);
}
const
T
q_norm
=
length
(
p
);
const
T
q_norm
=
length
(
p
);
// Solve R'*p = q for p.
// Solve R'*p = q for p.
if
(
R
.
nr
()
==
2
)
{
p
(
1
)
=
p
(
1
)
/
R
(
1
,
1
);
p
(
0
)
=
(
p
(
0
)
-
R
(
1
,
0
)
*
p
(
1
))
/
R
(
0
,
0
);
}
else
{
triangular_solver
(
CblasLeft
,
CblasLower
,
CblasTrans
,
CblasNonUnit
,
R
,
p
);
triangular_solver
(
CblasLeft
,
CblasLower
,
CblasTrans
,
CblasNonUnit
,
R
,
p
);
}
const
T
p_norm
=
length
(
p
);
const
T
p_norm
=
length
(
p
);
// check if we are done.
// check if we are done.
...
@@ -233,6 +251,8 @@ namespace dlib
...
@@ -233,6 +251,8 @@ namespace dlib
<<
"
\n\t
radius: "
<<
radius
<<
"
\n\t
radius: "
<<
radius
);
);
const
double
initial_radius
=
radius
;
typedef
typename
funct_model
::
column_vector
T
;
typedef
typename
funct_model
::
column_vector
T
;
typedef
typename
T
::
type
type
;
typedef
typename
T
::
type
type
;
typedef
typename
T
::
mem_manager_type
mem_manager_type
;
typedef
typename
T
::
mem_manager_type
mem_manager_type
;
...
@@ -280,7 +300,7 @@ namespace dlib
...
@@ -280,7 +300,7 @@ namespace dlib
// something has gone horribly wrong if the radius has shrunk to zero. So just
// something has gone horribly wrong if the radius has shrunk to zero. So just
// give up if that happens.
// give up if that happens.
if
(
static_cast
<
type
>
(
radius
)
<=
std
::
numeric_limits
<
type
>::
mi
n
())
if
(
radius
<=
initial_
radius
*
std
::
numeric_limits
<
double
>::
epsilo
n
())
break
;
break
;
}
}
else
else
...
...
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