-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbindings_propagator.h
62 lines (44 loc) · 2.51 KB
/
bindings_propagator.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
#ifndef MYPOP_BINDINGS_PROPAGATOR_H
#define MYPOP_BINDINGS_PROPAGATOR_H
#include <vector>
namespace MyPOP {
class Bindings;
class VariableDomain;
class Object;
/**
* It is the sole purpose of the propagator to check if the imposed bindings are valid. No other part of the
* planner does that. After the bindings have been added the functions below will be called appropriately. If,
* during the pruning stage, a domain becomes empty the function must return false, true otherwise.
*/
class BindingsPropagator
{
public:
// Called after the Bindings::merge function.
virtual bool propagateAfterMakeEqual(Bindings& bindings, VariableDomain& vd, const VariableDomain& vd2) const = 0;
// Called after the Bindings::assign function.
virtual bool propagateAfterMakeEqual(Bindings& bindings, VariableDomain& vd, const Object& object) const = 0;
// Called after the Bindings::assign function.
virtual bool propagateAfterMakeEqual(Bindings& bindings, VariableDomain& vd, const std::vector<const Object*>& objects) const = 0;
// Called after the Bindings::makeDistinct function.
virtual bool propagateAfterMakeUnequal(Bindings& bindings, VariableDomain& vd, VariableDomain& vd2) const = 0;
// Called after the Bindings::unassign function.
virtual bool propagateAfterMakeUnequal(Bindings& bindings, VariableDomain& vd, const Object& object) const = 0;
// Called after the Bindings::unassign function.
virtual bool propagateAfterMakeUnequal(Bindings& bindings, VariableDomain& vd, const std::vector<const Object*>& objects) const = 0;
};
/**
* Simple propagator which does only prune when a domain either becomes empty or only has a single object left in it.
*/
class SimpleBindingsPropagator : public BindingsPropagator
{
virtual bool propagateAfterMakeEqual(Bindings& bindings, VariableDomain& vd, const VariableDomain& vd2) const;
virtual bool propagateAfterMakeEqual(Bindings& bindings, VariableDomain& vd, const Object& object) const;
virtual bool propagateAfterMakeEqual(Bindings& bindings, VariableDomain& vd, const std::vector<const Object*>& objects) const;
virtual bool propagateAfterMakeUnequal(Bindings& bindings, VariableDomain& vd, VariableDomain& vd2) const;
virtual bool propagateAfterMakeUnequal(Bindings& bindings, VariableDomain& vd, const Object& object) const;
virtual bool propagateAfterMakeUnequal(Bindings& bindings, VariableDomain& vd, const std::vector<const Object*>& objects) const;
private:
bool removeObjectFromUnequalDomains(Bindings& bindings, VariableDomain& vd, const Object& object) const;
};
};
#endif