~ubuntu-branches/ubuntu/natty/gecode/natty

« back to all changes in this revision

Viewing changes to contribs/graph/path.icc

  • Committer: Bazaar Package Importer
  • Author(s): Kari Pahula
  • Date: 2005-12-24 07:51:25 UTC
  • Revision ID: james.westby@ubuntu.com-20051224075125-klkiqofvbfvusfvt
Tags: upstream-1.0.0.dfsg.1
Import upstream version 1.0.0.dfsg.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 *  Main authors:
 
4
 *     Gr�goire Dooms <dooms@info.ucl.ac.be>
 
5
 *
 
6
 *  Copyright:
 
7
 *     Gr�goire Dooms (Universit� catholique de Louvain), 2005
 
8
 *
 
9
 *  Last modified:
 
10
 *     $Date: 2005-11-29 10:57:21 +0100 (Tue, 29 Nov 2005) $
 
11
 *     $Revision: 271 $
 
12
 *
 
13
 *  This file is part of CP(Graph)
 
14
 *
 
15
 *  See the file "contribs/graph/LICENSE" for information on usage and
 
16
 *  redistribution of this file, and for a
 
17
 *     DISCLAIMER OF ALL WARRANTIES.
 
18
 *
 
19
 */
 
20
 
 
21
#include "path/pathdegree.icc"
 
22
namespace Gecode { namespace Graph {
 
23
 
 
24
/** \brief Posts a degree constraint on the graph view g.
 
25
 *
 
26
 * All nodes of g have indegree of 1 (except start) and out degree of 1 (except end)
 
27
 * \ingroup TaskModel
 
28
 */
 
29
template <class GView>
 
30
    void pathdegree(Space *home, GView &g, int start, int end){
 
31
        GECODE_ES_FAIL(home, PathDegreePropag<GView>::post(home, g, start, end));
 
32
}
 
33
 
 
34
 
 
35
 
 
36
/** \brief posts a simple path constraint on the graph view g. 
 
37
 *
 
38
 * The propagator uses cost filtering based on the upper bound of w and updates the lower bound of w.
 
39
 * \ingroup TaskModel
 
40
 */
 
41
template <class GView>
 
42
void path(Space* home, GView &g, int start, int end, const map <pair<int,int>,int> &edgecosts, IntVar w) {
 
43
        if (home->failed()) return;
 
44
        GECODE_ME_FAIL(home, g._nodeIn(home, start));
 
45
        GECODE_ME_FAIL(home, g._nodeIn(home, end));
 
46
        pathdegree(home,g,start,end);
 
47
        GECODE_ES_FAIL(home, PathCostPropag<GView>::post(home, g, start, end, w, edgecosts));
 
48
}
 
49
/** \brief posts a path constraint on the graph view g.
 
50
 * \ingroup TaskModel
 
51
 */
 
52
template <class GView>
 
53
void path(Space* home, GView &g, int start, int end) {
 
54
        if (home->failed()) return;
 
55
        GECODE_ME_FAIL(home, g._nodeIn(home, start));
 
56
        GECODE_ME_FAIL(home, g._nodeIn(home, end));
 
57
            pathdegree(home,g,start,end);
 
58
        GECODE_ES_FAIL(home, PathPropag<GView>::post(home, g, start, end));
 
59
}
 
60
 
 
61
} }
 
62
#include "path/path.icc"
 
63
 
 
64