{"action":"created","comment":{"url":"https://api.github.com/repos/opencog/atomspace/pulls/comments/38964969","id":38964969,"diff_hunk":"@@ -62,81 +69,79 @@ Logger* ForwardChainer::getLogger()\n }\n \n /**\n- * Does one step forward chaining\n+ * Does one step forward chaining *\n  *\n- * @param fcb a concrete implementation of of ForwardChainerCallBack class \n+ * @return An unordered sets of result of applying a particular selected rule.\n  */\n-void ForwardChainer::do_step(ForwardChainerCallBack& fcb)\n+UnorderedHandleSet ForwardChainer::do_step(bool search_focus_set/* = false*/)\n {\n \n     if (_fcmem.get_cur_source() == Handle::UNDEFINED) {\n         _log->info(\"[ForwardChainer] No current source, step \"\n                    \"forward chaining aborted.\");\n-        return;\n+        return {};\n     }\n \n     _log->info(\"[ForwardChainer] Next source %s\",\n                _fcmem.get_cur_source()->toString().c_str());\n \n-    // Choose matching rules whose input matches with the source.\n-    vector<Rule*> matched_rules = fcb.choose_rules(_fcmem);\n-    _log->info(\"[ForwardChainer] Found matching rule\");\n-\n-    //! If no rules matches the pattern of the source,\n-    //! set all rules for candidacy to be selected by the proceeding step.\n-    //! xxx this decision is maded based on recent discussion.I\n-    //! it might still face some changes.\n-    if (matched_rules.empty()) {\n-        _log->info(\"[ForwardChainer] No matching rule found. \"\n-                   \"Setting all rules as candidates.\");\n-        matched_rules = _fcmem.get_rules();\n-    }\n-\n-    // Select a rule amongst the matching rules by tournament selection\n-    map<Rule*, float> rule_weight;\n-    for (Rule* r : matched_rules) {\n-        rule_weight[r] = r->get_weight();\n-    }\n-\n     _log->info(\"[ForwardChainer] Selecting a rule from the set of \"\n                \"candidate rules.\");\n-    Rule* r = _rec.tournament_select(rule_weight);\n+\n+    Rule* r = _rec.tournament_select(_rule_weight);\n+    _log->info(\"[ForwardChainer] Selected rule is %s\",\n+               (r->get_handle())->toShortString().c_str());\n+\n     _fcmem.set_cur_rule(r);\n-    _log->info(\"[ForwardChainer] Selected rule is %s\", (r->get_handle())->toShortString().c_str());\n+    //TODO Should we use all derived rules or what?\n+    UnorderedHandleSet products;\n \n-    //!TODO Find/add premises?\n+    HandleSeq derived_rhandles = derive_rules(_fcmem.get_cur_source(), r);\n \n-    //! Apply rule.\n-    _log->info(\"[ForwardChainer] Applying chosen rule %s\",\n-               (r->get_handle())->toShortString().c_str());\n-    HandleSeq product = fcb.apply_rule(_fcmem);\n+    //try sub-atom unification on failure to full unification\n+    if (derived_rhandles.empty())\n+        derived_rhandles = derive_rules(_fcmem.get_cur_source(), r, true);\n+\n+    HandleSeq temp_result;\n+    if (not _fcmem.get_focus_set().empty()) {\n \n-    _log->info(\"PRODUCTS...\");\n-    for(const auto& p:product)\n-    {\n-        _log->info(\"%s \", p->toShortString().c_str() );\n+        for (Handle rhandle : derived_rhandles) {","path":"opencog/rule-engine/forwardchainer/ForwardChainer.cc","position":111,"original_position":111,"commit_id":"1404a2f27014c9b30a73ad354f5e1b1acce6ae83","original_commit_id":"1404a2f27014c9b30a73ad354f5e1b1acce6ae83","user":{"login":"eddiemonroe","id":4316602,"avatar_url":"https://avatars.githubusercontent.com/u/4316602?v=3","gravatar_id":"","url":"https://api.github.com/users/eddiemonroe","html_url":"https://github.com/eddiemonroe","followers_url":"https://api.github.com/users/eddiemonroe/followers","following_url":"https://api.github.com/users/eddiemonroe/following{/other_user}","gists_url":"https://api.github.com/users/eddiemonroe/gists{/gist_id}","starred_url":"https://api.github.com/users/eddiemonroe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eddiemonroe/subscriptions","organizations_url":"https://api.github.com/users/eddiemonroe/orgs","repos_url":"https://api.github.com/users/eddiemonroe/repos","events_url":"https://api.github.com/users/eddiemonroe/events{/privacy}","received_events_url":"https://api.github.com/users/eddiemonroe/received_events","type":"User","site_admin":false},"body":"@misgeatgit Ben's original spec is to choose one of the rule positions to unify the source with rather than applying all possible unification possibilities. If we are going to apply all of them as is being done here, that should be discussed with the group. In general every change from the spec should be run by the group and changed in the spec doc.","created_at":"2015-09-08T18:52:54Z","updated_at":"2015-09-08T18:52:54Z","html_url":"https://github.com/opencog/atomspace/pull/261#discussion_r38964969","pull_request_url":"https://api.github.com/repos/opencog/atomspace/pulls/261","_links":{"self":{"href":"https://api.github.com/repos/opencog/atomspace/pulls/comments/38964969"},"html":{"href":"https://github.com/opencog/atomspace/pull/261#discussion_r38964969"},"pull_request":{"href":"https://api.github.com/repos/opencog/atomspace/pulls/261"}}},"pull_request":{"url":"https://api.github.com/repos/opencog/atomspace/pulls/261","id":44195294,"html_url":"https://github.com/opencog/atomspace/pull/261","diff_url":"https://github.com/opencog/atomspace/pull/261.diff","patch_url":"https://github.com/opencog/atomspace/pull/261.patch","issue_url":"https://api.github.com/repos/opencog/atomspace/issues/261","number":261,"state":"open","locked":false,"title":"FC","user":{"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},"body":"Mainly\r\n\r\n- Added additional focus set parameter so cog-fc needs a third addtion argument which could be empty SetLink\r\n- Changed the logic inside do_chain and do_step - I need to completely decouple these two method on next PR.\r\n- Removed DefaultForwardChainer and ForwardChainerCallBack classes and moved code to ForwardChainer class.\r\n\r\n@eddiemonroe, @ngeiswei and @williampma please make review of these changes.","created_at":"2015-09-04T08:49:48Z","updated_at":"2015-09-08T18:52:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f16b97dc11e2752e2a0024dcfdcf2f6fc2bc9e3c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opencog/atomspace/pulls/261/commits","review_comments_url":"https://api.github.com/repos/opencog/atomspace/pulls/261/comments","review_comment_url":"https://api.github.com/repos/opencog/atomspace/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opencog/atomspace/issues/261/comments","statuses_url":"https://api.github.com/repos/opencog/atomspace/statuses/1404a2f27014c9b30a73ad354f5e1b1acce6ae83","head":{"label":"misgeatgit:FC","ref":"FC","sha":"1404a2f27014c9b30a73ad354f5e1b1acce6ae83","user":{"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},"repo":{"id":35009837,"name":"atomspace","full_name":"misgeatgit/atomspace","owner":{"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},"private":false,"html_url":"https://github.com/misgeatgit/atomspace","description":"The OpenCog hypergraph database and logic (reasoning) engine","fork":true,"url":"https://api.github.com/repos/misgeatgit/atomspace","forks_url":"https://api.github.com/repos/misgeatgit/atomspace/forks","keys_url":"https://api.github.com/repos/misgeatgit/atomspace/keys{/key_id}","collaborators_url":"https://api.github.com/repos/misgeatgit/atomspace/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/misgeatgit/atomspace/teams","hooks_url":"https://api.github.com/repos/misgeatgit/atomspace/hooks","issue_events_url":"https://api.github.com/repos/misgeatgit/atomspace/issues/events{/number}","events_url":"https://api.github.com/repos/misgeatgit/atomspace/events","assignees_url":"https://api.github.com/repos/misgeatgit/atomspace/assignees{/user}","branches_url":"https://api.github.com/repos/misgeatgit/atomspace/branches{/branch}","tags_url":"https://api.github.com/repos/misgeatgit/atomspace/tags","blobs_url":"https://api.github.com/repos/misgeatgit/atomspace/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/misgeatgit/atomspace/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/misgeatgit/atomspace/git/refs{/sha}","trees_url":"https://api.github.com/repos/misgeatgit/atomspace/git/trees{/sha}","statuses_url":"https://api.github.com/repos/misgeatgit/atomspace/statuses/{sha}","languages_url":"https://api.github.com/repos/misgeatgit/atomspace/languages","stargazers_url":"https://api.github.com/repos/misgeatgit/atomspace/stargazers","contributors_url":"https://api.github.com/repos/misgeatgit/atomspace/contributors","subscribers_url":"https://api.github.com/repos/misgeatgit/atomspace/subscribers","subscription_url":"https://api.github.com/repos/misgeatgit/atomspace/subscription","commits_url":"https://api.github.com/repos/misgeatgit/atomspace/commits{/sha}","git_commits_url":"https://api.github.com/repos/misgeatgit/atomspace/git/commits{/sha}","comments_url":"https://api.github.com/repos/misgeatgit/atomspace/comments{/number}","issue_comment_url":"https://api.github.com/repos/misgeatgit/atomspace/issues/comments{/number}","contents_url":"https://api.github.com/repos/misgeatgit/atomspace/contents/{+path}","compare_url":"https://api.github.com/repos/misgeatgit/atomspace/compare/{base}...{head}","merges_url":"https://api.github.com/repos/misgeatgit/atomspace/merges","archive_url":"https://api.github.com/repos/misgeatgit/atomspace/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/misgeatgit/atomspace/downloads","issues_url":"https://api.github.com/repos/misgeatgit/atomspace/issues{/number}","pulls_url":"https://api.github.com/repos/misgeatgit/atomspace/pulls{/number}","milestones_url":"https://api.github.com/repos/misgeatgit/atomspace/milestones{/number}","notifications_url":"https://api.github.com/repos/misgeatgit/atomspace/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/misgeatgit/atomspace/labels{/name}","releases_url":"https://api.github.com/repos/misgeatgit/atomspace/releases{/id}","created_at":"2015-05-04T02:26:26Z","updated_at":"2015-05-04T02:26:31Z","pushed_at":"2015-09-08T04:18:17Z","git_url":"git://github.com/misgeatgit/atomspace.git","ssh_url":"git@github.com:misgeatgit/atomspace.git","clone_url":"https://github.com/misgeatgit/atomspace.git","svn_url":"https://github.com/misgeatgit/atomspace","homepage":"","size":140571,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"opencog:master","ref":"master","sha":"3ae54c71237d13c45e7df2b19094d56207ff1157","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":34678084,"name":"atomspace","full_name":"opencog/atomspace","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/atomspace","description":"The OpenCog hypergraph database and logic (reasoning) engine","fork":false,"url":"https://api.github.com/repos/opencog/atomspace","forks_url":"https://api.github.com/repos/opencog/atomspace/forks","keys_url":"https://api.github.com/repos/opencog/atomspace/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opencog/atomspace/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opencog/atomspace/teams","hooks_url":"https://api.github.com/repos/opencog/atomspace/hooks","issue_events_url":"https://api.github.com/repos/opencog/atomspace/issues/events{/number}","events_url":"https://api.github.com/repos/opencog/atomspace/events","assignees_url":"https://api.github.com/repos/opencog/atomspace/assignees{/user}","branches_url":"https://api.github.com/repos/opencog/atomspace/branches{/branch}","tags_url":"https://api.github.com/repos/opencog/atomspace/tags","blobs_url":"https://api.github.com/repos/opencog/atomspace/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opencog/atomspace/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opencog/atomspace/git/refs{/sha}","trees_url":"https://api.github.com/repos/opencog/atomspace/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opencog/atomspace/statuses/{sha}","languages_url":"https://api.github.com/repos/opencog/atomspace/languages","stargazers_url":"https://api.github.com/repos/opencog/atomspace/stargazers","contributors_url":"https://api.github.com/repos/opencog/atomspace/contributors","subscribers_url":"https://api.github.com/repos/opencog/atomspace/subscribers","subscription_url":"https://api.github.com/repos/opencog/atomspace/subscription","commits_url":"https://api.github.com/repos/opencog/atomspace/commits{/sha}","git_commits_url":"https://api.github.com/repos/opencog/atomspace/git/commits{/sha}","comments_url":"https://api.github.com/repos/opencog/atomspace/comments{/number}","issue_comment_url":"https://api.github.com/repos/opencog/atomspace/issues/comments{/number}","contents_url":"https://api.github.com/repos/opencog/atomspace/contents/{+path}","compare_url":"https://api.github.com/repos/opencog/atomspace/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opencog/atomspace/merges","archive_url":"https://api.github.com/repos/opencog/atomspace/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opencog/atomspace/downloads","issues_url":"https://api.github.com/repos/opencog/atomspace/issues{/number}","pulls_url":"https://api.github.com/repos/opencog/atomspace/pulls{/number}","milestones_url":"https://api.github.com/repos/opencog/atomspace/milestones{/number}","notifications_url":"https://api.github.com/repos/opencog/atomspace/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opencog/atomspace/labels{/name}","releases_url":"https://api.github.com/repos/opencog/atomspace/releases{/id}","created_at":"2015-04-27T16:32:57Z","updated_at":"2015-08-31T14:49:03Z","pushed_at":"2015-09-08T04:18:18Z","git_url":"git://github.com/opencog/atomspace.git","ssh_url":"git@github.com:opencog/atomspace.git","clone_url":"https://github.com/opencog/atomspace.git","svn_url":"https://github.com/opencog/atomspace","homepage":"","size":150978,"stargazers_count":20,"watchers_count":20,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":29,"mirror_url":null,"open_issues_count":27,"forks":29,"open_issues":27,"watchers":20,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opencog/atomspace/pulls/261"},"html":{"href":"https://github.com/opencog/atomspace/pull/261"},"issue":{"href":"https://api.github.com/repos/opencog/atomspace/issues/261"},"comments":{"href":"https://api.github.com/repos/opencog/atomspace/issues/261/comments"},"review_comments":{"href":"https://api.github.com/repos/opencog/atomspace/pulls/261/comments"},"review_comment":{"href":"https://api.github.com/repos/opencog/atomspace/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opencog/atomspace/pulls/261/commits"},"statuses":{"href":"https://api.github.com/repos/opencog/atomspace/statuses/1404a2f27014c9b30a73ad354f5e1b1acce6ae83"}}}}