OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ForwardChainerPMCB.cc
Go to the documentation of this file.
1 /*
2  * ForwardChainPatternMatchCB.cc
3  *
4  * Copyright (C) 2014 Misgana Bayetta
5  *
6  * Author: Misgana Bayetta <misgana.bayetta@gmail.com> Sept 2014
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 #include "ForwardChainerPMCB.h"
26 
27 using namespace opencog;
28 
29 //TODO Enable attentional focus search
32  /*AttentionalFocusCB(as),*/_as(as)
33 {
34  _fcmem = nullptr;
35 }
36 
38 {
39 }
40 
41 bool ForwardChainerPMCB::node_match(const Handle& node1, const Handle& node2)
42 {
43  //constrain search within premise list
44  bool accept =
45  /*_fcmem->is_search_in_af() ?
46  AttentionalFocusCB::node_match(node1, node2) :*/
48 
49  return accept;
50 }
51 
52 bool ForwardChainerPMCB::link_match(const LinkPtr& lpat, const LinkPtr& lsoln)
53 {
54  //constrain search within premise list
55  bool accept =
56  /*_fcmem->is_search_in_af() ?
57  AttentionalFocusCB::link_match(lpat, lsoln) :*/
59 
60  return accept;
61 }
62 
63 bool ForwardChainerPMCB::grounding(const std::map<Handle, Handle> &var_soln,
64  const std::map<Handle, Handle> &pred_soln)
65 {
66  Handle source = _fcmem->get_cur_source();
67 
68  for (auto& vs : var_soln) {
69  if (vs.second == source) {
70  Handle h = inst.instantiate(implicand, var_soln);
71  insert_result(h);
72  }
73  }
74 
75  return false;
76 }
77 
79 {
80  _fcmem = fcmem;
81 }
82 
84 {
85  auto product = get_result_list();
86  _result_set.clear();
87  _result_list.clear();
88  return product;
89 }
void set_fcmem(FCMemory *fcmem)
std::vector< Handle > HandleSeq
a list of handles
Definition: Handle.h:246
Handle get_cur_source(void)
Definition: FCMemory.cc:123
virtual bool link_match(const LinkPtr &lpat, const LinkPtr &lsoln)
virtual bool node_match(const Handle &node1, const Handle &node2)
std::shared_ptr< Link > LinkPtr
Definition: Atom.h:53
Instantiator inst
Definition: Implicator.h:65
HandleSeq _result_list
Definition: Implicator.h:59
virtual void insert_result(const Handle &)
Definition: Implicator.cc:57
Handle instantiate(const Handle &expr, const std::map< Handle, Handle > &vars)
virtual bool link_match(const LinkPtr &, const LinkPtr &)
virtual bool grounding(const std::map< Handle, Handle > &var_soln, const std::map< Handle, Handle > &pred_soln)
UnorderedHandleSet _result_set
Definition: Implicator.h:58
virtual bool node_match(const Handle &, const Handle &)
virtual HandleSeq get_result_list()
Definition: Implicator.cc:72