OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BackwardChainerPMCB.cc
Go to the documentation of this file.
1 /*
2  * BackwardChainerPMCB.cc
3  *
4  * Copyright (C) 2014 Misgana Bayetta
5  * Copyright (C) 2015 OpenCog Foundation
6  *
7  * Author: Misgana Bayetta <misgana.bayetta@gmail.com> October 2014
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License v3 as
11  * published by the Free Software Foundation and including the exceptions
12  * at http://opencog.org/wiki/Licenses
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program; if not, write to:
21  * Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 
25 #include "BackwardChainerPMCB.h"
26 
27 using namespace opencog;
28 
30  : InitiateSearchCB(as),
32  _as(as),
33  _int_vars(int_vars)
34 {
35 }
36 
38 {
39 }
40 
41 bool BackwardChainerPMCB::grounding(const std::map<Handle, Handle> &var_soln,
42  const std::map<Handle, Handle> &pred_soln)
43 {
44  std::map<Handle, Handle> true_var_soln;
45 
46  // get rid of non-var mapping
47  for (auto& p : var_soln)
48  {
49  if (_int_vars->get_variables().varset.count(p.first) == 1)
50  true_var_soln[p.first] = p.second;
51  }
52 
53  if (true_var_soln.size() == 0)
54  return false;
55 
56  // store the variable solution
57  var_solns_.push_back(true_var_soln);
58  pred_solns_.push_back(pred_soln);
59 
60  return false;
61 }
62 
63 std::vector<std::map<Handle, Handle>> BackwardChainerPMCB::get_var_list()
64 {
65  return var_solns_;
66 }
67 std::vector<std::map<Handle, Handle>> BackwardChainerPMCB::get_pred_list()
68 {
69  return pred_solns_;
70 }
std::shared_ptr< VariableList > VariableListPtr
Definition: VariableList.h:94
std::vector< std::map< Handle, Handle > > get_pred_list()
virtual bool grounding(const std::map< Handle, Handle > &var_soln, const std::map< Handle, Handle > &pred_soln)
std::vector< std::map< Handle, Handle > > var_solns_
BackwardChainerPMCB(AtomSpace *, VariableListPtr)
std::vector< std::map< Handle, Handle > > pred_solns_
std::vector< std::map< Handle, Handle > > get_var_list()