25 #include <opencog/util/macros.h>
29 using namespace opencog;
34 throw (opencog::InvalidParamException) {
36 throw InvalidParamException(TRACE_INFO,
"Input must be a link type ");
40 himplicant = replace_nodes_with_varnode(himplicant);
47 if (vnode_is_typedv) {
48 Handle h = _as.add_node(TYPE_NODE,
"VariableNode");
49 for (
Handle hvn : variable_nodes) {
50 Handle hi = _as.add_link(TYPED_VARIABLE_LINK, hvn, h);
51 list_link_elem.push_back(hi);
54 list_link_elem.insert(list_link_elem.end(), variable_nodes.begin(),
55 variable_nodes.end());
57 Handle var_listLink = _as.add_link(VARIABLE_LIST, list_link_elem);
59 return _as.add_link(BIND_LINK, var_listLink, himplicant, himplicant);
69 map<Handle, Handle> node_unique_var_map;
71 node_unique_var_map[h] =
_as.
add_node(VARIABLE_NODE,
81 name.append(to_string(hs[0].value()));
82 name.append(
"-bcgen");
91 throw InvalidParamException(TRACE_INFO,
92 "Need a LINK type to look in");
94 if (find(outg.begin(), outg.end(), h) != outg.end())
107 map<Handle, Handle>& replacement_map) {
114 if (replacement_map.find(hi) != replacement_map.end())
115 hs_cpy.push_back(replacement_map[hi]);
117 hs_cpy.push_back(hi);
125 if (replacement_map.find(h) != replacement_map.end())
126 hcpy = replacement_map[h];
136 if (incoming.empty())
139 for (
Handle hi : incoming) {
142 if (find(parents.begin(), parents.end(), hi) == parents.end())
143 parents.push_back(hi);
Handle add_node(Type t, const std::string &name="", bool async=false)
std::vector< Handle > HandleSeq
a list of handles
Handle change_node_types(Handle &h, map< Handle, Handle > &replacement_map)
std::shared_ptr< TruthValue > TruthValuePtr
bool exists_in(Handle &hlink, Handle &h)
Handle create_bindLink(Handle himplicant, bool is_quoted=false)
void setTruthValue(TruthValuePtr)
Sets the TruthValue object of the atom.
static NodePtr NodeCast(const Handle &h)
UnorderedHandleSet get_outgoing_nodes(const Handle &hinput, const std::vector< Type > &types)
static LinkPtr LinkCast(const Handle &h)
TruthValuePtr get_TV(Handle h) const
URECommons(AtomSpace &as)
HandleSeq get_incoming(Handle h) const
string get_unique_name(Handle &h)
void get_root_links(Handle h, HandleSeq &parents)
const std::string & get_name(Handle h) const
unsigned short Type
type of Atoms, represented as short integer (16 bits)
const float FITNESS_PARAM
std::unordered_set< Handle, handle_hash > UnorderedHandleSet
a hash that associates the handle to its unique identificator
float tv_fitness(Handle h)
Handle add_link(Type t, const HandleSeq &outgoing, bool async=false)
Handle replace_nodes_with_varnode(Handle &himplication_link, Type t=VARIABLE_NODE)
Type get_type(Handle h) const
const HandleSeq & get_outgoing(Handle h) const