-
Notifications
You must be signed in to change notification settings - Fork 0
/
utility.h
206 lines (172 loc) · 6.76 KB
/
utility.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*! \file utility.h
* \brief The declaration of some utility functions.
* \author Christos Nitsas
* \date 2012
*/
#ifndef PARETO_APPROXIMATOR_UTILITIES_H
#define PARETO_APPROXIMATOR_UTILITIES_H
#include <vector>
#include <list>
#include "Point.h"
#include "PointAndSolution.h"
#include "Facet.h"
/*!
* \weakgroup ParetoApproximator Everything needed for the Pareto set approximation algorithms.
* @{
*/
//! The namespace containing everything needed for the Pareto set approximation algorithms.
namespace pareto_approximator {
//! The namespace containing utility functions.
/*!
* (i.e. functions called by class methods e.t.c.)
*/
namespace utility {
//! Compute the facets of the convex hull of the given set of points.
/*!
* \param points A (const reference to a) std::vector of points.
* (PointAndSolution<S> instances)
* \param spaceDimension The dimension of the space that the points live in.
* \return A list containing all the facets (Facet<S> instances) of the
* convex hull.
*
* This function requires that the external program/tool qconvex,
* distributed with qhull (see www.qhull.org) be installed on the system
* (and be on the PATH).
*
* This function currently only works for Unix-like systems, it won't
* work on Windows. It has only been tested on Mac OS X Mountain Lion
* but should work on other Unix-like systems as well.
*
* \sa BaseProblem::doPgen()
*/
template <class S>
typename std::list< Facet<S> >
computeConvexHullFacets(const std::vector< PointAndSolution<S> > & points,
unsigned int spaceDimension);
//! Compute the convex hull of the given set of points.
/*!
* \param points A (const reference to a) std::vector of points.
* (PointAndSolution<S> instances)
* \param spaceDimension The dimension of the space that the points live in.
* \return A vector containing all the extreme points (PointAndSolution<S>
* instances) of the convex hull.
*
* This function requires that the external program/tool qconvex,
* distributed with qhull (see www.qhull.org) be installed on the system
* (and be on the PATH).
*
* This function currently only works for Unix-like systems, it won't
* work on Windows. It has only been tested on Mac OS X Mountain Lion
* but should work on other Unix-like systems as well.
*
* \sa BaseProblem::doPgen()
*/
template <class S>
typename std::list< PointAndSolution<S> >
computeConvexHull(const std::vector< PointAndSolution<S> > & points,
unsigned int spaceDimension);
/*!
* \brief Filter a sequence of PointAndSolution instances and return
* only the non-dominated ones.
*
* \param first An iterator to the first element in the sequence.
* \param last An iterator to the past-the-end element in the sequence.
*
* We will use a pareto_approximator::NonDominatedSet to discard dominated
* points.
*
* \sa NonDominatedSet
*/
template <class S>
std::vector< PointAndSolution<S> >
filterDominatedPoints(
typename std::vector< PointAndSolution<S> >::const_iterator first,
typename std::vector< PointAndSolution<S> >::const_iterator last);
//! Discard facets not useful for generating new Pareto points.
/*!
* \param facets A (reference to a) list of facets.
*
* Discard facets with all normal vector coefficients non-positive (<= 0).
* Facets with no positive normal vector coefficient are not useful for
* generating new Pareto optimal points.
*
* Only facets with all-positive or mixed (i.e. containing at least some
* positive coefficients) normal vectors can be used to generate new
* Pareto optimal points.
*
* \sa Facet, BaseProblem::doChord() and BaseProblem::doPgen()
*/
template <class S>
void
discardUselessFacets(std::list< Facet<S> > & facets);
/*! \brief Choose the Facet instance with the largest local approximation
* error upper bound from sequence of Facet instances.
*
* \param first A const_iterator to the first element in the sequence.
* \param last A const_iterator to the past-the-end element in the sequence.
* \return A const_iterator to the first element in the range that has the
* largest local approximation error upper bound. If no element
* is a non-boundary facet the function returns "last".
*
* The Facet::getLocalApproximationErrorUpperBound() method is used (of
* course) for the facet's local approximation error upper bound.
*
* Boundary facets (i.e. those with isBoundaryFacet() == true) are ignored.
*
* If all the facets in the sequence are boundary facets the iterator
* "last" is returned.
*
* \sa Facet
*/
template <class S>
typename std::list< Facet<S> >::iterator
chooseFacetWithLargestLocalApproximationErrorUpperBound(
typename std::list< Facet<S> >::iterator first,
typename std::list< Facet<S> >::iterator last);
/*! \brief Choose a boundary Facet instance with the smallest angle
* from the given sequence of Facet instances.
*
* \param first A const_iterator to the first element in the sequence.
* \param last A const_iterator to the past-the-end element in the sequence.
* \return A const_iterator to the first element in the range that is a
* boundary facet and has the smallest angle. If there are no
* boundary facets the function returns "last".
*
* Non boundary facets (i.e. those with isBoundaryFacet() == false) are
* ignored.
*
* If all the facets in the sequence are non boundary facets the iterator
* "last" is returned.
*
* \sa Facet
*/
template <class S>
typename std::list< Facet<S> >::iterator
chooseBoundaryFacetWithSmallestAngle(
typename std::list< Facet<S> >::iterator first,
typename std::list< Facet<S> >::iterator last);
//! Generate a weight vector (for comb()) using the given facet.
/*!
* \param facet A Facet instance. (Its vertices' weightsUsed attributes
* will be needed if the facet's normal vector is not
* all-positive.)
* \return A std::vector of objective weights (for BaseProblem::comb()).
*
* The resulting weights will be:
* - Either the facet's normal vector.
* (if it has no negative elements)
* - Or the mean of the weights used to obtain the facet's vertices.
*
* \sa BaseProblem, BaseProblem::comb() and
* BaseProblem::generateNewParetoPoint()
*/
template <class S>
std::vector<double>
generateNewWeightVector(const Facet<S> & facet);
} // namespace utility
} // namespace pareto_approximator
/* @} */
// We've got to #include the implementation here because this file contains
// function templates, not only simple functions.
#include "utility.cpp"
#endif // PARETO_APPROXIMATOR_UTILITIES_H