forked from hlsyounes/vhpop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
effects.h
120 lines (91 loc) · 3.65 KB
/
effects.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
// 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
//
// Effects.
#ifndef EFFECTS_H
#define EFFECTS_H
#include <vector>
#include "terms.h"
struct Formula;
struct Literal;
struct Problem;
/* ====================================================================== */
/* Effect */
struct EffectList;
/*
* A single effect.
*/
struct Effect {
/* Possible temporal annotations for effects. */
typedef enum { AT_START, AT_END } EffectTime;
/* Constructs an effect. */
Effect(const Literal& literal, EffectTime when);
/* Deletes this effect. */
~Effect();
/* Adds a universally quantified variable to this effect. */
void add_parameter(Variable parameter);
/* Sets the condition of this effect. */
void set_condition(const Formula& condition);
/* Sets the link condition of this effect. */
void set_link_condition(const Formula& link_condition) const;
/* Returns the number of universally quantified variables of this effect. */
size_t arity() const { return parameters_.size(); }
/* Returns the ith universally quantified variable of this effect. */
Variable parameter(size_t i) const { return parameters_[i]; }
/* Returns the condition for this effect. */
const Formula& condition() const { return *condition_; }
/* Returns the condition that must hold for this effect to be
considered for linking. */
const Formula& link_condition() const { return *link_condition_; }
/* Returns the literal added by this effect. */
const Literal& literal() const { return *literal_; }
/* Returns the temporal annotation for this effect. */
EffectTime when() const { return when_; }
/* Tests if this effect quantifies the given variable. */
bool quantifies(Variable variable) const;
/* Fills the provided list with instantiations of this effect. */
void instantiations(EffectList& effects, size_t& useful,
const std::map<Variable, Term>& subst,
const Problem& problem) const;
/* Prints this effect on the given stream. */
void print(std::ostream& os) const;
private:
/* List of universally quantified variables for this effect. */
std::vector<Variable> parameters_;
/* Condition for this effect, or TRUE if unconditional effect. */
const Formula* condition_;
/* Condition that must hold for this effect to be considered for linking. */
mutable const Formula* link_condition_;
/* Litteral added by this effect. */
const Literal* literal_;
/* Temporal annotation for this effect. */
EffectTime when_;
/* Returns an instantiation of this effect. */
const Effect* instantiation(const std::map<Variable, Term>& args,
const Problem& problem,
const Formula& condition) const;
};
/* ====================================================================== */
/* EffectList */
/*
* List of effects.
*/
struct EffectList : public std::vector<const Effect*> {
};
#endif /* EFFECTS_H */