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

#include <URECommons.h>

+ Collaboration diagram for opencog::URECommons:

Public Member Functions

 URECommons (AtomSpace &as)
 
Handle create_bindLink (Handle himplicant, bool is_quoted=false) throw (opencog::InvalidParamException)
 
bool exists_in (Handle &hlink, Handle &h)
 
string get_unique_name (Handle &h)
 
Handle replace_nodes_with_varnode (Handle &himplication_link, Type t=VARIABLE_NODE)
 
Handle change_node_types (Handle &h, map< Handle, Handle > &replacement_map)
 
void get_root_links (Handle h, HandleSeq &parents)
 
template<class Type >
Type tournament_select (map< Type, float > tfitnes_map)
 
float tv_fitness (Handle h)
 

Public Attributes

const float FITNESS_PARAM = 0.9
 

Private Attributes

AtomSpace_as
 

Detailed Description

Reusable functions in the PLN module

Definition at line 40 of file URECommons.h.

Constructor & Destructor Documentation

URECommons::URECommons ( AtomSpace as)

Definition at line 31 of file URECommons.cc.

Member Function Documentation

Handle URECommons::change_node_types ( Handle h,
map< Handle, Handle > &  replacement_map 
)

create a copy of the handle with a different variable name passed in

Parameters
var_uniq_varmap input

Definition at line 106 of file URECommons.cc.

References _as, opencog::AtomSpace::add_link(), opencog::AtomSpace::get_outgoing(), opencog::AtomSpace::get_TV(), opencog::AtomSpace::get_type(), opencog::LinkCast(), opencog::NodeCast(), and opencog::Atom::setTruthValue().

+ Here is the caller graph for this function:

Handle URECommons::create_bindLink ( Handle  himplicant,
bool  is_quoted = false 
)
throw (opencog::InvalidParamException
)

creates a BindLink instance that could be passed to to PatternMatching module

Parameters
himplicant- an implicant part of the BindLink must have a variable node.
Returns
- a Handle to the BindLink instance created

Definition at line 33 of file URECommons.cc.

References opencog::get_outgoing_nodes(), and opencog::LinkCast().

bool URECommons::exists_in ( Handle hlink,
Handle h 
)

checks if a handle already exists in a HandleSeq

Definition at line 86 of file URECommons.cc.

References _as, opencog::AtomSpace::get_outgoing(), and opencog::LinkCast().

void URECommons::get_root_links ( Handle  h,
HandleSeq parents 
)

Get top level parent of the handle

Returns
a Link or Handle::UNDEFINED if there is no

Definition at line 134 of file URECommons.cc.

References _as, and opencog::AtomSpace::get_incoming().

+ Here is the caller graph for this function:

string URECommons::get_unique_name ( Handle h)

Definition at line 76 of file URECommons.cc.

References _as, opencog::AtomSpace::get_incoming(), and opencog::AtomSpace::get_name().

+ Here is the caller graph for this function:

Handle URECommons::replace_nodes_with_varnode ( Handle himplication_link,
Type  t = VARIABLE_NODE 
)

create a copy of the given implicatoin link with unique variables

Definition at line 62 of file URECommons.cc.

References _as, opencog::AtomSpace::add_node(), change_node_types(), opencog::get_outgoing_nodes(), and get_unique_name().

template<class Type >
Type opencog::URECommons::tournament_select ( map< Type, float >  tfitnes_map)
inline

Randomly pick about half of the elements, and amongst those return the fittest (higher is better). If tfitness_map is empty, then return the default value (build with Type()).

Definition at line 91 of file URECommons.h.

+ Here is the caller graph for this function:

float URECommons::tv_fitness ( Handle  h)

Calculates fitness values in source_list_atom_space (or target_list_atom_space for the BC) using the formula

F = s^x * c^(2-x)

where s is strength,c is confidence and x is some fixed value

Parameters
h- a handle
Returns
a fitness value

Definition at line 151 of file URECommons.cc.

References _as, FITNESS_PARAM, and opencog::AtomSpace::get_TV().

+ Here is the caller graph for this function:

Member Data Documentation

AtomSpace& opencog::URECommons::_as
private

Definition at line 41 of file URECommons.h.

const float opencog::URECommons::FITNESS_PARAM = 0.9

Definition at line 44 of file URECommons.h.


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