OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
opencog::ForwardChainer Class Reference

#include <ForwardChainer.h>

+ Collaboration diagram for opencog::ForwardChainer:

Public Member Functions

 ForwardChainer (AtomSpace &as, Handle rbs)
 
void do_chain (ForwardChainerCallBack &fcb, Handle hsource=Handle::UNDEFINED)
 
void do_step (ForwardChainerCallBack &fcb)
 
HandleSeq get_chaining_result (void)
 
void setLogger (Logger *log)
 
Logger * getLogger (void)
 

Protected Types

enum  source_selection_mode { TV_FITNESS_BASED, STI_BASED }
 

Private Member Functions

void init ()
 
void add_to_source_list (Handle h)
 
void do_pm ()
 
void do_pm (const Handle &hsource, const UnorderedHandleSet &var_nodes, ForwardChainerCallBack &fcb)
 

Private Attributes

AtomSpace_as
 
URECommons _rec
 
Handle _rbs
 
UREConfigReader _configReader
 
FCMemory _fcmem
 
Logger * _log
 
int _iteration = 0
 

Friends

class ::ForwardChainerUTest
 

Detailed Description

Definition at line 38 of file ForwardChainer.h.

Member Enumeration Documentation

Enumerator
TV_FITNESS_BASED 
STI_BASED 

Definition at line 63 of file ForwardChainer.h.

Constructor & Destructor Documentation

ForwardChainer::ForwardChainer ( AtomSpace as,
Handle  rbs 
)

Ctor. rbs is a Handle pointing to rule-based system.

Definition at line 35 of file ForwardChainer.cc.

References init().

Member Function Documentation

void opencog::ForwardChainer::add_to_source_list ( Handle  h)
private
void ForwardChainer::do_pm ( )
private

Invokes pattern matcher using each rule declared in the configuration file.

Do pattern matching using the rules declared in the declaration file

Definition at line 213 of file ForwardChainer.cc.

References _as, _fcmem, _log, _rbs, opencog::FCMemory::add_rules_product(), opencog::BindLinkCast(), opencog::Implicator::get_result_list(), opencog::FCMemory::get_rules(), opencog::Implicator::implicand, opencog::FCMemory::set_cur_rule(), and opencog::Atom::toString().

+ Here is the caller graph for this function:

void ForwardChainer::do_pm ( const Handle hsource,
const UnorderedHandleSet var_nodes,
ForwardChainerCallBack fcb 
)
private

Does pattern matching for a variable containing query.

Parameters
sourcea variable containing handle passed as an input to the pattern matcher
var_nodesthe VariableNodes in
hsource
fcba forward chainer callback implementation used here only for choosing rules that contain
hsourcein their implicant

Additionally, find applicable rules and apply.

Definition at line 174 of file ForwardChainer.cc.

References _as, _fcmem, opencog::AtomSpace::add_link(), opencog::FCMemory::add_rules_product(), opencog::BindLinkCast(), opencog::ForwardChainerCallBack::choose_rules(), createPatternLink, opencog::Implicator::get_result_list(), opencog::Implicator::implicand, opencog::AtomSpace::remove_atom(), opencog::FCMemory::set_cur_rule(), and opencog::FCMemory::set_source().

void ForwardChainer::do_step ( ForwardChainerCallBack fcb)

Does one step forward chaining

Parameters
fcba concrete implementation of of ForwardChainerCallBack class

If no rules matches the pattern of the source, set all rules for candidacy to be selected by the proceeding step. xxx this decision is maded based on recent discussion.I it might still face some changes.

TODO Find/add premises?

Apply rule.

Definition at line 69 of file ForwardChainer.cc.

References _fcmem, _iteration, _log, _rec, opencog::FCMemory::add_rules_product(), opencog::ForwardChainerCallBack::apply_rule(), opencog::ForwardChainerCallBack::choose_rules(), opencog::FCMemory::get_cur_source(), opencog::Rule::get_handle(), opencog::FCMemory::get_rules(), opencog::FCMemory::set_cur_rule(), opencog::Atom::toString(), opencog::URECommons::tournament_select(), opencog::Handle::UNDEFINED, and opencog::FCMemory::update_potential_sources().

+ Here is the caller graph for this function:

HandleSeq ForwardChainer::get_chaining_result ( void  )

Definition at line 236 of file ForwardChainer.cc.

References _fcmem, and opencog::FCMemory::get_result().

+ Here is the caller graph for this function:

Logger * ForwardChainer::getLogger ( void  )

Definition at line 59 of file ForwardChainer.cc.

References _log.

void ForwardChainer::init ( void  )
private
void ForwardChainer::setLogger ( Logger *  log)

Definition at line 52 of file ForwardChainer.cc.

References _log.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class ::ForwardChainerUTest
friend

Definition at line 40 of file ForwardChainer.h.

Member Data Documentation

AtomSpace& opencog::ForwardChainer::_as
private

Definition at line 42 of file ForwardChainer.h.

UREConfigReader opencog::ForwardChainer::_configReader
private

Definition at line 46 of file ForwardChainer.h.

FCMemory opencog::ForwardChainer::_fcmem
private

Definition at line 49 of file ForwardChainer.h.

int opencog::ForwardChainer::_iteration = 0
private

Definition at line 51 of file ForwardChainer.h.

Logger* opencog::ForwardChainer::_log
private

Definition at line 50 of file ForwardChainer.h.

Handle opencog::ForwardChainer::_rbs
private

Definition at line 44 of file ForwardChainer.h.

URECommons opencog::ForwardChainer::_rec
private

Definition at line 43 of file ForwardChainer.h.


The documentation for this class was generated from the following files: