{"action":"created","comment":{"url":"https://api.github.com/repos/opencog/opencog/pulls/comments/71386432","id":71386432,"diff_hunk":"@@ -0,0 +1,173 @@\n+/*\n+ * opencog/attention/HebbianCreationAgent.cc\n+ *\n+ * Written by Roman Treutlein\n+ * All Rights Reserved\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU Affero General Public License v3 as\n+ * published by the Free Software Foundation and including the exceptions\n+ * at http://opencog.org/wiki/Licenses\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Affero General Public License\n+ * along with this program; if not, write to:\n+ * Free Software Foundation, Inc.,\n+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n+ */\n+#include <opencog/util/Config.h>\n+#include <opencog/util/algorithm.h>\n+\n+#include <opencog/atoms/base/Link.h>\n+#include <opencog/truthvalue/IndefiniteTruthValue.h>\n+#include <opencog/truthvalue/SimpleTruthValue.h>\n+#include <opencog/attention/atom_types.h>\n+#include <opencog/atomutils/Neighbors.h>\n+\n+#define DEPRECATED_ATOMSPACE_CALLS\n+#include <opencog/atomspace/AtomSpace.h>\n+#include <opencog/cogserver/server/CogServer.h>\n+\n+#include \"HebbianCreationAgent.h\"\n+\n+using namespace opencog;\n+\n+HebbianCreationAgent::HebbianCreationAgent(CogServer& cs) :\n+    Agent(cs)\n+{\n+    // Provide a logger, but disable it initially\n+    log = NULL;\n+    setLogger(new opencog::Logger(\"HebbianCreationAgent.log\", Logger::FINE, true));\n+\n+    maxLinkNum = config().get_int(\"ECAN_MAXLINKS\");\n+    localToFarLinks = config().get_int(\"ECAN_LOCAL_FAR_LINK_RATIO\");\n+\n+    as = &_cogserver.getAtomSpace();\n+}\n+\n+HebbianCreationAgent::~HebbianCreationAgent()\n+{\n+    if (log) delete log;\n+}\n+\n+void HebbianCreationAgent::setLogger(Logger* _log)\n+{\n+    if (log) delete log;\n+    log = _log;\n+}\n+\n+Logger* HebbianCreationAgent::getLogger()\n+{\n+    return log;\n+}\n+\n+void HebbianCreationAgent::run()\n+{\n+    Handle source;\n+    newAtomsInAV.pop(source);\n+\n+    //HebbianLinks should not normally enter to the AF boundary since they\n+    //should not normally have STI values.The below check will avoid such\n+    //Scenarios from happening which could lead to HebbianLink creation\n+    //bn atoms containing HebbianLink.\n+    if (classserver().isA(source->getType(), HEBBIAN_LINK))\n+        return;\n+\n+    HandleSeq notAttentionalFocus;\n+    int afb = as->get_attentional_focus_boundary();\n+    as->get_handles_by_AV(back_inserter(notAttentionalFocus),0,afb);\n+\n+   // Retrieve the atoms in the AttentionalFocus\n+    HandleSeq attentionalFocus;\n+    as->get_handle_set_in_attentional_focus(back_inserter(attentionalFocus));\n+\n+    // Exclude the source atom\n+    attentionalFocus.erase(std::remove(attentionalFocus.begin(),\n+                                       attentionalFocus.end(),\n+                                       source), attentionalFocus.end());\n+\n+    if (source == Handle::UNDEFINED)\n+        return;\n+\n+    // Get the neighboring atoms, where the connecting edge\n+    // is an AsymmetricHebbianLink in either direction\n+    HandleSeq existingAsSource =\n+            get_target_neighbors(source, ASYMMETRIC_HEBBIAN_LINK);\n+    HandleSeq existingAsTarget =\n+            get_source_neighbors(source, ASYMMETRIC_HEBBIAN_LINK);\n+\n+    // Get the set differences between the AttentionalFocus\n+    // and the sets of existing sources and targets\n+    std::sort(existingAsSource.begin(), existingAsSource.end());\n+    std::sort(existingAsTarget.begin(), existingAsTarget.end());\n+    std::sort(attentionalFocus.begin(), attentionalFocus.end());\n+    HandleSeq needToBeSource = set_difference(attentionalFocus,\n+                                              existingAsSource);\n+    HandleSeq needToBeTarget = set_difference(attentionalFocus,\n+                                              existingAsTarget);\n+\n+\n+    int count = 0;\n+\n+    // Resulting in the sets of nodes that require\n+    // a new AsymmetricHebbianLink in either direction\n+    for (Handle atom : needToBeSource) {\n+        if (atom == Handle::UNDEFINED)","path":"opencog/attention/experimental/HebbianCreationAgent.cc","position":119,"original_position":119,"commit_id":"cc63a2d51d96fe754d6bbdee5e2b7ba7e176db1d","original_commit_id":"cc63a2d51d96fe754d6bbdee5e2b7ba7e176db1d","user":{"login":"rTreutlein","id":2064628,"avatar_url":"https://avatars.githubusercontent.com/u/2064628?v=3","gravatar_id":"","url":"https://api.github.com/users/rTreutlein","html_url":"https://github.com/rTreutlein","followers_url":"https://api.github.com/users/rTreutlein/followers","following_url":"https://api.github.com/users/rTreutlein/following{/other_user}","gists_url":"https://api.github.com/users/rTreutlein/gists{/gist_id}","starred_url":"https://api.github.com/users/rTreutlein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rTreutlein/subscriptions","organizations_url":"https://api.github.com/users/rTreutlein/orgs","repos_url":"https://api.github.com/users/rTreutlein/repos","events_url":"https://api.github.com/users/rTreutlein/events{/privacy}","received_events_url":"https://api.github.com/users/rTreutlein/received_events","type":"User","site_admin":false},"body":"The Forgetting Agent might delete it while this is running so yes it is possible.","created_at":"2016-07-19T17:39:54Z","updated_at":"2016-07-19T17:39:54Z","html_url":"https://github.com/opencog/opencog/pull/2302#discussion_r71386432","pull_request_url":"https://api.github.com/repos/opencog/opencog/pulls/2302","_links":{"self":{"href":"https://api.github.com/repos/opencog/opencog/pulls/comments/71386432"},"html":{"href":"https://github.com/opencog/opencog/pull/2302#discussion_r71386432"},"pull_request":{"href":"https://api.github.com/repos/opencog/opencog/pulls/2302"}}},"pull_request":{"url":"https://api.github.com/repos/opencog/opencog/pulls/2302","id":77956482,"html_url":"https://github.com/opencog/opencog/pull/2302","diff_url":"https://github.com/opencog/opencog/pull/2302.diff","patch_url":"https://github.com/opencog/opencog/pull/2302.patch","issue_url":"https://api.github.com/repos/opencog/opencog/issues/2302","number":2302,"state":"open","locked":false,"title":"Merged rest of Experimental ECAN","user":{"login":"rTreutlein","id":2064628,"avatar_url":"https://avatars.githubusercontent.com/u/2064628?v=3","gravatar_id":"","url":"https://api.github.com/users/rTreutlein","html_url":"https://github.com/rTreutlein","followers_url":"https://api.github.com/users/rTreutlein/followers","following_url":"https://api.github.com/users/rTreutlein/following{/other_user}","gists_url":"https://api.github.com/users/rTreutlein/gists{/gist_id}","starred_url":"https://api.github.com/users/rTreutlein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rTreutlein/subscriptions","organizations_url":"https://api.github.com/users/rTreutlein/orgs","repos_url":"https://api.github.com/users/rTreutlein/repos","events_url":"https://api.github.com/users/rTreutlein/events{/privacy}","received_events_url":"https://api.github.com/users/rTreutlein/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-19T11:01:02Z","updated_at":"2016-07-19T17:39:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ddeaabe13505aa6fc2ab42e43c5c1b3229eb35dd","assignee":{"login":"rTreutlein","id":2064628,"avatar_url":"https://avatars.githubusercontent.com/u/2064628?v=3","gravatar_id":"","url":"https://api.github.com/users/rTreutlein","html_url":"https://github.com/rTreutlein","followers_url":"https://api.github.com/users/rTreutlein/followers","following_url":"https://api.github.com/users/rTreutlein/following{/other_user}","gists_url":"https://api.github.com/users/rTreutlein/gists{/gist_id}","starred_url":"https://api.github.com/users/rTreutlein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rTreutlein/subscriptions","organizations_url":"https://api.github.com/users/rTreutlein/orgs","repos_url":"https://api.github.com/users/rTreutlein/repos","events_url":"https://api.github.com/users/rTreutlein/events{/privacy}","received_events_url":"https://api.github.com/users/rTreutlein/received_events","type":"User","site_admin":false},"assignees":[{"login":"rTreutlein","id":2064628,"avatar_url":"https://avatars.githubusercontent.com/u/2064628?v=3","gravatar_id":"","url":"https://api.github.com/users/rTreutlein","html_url":"https://github.com/rTreutlein","followers_url":"https://api.github.com/users/rTreutlein/followers","following_url":"https://api.github.com/users/rTreutlein/following{/other_user}","gists_url":"https://api.github.com/users/rTreutlein/gists{/gist_id}","starred_url":"https://api.github.com/users/rTreutlein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rTreutlein/subscriptions","organizations_url":"https://api.github.com/users/rTreutlein/orgs","repos_url":"https://api.github.com/users/rTreutlein/repos","events_url":"https://api.github.com/users/rTreutlein/events{/privacy}","received_events_url":"https://api.github.com/users/rTreutlein/received_events","type":"User","site_admin":false},{"login":"misgeatgit","id":2872565,"avatar_url":"https://avatars.githubusercontent.com/u/2872565?v=3","gravatar_id":"","url":"https://api.github.com/users/misgeatgit","html_url":"https://github.com/misgeatgit","followers_url":"https://api.github.com/users/misgeatgit/followers","following_url":"https://api.github.com/users/misgeatgit/following{/other_user}","gists_url":"https://api.github.com/users/misgeatgit/gists{/gist_id}","starred_url":"https://api.github.com/users/misgeatgit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/misgeatgit/subscriptions","organizations_url":"https://api.github.com/users/misgeatgit/orgs","repos_url":"https://api.github.com/users/misgeatgit/repos","events_url":"https://api.github.com/users/misgeatgit/events{/privacy}","received_events_url":"https://api.github.com/users/misgeatgit/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/opencog/opencog/pulls/2302/commits","review_comments_url":"https://api.github.com/repos/opencog/opencog/pulls/2302/comments","review_comment_url":"https://api.github.com/repos/opencog/opencog/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opencog/opencog/issues/2302/comments","statuses_url":"https://api.github.com/repos/opencog/opencog/statuses/cc63a2d51d96fe754d6bbdee5e2b7ba7e176db1d","head":{"label":"rTreutlein:master","ref":"master","sha":"cc63a2d51d96fe754d6bbdee5e2b7ba7e176db1d","user":{"login":"rTreutlein","id":2064628,"avatar_url":"https://avatars.githubusercontent.com/u/2064628?v=3","gravatar_id":"","url":"https://api.github.com/users/rTreutlein","html_url":"https://github.com/rTreutlein","followers_url":"https://api.github.com/users/rTreutlein/followers","following_url":"https://api.github.com/users/rTreutlein/following{/other_user}","gists_url":"https://api.github.com/users/rTreutlein/gists{/gist_id}","starred_url":"https://api.github.com/users/rTreutlein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rTreutlein/subscriptions","organizations_url":"https://api.github.com/users/rTreutlein/orgs","repos_url":"https://api.github.com/users/rTreutlein/repos","events_url":"https://api.github.com/users/rTreutlein/events{/privacy}","received_events_url":"https://api.github.com/users/rTreutlein/received_events","type":"User","site_admin":false},"repo":{"id":46968067,"name":"opencog","full_name":"rTreutlein/opencog","owner":{"login":"rTreutlein","id":2064628,"avatar_url":"https://avatars.githubusercontent.com/u/2064628?v=3","gravatar_id":"","url":"https://api.github.com/users/rTreutlein","html_url":"https://github.com/rTreutlein","followers_url":"https://api.github.com/users/rTreutlein/followers","following_url":"https://api.github.com/users/rTreutlein/following{/other_user}","gists_url":"https://api.github.com/users/rTreutlein/gists{/gist_id}","starred_url":"https://api.github.com/users/rTreutlein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rTreutlein/subscriptions","organizations_url":"https://api.github.com/users/rTreutlein/orgs","repos_url":"https://api.github.com/users/rTreutlein/repos","events_url":"https://api.github.com/users/rTreutlein/events{/privacy}","received_events_url":"https://api.github.com/users/rTreutlein/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rTreutlein/opencog","description":"A framework for integrated Artificial Intelligence & Artificial General Intelligence (AGI)","fork":true,"url":"https://api.github.com/repos/rTreutlein/opencog","forks_url":"https://api.github.com/repos/rTreutlein/opencog/forks","keys_url":"https://api.github.com/repos/rTreutlein/opencog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rTreutlein/opencog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rTreutlein/opencog/teams","hooks_url":"https://api.github.com/repos/rTreutlein/opencog/hooks","issue_events_url":"https://api.github.com/repos/rTreutlein/opencog/issues/events{/number}","events_url":"https://api.github.com/repos/rTreutlein/opencog/events","assignees_url":"https://api.github.com/repos/rTreutlein/opencog/assignees{/user}","branches_url":"https://api.github.com/repos/rTreutlein/opencog/branches{/branch}","tags_url":"https://api.github.com/repos/rTreutlein/opencog/tags","blobs_url":"https://api.github.com/repos/rTreutlein/opencog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rTreutlein/opencog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rTreutlein/opencog/git/refs{/sha}","trees_url":"https://api.github.com/repos/rTreutlein/opencog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rTreutlein/opencog/statuses/{sha}","languages_url":"https://api.github.com/repos/rTreutlein/opencog/languages","stargazers_url":"https://api.github.com/repos/rTreutlein/opencog/stargazers","contributors_url":"https://api.github.com/repos/rTreutlein/opencog/contributors","subscribers_url":"https://api.github.com/repos/rTreutlein/opencog/subscribers","subscription_url":"https://api.github.com/repos/rTreutlein/opencog/subscription","commits_url":"https://api.github.com/repos/rTreutlein/opencog/commits{/sha}","git_commits_url":"https://api.github.com/repos/rTreutlein/opencog/git/commits{/sha}","comments_url":"https://api.github.com/repos/rTreutlein/opencog/comments{/number}","issue_comment_url":"https://api.github.com/repos/rTreutlein/opencog/issues/comments{/number}","contents_url":"https://api.github.com/repos/rTreutlein/opencog/contents/{+path}","compare_url":"https://api.github.com/repos/rTreutlein/opencog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rTreutlein/opencog/merges","archive_url":"https://api.github.com/repos/rTreutlein/opencog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rTreutlein/opencog/downloads","issues_url":"https://api.github.com/repos/rTreutlein/opencog/issues{/number}","pulls_url":"https://api.github.com/repos/rTreutlein/opencog/pulls{/number}","milestones_url":"https://api.github.com/repos/rTreutlein/opencog/milestones{/number}","notifications_url":"https://api.github.com/repos/rTreutlein/opencog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rTreutlein/opencog/labels{/name}","releases_url":"https://api.github.com/repos/rTreutlein/opencog/releases{/id}","deployments_url":"https://api.github.com/repos/rTreutlein/opencog/deployments","created_at":"2015-11-27T08:19:26Z","updated_at":"2016-06-30T19:36:53Z","pushed_at":"2016-07-19T10:59:41Z","git_url":"git://github.com/rTreutlein/opencog.git","ssh_url":"git@github.com:rTreutlein/opencog.git","clone_url":"https://github.com/rTreutlein/opencog.git","svn_url":"https://github.com/rTreutlein/opencog","homepage":"http://wiki.opencog.org/w/Development","size":148859,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"opencog:master","ref":"master","sha":"e7fb8eb5d46bf0242c37075b1b88b9eb9f232398","user":{"login":"opencog","id":2109913,"avatar_url":"https://avatars.githubusercontent.com/u/2109913?v=3","gravatar_id":"","url":"https://api.github.com/users/opencog","html_url":"https://github.com/opencog","followers_url":"https://api.github.com/users/opencog/followers","following_url":"https://api.github.com/users/opencog/following{/other_user}","gists_url":"https://api.github.com/users/opencog/gists{/gist_id}","starred_url":"https://api.github.com/users/opencog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencog/subscriptions","organizations_url":"https://api.github.com/users/opencog/orgs","repos_url":"https://api.github.com/users/opencog/repos","events_url":"https://api.github.com/users/opencog/events{/privacy}","received_events_url":"https://api.github.com/users/opencog/received_events","type":"Organization","site_admin":false},"repo":{"id":6365343,"name":"opencog","full_name":"opencog/opencog","owner":{"login":"opencog","id":2109913,"avatar_url":"https://avatars.githubusercontent.com/u/2109913?v=3","gravatar_id":"","url":"https://api.github.com/users/opencog","html_url":"https://github.com/opencog","followers_url":"https://api.github.com/users/opencog/followers","following_url":"https://api.github.com/users/opencog/following{/other_user}","gists_url":"https://api.github.com/users/opencog/gists{/gist_id}","starred_url":"https://api.github.com/users/opencog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencog/subscriptions","organizations_url":"https://api.github.com/users/opencog/orgs","repos_url":"https://api.github.com/users/opencog/repos","events_url":"https://api.github.com/users/opencog/events{/privacy}","received_events_url":"https://api.github.com/users/opencog/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opencog/opencog","description":"A framework for integrated Artificial Intelligence & Artificial General Intelligence (AGI)","fork":false,"url":"https://api.github.com/repos/opencog/opencog","forks_url":"https://api.github.com/repos/opencog/opencog/forks","keys_url":"https://api.github.com/repos/opencog/opencog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opencog/opencog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opencog/opencog/teams","hooks_url":"https://api.github.com/repos/opencog/opencog/hooks","issue_events_url":"https://api.github.com/repos/opencog/opencog/issues/events{/number}","events_url":"https://api.github.com/repos/opencog/opencog/events","assignees_url":"https://api.github.com/repos/opencog/opencog/assignees{/user}","branches_url":"https://api.github.com/repos/opencog/opencog/branches{/branch}","tags_url":"https://api.github.com/repos/opencog/opencog/tags","blobs_url":"https://api.github.com/repos/opencog/opencog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opencog/opencog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opencog/opencog/git/refs{/sha}","trees_url":"https://api.github.com/repos/opencog/opencog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opencog/opencog/statuses/{sha}","languages_url":"https://api.github.com/repos/opencog/opencog/languages","stargazers_url":"https://api.github.com/repos/opencog/opencog/stargazers","contributors_url":"https://api.github.com/repos/opencog/opencog/contributors","subscribers_url":"https://api.github.com/repos/opencog/opencog/subscribers","subscription_url":"https://api.github.com/repos/opencog/opencog/subscription","commits_url":"https://api.github.com/repos/opencog/opencog/commits{/sha}","git_commits_url":"https://api.github.com/repos/opencog/opencog/git/commits{/sha}","comments_url":"https://api.github.com/repos/opencog/opencog/comments{/number}","issue_comment_url":"https://api.github.com/repos/opencog/opencog/issues/comments{/number}","contents_url":"https://api.github.com/repos/opencog/opencog/contents/{+path}","compare_url":"https://api.github.com/repos/opencog/opencog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opencog/opencog/merges","archive_url":"https://api.github.com/repos/opencog/opencog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opencog/opencog/downloads","issues_url":"https://api.github.com/repos/opencog/opencog/issues{/number}","pulls_url":"https://api.github.com/repos/opencog/opencog/pulls{/number}","milestones_url":"https://api.github.com/repos/opencog/opencog/milestones{/number}","notifications_url":"https://api.github.com/repos/opencog/opencog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opencog/opencog/labels{/name}","releases_url":"https://api.github.com/repos/opencog/opencog/releases{/id}","deployments_url":"https://api.github.com/repos/opencog/opencog/deployments","created_at":"2012-10-24T06:10:15Z","updated_at":"2016-07-19T09:20:25Z","pushed_at":"2016-07-19T11:01:02Z","git_url":"git://github.com/opencog/opencog.git","ssh_url":"git@github.com:opencog/opencog.git","clone_url":"https://github.com/opencog/opencog.git","svn_url":"https://github.com/opencog/opencog","homepage":"http://wiki.opencog.org/w/Development","size":162569,"stargazers_count":997,"watchers_count":997,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":452,"mirror_url":null,"open_issues_count":65,"forks":452,"open_issues":65,"watchers":997,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opencog/opencog/pulls/2302"},"html":{"href":"https://github.com/opencog/opencog/pull/2302"},"issue":{"href":"https://api.github.com/repos/opencog/opencog/issues/2302"},"comments":{"href":"https://api.github.com/repos/opencog/opencog/issues/2302/comments"},"review_comments":{"href":"https://api.github.com/repos/opencog/opencog/pulls/2302/comments"},"review_comment":{"href":"https://api.github.com/repos/opencog/opencog/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opencog/opencog/pulls/2302/commits"},"statuses":{"href":"https://api.github.com/repos/opencog/opencog/statuses/cc63a2d51d96fe754d6bbdee5e2b7ba7e176db1d"}}}}
{"actor":{"display_login":"rTreutlein"}}