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
GitLab 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
Show 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
...
@@ -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
>
...
@@ -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
);
for
(
vertex_iterator
it
=
vs
.
first
;
it
!=
vs
.
second
;
it
++
)
{
vertex
v
=
*
it
;
if
(
fragment
.
vertices
.
find
(
v
)
==
fragment
.
vertices
.
end
())
removed
.
insert
(
v
);
}
}
std
::
map
<
size_t
,
size_t
>
size_delta
;
lns_assignment
<
Graph
>
operator
()(
const
lns_state
<
Graph
,
WeightMap
>
&
l_state
,
for
(
typename
std
::
set
<
vertex
>::
const_iterator
it
=
removed
.
begin
();
const
lns_fragment
<
Graph
>
&
fragment
)
const
{
it
!=
removed
.
end
();
it
++
)
{
vertex
v
=
*
it
;
const
std
::
vector
<
vertex
>
&
cliques
=
get
(
search_state
.
clique_map
,
v
);
std
::
set
<
std
::
size_t
>
clique_ids
;
for
(
std
::
size_t
i
=
0
;
i
<
cliques
.
size
();
i
++
)
{
std
::
size_t
clique
=
cliques
[
i
];
size_delta
[
clique
]
++
;
weight
best_value
(
0
);
if
(
size_delta
[
clique
]
==
search_state
.
clique_sizes
[
clique
])
{
std
::
vector
<
vertex
>
best_solution
;
assigned
.
insert
(
clique
);
}
for
(
typename
std
::
set
<
vertex
>::
const_iterator
it
=
fragment
.
vertices
.
begin
();
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
++
)
{
std
::
vector
<
vertex
>
data
=
_clique_contents
[
*
it
];
data
.
erase
(
std
::
remove_if
(
data
.
begin
(),
data
.
end
(),
std
::
not1
(
make_set_membership_test
(
fragment
.
vertices
))),
data
.
end
());
state_change
<
Graph
,
WeightMap
>
delta
(
if
(
data
.
size
()
!=
0
)
assigned_v
,
size_delta
,
selectable_cliques
.
push_back
(
data
);
selected_vertex
,
removed_v
,
}
weight
(
0
),
new_weight
);
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
);
}
}
};
};
...
...
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