Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
psco-2019-gp
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Florian Heinrichs
psco-2019-gp
Commits
071fede7
Commit
071fede7
authored
5 years ago
by
Florian Heinrichs
Browse files
Options
Downloads
Patches
Plain Diff
Some tests
parent
7f2070d0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/bnb_test.cpp
+92
-8
92 additions, 8 deletions
test/bnb_test.cpp
with
92 additions
and
8 deletions
test/bnb_test.cpp
+
92
−
8
View file @
071fede7
...
...
@@ -8,21 +8,105 @@
TEST_CASE
(
"BnbTest"
)
{
//test partitioning of tiny graph
std
::
string
graph
=
"../test/inputs/tiny_01.graph"
;
auto
g
=
metis_reader
().
read
(
graph
);
auto
sol
=
gp_bnb
::
solver
(
g
);
sol
.
solve
();
std
::
vector
<
partition
::
subgraph
>
f
=
sol
.
best_solution
();
//node 1, 2,3 and 5 in one partition
REQUIRE
(
f
[
0
]
==
f
[
1
]);
REQUIRE
(
f
[
1
]
==
f
[
2
]);
REQUIRE
(
f
[
2
]
==
f
[
4
]);
//node 4, 6, 7 in the other one
REQUIRE
(
f
[
3
]
==
f
[
5
]);
REQUIRE
(
f
[
5
]
==
f
[
6
]);
//test solver
//
//test expand-function
//test backtrack-function
//test next_possible_subgraph
//tests partition functions
//
node_id
node
;
node
=
2
;
partition
::
subgraph
sg
;
sg
=
partition
::
subgraph
::
sg_a
;
partition
par
(
g
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
sg_a
)
==
0
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
sg_b
)
==
0
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
none
)
==
7
);
REQUIRE
(
par
.
assigned_subgraph_of
(
node
)
==
partition
::
subgraph
::
none
);
//test partition::assign_node
par
.
assign_node
(
node
,
sg
);
REQUIRE
(
par
.
assigned_subgraph_of
(
node
)
==
partition
::
subgraph
::
sg_a
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
sg_a
)
==
1
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
none
)
==
6
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
sg_b
)
==
0
);
node
=
4
;
sg
=
partition
::
subgraph
::
sg_b
;
par
.
assign_node
(
node
,
sg
);
REQUIRE
(
par
.
assigned_subgraph_of
(
node
)
==
partition
::
subgraph
::
sg_b
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
sg_a
)
==
1
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
none
)
==
5
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
sg_b
)
==
1
);
//REQUIRE_THROWS(par.assign_node(node, partition::subgraph::none));
//REQUIRE_THROWS(par.unassign_node(3));
//test partition::unassign_node
node
=
2
;
par
.
unassign_node
(
node
);
REQUIRE
(
par
.
assigned_subgraph_of
(
node
)
==
partition
::
subgraph
::
none
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
sg_a
)
==
0
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
none
)
==
6
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
sg_b
)
==
1
);
node
=
4
;
par
.
unassign_node
(
node
);
REQUIRE
(
par
.
assigned_subgraph_of
(
node
)
==
partition
::
subgraph
::
none
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
sg_a
)
==
0
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
none
)
==
7
);
REQUIRE
(
par
.
num_nodes_of
(
partition
::
sg_b
)
==
0
);
//trail_state
//
auto
tr
=
gp_bnb
::
trail_state
();
node
=
2
;
REQUIRE
(
tr
.
length
()
==
0
);
//test trail_state::push_node
tr
.
push_node
(
node
,
partition
::
subgraph
::
sg_a
);
REQUIRE
(
tr
.
length
()
==
1
);
REQUIRE
(
tr
.
node_at
(
0
)
==
2
);
REQUIRE
(
tr
.
alternative_at
(
0
)
==
partition
::
sg_a
);
node
=
3
;
tr
.
push_node
(
node
,
partition
::
subgraph
::
sg_b
);
REQUIRE
(
tr
.
length
()
==
2
);
REQUIRE
(
tr
.
node_at
(
1
)
==
3
);
REQUIRE
(
tr
.
alternative_at
(
1
)
==
partition
::
sg_b
);
REQUIRE
(
f
[
0
]
==
-
1
);
REQUIRE
(
f
[
1
]
==
-
1
);
REQUIRE
(
f
[
2
]
==
-
1
);
REQUIRE
(
f
[
3
]
==
1
);
REQUIRE
(
f
[
4
]
==
-
1
);
REQUIRE
(
f
[
5
]
==
1
);
REQUIRE
(
f
[
6
]
==
1
);
//test trail_state::pop
tr
.
pop
();
REQUIRE
(
tr
.
length
()
==
1
);
REQUIRE
(
tr
.
node_at
(
0
)
==
2
);
REQUIRE
(
tr
.
alternative_at
(
0
)
==
partition
::
sg_a
);
tr
.
pop
();
REQUIRE
(
tr
.
length
()
==
0
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
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