-
Notifications
You must be signed in to change notification settings - Fork 10
/
flaws.h
194 lines (150 loc) · 5.39 KB
/
flaws.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
// Copyright (C) 2002--2005 Carnegie Mellon University
// Copyright (C) 2019 Google Inc
//
// This file is part of VHPOP.
//
// VHPOP is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// VHPOP is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with VHPOP; if not, write to the Free Software Foundation,
// Inc., #59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Plan flaws.
#ifndef FLAWS_H
#define FLAWS_H
#include <config.h>
#include "formulas.h"
#include "chain.h"
#include <iostream>
struct Domain;
struct Effect;
struct Link;
/* ====================================================================== */
/* Flaw */
/*
* Abstract flaw.
*/
struct Flaw {
/* Prints this object on the given stream. */
virtual void print(std::ostream& os, const Bindings& bindings) const = 0;
};
/* ====================================================================== */
/* OpenCondition */
/*
* Open condition.
*/
struct OpenCondition : public Flaw {
/* Constructs an open condition. */
OpenCondition(size_t step_id, const Formula& condition);
/* Constructs an open condition. */
OpenCondition(size_t step_id, const Literal& condition, FormulaTime when);
/* Constructs an open condition. */
OpenCondition(const OpenCondition& oc);
/* Deletes this open condition. */
virtual ~OpenCondition();
/* Returns the step id. */
size_t step_id() const { return step_id_; }
/* Returns the open condition. */
const Formula& condition() const { return *condition_; }
/* Checks if this is a static open condition. */
bool is_static() const;
/* Returns a literal, or NULL if this is not a literal open
condition. */
const Literal* literal() const;
/* Returns the time stamp associated with a literal open condition. */
FormulaTime when() const { return when_; }
/* Returns a inequality, or NULL if this is not an inequality open
condition. */
const Inequality* inequality() const;
/* Returns a disjunction, or NULL if this is not a disjunctive open
condition. */
const Disjunction* disjunction() const;
/* Prints this object on the given stream. */
virtual void print(std::ostream& os, const Bindings& bindings) const;
private:
/* Id of step to which this open condition belongs. */
size_t step_id_;
/* The open condition. */
const Formula* condition_;
/* Time stamp associated with a literal open condition. */
FormulaTime when_;
};
/* Equality operator for open conditions. */
inline bool operator==(const OpenCondition& oc1, const OpenCondition& oc2) {
return &oc1 == &oc2;
}
/* ====================================================================== */
/* Unsafe */
/*
* Threatened causal link.
*/
struct Unsafe : public Flaw {
/* Constructs a threatened causal link. */
Unsafe(const Link& link, size_t step_id, const Effect& effect)
: link_(&link), step_id_(step_id), effect_(&effect) {}
/* Returns the threatened link. */
const Link& link() const { return *link_; }
/* Returns the id of threatening step. */
size_t step_id() const { return step_id_; }
/* Returns the threatening effect. */
const Effect& effect() const { return *effect_; }
/* Prints this object on the given stream. */
virtual void print(std::ostream& os, const Bindings& bindings) const;
private:
/* Threatened link. */
const Link* link_;
/* Id of threatening step. */
size_t step_id_;
/* Threatening effect. */
const Effect* effect_;
};
/* Equality operator for unsafe links. */
inline bool operator==(const Unsafe& u1, const Unsafe& u2) {
return &u1 == &u2;
}
/* ====================================================================== */
/* MutexThreat */
/*
* A mutex threat between effects of two separate steps.
*/
struct MutexThreat : public Flaw {
/* Constructs a mutex threat place hoder. */
MutexThreat() : step_id1_(0) {}
/* Constructs a mutex threat. */
MutexThreat(size_t step_id1, const Effect& effect1,
size_t step_id2, const Effect& effect2)
: step_id1_(step_id1), effect1_(&effect1),
step_id2_(step_id2), effect2_(&effect2) {}
/* Returns the id for the first step. */
size_t step_id1() const { return step_id1_; }
/* Returns the threatening effect for the first step. */
const Effect& effect1() const { return *effect1_; }
/* Returns the id for the second step. */
size_t step_id2() const { return step_id2_; }
/* Returns the threatening effect for the second step. */
const Effect& effect2() const { return *effect2_; }
/* Prints this object on the given stream. */
virtual void print(std::ostream& os, const Bindings& bindings) const;
private:
/* The id for the first step. */
size_t step_id1_;
/* The threatening effect for the first step. */
const Effect* effect1_;
/* The id for the second step. */
size_t step_id2_;
/* The threatening effect for the second step. */
const Effect* effect2_;
};
/* Equality operator for mutex threats. */
inline bool operator==(const MutexThreat& mt1, const MutexThreat& mt2) {
return &mt1 == &mt2;
}
#endif /* FLAWS_H */