Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Distributed Autonomous Networked Control Lab
MicroCART
Commits
1c50d605
Commit
1c50d605
authored
8 years ago
by
dawehr
Browse files
Options
Downloads
Patches
Plain Diff
Added another test for computation graph update rules.
parent
c9b3190f
No related branches found
No related tags found
1 merge request
!8
Controller network
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
quad/computation_graph/test/test_computation_graph.c
+29
-0
29 additions, 0 deletions
quad/computation_graph/test/test_computation_graph.c
with
29 additions
and
0 deletions
quad/computation_graph/test/test_computation_graph.c
+
29
−
0
View file @
1c50d605
...
...
@@ -160,6 +160,34 @@ int graph_test_update_rules() {
return
nequal
(
result
,
3
);
}
/*
C1 --->| accum_b1 --->|
| Add --->
C2 --->| accum_b2 --->|
*/
int
graph_test_update_propagation
()
{
struct
computation_graph
*
graph
=
create_graph
();
int
cblock1
=
graph_add_node_const
(
graph
,
"const1"
);
int
cblock2
=
graph_add_node_const
(
graph
,
"const2"
);
int
accum_b1
=
graph_add_node_accum
(
graph
,
"accumulator1"
);
int
accum_b2
=
graph_add_node_accum
(
graph
,
"accumulator2"
);
int
add_b
=
graph_add_node_add
(
graph
,
"add"
);
graph_set_source
(
graph
,
accum_b1
,
ACCUM_IN
,
cblock1
,
CONST_VAL
);
graph_set_source
(
graph
,
accum_b2
,
ACCUM_IN
,
cblock2
,
CONST_VAL
);
graph_set_source
(
graph
,
add_b
,
ADD_SUMMAND1
,
accum_b1
,
ACCUMULATED
);
graph_set_source
(
graph
,
add_b
,
ADD_SUMMAND2
,
accum_b2
,
ACCUMULATED
);
graph_set_param_val
(
graph
,
cblock1
,
CONST_SET
,
5
);
graph_set_param_val
(
graph
,
cblock2
,
CONST_SET
,
2
);
int
to_compute_for
[]
=
{
add_b
};
graph_compute_nodes
(
graph
,
to_compute_for
,
1
);
double
result1
=
graph_get_output
(
graph
,
add_b
,
ADD_SUM
);
graph_set_param_val
(
graph
,
cblock1
,
CONST_SET
,
1
);
graph_compute_nodes
(
graph
,
to_compute_for
,
1
);
double
result2
=
graph_get_output
(
graph
,
add_b
,
ADD_SUM
);
return
nequal
(
result1
,
7
)
||
nequal
(
result2
,
8
);
}
int
main
()
{
int
success
=
0
;
...
...
@@ -171,5 +199,6 @@ int main() {
test
(
graph_test_reset_rules
,
"Tests that already connected blocks don't get reset"
);
test
(
graph_test_self_loop
,
"Tests that a self-loop computation terminates"
);
test
(
graph_test_update_rules
,
"Tests that nodes only update when their inputs change"
);
test
(
graph_test_update_propagation
,
"Tests that updates propagate only to their children"
);
test_summary
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment