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
4a8dec61
Commit
4a8dec61
authored
8 years ago
by
Kilian Verhetsel
Browse files
Options
Downloads
Patches
Plain Diff
Removed nested angle brackets from mwis.hpp
parent
d3c4cb7b
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
+82
-80
82 additions, 80 deletions
Mesh/mwis.hpp
with
82 additions
and
80 deletions
Mesh/mwis.hpp
+
82
−
80
View file @
4a8dec61
...
@@ -111,7 +111,7 @@ class lagrangian_bound {
...
@@ -111,7 +111,7 @@ class lagrangian_bound {
typedef
boost
::
iterator_property_map
<
typedef
boost
::
iterator_property_map
<
std
::
vector
<
bool
>::
iterator
,
index_map
>
selected_map_type
;
std
::
vector
<
bool
>::
iterator
,
index_map
>
selected_map_type
;
typedef
boost
::
iterator_property_map
<
typedef
boost
::
iterator_property_map
<
std
::
vector
<
std
::
vector
<
size_t
>>::
iterator
,
index_map
>
clique_map_type
;
std
::
vector
<
std
::
vector
<
size_t
>
>::
iterator
,
index_map
>
clique_map_type
;
typedef
boost
::
iterator_property_map
<
typedef
boost
::
iterator_property_map
<
typename
std
::
vector
<
weight
>::
iterator
,
index_map
>
weight_map_type
;
typename
std
::
vector
<
weight
>::
iterator
,
index_map
>
weight_map_type
;
...
@@ -119,11 +119,11 @@ class lagrangian_bound {
...
@@ -119,11 +119,11 @@ class lagrangian_bound {
WeightMap
_weight
;
WeightMap
_weight
;
size_t
_max_size
;
size_t
_max_size
;
std
::
vector
<
std
::
vector
<
vertex
>>
_clique_contents
;
std
::
vector
<
std
::
vector
<
vertex
>
>
_clique_contents
;
std
::
vector
<
weight
>
_lambda
,
_gradient
;
std
::
vector
<
weight
>
_lambda
,
_gradient
;
std
::
vector
<
std
::
vector
<
size_t
>>
_clique_storage
;
std
::
vector
<
std
::
vector
<
size_t
>
>
_clique_storage
;
std
::
vector
<
bool
>
_selected_storage
;
std
::
vector
<
bool
>
_selected_storage
;
std
::
vector
<
weight
>
_effective_weight_storage
;
std
::
vector
<
weight
>
_effective_weight_storage
;
...
@@ -767,7 +767,7 @@ class evaluator {
...
@@ -767,7 +767,7 @@ class evaluator {
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex
;
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
;
size_t
_limit
;
size_t
_limit
;
public:
public:
typedef
weight
result_type
;
typedef
weight
result_type
;
...
@@ -795,16 +795,28 @@ public:
...
@@ -795,16 +795,28 @@ public:
template
<
typename
Graph
,
typename
WeightMap
>
template
<
typename
Graph
,
typename
WeightMap
>
struct
lns_state
{
struct
lns_state
{
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
vertex
;
typedef
typename
boost
::
property_map
<
Graph
,
boost
::
vertex_index_t
>::
type
index_map
;
typedef
boost
::
iterator_property_map
<
std
::
vector
<
bool
>::
iterator
,
index_map
>
solution_map_type
;
const
Graph
&
graph
;
const
Graph
&
graph
;
WeightMap
weight_map
;
WeightMap
weight_map
;
std
::
vector
<
vertex
>
solution
;
std
::
vector
<
bool
>
solution_storage
;
solution_map_type
solution
;
lns_state
(
const
Graph
&
graph
,
WeightMap
weight_map
,
lns_state
(
const
Graph
&
graph
,
WeightMap
weight_map
,
const
std
::
vector
<
vertex
>
&
solution
)
:
const
std
::
vector
<
vertex
>
&
initial_solution
)
:
graph
(
graph
),
weight_map
(
weight_map
),
solution
(
solution
)
graph
(
graph
),
weight_map
(
weight_map
),
{}
solution_storage
(
num_vertices
(
graph
),
false
)
{
index_map
ids
=
boost
::
get
(
boost
::
vertex_index
,
graph
);
solution
=
make_iterator_property_map
(
solution_storage
.
begin
(),
ids
);
for
(
std
::
size_t
i
=
0
;
i
<
initial_solution
.
size
();
i
++
)
{
put
(
solution
,
initial_solution
[
i
],
true
);
}
}
};
};
template
<
typename
Graph
>
template
<
typename
Graph
>
...
@@ -855,7 +867,7 @@ public:
...
@@ -855,7 +867,7 @@ public:
* visited edge into a set.
* visited edge into a set.
*/
*/
template
<
typename
Graph
,
typename
Tag
>
template
<
typename
Graph
,
typename
Tag
>
class
set_recorder
:
public
boost
::
base_visitor
<
set_recorder
<
Graph
,
Tag
>>
{
class
set_recorder
:
public
boost
::
base_visitor
<
set_recorder
<
Graph
,
Tag
>
>
{
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_descriptor
edge
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
edge_descriptor
edge
;
...
@@ -930,104 +942,94 @@ class lns_search {
...
@@ -930,104 +942,94 @@ class lns_search {
typedef
typename
boost
::
graph_traits
<
Graph
>::
out_edge_iterator
out_edge_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
;
typedef
typename
boost
::
property_map
<
Graph
,
boost
::
vertex_index_t
>::
type
index_map
;
typedef
boost
::
iterator_property_map
<
std
::
vector
<
std
::
vector
<
size_t
>
>::
iterator
,
index_map
>
clique_map_type
;
const
Graph
&
_graph
;
std
::
vector
<
std
::
vector
<
vertex
>
>
_clique_contents
;
std
::
vector
<
std
::
vector
<
std
::
size_t
>
>
_clique_storage
;
clique_map_type
_cliques
;
public:
public:
typedef
lns_assignment
<
Graph
>
result_type
;
typedef
lns_assignment
<
Graph
>
result_type
;
typedef
lns_state
<
Graph
,
WeightMap
>
first_argument_type
;
typedef
lns_state
<
Graph
,
WeightMap
>
first_argument_type
;
typedef
lns_fragment
<
Graph
>
second_argument_type
;
typedef
lns_fragment
<
Graph
>
second_argument_type
;
template
<
typename
Iterator
>
template
<
typename
Iterator
>
lns_search
(
Iterator
begin
,
Iterator
end
)
:
_cliques
(
begin
,
end
)
{}
lns_search
(
const
Graph
&
graph
,
Iterator
begin
,
Iterator
end
)
:
_graph
(
graph
),
_clique_contents
(
begin
,
end
)
{
lns_assignment
<
Graph
>
operator
()(
const
lns_state
<
Graph
,
WeightMap
>
&
l_state
,
size_t
vertex_count
=
num_vertices
(
graph
);
const
lns_fragment
<
Graph
>
&
fragment
)
const
{
_clique_storage
.
resize
(
vertex_count
);
state
<
Graph
,
WeightMap
>
search_state
(
l_state
.
graph
,
l_state
.
weight_map
,
_cliques
.
begin
(),
_cliques
.
end
());
std
::
vector
<
vertex
>
selected_vertex
;
std
::
set
<
vertex
>
removed
;
std
::
set
<
size_t
>
assigned
;
weight
new_weight
(
0
);
for
(
std
::
size_t
i
=
0
;
i
<
l_state
.
solution
.
size
();
i
++
)
{
vertex
v
=
l_state
.
solution
[
i
];
if
(
fragment
.
vertices
.
find
(
v
)
!=
fragment
.
vertices
.
end
())
continue
;
selected_vertex
.
push_back
(
v
);
new_weight
+=
get
(
l_state
.
weight_map
,
v
);
index_map
ids
=
boost
::
get
(
boost
::
vertex_index
,
graph
);
_cliques
=
make_iterator_property_map
(
_clique_storage
.
begin
(),
ids
);
std
::
pair
<
out_edge_iterator
,
out_edge_iterator
>
edges
=
size_t
i
=
0
;
out_edges
(
v
,
l_state
.
graph
);
for
(
Iterator
it
=
begin
;
it
!=
end
;
it
++
,
i
++
)
{
for
(
out_edge_iterator
eit
=
edges
.
first
;
e
it
!
=
edges
.
second
;
eit
++
)
{
for
(
typename
std
::
vector
<
vertex
>::
const_iterator
v_
it
=
it
->
begin
();
const
vertex
&
other
=
target
(
*
eit
,
l_state
.
graph
);
v_it
!=
it
->
end
();
v_it
++
)
{
removed
.
insert
(
other
);
get
(
_cliques
,
*
v_it
).
push_back
(
i
);
}
}
const
std
::
vector
<
std
::
size_t
>
&
clique
=
get
(
search_state
.
clique_map
,
v
);
for
(
size_t
i
=
0
;
i
<
clique
.
size
();
i
++
)
assigned
.
insert
(
clique
[
i
]);
}
}
}
std
::
pair
<
vertex_iterator
,
vertex_iterator
>
vs
=
boost
::
vertices
(
l_state
.
graph
);
lns_assignment
<
Graph
>
operator
()(
const
lns_state
<
Graph
,
WeightMap
>
&
l_state
,
for
(
vertex_iterator
it
=
vs
.
first
;
it
!=
vs
.
second
;
it
++
)
{
const
lns_fragment
<
Graph
>
&
fragment
)
const
{
vertex
v
=
*
it
;
if
(
fragment
.
vertices
.
find
(
v
)
==
fragment
.
vertices
.
end
())
removed
.
insert
(
v
);
}
std
::
map
<
size_t
,
size_t
>
size_delta
;
std
::
set
<
std
::
size_t
>
clique_ids
;
for
(
typename
std
::
set
<
vertex
>::
const_iterator
it
=
removed
.
begin
();
it
!=
removed
.
end
();
it
++
)
{
vertex
v
=
*
it
;
const
std
::
vector
<
vertex
>
&
cliques
=
get
(
search_state
.
clique_map
,
v
);
weight
best_value
(
0
);
for
(
std
::
size_t
i
=
0
;
i
<
cliques
.
size
();
i
++
)
{
std
::
vector
<
vertex
>
best_solution
;
std
::
size_t
clique
=
cliques
[
i
];
size_delta
[
clique
]
++
;
for
(
typename
std
::
set
<
vertex
>::
const_iterator
it
=
if
(
size_delta
[
clique
]
==
search_state
.
clique_sizes
[
clique
])
{
fragment
.
vertices
.
begin
();
assigned
.
insert
(
clique
);
it
!=
fragment
.
vertices
.
end
();
it
++
)
{
}
const
std
::
vector
<
size_t
>
cs
=
get
(
_cliques
,
*
it
);
std
::
copy
(
cs
.
begin
(),
cs
.
end
(),
std
::
inserter
(
clique_ids
,
clique_ids
.
begin
()));
if
(
get
(
l_state
.
solution
,
*
it
))
{
best_value
+=
get
(
l_state
.
weight_map
,
*
it
);
best_solution
.
push_back
(
*
it
);
}
}
}
}
std
::
vector
<
size_t
>
assigned_v
(
assigned
.
begin
(),
assigned
.
end
());
std
::
vector
<
std
::
vector
<
vertex
>
>
selectable_cliques
;
std
::
vector
<
vertex
>
removed_v
(
removed
.
begin
(),
removed
.
end
());
for
(
std
::
set
<
std
::
size_t
>::
const_iterator
it
=
clique_ids
.
begin
();
it
!=
clique_ids
.
end
();
it
++
)
{
state_change
<
Graph
,
WeightMap
>
delta
(
std
::
vector
<
vertex
>
data
=
_clique_contents
[
*
it
];
assigned_v
,
size_delta
,
data
.
erase
(
selected_vertex
,
removed_v
,
std
::
remove_if
(
data
.
begin
(),
data
.
end
(),
weight
(
0
),
new_weight
);
std
::
not1
(
make_set_membership_test
(
fragment
.
vertices
))),
data
.
end
());
if
(
data
.
size
()
!=
0
)
selectable_cliques
.
push_back
(
data
);
}
delta
.
apply
(
search_state
);
state
<
Graph
,
WeightMap
>
search_state
(
l_state
.
graph
,
l_state
.
weight_map
,
selectable_cliques
.
begin
(),
selectable_cliques
.
end
());
lagrangian_bound
<
Graph
,
WeightMap
>
lagrangian_bound
<
Graph
,
WeightMap
>
bound
(
l_state
.
graph
,
l_state
.
weight_map
,
bound
(
l_state
.
graph
,
l_state
.
weight_map
,
_cliques
.
begin
(),
_cliques
.
end
());
selectable_cliques
.
begin
(),
selectable_cliques
.
end
());
visit_state
<
Graph
,
WeightMap
>
visitor
;
visit_state
<
Graph
,
WeightMap
>
visitor
;
visitor
.
best_solution
=
l_state
.
solution
;
visitor
.
best_solution
=
best_solution
;
visitor
.
best_value
=
weight
(
0
);
visitor
.
best_value
=
best_value
;
for
(
std
::
size_t
i
=
0
;
i
<
visitor
.
best_solution
.
size
();
i
++
)
visitor
.
best_value
+=
get
(
l_state
.
weight_map
,
visitor
.
best_solution
[
i
]);
successor
<
Graph
,
WeightMap
,
lagrangian_bound
<
Graph
,
WeightMap
>
>
successor
(
successor
<
Graph
,
WeightMap
,
lagrangian_bound
<
Graph
,
WeightMap
>
>
successor
(
bound
,
visitor
.
best_value
);
bound
,
visitor
.
best_value
);
search
::
depth_first_search
(
search_state
,
visitor
,
successor
);
search
::
depth_first_search
(
search_state
,
visitor
,
successor
);
std
::
vector
<
vertex
>
newly_selected
;
return
lns_assignment
<
Graph
>
(
visitor
.
best_solution
);
for
(
std
::
size_t
i
=
0
;
i
<
visitor
.
best_solution
.
size
();
i
++
)
{
vertex
v
=
visitor
.
best_solution
[
i
];
if
(
fragment
.
vertices
.
find
(
v
)
!=
fragment
.
vertices
.
end
())
newly_selected
.
push_back
(
v
);
}
return
lns_assignment
<
Graph
>
(
newly_selected
);
}
}
};
};
...
@@ -1081,7 +1083,7 @@ void find_cliques(const Graph &graph, OutputIterator out) {
...
@@ -1081,7 +1083,7 @@ void find_cliques(const Graph &graph, OutputIterator out) {
typedef
typename
boost
::
graph_traits
<
Graph
>::
edge_iterator
edge_iterator
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
edge_iterator
edge_iterator
;
typedef
typename
boost
::
graph_traits
<
Graph
>::
out_edge_iterator
out_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
;
std
::
pair
<
edge_iterator
,
edge_iterator
>
es
=
edges
(
graph
);
std
::
pair
<
edge_iterator
,
edge_iterator
>
es
=
edges
(
graph
);
for
(
edge_iterator
eit
=
es
.
first
;
eit
!=
es
.
second
;
eit
++
)
{
for
(
edge_iterator
eit
=
es
.
first
;
eit
!=
es
.
second
;
eit
++
)
{
...
@@ -1139,7 +1141,7 @@ void maximum_weight_independent_set(const Graph &graph, WeightMap weight_map,
...
@@ -1139,7 +1141,7 @@ void maximum_weight_independent_set(const Graph &graph, WeightMap weight_map,
typedef
typename
boost
::
graph_traits
<
Graph
>::
vertex_iterator
vertex_iterator
;
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
;
mwis
::
find_cliques
(
graph
,
std
::
back_inserter
(
cliques
));
mwis
::
find_cliques
(
graph
,
std
::
back_inserter
(
cliques
));
mwis
::
lagrangian_bound
<
Graph
,
WeightMap
>
bound
(
mwis
::
lagrangian_bound
<
Graph
,
WeightMap
>
bound
(
...
...
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