OpenCog Framework
Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
|
#include <ForwardChainer.h>
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 |
Definition at line 38 of file ForwardChainer.h.
|
protected |
Enumerator | |
---|---|
TV_FITNESS_BASED | |
STI_BASED |
Definition at line 63 of file ForwardChainer.h.
Ctor. rbs is a Handle pointing to rule-based system.
Definition at line 35 of file ForwardChainer.cc.
References init().
|
private |
void ForwardChainer::do_chain | ( | ForwardChainerCallBack & | fcb, |
Handle | hsource = Handle::UNDEFINED |
||
) |
Choose next source.
Definition at line 128 of file ForwardChainer.cc.
References _as, _configReader, _fcmem, _iteration, _log, opencog::ForwardChainerCallBack::choose_next_source(), do_pm(), do_step(), opencog::UREConfigReader::get_maximum_iterations(), opencog::AtomSpace::get_outgoing(), opencog::get_outgoing_nodes(), opencog::Atom::getType(), opencog::LinkCast(), opencog::FCMemory::set_source(), opencog::Handle::UNDEFINED, and opencog::FCMemory::update_potential_sources().
|
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().
|
private |
Does pattern matching for a variable containing query.
source | a variable containing handle passed as an input to the pattern matcher |
var_nodes | the VariableNodes in |
hsource | |
fcb | a forward chainer callback implementation used here only for choosing rules that contain |
hsource | in 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
fcb | a 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().
HandleSeq ForwardChainer::get_chaining_result | ( | void | ) |
Definition at line 236 of file ForwardChainer.cc.
References _fcmem, and opencog::FCMemory::get_result().
Logger * ForwardChainer::getLogger | ( | void | ) |
Definition at line 59 of file ForwardChainer.cc.
References _log.
|
private |
initialize config methods
Definition at line 41 of file ForwardChainer.cc.
References _configReader, _fcmem, _log, opencog::UREConfigReader::get_attention_allocation(), opencog::UREConfigReader::get_rules(), opencog::FCMemory::set_cur_rule(), opencog::FCMemory::set_rules(), opencog::FCMemory::set_search_in_af(), and setLogger().
void ForwardChainer::setLogger | ( | Logger * | log | ) |
Definition at line 52 of file ForwardChainer.cc.
References _log.
|
friend |
Definition at line 40 of file ForwardChainer.h.
|
private |
Definition at line 42 of file ForwardChainer.h.
|
private |
Definition at line 46 of file ForwardChainer.h.
|
private |
Definition at line 49 of file ForwardChainer.h.
|
private |
Definition at line 51 of file ForwardChainer.h.
|
private |
Definition at line 50 of file ForwardChainer.h.
|
private |
Definition at line 44 of file ForwardChainer.h.
|
private |
Definition at line 43 of file ForwardChainer.h.