Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
55dd5b27
Commit
55dd5b27
authored
8 years ago
by
Kilian Verhetsel
Browse files
Options
Downloads
Patches
Plain Diff
Removed uses of auto in mwis.hpp
parent
b406d337
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Mesh/mwis.hpp
+31
-20
31 additions, 20 deletions
Mesh/mwis.hpp
with
31 additions
and
20 deletions
Mesh/mwis.hpp
+
31
−
20
View file @
55dd5b27
...
@@ -139,8 +139,7 @@ public:
...
@@ -139,8 +139,7 @@ public:
CliqueIterator
clique_end
,
CliqueIterator
clique_end
,
size_t
max_size
=
std
::
numeric_limits
<
size_t
>::
max
())
:
size_t
max_size
=
std
::
numeric_limits
<
size_t
>::
max
())
:
_graph
(
graph
),
_weight
(
weight_map
),
_max_size
(
max_size
)
{
_graph
(
graph
),
_weight
(
weight_map
),
_max_size
(
max_size
)
{
auto
vs
=
vertices
(
graph
);
size_t
vertex_count
=
num_vertices
(
graph
);
size_t
vertex_count
=
vs
.
second
-
vs
.
first
;
_clique_storage
.
resize
(
vertex_count
);
_clique_storage
.
resize
(
vertex_count
);
_selected_storage
.
resize
(
vertex_count
);
_selected_storage
.
resize
(
vertex_count
);
...
@@ -236,8 +235,10 @@ public:
...
@@ -236,8 +235,10 @@ public:
* (u, v) \in E <=> there is a clique which contains both u and v.
* (u, v) \in E <=> there is a clique which contains both u and v.
*/
*/
void
check_consistency
()
{
void
check_consistency
()
{
auto
es
=
boost
::
edges
(
_graph
);
typedef
typename
boost
::
graph_traits
<
Graph
>::
edge_iterator
edge_iterator
;
for
(
auto
eit
=
es
.
first
;
eit
!=
es
.
second
;
eit
++
)
{
std
::
pair
<
edge_iterator
,
edge_iterator
>
es
=
boost
::
edges
(
_graph
);
for
(
edge_iterator
eit
=
es
.
first
;
eit
!=
es
.
second
;
eit
++
)
{
bool
found
=
false
;
bool
found
=
false
;
vertex
v
=
boost
::
source
(
*
eit
,
_graph
);
vertex
v
=
boost
::
source
(
*
eit
,
_graph
);
...
@@ -468,6 +469,7 @@ struct state {
...
@@ -468,6 +469,7 @@ struct state {
template
<
typename
Graph
,
typename
WeightMap
>
template
<
typename
Graph
,
typename
WeightMap
>
class
clique_assignment
{
class
clique_assignment
{
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
out_edge_iterator
out_edge_iterator
;
typedef
typename
boost
::
property_traits
<
WeightMap
>::
value_type
weight
;
typedef
typename
boost
::
property_traits
<
WeightMap
>::
value_type
weight
;
size_t
_id
;
size_t
_id
;
...
@@ -497,8 +499,9 @@ public:
...
@@ -497,8 +499,9 @@ public:
selected_vertex
.
push_back
(
_vertex
);
selected_vertex
.
push_back
(
_vertex
);
new_weight
+=
get
(
state
.
weight_map
,
_vertex
);
new_weight
+=
get
(
state
.
weight_map
,
_vertex
);
auto
edges
=
out_edges
(
_vertex
,
state
.
graph
);
std
::
pair
<
out_edge_iterator
,
out_edge_iterator
>
edges
=
for
(
auto
eit
=
edges
.
first
;
eit
!=
edges
.
second
;
eit
++
)
{
out_edges
(
_vertex
,
state
.
graph
);
for
(
out_edge_iterator
eit
=
edges
.
first
;
eit
!=
edges
.
second
;
eit
++
)
{
const
vertex
&
other
=
target
(
*
eit
,
state
.
graph
);
const
vertex
&
other
=
target
(
*
eit
,
state
.
graph
);
if
(
state
.
selectable
.
find
(
other
)
!=
state
.
selectable
.
end
())
{
if
(
state
.
selectable
.
find
(
other
)
!=
state
.
selectable
.
end
())
{
removed
.
push_back
(
other
);
removed
.
push_back
(
other
);
...
@@ -897,6 +900,8 @@ public:
...
@@ -897,6 +900,8 @@ public:
template
<
typename
Graph
,
typename
WeightMap
>
template
<
typename
Graph
,
typename
WeightMap
>
class
lns_search
{
class
lns_search
{
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_iterator
vertex_iterator
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
out_edge_iterator
out_edge_iterator
;
typedef
typename
boost
::
property_traits
<
WeightMap
>::
value_type
weight
;
typedef
typename
boost
::
property_traits
<
WeightMap
>::
value_type
weight
;
std
::
vector
<
std
::
vector
<
vertex
>>
_cliques
;
std
::
vector
<
std
::
vector
<
vertex
>>
_cliques
;
...
@@ -929,8 +934,9 @@ public:
...
@@ -929,8 +934,9 @@ public:
new_weight
+=
get
(
l_state
.
weight_map
,
v
);
new_weight
+=
get
(
l_state
.
weight_map
,
v
);
auto
edges
=
out_edges
(
v
,
l_state
.
graph
);
std
::
pair
<
out_edge_iterator
,
out_edge_iterator
>
edges
=
for
(
auto
eit
=
edges
.
first
;
eit
!=
edges
.
second
;
eit
++
)
{
out_edges
(
v
,
l_state
.
graph
);
for
(
out_edge_iterator
eit
=
edges
.
first
;
eit
!=
edges
.
second
;
eit
++
)
{
const
vertex
&
other
=
target
(
*
eit
,
l_state
.
graph
);
const
vertex
&
other
=
target
(
*
eit
,
l_state
.
graph
);
removed
.
insert
(
other
);
removed
.
insert
(
other
);
}
}
...
@@ -940,8 +946,8 @@ public:
...
@@ -940,8 +946,8 @@ public:
assigned
.
insert
(
clique
[
i
]);
assigned
.
insert
(
clique
[
i
]);
}
}
auto
vs
=
boost
::
vertices
(
l_state
.
graph
);
std
::
pair
<
vertex_iterator
,
vertex_iterator
>
vs
=
boost
::
vertices
(
l_state
.
graph
);
for
(
a
u
to
it
=
vs
.
first
;
it
!=
vs
.
second
;
it
++
)
{
for
(
vertex_iter
ato
r
it
=
vs
.
first
;
it
!=
vs
.
second
;
it
++
)
{
vertex
v
=
*
it
;
vertex
v
=
*
it
;
if
(
fragment
.
vertices
.
find
(
v
)
==
fragment
.
vertices
.
end
())
if
(
fragment
.
vertices
.
find
(
v
)
==
fragment
.
vertices
.
end
())
removed
.
insert
(
v
);
removed
.
insert
(
v
);
...
@@ -1046,20 +1052,24 @@ public:
...
@@ -1046,20 +1052,24 @@ public:
template
<
typename
Graph
,
typename
OutputIterator
>
template
<
typename
Graph
,
typename
OutputIterator
>
void
find_cliques
(
const
Graph
&
graph
,
OutputIterator
out
)
{
void
find_cliques
(
const
Graph
&
graph
,
OutputIterator
out
)
{
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
edge_iterator
edge_iterator
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
out_edge_iterator
out_edge_iterator
;
std
::
set
<
std
::
pair
<
vertex
,
vertex
>>
visited_edges
;
std
::
set
<
std
::
pair
<
vertex
,
vertex
>>
visited_edges
;
auto
es
=
edges
(
graph
);
std
::
pair
<
edge_iterator
,
edge_iterator
>
es
=
edges
(
graph
);
for
(
a
u
to
eit
=
es
.
first
;
eit
!=
es
.
second
;
eit
++
)
{
for
(
edge_iter
ato
r
eit
=
es
.
first
;
eit
!=
es
.
second
;
eit
++
)
{
auto
u
=
source
(
*
eit
,
graph
);
vertex
u
=
source
(
*
eit
,
graph
);
auto
v
=
target
(
*
eit
,
graph
);
vertex
v
=
target
(
*
eit
,
graph
);
if
(
visited_edges
.
find
(
std
::
make_pair
(
u
,
v
))
==
visited_edges
.
end
())
{
if
(
visited_edges
.
find
(
std
::
make_pair
(
u
,
v
))
==
visited_edges
.
end
())
{
std
::
vector
<
vertex
>
contents
,
candidates
;
std
::
vector
<
vertex
>
contents
,
candidates
;
auto
connected_es
=
out_edges
(
u
,
graph
);
std
::
pair
<
out_edge_iterator
,
out_edge_iterator
>
connected_es
=
for
(
auto
eit
=
connected_es
.
first
;
eit
!=
connected_es
.
second
;
eit
++
)
{
out_edges
(
u
,
graph
);
auto
new_v
=
target
(
*
eit
,
graph
);
for
(
out_edge_iterator
eit
=
connected_es
.
first
;
eit
!=
connected_es
.
second
;
eit
++
)
{
vertex
new_v
=
target
(
*
eit
,
graph
);
if
(
new_v
!=
v
&&
visited_edges
.
find
(
std
::
make_pair
(
u
,
new_v
))
==
if
(
new_v
!=
v
&&
visited_edges
.
find
(
std
::
make_pair
(
u
,
new_v
))
==
visited_edges
.
end
())
{
visited_edges
.
end
())
{
candidates
.
push_back
(
new_v
);
candidates
.
push_back
(
new_v
);
...
@@ -1100,6 +1110,7 @@ template<typename Graph, typename WeightMap, typename OutputIterator>
...
@@ -1100,6 +1110,7 @@ template<typename Graph, typename WeightMap, typename OutputIterator>
void
maximum_weight_independent_set
(
const
Graph
&
graph
,
WeightMap
weight_map
,
void
maximum_weight_independent_set
(
const
Graph
&
graph
,
WeightMap
weight_map
,
OutputIterator
out
)
{
OutputIterator
out
)
{
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_iterator
vertex_iterator
;
typedef
typename
boost
::
property_traits
<
WeightMap
>::
value_type
weight
;
typedef
typename
boost
::
property_traits
<
WeightMap
>::
value_type
weight
;
std
::
vector
<
std
::
vector
<
vertex
>>
cliques
;
std
::
vector
<
std
::
vector
<
vertex
>>
cliques
;
...
@@ -1120,13 +1131,13 @@ void maximum_weight_independent_set(const Graph &graph, WeightMap weight_map,
...
@@ -1120,13 +1131,13 @@ void maximum_weight_independent_set(const Graph &graph, WeightMap weight_map,
cliques
.
begin
(),
cliques
.
end
());
cliques
.
begin
(),
cliques
.
end
());
#ifdef MWIS_MCTS
#ifdef MWIS_MCTS
auto
vs
=
vertices
(
graph
);
std
::
pair
<
vertex_iterator
,
vertex_iterator
>
vs
=
vertices
(
graph
);
weight
root_bound
(
bound
(
vs
.
second
,
vs
.
second
,
vs
.
first
,
vs
.
second
));
weight
root_bound
(
bound
(
vs
.
second
,
vs
.
second
,
vs
.
first
,
vs
.
second
));
mwis
::
direct_evaluator
<
Graph
,
WeightMap
>
direct_eval
(
root_bound
);
mwis
::
direct_evaluator
<
Graph
,
WeightMap
>
direct_eval
(
root_bound
);
mwis
::
max_bound
<
weight
>
max_bound
;
mwis
::
max_bound
<
weight
>
max_bound
;
mwis
::
successor
<
Graph
,
WeightMap
,
decltype
(
max_bound
)
>
mwis
::
successor
<
Graph
,
WeightMap
,
mwis
::
max_bound
<
weight
>
>
max_successor
(
max_bound
,
visitor
.
best_value
);
max_successor
(
max_bound
,
visitor
.
best_value
);
search
::
monte_carlo_tree_search
(
state
,
max_successor
,
direct_eval
);
search
::
monte_carlo_tree_search
(
state
,
max_successor
,
direct_eval
);
...
@@ -1145,7 +1156,7 @@ void maximum_weight_independent_set(const Graph &graph, WeightMap weight_map,
...
@@ -1145,7 +1156,7 @@ void maximum_weight_independent_set(const Graph &graph, WeightMap weight_map,
mwis
::
fragment_selector
<
Graph
,
WeightMap
>
;
mwis
::
fragment_selector
<
Graph
,
WeightMap
>
;
mwis
::
lns_search
<
Graph
,
WeightMap
>
l_search
(
cliques
.
begin
(),
cliques
.
end
());
mwis
::
lns_search
<
Graph
,
WeightMap
>
l_search
(
cliques
.
begin
(),
cliques
.
end
());
search
::
large_neighborhood_search
(
l_state
,
l_selector
,
l_search
,
30
0
);
search
::
large_neighborhood_search
(
l_state
,
l_selector
,
l_search
,
1
0
);
std
::
cout
<<
"
\n
"
;
std
::
cout
<<
"
\n
"
;
for
(
std
::
size_t
i
=
0
;
i
<
l_state
.
solution
.
size
();
i
++
)
for
(
std
::
size_t
i
=
0
;
i
<
l_state
.
solution
.
size
();
i
++
)
...
...
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