{"action":"created","comment":{"url":"https://api.github.com/repos/PolyJIT/benchbuild/pulls/comments/201303873","pull_request_review_id":135776454,"id":201303873,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTMwMzg3Mw==","diff_hunk":"@@ -0,0 +1,210 @@\n+# !/usr/bin/env python\n+\"\"\"This module represents an optimized variant of the module genetic2.py.\n+\n+It uses the multiprocessing module instead of the threading module to take\n+advantage of systems with multiple cores.\n+\"\"\"\n+import random\n+import multiprocessing\n+\n+import benchbuild.experiments.sequences.polly_stats as polly_stats\n+\n+\n+__author__ = \"Christoph Woller\"\n+__credits__ = [\"Christoph Woller\"]\n+__maintainer__ = \"Christoph Woller\"\n+__email__ = \"wollerch@fim.uni-passau.de\"\n+\n+# Default values for the population of chromosomes\n+MIN_POPULATION_SIZE = 10\n+DEFAULT_CHROMOSOME_SIZE = 20\n+DEFAULT_POPULATION_SIZE = 50\n+DEFAULT_GENE_POOL = ['-basicaa', '-mem2reg']\n+DEFAULT_GENERATIONS = 50\n+\n+# Should the program print debug information?\n+print_out = False\n+\n+\n+def simulate_generations(gene_pool, environment, gen=DEFAULT_GENERATIONS):\n+    \"\"\"Simulates a certain number of generations.\n+\n+    Args:\n+        gene_pool (list[string]): list of available genes.\n+        environment (string): the environment for which the fitness should be\n+            calculated.\n+        gen (int, optional): the number of generations to simulate.\n+\n+    Returns:\n+        Chromosome: the fittest chromosome of the last generation for the\n+            specified environment.\n+    \"\"\"\n+    seq_to_fitness = multiprocessing.Manager().dict()\n+    chromosomes = []\n+    fittest_chromosome = []\n+\n+    for i in range(DEFAULT_POPULATION_SIZE):\n+        chromosomes.append(generate_random_gene_sequence(gene_pool))\n+\n+    for i in range(gen):\n+        chromosomes, fittest_chromosome = simulate_generation(chromosomes,\n+                                                              gene_pool,\n+                                                              environment,\n+                                                              seq_to_fitness)\n+\n+        if i < gen - 1:\n+            chromosomes = delete_duplicates(chromosomes, gene_pool)\n+\n+    return fittest_chromosome\n+\n+\n+def simulate_generation(chromosomes, gene_pool, environment, seq_to_fitness):\n+    \"\"\"Simulates a single generation change of the population.\"\"\"\n+    # 1. calculate fitness value of each chromosome.\n+    pool = multiprocessing.Pool()\n+\n+    for chromosome in chromosomes:\n+        pool.apply_async(calculate_fitness_value, args=(\n+            chromosome, seq_to_fitness, str(chromosome), environment))\n+\n+    pool.close()\n+    pool.join()\n+\n+    # 2. sort the chromosomes by its fitness value and reverse the list,\n+    # because the chromosome with the lowest fitness value is the best.\n+    chromosomes.sort(key=lambda c: seq_to_fitness[str(c)])\n+    chromosomes = chromosomes[::-1]\n+\n+    # 3. best 10% of chromosomes survive without change.\n+    num_best = len(chromosomes) // 10\n+    fittest_chromosome = chromosomes.pop()\n+    best_chromosomes = [fittest_chromosome]\n+    for i in range(num_best - 1):\n+        best_chromosomes.append(chromosomes.pop())\n+\n+    # 4. crossover: fill the vacancies in the population with new\n+    # chromosomes. The genes of the new chromosomes are mixtures of the\n+    # genes of two randomly chosen strong chromosomes.\n+    new_chromosomes = []\n+    num_of_new = DEFAULT_POPULATION_SIZE - len(best_chromosomes)\n+    half_index = len(fittest_chromosome) // 2\n+\n+    while len(new_chromosomes) < num_of_new:\n+        c1 = random.choice(best_chromosomes)\n+        c2 = random.choice(best_chromosomes)","path":"benchbuild/experiments/sequences/genetic2_opt.py","position":94,"original_position":94,"commit_id":"861410375f57bc430ea96f3662050da0e87c7dc0","original_commit_id":"861410375f57bc430ea96f3662050da0e87c7dc0","user":{"login":"codacy-bot","id":19940114,"node_id":"MDQ6VXNlcjE5OTQwMTE0","avatar_url":"https://avatars1.githubusercontent.com/u/19940114?v=4","gravatar_id":"","url":"https://api.github.com/users/codacy-bot","html_url":"https://github.com/codacy-bot","followers_url":"https://api.github.com/users/codacy-bot/followers","following_url":"https://api.github.com/users/codacy-bot/following{/other_user}","gists_url":"https://api.github.com/users/codacy-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/codacy-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codacy-bot/subscriptions","organizations_url":"https://api.github.com/users/codacy-bot/orgs","repos_url":"https://api.github.com/users/codacy-bot/repos","events_url":"https://api.github.com/users/codacy-bot/events{/privacy}","received_events_url":"https://api.github.com/users/codacy-bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://app.codacy.com/assets/images/favicon.png) Issue found: [Standard pseudo-random generators are not suitable for security/cryptographic purposes.](https://app.codacy.com/app/polyjit/benchbuild_2/pullRequest?prid=1882779)","created_at":"2018-07-10T11:13:03Z","updated_at":"2018-07-10T11:13:03Z","html_url":"https://github.com/PolyJIT/benchbuild/pull/195#discussion_r201303873","pull_request_url":"https://api.github.com/repos/PolyJIT/benchbuild/pulls/195","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/PolyJIT/benchbuild/pulls/comments/201303873"},"html":{"href":"https://github.com/PolyJIT/benchbuild/pull/195#discussion_r201303873"},"pull_request":{"href":"https://api.github.com/repos/PolyJIT/benchbuild/pulls/195"}}},"pull_request":{"url":"https://api.github.com/repos/PolyJIT/benchbuild/pulls/195","id":200360605,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwMzYwNjA1","html_url":"https://github.com/PolyJIT/benchbuild/pull/195","diff_url":"https://github.com/PolyJIT/benchbuild/pull/195.diff","patch_url":"https://github.com/PolyJIT/benchbuild/pull/195.patch","issue_url":"https://api.github.com/repos/PolyJIT/benchbuild/issues/195","number":195,"state":"closed","locked":false,"title":"Revert \"experiments: remove all polyjit related experiments\"","user":{"login":"simbuerg","id":598281,"node_id":"MDQ6VXNlcjU5ODI4MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/598281?v=4","gravatar_id":"","url":"https://api.github.com/users/simbuerg","html_url":"https://github.com/simbuerg","followers_url":"https://api.github.com/users/simbuerg/followers","following_url":"https://api.github.com/users/simbuerg/following{/other_user}","gists_url":"https://api.github.com/users/simbuerg/gists{/gist_id}","starred_url":"https://api.github.com/users/simbuerg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simbuerg/subscriptions","organizations_url":"https://api.github.com/users/simbuerg/orgs","repos_url":"https://api.github.com/users/simbuerg/repos","events_url":"https://api.github.com/users/simbuerg/events{/privacy}","received_events_url":"https://api.github.com/users/simbuerg/received_events","type":"User","site_admin":false},"body":"Reverts PolyJIT/benchbuild#194","created_at":"2018-07-10T11:10:46Z","updated_at":"2018-07-10T11:13:03Z","closed_at":"2018-07-10T11:12:44Z","merged_at":"2018-07-10T11:12:44Z","merge_commit_sha":"113b8f7581ddcc97ce7371d5f2e1c7c24d8d6909","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/PolyJIT/benchbuild/pulls/195/commits","review_comments_url":"https://api.github.com/repos/PolyJIT/benchbuild/pulls/195/comments","review_comment_url":"https://api.github.com/repos/PolyJIT/benchbuild/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PolyJIT/benchbuild/issues/195/comments","statuses_url":"https://api.github.com/repos/PolyJIT/benchbuild/statuses/861410375f57bc430ea96f3662050da0e87c7dc0","head":{"label":"PolyJIT:revert-194-f/split-polyjit.experiments","ref":"revert-194-f/split-polyjit.experiments","sha":"861410375f57bc430ea96f3662050da0e87c7dc0","user":{"login":"PolyJIT","id":19994531,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTk0NTMx","avatar_url":"https://avatars0.githubusercontent.com/u/19994531?v=4","gravatar_id":"","url":"https://api.github.com/users/PolyJIT","html_url":"https://github.com/PolyJIT","followers_url":"https://api.github.com/users/PolyJIT/followers","following_url":"https://api.github.com/users/PolyJIT/following{/other_user}","gists_url":"https://api.github.com/users/PolyJIT/gists{/gist_id}","starred_url":"https://api.github.com/users/PolyJIT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PolyJIT/subscriptions","organizations_url":"https://api.github.com/users/PolyJIT/orgs","repos_url":"https://api.github.com/users/PolyJIT/repos","events_url":"https://api.github.com/users/PolyJIT/events{/privacy}","received_events_url":"https://api.github.com/users/PolyJIT/received_events","type":"Organization","site_admin":false},"repo":{"id":13425606,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQyNTYwNg==","name":"benchbuild","full_name":"PolyJIT/benchbuild","owner":{"login":"PolyJIT","id":19994531,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTk0NTMx","avatar_url":"https://avatars0.githubusercontent.com/u/19994531?v=4","gravatar_id":"","url":"https://api.github.com/users/PolyJIT","html_url":"https://github.com/PolyJIT","followers_url":"https://api.github.com/users/PolyJIT/followers","following_url":"https://api.github.com/users/PolyJIT/following{/other_user}","gists_url":"https://api.github.com/users/PolyJIT/gists{/gist_id}","starred_url":"https://api.github.com/users/PolyJIT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PolyJIT/subscriptions","organizations_url":"https://api.github.com/users/PolyJIT/orgs","repos_url":"https://api.github.com/users/PolyJIT/repos","events_url":"https://api.github.com/users/PolyJIT/events{/privacy}","received_events_url":"https://api.github.com/users/PolyJIT/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PolyJIT/benchbuild","description":"Empirical-Research Toolkit","fork":false,"url":"https://api.github.com/repos/PolyJIT/benchbuild","forks_url":"https://api.github.com/repos/PolyJIT/benchbuild/forks","keys_url":"https://api.github.com/repos/PolyJIT/benchbuild/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PolyJIT/benchbuild/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PolyJIT/benchbuild/teams","hooks_url":"https://api.github.com/repos/PolyJIT/benchbuild/hooks","issue_events_url":"https://api.github.com/repos/PolyJIT/benchbuild/issues/events{/number}","events_url":"https://api.github.com/repos/PolyJIT/benchbuild/events","assignees_url":"https://api.github.com/repos/PolyJIT/benchbuild/assignees{/user}","branches_url":"https://api.github.com/repos/PolyJIT/benchbuild/branches{/branch}","tags_url":"https://api.github.com/repos/PolyJIT/benchbuild/tags","blobs_url":"https://api.github.com/repos/PolyJIT/benchbuild/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PolyJIT/benchbuild/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PolyJIT/benchbuild/git/refs{/sha}","trees_url":"https://api.github.com/repos/PolyJIT/benchbuild/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PolyJIT/benchbuild/statuses/{sha}","languages_url":"https://api.github.com/repos/PolyJIT/benchbuild/languages","stargazers_url":"https://api.github.com/repos/PolyJIT/benchbuild/stargazers","contributors_url":"https://api.github.com/repos/PolyJIT/benchbuild/contributors","subscribers_url":"https://api.github.com/repos/PolyJIT/benchbuild/subscribers","subscription_url":"https://api.github.com/repos/PolyJIT/benchbuild/subscription","commits_url":"https://api.github.com/repos/PolyJIT/benchbuild/commits{/sha}","git_commits_url":"https://api.github.com/repos/PolyJIT/benchbuild/git/commits{/sha}","comments_url":"https://api.github.com/repos/PolyJIT/benchbuild/comments{/number}","issue_comment_url":"https://api.github.com/repos/PolyJIT/benchbuild/issues/comments{/number}","contents_url":"https://api.github.com/repos/PolyJIT/benchbuild/contents/{+path}","compare_url":"https://api.github.com/repos/PolyJIT/benchbuild/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PolyJIT/benchbuild/merges","archive_url":"https://api.github.com/repos/PolyJIT/benchbuild/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PolyJIT/benchbuild/downloads","issues_url":"https://api.github.com/repos/PolyJIT/benchbuild/issues{/number}","pulls_url":"https://api.github.com/repos/PolyJIT/benchbuild/pulls{/number}","milestones_url":"https://api.github.com/repos/PolyJIT/benchbuild/milestones{/number}","notifications_url":"https://api.github.com/repos/PolyJIT/benchbuild/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PolyJIT/benchbuild/labels{/name}","releases_url":"https://api.github.com/repos/PolyJIT/benchbuild/releases{/id}","deployments_url":"https://api.github.com/repos/PolyJIT/benchbuild/deployments","created_at":"2013-10-08T21:07:28Z","updated_at":"2018-07-10T11:12:46Z","pushed_at":"2018-07-10T11:12:50Z","git_url":"git://github.com/PolyJIT/benchbuild.git","ssh_url":"git@github.com:PolyJIT/benchbuild.git","clone_url":"https://github.com/PolyJIT/benchbuild.git","svn_url":"https://github.com/PolyJIT/benchbuild","homepage":"","size":181378,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":5,"open_issues":32,"watchers":2,"default_branch":"master"}},"base":{"label":"PolyJIT:master","ref":"master","sha":"973218c5c3ab6d796380e67971ee347577619bf8","user":{"login":"PolyJIT","id":19994531,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTk0NTMx","avatar_url":"https://avatars0.githubusercontent.com/u/19994531?v=4","gravatar_id":"","url":"https://api.github.com/users/PolyJIT","html_url":"https://github.com/PolyJIT","followers_url":"https://api.github.com/users/PolyJIT/followers","following_url":"https://api.github.com/users/PolyJIT/following{/other_user}","gists_url":"https://api.github.com/users/PolyJIT/gists{/gist_id}","starred_url":"https://api.github.com/users/PolyJIT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PolyJIT/subscriptions","organizations_url":"https://api.github.com/users/PolyJIT/orgs","repos_url":"https://api.github.com/users/PolyJIT/repos","events_url":"https://api.github.com/users/PolyJIT/events{/privacy}","received_events_url":"https://api.github.com/users/PolyJIT/received_events","type":"Organization","site_admin":false},"repo":{"id":13425606,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQyNTYwNg==","name":"benchbuild","full_name":"PolyJIT/benchbuild","owner":{"login":"PolyJIT","id":19994531,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTk0NTMx","avatar_url":"https://avatars0.githubusercontent.com/u/19994531?v=4","gravatar_id":"","url":"https://api.github.com/users/PolyJIT","html_url":"https://github.com/PolyJIT","followers_url":"https://api.github.com/users/PolyJIT/followers","following_url":"https://api.github.com/users/PolyJIT/following{/other_user}","gists_url":"https://api.github.com/users/PolyJIT/gists{/gist_id}","starred_url":"https://api.github.com/users/PolyJIT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PolyJIT/subscriptions","organizations_url":"https://api.github.com/users/PolyJIT/orgs","repos_url":"https://api.github.com/users/PolyJIT/repos","events_url":"https://api.github.com/users/PolyJIT/events{/privacy}","received_events_url":"https://api.github.com/users/PolyJIT/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PolyJIT/benchbuild","description":"Empirical-Research Toolkit","fork":false,"url":"https://api.github.com/repos/PolyJIT/benchbuild","forks_url":"https://api.github.com/repos/PolyJIT/benchbuild/forks","keys_url":"https://api.github.com/repos/PolyJIT/benchbuild/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PolyJIT/benchbuild/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PolyJIT/benchbuild/teams","hooks_url":"https://api.github.com/repos/PolyJIT/benchbuild/hooks","issue_events_url":"https://api.github.com/repos/PolyJIT/benchbuild/issues/events{/number}","events_url":"https://api.github.com/repos/PolyJIT/benchbuild/events","assignees_url":"https://api.github.com/repos/PolyJIT/benchbuild/assignees{/user}","branches_url":"https://api.github.com/repos/PolyJIT/benchbuild/branches{/branch}","tags_url":"https://api.github.com/repos/PolyJIT/benchbuild/tags","blobs_url":"https://api.github.com/repos/PolyJIT/benchbuild/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PolyJIT/benchbuild/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PolyJIT/benchbuild/git/refs{/sha}","trees_url":"https://api.github.com/repos/PolyJIT/benchbuild/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PolyJIT/benchbuild/statuses/{sha}","languages_url":"https://api.github.com/repos/PolyJIT/benchbuild/languages","stargazers_url":"https://api.github.com/repos/PolyJIT/benchbuild/stargazers","contributors_url":"https://api.github.com/repos/PolyJIT/benchbuild/contributors","subscribers_url":"https://api.github.com/repos/PolyJIT/benchbuild/subscribers","subscription_url":"https://api.github.com/repos/PolyJIT/benchbuild/subscription","commits_url":"https://api.github.com/repos/PolyJIT/benchbuild/commits{/sha}","git_commits_url":"https://api.github.com/repos/PolyJIT/benchbuild/git/commits{/sha}","comments_url":"https://api.github.com/repos/PolyJIT/benchbuild/comments{/number}","issue_comment_url":"https://api.github.com/repos/PolyJIT/benchbuild/issues/comments{/number}","contents_url":"https://api.github.com/repos/PolyJIT/benchbuild/contents/{+path}","compare_url":"https://api.github.com/repos/PolyJIT/benchbuild/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PolyJIT/benchbuild/merges","archive_url":"https://api.github.com/repos/PolyJIT/benchbuild/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PolyJIT/benchbuild/downloads","issues_url":"https://api.github.com/repos/PolyJIT/benchbuild/issues{/number}","pulls_url":"https://api.github.com/repos/PolyJIT/benchbuild/pulls{/number}","milestones_url":"https://api.github.com/repos/PolyJIT/benchbuild/milestones{/number}","notifications_url":"https://api.github.com/repos/PolyJIT/benchbuild/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PolyJIT/benchbuild/labels{/name}","releases_url":"https://api.github.com/repos/PolyJIT/benchbuild/releases{/id}","deployments_url":"https://api.github.com/repos/PolyJIT/benchbuild/deployments","created_at":"2013-10-08T21:07:28Z","updated_at":"2018-07-10T11:12:46Z","pushed_at":"2018-07-10T11:12:50Z","git_url":"git://github.com/PolyJIT/benchbuild.git","ssh_url":"git@github.com:PolyJIT/benchbuild.git","clone_url":"https://github.com/PolyJIT/benchbuild.git","svn_url":"https://github.com/PolyJIT/benchbuild","homepage":"","size":181378,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":5,"open_issues":32,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PolyJIT/benchbuild/pulls/195"},"html":{"href":"https://github.com/PolyJIT/benchbuild/pull/195"},"issue":{"href":"https://api.github.com/repos/PolyJIT/benchbuild/issues/195"},"comments":{"href":"https://api.github.com/repos/PolyJIT/benchbuild/issues/195/comments"},"review_comments":{"href":"https://api.github.com/repos/PolyJIT/benchbuild/pulls/195/comments"},"review_comment":{"href":"https://api.github.com/repos/PolyJIT/benchbuild/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PolyJIT/benchbuild/pulls/195/commits"},"statuses":{"href":"https://api.github.com/repos/PolyJIT/benchbuild/statuses/861410375f57bc430ea96f3662050da0e87c7dc0"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"codacy-bot"}}