]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/doc/r_c_shortest_paths.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / graph / doc / r_c_shortest_paths.html
1 <html>
2 <!--
3 Copyright Michael Drexl 2006, 2007.
4
5 Distributed under the Boost Software License, Version 1.0.
6 (See accompanying file LICENSE_1_0.txt or copy at
7 http://boost.org/LICENSE_1_0.txt)
8 -->
9 <head>
10 <title>Boost Graph Library: Resource-Constrained Shortest Paths</title>
11 <body bgcolor="#ffffff" link="#0000ee" text="#000000" vlink="#551a8b"
12 alink="#ff0000">
13 <img src="../../../boost.png"
14 alt="C++ Boost" width="277" height="86">
15
16 <br Clear>
17
18 <h1><a name="sec:espprc"></a>
19 <tt>r_c_shortest_paths</tt>
20 </h1>
21
22 <p>
23 <pre>
24
25 template&lt;class Graph,
26 class VertexIndexMap,
27 class EdgeIndexMap,
28 class Resource_Container,
29 class Resource_Extension_Function,
30 class Dominance_Function,
31 class Label_Allocator,
32 class Visitor&gt;
33 void r_c_shortest_paths( const Graph&amp; g,
34 const VertexIndexMap&amp; vertex_index_map,
35 const EdgeIndexMap&amp; edge_index_map,
36 typename graph_traits&lt;Graph&gt;::vertex_descriptor s,
37 typename graph_traits&lt;Graph&gt;::vertex_descriptor t,
38 std::vector&lt;std::vector&lt;typename graph_traits&lt;Graph&gt;::edge_descriptor&gt; &gt;&amp; pareto_optimal_solutions,
39 std::vector&lt;Resource_Container&gt;&amp; pareto_optimal_resource_containers,
40 const Resource_Container&amp; rc,
41 const Resource_Extension_Function&amp; ref,
42 const Dominance_Function&amp; dominance,
43 Label_Allocator la,
44 Visitor vis )
45
46 template&lt;class Graph,
47 class VertexIndexMap,
48 class EdgeIndexMap,
49 class Resource_Container,
50 class Resource_Extension_Function,
51 class Dominance_Function,
52 class Label_Allocator,
53 class Visitor&gt;
54 void r_c_shortest_paths( const Graph&amp; g,
55 const VertexIndexMap&amp; vertex_index_map,
56 const EdgeIndexMap&amp; edge_index_map,
57 typename graph_traits&lt;Graph&gt;::vertex_descriptor s,
58 typename graph_traits&lt;Graph&gt;::vertex_descriptor t,
59 std::vector&lt;typename graph_traits&lt;Graph&gt;::edge_descriptor&gt;&amp; pareto_optimal_solution,
60 Resource_Container&gt;&amp; pareto_optimal_resource_container,
61 const Resource_Container&amp; rc,
62 const Resource_Extension_Function&amp; ref,
63 const Dominance_Function&amp; dominance,
64 Label_Allocator la,
65 Visitor vis )
66
67 template&lt;class Graph,
68 class VertexIndexMap,
69 class EdgeIndexMap,
70 class Resource_Container,
71 class Resource_Extension_Function,
72 class Dominance_Function&gt;
73 void r_c_shortest_paths( const Graph&amp; g,
74 const VertexIndexMap&amp; vertex_index_map,
75 const EdgeIndexMap&amp; edge_index_map,
76 typename graph_traits&lt;Graph&gt;::vertex_descriptor s,
77 typename graph_traits&lt;Graph&gt;::vertex_descriptor t,
78 std::vector&lt;std::vector&lt;typename graph_traits&lt;Graph&gt;::edge_descriptor&gt; &gt;&amp; pareto_optimal_solutions,
79 std::vector&lt;Resource_Container&gt;&amp; pareto_optimal_resource_containers,
80 const Resource_Container&amp; rc,
81 const Resource_Extension_Function&amp; ref,
82 const Dominance_Function&amp; dominance )
83
84 template&lt;class Graph,
85 class VertexIndexMap,
86 class EdgeIndexMap,
87 class Resource_Container,
88 class Resource_Extension_Function,
89 class Dominance_Function&gt;
90 void r_c_shortest_paths( const Graph&amp; g,
91 const VertexIndexMap&amp; vertex_index_map,
92 const EdgeIndexMap&amp; edge_index_map,
93 typename graph_traits&lt;Graph&gt;::vertex_descriptor s,
94 typename graph_traits&lt;Graph&gt;::vertex_descriptor t,
95 std::vector&lt;typename graph_traits&lt;Graph&gt;::edge_descriptor&gt;&amp; pareto_optimal_solution,
96 Resource_Container&gt;&amp; pareto_optimal_resource_container,
97 const Resource_Container&amp; rc,
98 const Resource_Extension_Function&amp; ref,
99 const Dominance_Function&amp; dominance )
100
101 </pre>
102
103 <h3>Introduction and Problem Description</h3>
104
105 The shortest path problem with resource constraints (SPPRC) seeks a shortest (cheapest, fastest) path in a directed graph with arbitrary arc lengths (travel times, costs) from an origin node to a destination node subject to one or more resource constraints. For example, one might seek a path of minimum length from <i>s</i> to <i>t</i> subject to the constraints that
106 <ul>
107 <li>
108 the total travel time must not exceed some upper bound and/or
109 <li>
110 the total amount of some good that has to be picked up at the vertices along the path be less than or equal to some capacity limit and/or
111 <li>
112 if two vertices <i>i</i> and <i>j</i> are visited on a path, then <i>i</i> must be visited before <i>j</i>
113 <li>
114 etc.
115 </ul>
116
117 <p>
118 The problem is NP-hard in the strong sense. If the path need not be elementary, i.e., if it is allowed that vertices are visited more than once, the problem can be solved in pseudopolynomial time. A central aspect is that two (partial) paths in an SPPRC can be incomparable, contrary to the SPP without resource constraints. This makes the SPPRC similar to a multi-criteria decision problem.<br>
119 A recent survey on the problem is:<br>
120 Irnich, S.; Desaulniers, G. (2005):<br>
121 Shortest Path Problems with Resource Constraints<br>
122 in:<br>
123 Desaulniers, G.; Desrosiers, J.; Solomon, M. (eds.) (2005):<br>
124 Column Generation<br>
125 Springer, New York, pp. 33&ndash;65<br>
126 (available online <a href="http://logistik.bwl.uni-mainz.de/Dateien/or_2004-01.pdf">
127 here</a>)
128 <p>
129
130 <p>
131 The present document cannot give a complete introduction to SPPRCs. To get a thorough understanding of the problem, the reader is referred to the above paper. However, to understand the algorithm and its implementation, it is necessary to explain some fundamental ideas and point out the differences to a labelling algorithm for the shortest path problem without resource constraints (SPP).
132 </p>
133
134 <p>
135 The standard solution technique for SPPRCs is a labelling algorithm based on dynamic programming. This approach uses the concepts of <i>resources</i> and <i>resource extension functions</i>. A resource is an arbitrarily scaled one-dimensional piece of information that can be determined or measured at the vertices of a directed walk in a graph. Examples are cost, time, load, or the information &lsquo;Is a vertex <i>i</i> visited on the current path?&rsquo;. A resource is <i>constrained</i> if there is at least one vertex in the graph where the resource must not take all possible values. The <i>resource window</i> of a resource at a vertex is the set of allowed values for the resource at this vertex.
136 </p>
137
138 <p>
139 A resource extension function is defined on each arc in a graph for each resource considered. A resource extension function for a resource maps the set of all possible vectors (in a mathematical sense, not to be confused with a <tt>std::vector</tt>) of resource values at the source of an arc to the set of possible values of the resource at the target of the arc. This means that the value of a resource at a vertex may depend on the values of one or more other resources at the preceding vertex.
140 </p>
141
142 <p>
143 <i>Labels</i> are used to store the information on the resource values for partial paths. A label in an SPPRC labelling algorithm is not a mere triple of resident vertex, current cost and predecessor vertex, as it is the case in labelling algorithms for the SPP. A label for an SPPRC labelling algorithm stores its resident vertex, its predecessor <i>arc</i> over which it has been extended, its predecessor label, and its current vector of resource values. The criterion to be minimized (cost, travel time, travel distance, whatsoever) is also treated as a (possibly unconstrained) resource. It is necessary to store the predecessor arc instead of the predecessor vertex, because, due to the resource constraints, one can not assume that the underlying graph is simple. Labels reside at vertices, and they are propagated via resource extension functions when they are extended along an arc. An <i>extension</i> of a label along an arc (<i>i</i>, <i>j</i>) is <i>feasible</i> if the resulting label <i>l</i> at <i>j</i> is feasible, which is the case if and only if all resource values of <i>l</i> are within their resource windows.
144 </p>
145
146 <p>
147 To keep the number of labels as small as possible, it is decisive to perform a <i>dominance step</i> for eliminating unnecessary labels. A label <i>l</i><sub>1</sub> <i>dominates</i> a label <i>l</i><sub>2</sub> if both reside at the same vertex and if, for each feasible extension of <i>l</i><sub>2</sub>, there is also a feasible extension of <i>l</i><sub>1</sub> where the value of each cardinally scaled resource is less than or equal to the value of the resource in the extension of <i>l</i><sub>2</sub>, and where the value of each nominally scaled resource is equal to the value of the resource in the extension of <i>l</i><sub>2</sub>. Dominated labels need not be extended. A label which is not dominated by any other label is called undominated or Pareto-optimal. The application of the dominance principle is optional&mdash;at least from a theoretical perspective.
148 </p>
149
150 <p>
151 The implementation is a label-setting algorithm. This means that there must be one or more resources whose cumulated consumption(s) after extension is/are always at least as high as before. This is similar to the Dijkstra algorithm for the SPP without resource constraints where the distance measure must be non-negative. It is sufficient if there is one resource with a non-negative resource consumption along all arcs (for example, non-negative arc lengths or non-negative arc traversal times).
152 </p>
153
154 <h3>Concepts</h3>
155
156 <h4>ResourceContainer</h4>
157
158 <p>
159 A type modelling the ResourceContainer concept is used to store the current resource consumptions of a label.
160 </p>
161
162 <p>
163 <b>Refinement of</b><br>
164 <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>, <a href="../../utility/CopyConstructible.html">CopyConstructible</a>, <a href="http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>, <a href="http://www.sgi.com/tech/stl/LessThanComparable.html">LessThanComparable</a>, <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">EqualityComparable</a>
165 </p>
166
167 <p>
168 <b>Valid Expressions</b><br>
169 See <a href="#ResourceExtensionFunction">ResourceExtensionFunction</a> concept.
170 </p>
171
172 <a name="Label"><h4>Label</h4></a>
173
174 <p>
175 This concept defines the interface for a label in the <tt>r_c_shortest_paths</tt> functions. It is a design decision not to parameterize the functions on the type of label. The type <tt>template&lt;class Graph, class Resource_Container&gt struct r_c_shortest_paths_label</tt> is used to model this concept.
176 </p>
177
178 <p>
179 <b>Valid Expressions</b><br>
180 If <tt>label</tt> is an object of type <tt>r_c_shortest_paths_label</tt>, the following expressions are valid:<br>
181 <table border>
182 <tr>
183 <td>
184 <tt>label.num</tt>
185 </td>
186 <td>
187 Returns an unsigned integer value specifying the number of the label. Labels are numbered consecutively in order of their creation.
188 </td>
189 </tr>
190 <tr>
191 <td>
192 <tt>label.cumulated_resource_consumption</tt>
193 </td>
194 <td>
195 Returns the object associated with <tt>label</tt> modelling the ResourceContainer concept.
196 </td>
197 </tr>
198 <tr>
199 <td>
200 <tt>label.p_pred_label</tt>
201 </td>
202 <td>
203 Returns a <tt>const</tt> pointer to the predecessor label, i.e., to the label whose extension along <tt>label.pred_edge</tt> yielded the <tt>label} object</tt>.
204 </td>
205 </tr>
206 <tr>
207 <td>
208 <tt>label.pred_edge</tt>
209 </td>
210 <td>
211 Returns an edge descriptor for the arc along which <tt>label.p_pred_label</tt> was extended to yield the <tt>label</tt> object.
212 </td>
213 </tr>
214 <tr>
215 <td>
216 <tt>label.resident_vertex</tt>
217 </td>
218 <td>
219 Returns a vertex descriptor for the vertex at which the <tt>label</tt> object resides.
220 </td>
221 </tr>
222 <tr>
223 <td>
224 <tt>label.b_is_dominated</tt>
225 </td>
226 <td>
227 Returns a boolean value indicating whether the <tt>label</tt> object is dominated by some other label residing at the vertex <tt>label.resident_vertex</tt>. Is useful only after dominance checking has been performed, i.e. only in the visitor functions <tt>on_label_dominated</tt> and <tt>on_label_not_dominated</tt> (see <a href="#ResourceConstrainedShortestPathsVisitor">below</a>).
228 </td>
229 </tr>
230 </table>
231
232 <p>
233 <b>Invariants</b><br>
234 Every <tt>r_c_shortest_paths_label</tt> object, except for the first label, has a valid (not null) <tt>p_pred_label</tt> pointer and a valid <tt>pred_edge</tt> member. The <tt>p_pred_label</tt> pointer of the label with <tt>num</tt> member equal to zero is a null pointer, and the <tt>pred_edge</tt> member of this label is a default-constructed edge descriptor.
235 </p>
236
237 <a name="ResourceExtensionFunction"><h4>ResourceExtensionFunction</h4></a>
238
239 <p>
240 A model of the ResourceExtensionFunction concept is used to specify how a label is to be extended along an arc.
241 </p>
242
243 <p>
244 <b>Valid Expressions</b><br>
245 If <tt>ref</tt> models the ResourceExtensionFunction concept, and if the type <tt>Resource_Container</tt> models the ResourceContainer concept, the following expression is valid:<br>
246 <table border>
247 <tr>
248 <td>
249 <pre>
250 bool b = ref( const Graph&amp; g,
251 Resource_Container&amp; new_cont,
252 const Resource_Container&amp; old_cont,
253 graph_traits&lt;Graph&gt;::edge_descriptor ed )
254 </pre>
255 </td>
256 <td>
257 <tt>ref</tt> must return <tt>true</tt> if and only if the extension is feasible, i.e., if <tt>new_cont</tt> fulfills all resource constraints at the target vertex of <tt>ed</tt>.
258 </td>
259 </tr>
260 </table>
261 Moreover, a reference to a type modelling the ResourceExtensionFunction concept can be passed as a parameter to <tt>r_c_shortest_paths</tt>, see above.<br>
262 </p>
263
264 <p>
265 Hence, a type modelling the ResourceExtensionFunction concept is likely to be a function or a <a href="http://www.sgi.com/tech/stl/functors.html">function object</a>.
266 </p>
267
268 <p>
269 <b>Invariants</b><br>
270 If <tt>ref</tt> models the ResourceExtensionFunction concept, and if the type <tt>Resource_Container</tt> models the ResourceContainer concept, after the call
271 <pre>
272 ref( const Graph&amp; g,
273 Resource_Container&amp; new_cont,
274 const Resource_Container&amp; old_cont,
275 graph_traits&lt;Graph&gt;::edge_descriptor )
276 </pre>
277 the expression <tt>old_cont &lt;= new_cont</tt> evaluates to <tt>true</tt>.<br>
278 This is because, as stated above, the implementation is a label-setting algorithm. Therefore, the Less-Than operator for ResourceContainer must compare one or more resource(s) whose resource consumption(s) along any arc is/are non-decreasing in order for the algorithm to work properly.
279 </p>
280
281 <h4>DominanceFunction</h4>
282
283 <p>
284 A model of DominanceFunction is used to specify a dominance relation between two labels.
285 </p>
286
287 <p>
288 <b>Refinement of</b><br>
289 <a href="http://www.sgi.com/tech/stl/BinaryPredicate.html">BinaryPredicate</a>
290 </p>
291
292 <p>
293 <b>Valid Expressions</b><br>
294 If <tt>dominance</tt> models the DominanceFunction concept, and if the type <tt>Resource_Container</tt> models the ResourceContainer concept, the following expression is valid:
295 <table border>
296 <tr>
297 <td>
298 <pre>
299 bool b = dominance(const Resource_Container&amp; rc1, const Resource_Container&amp; rc2)
300 </pre>
301 </td>
302 <td>
303 <tt>dominance</tt> must return <tt>true</tt> if and only if <tt>rc1</tt> dominates <tt>rc2</tt>.
304 </td>
305 </tr>
306 </table>
307 Moreover, a reference to a type modelling the DominanceFunction concept can be passed as a parameter to <tt>r_c_shortest_paths</tt>, see above.
308 </p>
309
310 <p>
311 <b>Invariants</b><br>
312 A type modelling the DominanceFunction concept must return <tt>true</tt> if and only if <tt>rc1<=rc2</tt>. It must <i>not</i> return <tt>false</tt> if <tt>rc1==rc2</tt>. Then, it is guaranteed that no two labels with identical resource consumption dominate each other and are both considered as dominated by the <tt>r_c_shortest_paths</tt> functions.
313 </p>
314
315 <a name="ResourceConstrainedShortestPathsVisitor"><h4>ResourceConstrainedShortestPathsVisitor</h4></a>
316
317 <p>
318 This concept defines the visitor interface for <tt>r_c_shortest_paths</tt>. A user can define a type with this interface and pass an object of this type to <tt>r_c_shortest_paths</tt> to perform user-defined actions at the event points of the algorithm. Note that the object is passed by value.
319 </p>
320
321 <p>
322 <b>Refinement of</b><br>
323 <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>, <a href="../../utility/CopyConstructible.html">CopyConstructible</a>
324 </p>
325
326 <p>
327 <b>Valid Expressions</b><br>
328 If <tt>vis</tt> is an object of a type modelling the ResourceConstrainedShortestPathsVisitor concept, and if <tt>g</tt> is an object of a type <tt>Graph</tt> modelling the IncidenceGraph and the PropertyGraph concepts, and if it is a directed graph, and if <tt>l</tt> is an object of a type <tt>Label</tt> modelling the Label concept, the following expressions are valid:<br>
329 <table border>
330 <tr>
331 <td>
332 <tt>vis.on_label_popped( const Label&amp; l, const Graph&amp; g )</tt>
333 </td>
334 </tr>
335 <tr>
336 <td>
337 <tt>vis.on_label_feasible( const Label&amp; l, const Graph&amp; g )</tt>
338 </td>
339 </tr>
340 <tr>
341 <td>
342 <tt>vis.on_label_not_feasible( const Label&amp; l, const Graph&amp; g )</tt>
343 </td>
344 </tr>
345 <tr>
346 <td>
347 <tt>vis.on_label_dominated( const Label&amp; l, const Graph&amp; g )</tt>
348 </td>
349 </tr>
350 <tr>
351 <td>
352 <tt>vis.on_label_not_dominated( const Label&amp; l, const Graph&amp; g )</tt>
353 </td>
354 </tr>
355 </table>
356 See the <a href="#Label">description of the Label concept</a> for the interface of a Label. See the <a href="#FunctionsDescription">algorithm description</a> for information on when these functions are called.
357 <p>
358
359 <a name="FunctionsDescription"><h3>Functions Description</h3></a>
360
361 <p>
362 The functions are an implementation of a priority-queue-based label-setting algorithm. At each iteration, the algorithm picks a label <i>l</i> from a priority queue (the set of unprocessed labels) and checks it for dominance against the current set of labels at the vertex <i>i</i> where <i>l</i> resides. If <i>l</i> is dominated by some other label residing at <i>i</i>, <i>l</i> is deleted from the set of labels residing at <i>i</i>. If <i>l</i> is undominated, it is extended along all out-edges of <i>i</i>. Each resulting new label is checked for feasibility, and if it is feasible, it is added to the set of unprocessed labels and to the set of labels residing at the respective successor vertex of <i>i</i>. If a new label is not feasible, it is discarded. The algorithm stops when there are no more unprocessed labels. It then checks whether the destination vertex could be reached (which may not be the case even for a strongly connected graph because of the resource constraints), constructs one or all Pareto-optimal (i.e., undominated) <i>s</i>-<i>t</i>-path(s) and returns. A pseudo-code of the algorithm follows.
363 </p>
364
365 <pre>
366 r_c_shortest_paths( g,
367 vertex_index_map,
368 edge_index_map,
369 s,
370 t,
371 pareto_optimal_solutions,
372 pareto_optimal_resource_containers,
373 rc,
374 ref,
375 dominance,
376 la,
377 vis )
378 {
379 Label first_label, cur_label, new_label
380 Set of Labels unprocessed_labels, labels_cur_vertex
381 initialize first_label with rc
382 INSERT(unprocessed_labels, first_label)
383 <b>while</b>(unprocessed_labels != &Oslash;)
384 cur_label := EXTRACTMIN(unprocessed_labels) &#9665; vis.on_label_popped(cur_label)
385 <b>if</b>(cur_label is not dominated)
386 vertex i = ResidentVertex(cur_label)
387 perform pairwise dominance check over labels resident at i
388 mark all dominated labels as dominated
389 DELETE all labels which are dominated AND processed
390 <b>if</b>(cur_label is not dominated) &#9665; vis.on_label_not_dominated(cur_label)
391 mark cur_label as processed
392 <b>for each</b> arc (i, j) in the forward star of i
393 new_label := ref(cur_label)
394 <b>if</b>(new_label is not feasible) &#9665; vis.on_label_not_feasible(new_label)
395 DELETE(new_label)
396 <b>else</b> &#9665; vis.on_label_feasible(new_label)
397 INSERT(unprocessed_labels, new_label)
398 INSERT(set of labels resident at j,new_label)
399 <b>else</b> &#9665; vis.on_label_dominated(cur_label)
400 DELETE(cur_label)
401 <b>if</b>(t could be reached from s)
402 <b>for each</b> label resident at t
403 INSERT(pareto_optimal_resource_containers, label.resource_container)
404 recursively construct pareto_optimal_path
405 INSERT(pareto_optimal_solutions, pareto_optimal_path)
406 <b>if</b>(only one Pareto-optimal solution is sought)
407 BREAK
408 }
409 </pre>
410
411 <h3>Where Defined</h3>
412
413 <a href="../../../boost/graph/r_c_shortest_paths.hpp"><tt>boost/graph/r_c_shortest_paths.hpp</tt></a>
414
415 <h3>Parameters</h3>
416
417 IN: <tt>const Graph&amp; g</tt>
418 <blockquote>
419 The graph object on which the algorithm is applied. The type <tt>Graph</tt> must be directed and must be a model of <a href="./IncidenceGraph.html">Incidence Graph</a> and <a href="./PropertyGraph.html">PropertyGraph</a>.
420 </blockquote>
421 IN: <tt>const VertexIndexMap&amp; vertex_index_map</tt>
422 <blockquote>
423 A <a href="../../property_map/doc/ReadablePropertyMap.html">ReadablePropertyMap</a> mapping vertex descriptors to integers in [0, <tt>num_vertices(g)</tt>).
424 </blockquote>
425 IN: <tt>const EdgeIndexMap&amp; edge_index_map</tt>
426 <blockquote>
427 A <a href="../../property_map/doc/ReadablePropertyMap.html">ReadablePropertyMap</a> mapping edge descriptors to integers in [0, <tt>num_edges(g)</tt>).
428 </blockquote>
429 IN: <tt>typename graph_traits&lt;Graph&gt;::vertex_descriptor s</tt>
430 <blockquote>
431 A vertex descriptor describing the start vertex of the path.
432 </blockquote>
433 IN: <tt>typename graph_traits&lt;Graph&gt;::vertex_descriptor t</tt>
434 <blockquote>
435 A vertex descriptor describing the end vertex of the path.
436 </blockquote>
437 OUT: <tt>std::vector&lt;std::vector&lt;typename graph_traits&lt;Graph&gt;::edge_descriptor&gt; &gt;&amp;
438 pareto_optimal_solutions</tt>
439 <blockquote>
440 A container for storing the Pareto-optimal (undominated) solutions (<i>s</i>-<i>t</i>-paths) in the overloads where all Pareto-optimal solutions are returned. The paths are returned as sequences of edge descriptors in reverse order (from <tt>t</tt> to <tt>s</tt>).
441 </blockquote>
442 OUT: <tt>std::vector&lt;Resource_Container&gt;&amp; pareto_optimal_resource_containers</tt>
443 <blockquote>
444 A container for storing the Pareto-optimal resource containers in the overloads where all Pareto-optimal solutions are returned.
445 </blockquote>
446 OUT: <tt>std::vector&lt;typename graph_traits&lt;Graph&gt;::edge_descriptor&gt;&amp;
447 pareto_optimal_solution</tt>
448 <blockquote>
449 A container for storing the first Pareto-optimal (undominated) solution (<i>s</i>-<i>t</i>-path) in the overloads where only one Pareto-optimal solution is returned. The path is returned as a sequence of edge descriptors in reverse order (from <tt>t</tt> to <tt>s</tt>). This argument is not modified if there are no solutions.
450 </blockquote>
451 OUT: <tt>Resource_Container&amp; pareto_optimal_resource_container</tt>
452 <blockquote>
453 A <tt>Resource_Container</tt> object for storing the Pareto-optimal resource container corresponding to the first Pareto-optimal path in the overloads where only one Pareto-optimal solution is returned. This argument is not modified if there are no solutions.
454 </blockquote>
455 IN: <tt>const Resource_Container&amp; rc</tt>
456 <blockquote>
457 An object specifying the initial resource consumptions at vertex <tt>s</tt>. The type <tt>Resource_Container</tt> must be a model of the ResourceContainer concept.
458 </blockquote>
459 IN: <tt>Resource_Extension_Function&amp; ref</tt>
460 <blockquote>
461 A <a href="http://www.sgi.com/tech/stl/functors.html">function object</a> or function pointer or function specifying how a label is to be extended along an arc. The type <tt>Resource_Extension_Function</tt> must be a model of the ResourceExtensionFunction concept.
462 </blockquote>
463 IN: <tt>Dominance_Function&amp; dominance</tt>
464 <blockquote>
465 A <a href="http://www.sgi.com/tech/stl/functors.html">function object</a> or function pointer or function specifying a dominance relation between two labels. The type <tt>Dominance_Function</tt> must be a model of the DominanceFunction concept.
466 </blockquote>
467 IN: <tt>Label_Allocator la</tt>
468 <blockquote>
469 An object of type <tt>Label_Allocator</tt> specifying a strategy for the memory management of the labels. It must offer the same interface as <tt>std::allocator&lt;r_c_shortest_paths_label&lt;Graph, Resource_Container&gt; &gt;</tt>. There is a default type <tt>default_r_c_shortest_paths_allocator</tt> for this parameter using the STL standard allocator. If the third or the fourth overload of the function is used, an object of this type is used as <tt>Label_Allocator</tt> parameter. If the first or the second overload is used, one must specify both a <tt>Label_Allocator</tt> and a <tt>Visitor</tt> parameter. If one wants to develop a user-defined type only for <tt>Visitor</tt>, one can use <tt>default_r_c_shortest_paths_allocator</tt> as <tt>Label_Allocator</tt> parameter. If one wants to use a specialized allocator, one can specify an arbitrary type as template parameter for the value type to the allocator; it is rebound to the correct type.
470 </blockquote>
471 IN: <tt>Visitor vis</tt>
472 <blockquote>
473 A visitor object specifying what operations are to be performed at the event points in the algorithm. The type <tt>Visitor</tt> must be a model of the ResourceConstrainedShortestPathsVisitor concept. There is a default type <tt>default_r_c_shortest_paths_visitor</tt> for this parameter with empty function bodies. If the third or the fourth overload of the function is used, an object of this type is used as <tt>Visitor</tt> parameter. If the first or the second overload is used, one must specify both a <tt>Label_Allocator</tt> and a <tt>Visitor</tt> parameter. If one wants to use only a specialized allocator, one can use <tt>default_r_c_shortest_paths_visitor</tt> as <tt>Visitor</tt> parameter.
474 </blockquote>
475
476 <h4>Preconditions</h4>
477
478 <ul>
479 <li>
480 <tt>s</tt> and <tt>t</tt> are valid vertex descriptors for <tt>g</tt>.
481 <li>
482 <tt>rc</tt> is within the resource windows at <tt>s</tt>, i.e., it constitutes a feasible <tt>Resource_Container</tt> object at <tt>s</tt> (see <a href="#Discussion">discussion</a>).
483 </ul>
484
485 <h4>Throws</h4>
486
487 <p>
488 The function itself does not throw any exceptions. However, depending on the template parameters, exceptions may be thrown from within the function.
489 </p>
490
491 <h4>Complexity</h4>
492
493 <p>
494 The time complexity is problem-dependent. For a non-elementary problem or for a problem on a graph without negative cycles, the complexity is polynomial in the number of vertices and edges and a term dependent on the resources and resource extension functions used. For the elementary problem on a graph with negative cycles, the complexity is exponential in the number of vertices and edges and a term dependent on the resources and resource extension functions used.
495 </p>
496
497 <a name="Discussion"><h3>Discussion</h3></a>
498
499 <p>
500 The function leaves a lot of work to the user. It is almost like a small framework for SPPRCs. This, however, is a property inherent to the problem. It is entirely up to the user to make sure that he stores the &lsquo;right&rsquo; resources in his resource container object, that the resource extension function extends a label in the desired way, and that the dominance function declares the &lsquo;right&rsquo; labels as dominated and not dominated. In particular, the precondition that the initial ResourceContainer object supplied to the function must be feasible is as important as it is unpleasant. The implementation does not check this and, hence, sacrifices comfort for genericity here. It was a design decision not to make any assumptions with respect to the relationship between the type modelling ResourceContainer and the vertex properties of the graph type.
501 </p>
502
503 <p>
504 In case the underlying graph does not contain negative cycles (cycles with overall negative resource consumption for the unconstrained resource whose consumption is to be minimized, such as cost or distance), the resulting paths will always be elementary, i.e., without repetitions of vertices. In the presence of negative cycles, the algorithm is finite if there is at least one strictly increasing resource, i.e., one resource with strictly positive resource consumption on all arcs (this is a sufficient condition). Otherwise, one must provide a customized type for the ResourceContainer concept to ensure finiteness. See, for example<br>
505 Feillet, D.; Dejax, P.; Gendreau, M.; Gueguen, C. (2004):<br>
506 An Exact Algorithm for the Elementary Shortest Path Problem with Resource Constraints: Application to Some Vehicle Routing Problems<br>
507 Networks, vol. 44, pp. 216&ndash;229.
508 </p>
509
510 <p>
511 Experience shows that for &lsquo;small&rsquo; resource containers, it may be useful to try a specialized small object allocator, e.g., from the Boost Pool library. For larger resource containers (i.e., for a large number of resources), the default allocator is the right choice.
512 </p>
513
514 <p>
515 There is a utility function called <tt>check_path</tt> that can be used for debugging purposes, if <tt>r_c_shortest_paths</tt> returns a path as feasible and Pareto-optimal and the user is of the opinion that the path is either infeasible or not optimal:
516 <pre>
517 template&lt;class Graph,
518 class Resource_Container,
519 class Resource_Extension_Function&gt;
520 void check_r_c_path( const Graph&amp; g,
521 const std::vector&lt;typename graph_traits&lt;Graph&gt;::edge_descriptor&gt;&amp; ed_vec_path,
522 const Resource_Container&amp; initial_resource_levels,
523 bool b_result_must_be_equal_to_desired_final_resource_levels,
524 const Resource_Container&amp; desired_final_resource_levels,
525 Resource_Container&amp; actual_final_resource_levels,
526 const Resource_Extension_Function&amp; ref,
527 bool&amp; b_is_a_path_at_all,
528 bool&amp; b_feasible,
529 bool&amp; b_correctly_extended,
530 typename graph_traits&lt;Graph&gt;::edge_descriptor&amp;
531 ed_last_extended_arc )
532 </pre>
533 </p>
534
535 The boolean parameters have the following meaning:
536 <ul>
537 <li>
538 If <tt>b_result_must_be_equal_to_desired_final_resource_levels==true</tt>, computed accumulated final resource levels must be equal to <tt>desired_final_resource_levels</tt>.
539 <li>
540 If <tt>b_result_must_be_equal_to_desired_final_resource_levels==false</tt>, computed accumulated final resource levels must be less than or equal to <tt>desired_final_resource_levels</tt>.
541 <li>
542 <tt>b_is_a_path_at_all==true</tt> if and only if <tt>ed_vec_path</tt> specifies a walk in a graph-theoretical sense, i.e., a sequence of arcs where the target of an arc is the source of the next arc, or a reverse walk, where the source of one arc is the target of the next arc. Note that in the world of resource-constrained shortest paths, a path need not be elementary: Repetitions of vertices or arcs are allowed. When the graph does not have any cycles of negative cost (traversal cost, travel time etc.), the paths returned by <tt>r_c_shortest_paths</tt> will be elementary. Otherwise, one must use appropriate resource containers and resource extension and dominance functions (see the abovementioned references).
543 <li>
544 <tt>b_feasible==true</tt> if and only if <tt>b_is_a_path_at_all==true</tt> and all resource windows at all vertices along the path are maintained.
545 <li>
546 When <tt>b_result_must_be_equal_to_desired_final_resource_levels==true</tt> (<tt>false</tt>), <tt>b_correctly_extended==true</tt> if and only if <tt>b_feasible==true</tt> and the computed resource levels at the end of the path are equal to (less than or equal to) the desired final resource levels as specified in <tt>desired_final_resource_levels</tt>.
547 </ul>
548
549 <p>
550 <tt>ed_last_extended_arc</tt> stores the edge descriptor of the last extended arc. If <tt>ed_vec_path</tt> is a path of positive length and <tt>b_feasible==false</tt>, <tt>ed_last_extended_arc</tt> is the edge descriptor of the arc at whose target vertex the first violation of a resource window occured.
551 </p>
552
553 <h3>Examples</h3>
554
555 <p>
556 The file <a href="../example/r_c_shortest_paths_example.cpp">
557 <rr>example/r_c_shortest_paths_example.cpp</tt></a> provides examples for how SPPRCs can be solved with the <tt>r_c_shortest_paths</tt> functions. There is an example for an SPP without resource constraints and an example for a shortest path problem with time windows.<br>
558 It is obvious that one would not use the algorithm for SPPs without resource constraints, because there are faster algorithms for this problem, but one would expect a code for the SPP with resource constraints to be able to handle such a case.
559 </p>
560
561 <br>
562 <hr>
563 <table>
564 <tr valign=top>
565 <td
566 nowrap>Copyright &copy; 2006</td>
567 <td>
568 Michael Drexl (michaeldrexl at web dot de)
569 </td></tr></table>
570
571 </body>
572 </html>