{"action":"created","comment":{"url":"https://api.github.com/repos/CodethinkLabs/scalam/pulls/comments/73348529","id":73348529,"diff_hunk":"@@ -281,44 +284,75 @@ void test_population_next_generation()\n     /* keep a copy of the before population, so that it can be compared later */\n     assert(population_copy(&after, &before) == 0);\n \n-    /* Assign some dummy scores to simulate what we have after evaluation */\n+    /* create a temporary file to store average scores within */\n+    strcpy(log_file, template_file);\n+    fd = mkstemp(log_file);\n+    printf(\"\\nFilename is: %s\\n\", log_file);\n+\n+    /* assign some initial scores */\n     for (i = 0; i < population_size; i++) {\n         assert(population_set_test_passes(&after, i,\n                                           rand_num(&random_seed) % 100) == 0);\n     }\n \n-    /* create a new generation */\n-    assert(population_next_generation(&after) == 0);\n+    /* itterate through a few generations */\n+    for (gen = 0; gen < 256; gen++) {\n+        printf(\".\");\n \n-    /* TODO compare before with after */\n+        /* create a new generation */\n+        assert(population_next_generation(&after) == 0);\n \n-    /* only one genome goes straight to the goal */\n-    ctr = 0;\n-    for (i = 0; i < after.size; i++) {\n-        if (after.individual[i]->steps == 0)\n-            ctr++;\n-    }\n-    if (ctr != 1) {\n-        printf(\"\\nctr = %d\\n\", ctr);\n+        /* Assign some dummy scores to simulate what we have after evaluation.\n+           This is completely contrived and so perhaps should be replaced with\n+           something better */\n+        for (i = 0; i < population_size; i++) {\n+            assert(population_set_test_passes(&after, i,\n+                                              rand_num(&random_seed) % 100) == 0);\n+        }\n+\n+        /* only one genome goes straight to the goal */\n+        ctr = 0;\n         for (i = 0; i < after.size; i++) {\n             if (after.individual[i]->steps == 0)\n-                printf(\"%d \", i);\n+                ctr++;\n         }\n-        printf(\"\\n\");\n-        population_free(&before);\n-        population_free(&after);\n-    }\n-    assert(ctr == 1);\n-\n-    /* all genomes are unique */\n-    for (i = 0; i < after.size-1; i++) {\n-        is_unique = genome_unique(&after, after.individual[i], i, 0);\n-        if (!is_unique) {\n+        if (ctr != 1) {\n+            printf(\"\\nctr = %d\\n\", ctr);\n+            for (i = 0; i < after.size; i++) {\n+                if (after.individual[i]->steps == 0)\n+                    printf(\"%d \", i);\n+            }\n+            printf(\"\\n\");\n             population_free(&before);\n             population_free(&after);\n-            assert(0);\n         }\n+        assert(ctr == 1);\n+\n+        /* all genomes are unique */\n+        for (i = 0; i < after.size-1; i++) {\n+            is_unique = genome_unique(&after, after.individual[i], i, 0);\n+            if (!is_unique) {\n+                population_free(&before);\n+                population_free(&after);\n+                assert(0);\n+            }\n+        }\n+\n+        /* log to csv file */\n+        sprintf(str, \"%f,\", population_average_score(&after));\n+        write(fd, str, strlen(str));\n     }\n+    close(fd);\n+\n+    /* TODO plot the csv file */\n+\n+\n+    sprintf(commandstr,\"cp %s /home/bashrc/develop/scalam/test.txt\", log_file);","path":"tests/population_tests.c","position":104,"original_position":104,"commit_id":"69438ec31145d98b9ff57fc34f4532fe7667f8aa","original_commit_id":"69438ec31145d98b9ff57fc34f4532fe7667f8aa","user":{"login":"leeming","id":608325,"avatar_url":"https://avatars.githubusercontent.com/u/608325?v=3","gravatar_id":"","url":"https://api.github.com/users/leeming","html_url":"https://github.com/leeming","followers_url":"https://api.github.com/users/leeming/followers","following_url":"https://api.github.com/users/leeming/following{/other_user}","gists_url":"https://api.github.com/users/leeming/gists{/gist_id}","starred_url":"https://api.github.com/users/leeming/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leeming/subscriptions","organizations_url":"https://api.github.com/users/leeming/orgs","repos_url":"https://api.github.com/users/leeming/repos","events_url":"https://api.github.com/users/leeming/events{/privacy}","received_events_url":"https://api.github.com/users/leeming/received_events","type":"User","site_admin":false},"body":"absolute filepath","created_at":"2016-08-03T14:30:40Z","updated_at":"2016-08-03T14:30:40Z","html_url":"https://github.com/CodethinkLabs/scalam/pull/12#discussion_r73348529","pull_request_url":"https://api.github.com/repos/CodethinkLabs/scalam/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/CodethinkLabs/scalam/pulls/comments/73348529"},"html":{"href":"https://github.com/CodethinkLabs/scalam/pull/12#discussion_r73348529"},"pull_request":{"href":"https://api.github.com/repos/CodethinkLabs/scalam/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/CodethinkLabs/scalam/pulls/12","id":79910869,"html_url":"https://github.com/CodethinkLabs/scalam/pull/12","diff_url":"https://github.com/CodethinkLabs/scalam/pull/12.diff","patch_url":"https://github.com/CodethinkLabs/scalam/pull/12.patch","issue_url":"https://api.github.com/repos/CodethinkLabs/scalam/issues/12","number":12,"state":"open","locked":false,"title":"Test over multiple generations","user":{"login":"bashrc","id":3055239,"avatar_url":"https://avatars.githubusercontent.com/u/3055239?v=3","gravatar_id":"","url":"https://api.github.com/users/bashrc","html_url":"https://github.com/bashrc","followers_url":"https://api.github.com/users/bashrc/followers","following_url":"https://api.github.com/users/bashrc/following{/other_user}","gists_url":"https://api.github.com/users/bashrc/gists{/gist_id}","starred_url":"https://api.github.com/users/bashrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bashrc/subscriptions","organizations_url":"https://api.github.com/users/bashrc/orgs","repos_url":"https://api.github.com/users/bashrc/repos","events_url":"https://api.github.com/users/bashrc/events{/privacy}","received_events_url":"https://api.github.com/users/bashrc/received_events","type":"User","site_admin":false},"body":"With TODO for plotting the graph","created_at":"2016-08-03T13:59:34Z","updated_at":"2016-08-03T14:30:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7bd6b343c6e84f96f76530e732840ff07920eec4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CodethinkLabs/scalam/pulls/12/commits","review_comments_url":"https://api.github.com/repos/CodethinkLabs/scalam/pulls/12/comments","review_comment_url":"https://api.github.com/repos/CodethinkLabs/scalam/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CodethinkLabs/scalam/issues/12/comments","statuses_url":"https://api.github.com/repos/CodethinkLabs/scalam/statuses/69438ec31145d98b9ff57fc34f4532fe7667f8aa","head":{"label":"bashrc:bashrc/generations-test","ref":"bashrc/generations-test","sha":"69438ec31145d98b9ff57fc34f4532fe7667f8aa","user":{"login":"bashrc","id":3055239,"avatar_url":"https://avatars.githubusercontent.com/u/3055239?v=3","gravatar_id":"","url":"https://api.github.com/users/bashrc","html_url":"https://github.com/bashrc","followers_url":"https://api.github.com/users/bashrc/followers","following_url":"https://api.github.com/users/bashrc/following{/other_user}","gists_url":"https://api.github.com/users/bashrc/gists{/gist_id}","starred_url":"https://api.github.com/users/bashrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bashrc/subscriptions","organizations_url":"https://api.github.com/users/bashrc/orgs","repos_url":"https://api.github.com/users/bashrc/repos","events_url":"https://api.github.com/users/bashrc/events{/privacy}","received_events_url":"https://api.github.com/users/bashrc/received_events","type":"User","site_admin":false},"repo":{"id":64656248,"name":"scalam","full_name":"bashrc/scalam","owner":{"login":"bashrc","id":3055239,"avatar_url":"https://avatars.githubusercontent.com/u/3055239?v=3","gravatar_id":"","url":"https://api.github.com/users/bashrc","html_url":"https://github.com/bashrc","followers_url":"https://api.github.com/users/bashrc/followers","following_url":"https://api.github.com/users/bashrc/following{/other_user}","gists_url":"https://api.github.com/users/bashrc/gists{/gist_id}","starred_url":"https://api.github.com/users/bashrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bashrc/subscriptions","organizations_url":"https://api.github.com/users/bashrc/orgs","repos_url":"https://api.github.com/users/bashrc/repos","events_url":"https://api.github.com/users/bashrc/events{/privacy}","received_events_url":"https://api.github.com/users/bashrc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bashrc/scalam","description":"Smart search for upgrade paths","fork":true,"url":"https://api.github.com/repos/bashrc/scalam","forks_url":"https://api.github.com/repos/bashrc/scalam/forks","keys_url":"https://api.github.com/repos/bashrc/scalam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bashrc/scalam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bashrc/scalam/teams","hooks_url":"https://api.github.com/repos/bashrc/scalam/hooks","issue_events_url":"https://api.github.com/repos/bashrc/scalam/issues/events{/number}","events_url":"https://api.github.com/repos/bashrc/scalam/events","assignees_url":"https://api.github.com/repos/bashrc/scalam/assignees{/user}","branches_url":"https://api.github.com/repos/bashrc/scalam/branches{/branch}","tags_url":"https://api.github.com/repos/bashrc/scalam/tags","blobs_url":"https://api.github.com/repos/bashrc/scalam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bashrc/scalam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bashrc/scalam/git/refs{/sha}","trees_url":"https://api.github.com/repos/bashrc/scalam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bashrc/scalam/statuses/{sha}","languages_url":"https://api.github.com/repos/bashrc/scalam/languages","stargazers_url":"https://api.github.com/repos/bashrc/scalam/stargazers","contributors_url":"https://api.github.com/repos/bashrc/scalam/contributors","subscribers_url":"https://api.github.com/repos/bashrc/scalam/subscribers","subscription_url":"https://api.github.com/repos/bashrc/scalam/subscription","commits_url":"https://api.github.com/repos/bashrc/scalam/commits{/sha}","git_commits_url":"https://api.github.com/repos/bashrc/scalam/git/commits{/sha}","comments_url":"https://api.github.com/repos/bashrc/scalam/comments{/number}","issue_comment_url":"https://api.github.com/repos/bashrc/scalam/issues/comments{/number}","contents_url":"https://api.github.com/repos/bashrc/scalam/contents/{+path}","compare_url":"https://api.github.com/repos/bashrc/scalam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bashrc/scalam/merges","archive_url":"https://api.github.com/repos/bashrc/scalam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bashrc/scalam/downloads","issues_url":"https://api.github.com/repos/bashrc/scalam/issues{/number}","pulls_url":"https://api.github.com/repos/bashrc/scalam/pulls{/number}","milestones_url":"https://api.github.com/repos/bashrc/scalam/milestones{/number}","notifications_url":"https://api.github.com/repos/bashrc/scalam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bashrc/scalam/labels{/name}","releases_url":"https://api.github.com/repos/bashrc/scalam/releases{/id}","deployments_url":"https://api.github.com/repos/bashrc/scalam/deployments","created_at":"2016-08-01T09:57:36Z","updated_at":"2016-08-01T09:57:38Z","pushed_at":"2016-08-03T13:58:13Z","git_url":"git://github.com/bashrc/scalam.git","ssh_url":"git@github.com:bashrc/scalam.git","clone_url":"https://github.com/bashrc/scalam.git","svn_url":"https://github.com/bashrc/scalam","homepage":null,"size":232,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"CodethinkLabs:master","ref":"master","sha":"79a24da8084882f3280ef8089c24cf6921909968","user":{"login":"CodethinkLabs","id":5488087,"avatar_url":"https://avatars.githubusercontent.com/u/5488087?v=3","gravatar_id":"","url":"https://api.github.com/users/CodethinkLabs","html_url":"https://github.com/CodethinkLabs","followers_url":"https://api.github.com/users/CodethinkLabs/followers","following_url":"https://api.github.com/users/CodethinkLabs/following{/other_user}","gists_url":"https://api.github.com/users/CodethinkLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/CodethinkLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CodethinkLabs/subscriptions","organizations_url":"https://api.github.com/users/CodethinkLabs/orgs","repos_url":"https://api.github.com/users/CodethinkLabs/repos","events_url":"https://api.github.com/users/CodethinkLabs/events{/privacy}","received_events_url":"https://api.github.com/users/CodethinkLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":63938977,"name":"scalam","full_name":"CodethinkLabs/scalam","owner":{"login":"CodethinkLabs","id":5488087,"avatar_url":"https://avatars.githubusercontent.com/u/5488087?v=3","gravatar_id":"","url":"https://api.github.com/users/CodethinkLabs","html_url":"https://github.com/CodethinkLabs","followers_url":"https://api.github.com/users/CodethinkLabs/followers","following_url":"https://api.github.com/users/CodethinkLabs/following{/other_user}","gists_url":"https://api.github.com/users/CodethinkLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/CodethinkLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CodethinkLabs/subscriptions","organizations_url":"https://api.github.com/users/CodethinkLabs/orgs","repos_url":"https://api.github.com/users/CodethinkLabs/repos","events_url":"https://api.github.com/users/CodethinkLabs/events{/privacy}","received_events_url":"https://api.github.com/users/CodethinkLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CodethinkLabs/scalam","description":"Smart search for upgrade paths","fork":false,"url":"https://api.github.com/repos/CodethinkLabs/scalam","forks_url":"https://api.github.com/repos/CodethinkLabs/scalam/forks","keys_url":"https://api.github.com/repos/CodethinkLabs/scalam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CodethinkLabs/scalam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CodethinkLabs/scalam/teams","hooks_url":"https://api.github.com/repos/CodethinkLabs/scalam/hooks","issue_events_url":"https://api.github.com/repos/CodethinkLabs/scalam/issues/events{/number}","events_url":"https://api.github.com/repos/CodethinkLabs/scalam/events","assignees_url":"https://api.github.com/repos/CodethinkLabs/scalam/assignees{/user}","branches_url":"https://api.github.com/repos/CodethinkLabs/scalam/branches{/branch}","tags_url":"https://api.github.com/repos/CodethinkLabs/scalam/tags","blobs_url":"https://api.github.com/repos/CodethinkLabs/scalam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CodethinkLabs/scalam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CodethinkLabs/scalam/git/refs{/sha}","trees_url":"https://api.github.com/repos/CodethinkLabs/scalam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CodethinkLabs/scalam/statuses/{sha}","languages_url":"https://api.github.com/repos/CodethinkLabs/scalam/languages","stargazers_url":"https://api.github.com/repos/CodethinkLabs/scalam/stargazers","contributors_url":"https://api.github.com/repos/CodethinkLabs/scalam/contributors","subscribers_url":"https://api.github.com/repos/CodethinkLabs/scalam/subscribers","subscription_url":"https://api.github.com/repos/CodethinkLabs/scalam/subscription","commits_url":"https://api.github.com/repos/CodethinkLabs/scalam/commits{/sha}","git_commits_url":"https://api.github.com/repos/CodethinkLabs/scalam/git/commits{/sha}","comments_url":"https://api.github.com/repos/CodethinkLabs/scalam/comments{/number}","issue_comment_url":"https://api.github.com/repos/CodethinkLabs/scalam/issues/comments{/number}","contents_url":"https://api.github.com/repos/CodethinkLabs/scalam/contents/{+path}","compare_url":"https://api.github.com/repos/CodethinkLabs/scalam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CodethinkLabs/scalam/merges","archive_url":"https://api.github.com/repos/CodethinkLabs/scalam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CodethinkLabs/scalam/downloads","issues_url":"https://api.github.com/repos/CodethinkLabs/scalam/issues{/number}","pulls_url":"https://api.github.com/repos/CodethinkLabs/scalam/pulls{/number}","milestones_url":"https://api.github.com/repos/CodethinkLabs/scalam/milestones{/number}","notifications_url":"https://api.github.com/repos/CodethinkLabs/scalam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CodethinkLabs/scalam/labels{/name}","releases_url":"https://api.github.com/repos/CodethinkLabs/scalam/releases{/id}","deployments_url":"https://api.github.com/repos/CodethinkLabs/scalam/deployments","created_at":"2016-07-22T08:54:12Z","updated_at":"2016-07-22T11:19:59Z","pushed_at":"2016-08-03T13:59:34Z","git_url":"git://github.com/CodethinkLabs/scalam.git","ssh_url":"git@github.com:CodethinkLabs/scalam.git","clone_url":"https://github.com/CodethinkLabs/scalam.git","svn_url":"https://github.com/CodethinkLabs/scalam","homepage":null,"size":235,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CodethinkLabs/scalam/pulls/12"},"html":{"href":"https://github.com/CodethinkLabs/scalam/pull/12"},"issue":{"href":"https://api.github.com/repos/CodethinkLabs/scalam/issues/12"},"comments":{"href":"https://api.github.com/repos/CodethinkLabs/scalam/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/CodethinkLabs/scalam/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/CodethinkLabs/scalam/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CodethinkLabs/scalam/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/CodethinkLabs/scalam/statuses/69438ec31145d98b9ff57fc34f4532fe7667f8aa"}}}}
{"actor":{"display_login":"leeming"}}