-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
452 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,263 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "cf8d4bbc-9fe2-43b8-945d-403e6f91b190", | ||
"metadata": {}, | ||
"source": [ | ||
"This notebook is part of [**Byron v0.8**](https://pypi.org/project/byron/) \n", | ||
"Copyright 2023 Giovanni Squillero and Alberto Tonda \n", | ||
"SPDX-License-Identifier: [Apache-2.0](https://opensource.org/license/apache-2-0/) " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "3bb17efa-7918-4bfe-a5dd-d4a6bcf08165", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2023-09-07T21:23:15.766070Z", | ||
"start_time": "2023-09-07T21:23:15.760095Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from pprint import pprint\n", | ||
"import logging" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "43a1401d-bf66-4725-83cf-5907f9407928", | ||
"metadata": {}, | ||
"source": [ | ||
"# Onemax in Go" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "52ad6183-c167-4768-b57c-e91244e29584", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2023-09-07T21:23:16.946969Z", | ||
"start_time": "2023-09-07T21:23:15.767477Z" | ||
} | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/var/folders/31/dkl97hks2c14b663vl55pt440000gn/T/ipykernel_23482/1429530752.py:1: ByronPerformanceWarning: \n", | ||
" Paranoia checks are enabled in this notebook: performances can be significantly impaired\n", | ||
" [see https://github.com/cad-polito-it/byron/blob/alpha/docs/paranoia.md for details]\n", | ||
" import byron\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import byron" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"outputs": [], | ||
"source": [ | ||
"import golang\n", | ||
"\n", | ||
"top_frame = golang.framework()" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2023-09-07T21:23:16.994590Z", | ||
"start_time": "2023-09-07T21:23:16.944536Z" | ||
} | ||
}, | ||
"id": "f1cdfbb3ff40b342" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"outputs": [], | ||
"source": [ | ||
"@byron.fitness_function\n", | ||
"def dummy_fitness(text):\n", | ||
" return 1 / len(text)" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2023-09-07T21:23:17.014319Z", | ||
"start_time": "2023-09-07T21:23:16.991071Z" | ||
} | ||
}, | ||
"id": "936c134dc57395a7" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "70a6fb4c-9caf-4675-9e55-eb8a792aea1a", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2023-09-07T21:23:17.020873Z", | ||
"start_time": "2023-09-07T21:23:16.991832Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"evaluator = byron.evaluator.PythonEvaluator(dummy_fitness)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"INFO ▷ VanillaEA: 🍦 [b]VanillaEA started[/] ┈ ⌛ 0:00:00.00 [t] / ⏱️ 0:00:00.00 [byron]\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢1/random_individual() is 0.0049505Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢2/random_individual() is 0.00184162Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢3/random_individual() is 0.00196078Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢4/random_individual() is 0.00155763Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢6/random_individual() is 0.00171821Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢7/random_individual() is 0.00395257Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢8/random_individual() is 0.00219298Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢10/random_individual() is 0.00409836Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢11/random_individual() is 0.00371747Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢13/random_individual() is 0.00369004Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢14/random_individual() is 0.00221729Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢15/random_individual() is 0.00454545Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢16/random_individual() is 0.00244499Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢17/random_individual() is 0.00255102Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢18/random_individual() is 0.00223214Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢19/random_individual() is 0.00289855Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢22/random_individual() is 0.00309598Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢24/random_individual() is 0.0010661Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢27/random_individual() is 0.00367647Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢29/random_individual() is 0.003861Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢32/random_individual() is 0.0018797Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢33/random_individual() is 0.00137174Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢34/random_individual() is 0.00154799Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢35/random_individual() is 0.00179533Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢36/random_individual() is 0.00414938Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢37/random_individual() is 0.00180505Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢38/random_individual() is 0.0035461Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢39/random_individual() is 0.00107875Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢40/random_individual() is 0.00150376Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢41/random_individual() is 0.00172414Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢44/random_individual() is 0.00423729Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢45/random_individual() is 0.00126103Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢46/random_individual() is 0.00144092Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢47/random_individual() is 0.00258398Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢48/random_individual() is 0.00200803Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢49/random_individual() is 0.00230947Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢50/random_individual() is 0.00161031Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢51/random_individual() is 0.00423729Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢52/random_individual() is 0.00185529Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢54/random_individual() is 0.00178571Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢55/random_individual() is 0.00181818Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢56/random_individual() is 0.00212314Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢57/random_individual() is 0.00214133Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢58/random_individual() is 0.00440529Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢59/random_individual() is 0.00147493Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢60/random_individual() is 0.00299401Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢64/random_individual() is 0.00302115Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢65/random_individual() is 0.00229358Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢66/random_individual() is 0.00136612Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢67/random_individual() is 0.00363636Ƒ\n", | ||
"INFO ▷ VanillaEA: 🍀 𝐢1 ⇨ fitness: 0.0049505Ƒ / ⚝ 0\n", | ||
"INFO ▷ VanillaEA: End of initialization ┈ ⌛ 0:00:00.61 [t] / 🏃 0:00:00.01\n", | ||
"DEBUG ▷ generic_node_crossover: n870/Macro❬Text#1❭ <-> n590/Macro❬Text#1❭\n", | ||
"DEBUG ▷ generic_node_crossover: n986/Macro❬Text#1❭ <-> n995/Macro❬Text#1❭\n", | ||
"DEBUG ▷ generic_node_crossover: Failed (invalid structure)\n", | ||
"DEBUG ▷ generic_node_crossover: n120/Frame❬FrameSequence#1❭ <-> n540/Frame❬FrameSequence#1❭\n", | ||
"DEBUG ▷ generic_node_crossover: n1056/Frame❬FrameSequence#1❭ <-> n375/Frame❬FrameSequence#1❭\n", | ||
"DEBUG ▷ generic_node_crossover: n106/Macro❬User#2❭ <-> n570/Macro❬User#2❭\n", | ||
"DEBUG ▷ generic_node_crossover: Failed (invalid structure)\n", | ||
"DEBUG ▷ generic_node_crossover: n220/Macro❰prologue❱ <-> n643/Macro❰prologue❱\n", | ||
"DEBUG ▷ is_valid: Failed check on n1543: functools.partial(<function _check_instances_number at 0x12dca2e80>, max_instances=1)\n", | ||
"DEBUG ▷ generic_node_crossover: Failed (invalid individual)\n", | ||
"DEBUG ▷ generic_node_crossover: n1129/Macro❬Text#1❭ <-> n712/Macro❬Text#1❭\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢68/add_macro_to_bunch(𝐢67) is 0.003367Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢70/remove_macro_from_bunch(𝐢11) is 0.00403226Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢71/node_crossover_choosy(𝐢45, 𝐢33) is 0.00116144Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢72/single_parameter_mutation(𝐢6) is 0.00162866Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢74/single_parameter_mutation(𝐢58) is 0.00440529Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢75/leaf_crossover_unfussy(𝐢7, 𝐢32) is 0.00176678Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢76/leaf_crossover_unfussy(𝐢55, 𝐢24) is 0.00101937Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢78/single_parameter_mutation(𝐢44) is 0.00404858Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢79/add_macro_to_bunch(𝐢11) is 0.00325733Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢80/single_parameter_mutation(𝐢44) is 0.00401606Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢82/add_macro_to_bunch(𝐢60) is 0.00280899Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢84/add_macro_to_bunch(𝐢19) is 0.0025641Ƒ\n", | ||
"DEBUG ▷ Individual: Fitness of 𝐢85/node_crossover_unfussy(𝐢59, 𝐢39) is 0.00143885Ƒ\n", | ||
"INFO ▷ VanillaEA: End of generation 1 (𝐻: 6.3888) ┈ ⌛ 0:00:00.95 [t] / 🏃 0:00:00.01\n", | ||
"INFO ▷ VanillaEA: 🍦 [b]VanillaEA completed[/] ┈ ⌛ 0:00:00.95 [t] / ⏱️ 0:00:00.95 [byron]\n", | ||
"INFO ▷ VanillaEA: 🏆 𝐢1 ⇨ fitness: 0.0049505Ƒ / ⚝ 0 / random_individual()\n" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"text/plain": "<byron.classes.population.Population at 0x10f486a90>" | ||
}, | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"byron.ea.vanilla_ea(\n", | ||
" top_frame, evaluator, max_generation=1, mu=50, lambda_=20, max_fitness=64.0\n", | ||
" )" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2023-09-07T21:23:17.959181Z", | ||
"start_time": "2023-09-07T21:23:16.997064Z" | ||
} | ||
}, | ||
"id": "b5294736a8ac382a" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"outputs": [], | ||
"source": [], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2023-09-07T21:23:17.959508Z", | ||
"start_time": "2023-09-07T21:23:17.956804Z" | ||
} | ||
}, | ||
"id": "101801adf0d0415b" | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.