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
b509a169
Commit
b509a169
authored
Apr 09, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made tests more robust.
parent
5fecb30c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
19 deletions
+14
-19
opt_qp_solver.cpp
dlib/test/opt_qp_solver.cpp
+14
-19
No files found.
dlib/test/opt_qp_solver.cpp
View file @
b509a169
...
@@ -253,7 +253,7 @@ namespace
...
@@ -253,7 +253,7 @@ namespace
const
double
C
=
2
;
const
double
C
=
2
;
matrix
<
double
,
0
,
1
>
alpha
(
2
),
true_alpha
(
2
),
d
(
3
),
lambda
;
matrix
<
double
,
0
,
1
>
alpha
(
2
),
d
(
3
),
lambda
;
alpha
=
C
/
2
,
C
/
2
;
alpha
=
C
/
2
,
C
/
2
;
solve_qp4_using_smo
(
A
,
tmp
(
trans
(
A
)
*
A
),
b
,
d
,
alpha
,
lambda
,
1e-9
,
800
);
solve_qp4_using_smo
(
A
,
tmp
(
trans
(
A
)
*
A
),
b
,
d
,
alpha
,
lambda
,
1e-9
,
800
);
...
@@ -263,16 +263,13 @@ namespace
...
@@ -263,16 +263,13 @@ namespace
dlog
<<
LINFO
<<
"w: "
<<
trans
(
w
);
dlog
<<
LINFO
<<
"w: "
<<
trans
(
w
);
dlog
<<
LINFO
<<
"computed obj: "
<<
compute_objective_value
(
w
,
A
,
b
,
C
);
const
double
computed_obj
=
compute_objective_value
(
w
,
A
,
b
,
C
);
w
=
0
,
0
,
0
;
w
=
0
,
0
,
0
;
dlog
<<
LINFO
<<
"with true w obj: "
<<
compute_objective_value
(
w
,
A
,
b
,
C
);
const
double
true_obj
=
compute_objective_value
(
w
,
A
,
b
,
C
);
dlog
<<
LINFO
<<
"computed obj: "
<<
computed_obj
;
dlog
<<
LINFO
<<
"with true w obj: "
<<
true_obj
;
dlog
<<
LINFO
<<
"alpha: "
<<
trans
(
alpha
);
DLIB_TEST_MSG
(
abs
(
computed_obj
-
true_obj
)
<
1e-8
,
abs
(
computed_obj
-
true_obj
));
true_alpha
=
0
,
2
;
dlog
<<
LINFO
<<
"true alpha: "
<<
trans
(
true_alpha
);
dlog
<<
LINFO
<<
"alpha error: "
<<
max
(
abs
(
alpha
-
true_alpha
));
DLIB_TEST_MSG
(
max
(
abs
(
alpha
-
true_alpha
))
<
1e-8
,
max
(
abs
(
alpha
-
true_alpha
)));
}
}
void
test_qp4_test6
()
void
test_qp4_test6
()
...
@@ -289,26 +286,24 @@ namespace
...
@@ -289,26 +286,24 @@ namespace
const
double
C
=
2
;
const
double
C
=
2
;
matrix
<
double
,
0
,
1
>
alpha
(
3
),
true_alpha
(
3
),
d
(
3
),
lambda
;
matrix
<
double
,
0
,
1
>
alpha
(
3
),
d
(
3
),
lambda
;
alpha
=
C
/
2
,
C
/
2
,
0
;
alpha
=
C
/
2
,
C
/
2
,
0
;
solve_qp4_using_smo
(
A
,
tmp
(
trans
(
A
)
*
A
),
b
,
d
,
alpha
,
lambda
,
1e-9
,
8
00
);
solve_qp4_using_smo
(
A
,
tmp
(
trans
(
A
)
*
A
),
b
,
d
,
alpha
,
lambda
,
1e-9
,
30
00
);
matrix
<
double
,
0
,
1
>
w
=
lowerbound
(
-
A
*
alpha
,
0
);
matrix
<
double
,
0
,
1
>
w
=
lowerbound
(
-
A
*
alpha
,
0
);
dlog
<<
LINFO
<<
"*******************************************************"
;
dlog
<<
LINFO
<<
"*******************************************************"
;
dlog
<<
LINFO
<<
"w: "
<<
trans
(
w
);
dlog
<<
LINFO
<<
"w: "
<<
trans
(
w
);
dlog
<<
LINFO
<<
"computed obj: "
<<
compute_objective_value
(
w
,
A
,
b
,
C
);
w
=
0
,
0
,
0
;
dlog
<<
LINFO
<<
"with true w obj: "
<<
compute_objective_value
(
w
,
A
,
b
,
C
);
dlog
<<
LINFO
<<
"alpha: "
<<
trans
(
alpha
);
const
double
computed_obj
=
compute_objective_value
(
w
,
A
,
b
,
C
);
true_alpha
=
2
,
0
,
0
;
w
=
0
,
0
,
0
;
dlog
<<
LINFO
<<
"true alpha: "
<<
trans
(
true_alpha
);
const
double
true_obj
=
compute_objective_value
(
w
,
A
,
b
,
C
);
dlog
<<
LINFO
<<
"computed obj: "
<<
computed_obj
;
dlog
<<
LINFO
<<
"with true w obj: "
<<
true_obj
;
dlog
<<
LINFO
<<
"alpha error: "
<<
max
(
abs
(
alpha
-
true_alpha
));
DLIB_TEST_MSG
(
abs
(
computed_obj
-
true_obj
)
<
1e-8
,
abs
(
computed_obj
-
true_obj
));
DLIB_TEST
(
max
(
abs
(
alpha
-
true_alpha
))
<
1e-9
);
}
}
void
test_qp4_test7
()
void
test_qp4_test7
()
...
...
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