OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Satisfier.h
Go to the documentation of this file.
1 /*
2  * Satisfier.h
3  *
4  * Copyright (C) 2009, 2014, 2015 Linas Vepstas
5  *
6  * Author: Linas Vepstas <linasvepstas@gmail.com> January 2009
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Affero General Public License v3 as
10  * published by the Free Software Foundation and including the exceptions
11  * at http://opencog.org/wiki/Licenses
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Affero General Public License
19  * along with this program; if not, write to:
20  * Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 #ifndef _OPENCOG_SATISFIER_H
25 #define _OPENCOG_SATISFIER_H
26 
27 #include <vector>
28 
31 
34 
35 namespace opencog {
36 
48 class Satisfier :
49  public virtual InitiateSearchCB,
50  public virtual DefaultPatternMatchCB
51 {
52  public:
54  InitiateSearchCB(as),
56  _result(TruthValue::FALSE_TV()) {}
58 
59  virtual void set_pattern(const Variables& vars,
60  const Pattern& pat)
61  {
64  }
65 
66  // Return true if a satisfactory grounding has been
67  // found. Note that in case where you want all possible
68  // groundings, this will usually return false, so the
69  // patternMatchEngine can keep looking for ever more
70  // groundings.
71  virtual bool grounding(const std::map<Handle, Handle> &var_soln,
72  const std::map<Handle, Handle> &term_soln);
73 };
74 
88  public virtual InitiateSearchCB,
89  public virtual DefaultPatternMatchCB
90 {
91  public:
96 
97  virtual void set_pattern(const Variables& vars,
98  const Pattern& pat)
99  {
100  _varseq = vars.varseq;
103  }
104 
105  // Return true if a satisfactory grounding has been
106  // found. Note that in case where you want all possible
107  // groundings, this will usually return false, so the
108  // patternMatchEngine can keep looking for ever more
109  // groundings.
110  virtual bool grounding(const std::map<Handle, Handle> &var_soln,
111  const std::map<Handle, Handle> &term_soln);
112 };
113 
114 }; // namespace opencog
115 
116 #endif // _OPENCOG_SATISFIER_H
virtual void set_pattern(const Variables &, const Pattern &)
HandleSeq varseq
Definition: Pattern.h:64
std::vector< Handle > HandleSeq
a list of handles
Definition: Handle.h:246
HandleSeq _satisfying_set
Definition: Satisfier.h:95
std::shared_ptr< TruthValue > TruthValuePtr
Definition: TruthValue.h:85
Satisfier(AtomSpace *as)
Definition: Satisfier.h:53
virtual bool grounding(const std::map< Handle, Handle > &var_soln, const std::map< Handle, Handle > &term_soln)
Definition: Satisfier.cc:43
virtual void set_pattern(const Variables &vars, const Pattern &pat)
Definition: Satisfier.h:97
virtual void set_pattern(const Variables &vars, const Pattern &pat)
Definition: Satisfier.h:59
TruthValuePtr _result
Definition: Satisfier.h:57
SatisfyingSet(AtomSpace *as)
Definition: Satisfier.h:92
virtual bool grounding(const std::map< Handle, Handle > &var_soln, const std::map< Handle, Handle > &term_soln)
Definition: Satisfier.cc:33
virtual void set_pattern(const Variables &, const Pattern &)