{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Generated Recipes for evaluation"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.path.append(\"../\")\n",
"sys.path.append(\"../EvolutionaryAlgorithm/\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
" \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
" \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"../EvolutionaryAlgorithm/EvolutionaryAlgorithm.py:60: TqdmExperimentalWarning:\n",
"\n",
"Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)\n",
"\n"
]
}
],
"source": [
"import EvolutionaryAlgorithm as EA"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Noodle recipes\n",
"* generate noodle recipes with a population size of 50 over 50 cycles and choose randomly 5 from the 20 best"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3130e9bf5e3d4cbf943a1e55e7f54016",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "76a6bc19191343de8bd711236b147421",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Noodle Recipe 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * ricotta cheese\n",
" * butter\n",
" * salt\n",
" * chicken\n",
" * broccoli\n",
" * noodle\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | cut chicken, saute butter, broil salt and mix it with noodle. Then heat it. |\n",
"| 2 | cut broccoli and mix it with ricotta cheese and mix it together with the results of step 1. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "43d8bed61ec74e81b1357593d5adf427",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "46a7b359216c41e3b94831280b96f1c4",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Noodle Recipe 2"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * basil\n",
" * carrot\n",
" * ground beef\n",
" * tomato sauce\n",
" * sauce\n",
" * turkey\n",
" * cheese\n",
" * noodle\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | chop carrot and mix it with turkey, sauce, tomato sauce, noodle, basil and ground beef. Then cook it. |\n",
"| 2 | cook and bake cheese |\n",
"| 3 | Mix together the results of step 1 and step 2. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "38608bae11c14f41a9fc905ed1ced7f5",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "abd89963403d4a0f84a03c2f4665d529",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Noodle Recipe 3"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * garlic clove\n",
" * egg\n",
" * chicken broth\n",
" * onion\n",
" * tomato\n",
" * cream\n",
" * cheese\n",
" * noodle\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | peel garlic clove, grate onion and mix it with noodle, chicken broth, cheese and cream. Then heat it. |\n",
"| 2 | slice tomato, slice egg and mix it together with the results of step 1. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "596e572e066348c99dbc0124f8790b25",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2d5cac3819b141ae98e70a5d315e22e9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Noodle Recipe 4"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * mozzarella cheese\n",
" * water\n",
" * garlic clove\n",
" * ground beef\n",
" * egg\n",
" * onion\n",
" * milk\n",
" * soy sauce\n",
" * spaghetti sauce\n",
" * cheese\n",
" * broccoli\n",
" * noodle\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | slice garlic clove, dice onion and mix it with milk, soy sauce, ground beef, noodle, water and spaghetti sauce. Then bake it. |\n",
"| 2 | wash broccoli, crack egg and mix it with cheese and mozzarella cheese and mix it together with the results of step 1. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7746dd20b801414bba3adc1d8a5870b1",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d7e1511fbfed478a969d0a6d211ae60d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Noodle Recipe 5"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * ground beef\n",
" * onion\n",
" * milk\n",
" * olive oil\n",
" * cheese\n",
" * noodle\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | chop onion, place milk and mix it with olive oil, noodle and ground beef. Then bake it. |\n",
"| 2 | Mix cheese and mix it together with the results of step 1. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8ea12174e1ed480f9bf79f5bad38df3b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c77e6d00023647679f9d4139b0b3669f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Noodle Recipe 6"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * garlic\n",
" * pepper\n",
" * sauce\n",
" * tomato\n",
" * cream\n",
" * noodle\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | blend sauce, cook noodle and mix it with garlic and pepper. Then heat it. |\n",
"| 2 | warm and heat cream |\n",
"| 3 | grate tomato and mix it together with the results of step 1 and step 2. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2ec7b1dbaf434160b22abaf8dd04608b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "94ff28309e6e4e6ab0b51ca403a8f30f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Noodle Recipe 7"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * oregano\n",
" * basil\n",
" * mozzarella cheese\n",
" * water\n",
" * chicken broth\n",
" * red bell pepper\n",
" * chicken\n",
" * sauce\n",
" * cayenne pepper\n",
" * cheese\n",
" * noodle\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | cut red bell pepper, wash chicken and mix it with sauce, basil, chicken broth, cayenne pepper, oregano, noodle, water and mozzarella cheese. Then bake it. |\n",
"| 2 | Mix cheese and mix it together with the results of step 1. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3970031df6d04cee8856eee14c6118e5",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d7ec3eb268a34778a415eff7b5f80458",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Noodle Recipe 8"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * butter\n",
" * mozzarella cheese\n",
" * pea\n",
" * onion\n",
" * milk\n",
" * parsley\n",
" * sauce\n",
" * corn\n",
" * shrimp\n",
" * noodle\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | peel onion, peel shrimp and mix it with noodle, sauce, pea, mozzarella cheese, butter, milk, parsley and corn. Then bake it. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4ef27f0f13b54eeea1f7aa43ac79234d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "008b5788593e44b8ab8492cc0c745d3f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Noodle Recipe 9"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * zucchini\n",
" * red pepper\n",
" * water\n",
" * tomato sauce\n",
" * onion\n",
" * noodle\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | chop onion, chop zucchini and mix it with water, red pepper, tomato sauce and noodle. Then heat it. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fd689db9388141618604b2094906769a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0448e4f462384ca2b01ca6b8b891a76f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Noodle Recipe 10"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * green onion\n",
" * garlic\n",
" * water\n",
" * garlic clove\n",
" * ground beef\n",
" * salt\n",
" * cream\n",
" * noodle\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | bake cream, cut green onion, peel garlic clove and mix it with salt, garlic, water, noodle and ground beef. Then cook it. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"for i in range(10):\n",
"\n",
" p = EA.Population([\"noodle\",],['noodle'], min_additional=5, max_additional=11, n_population = 75, mutations=2)\n",
"\n",
" p.run(35)\n",
"\n",
" scores = [tree.score() for tree in p.population]\n",
"\n",
" ii = np.argsort(-np.array(scores))\n",
"\n",
" samples_i = EA.np.random.choice(ii[:1],1)\n",
"\n",
" samples = [p.population[i] for i in samples_i]\n",
"\n",
" for k, s in enumerate(samples):\n",
" display(EA.Markdown(f\"### Noodle Recipe {i+1}\"))\n",
" display(s.root().dot())\n",
" display(s.root().to_instruction().to_markdown())\n",
" with open(f\"noodle_{i}.md\", \"w\") as f:\n",
" f.write(s.root().to_instruction().to_markdown().data)\n",
" f.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Rice recipes\n",
"* generate noodle recipes with a population size of 50 over 50 cycles and choose randomly 5 from the 20 best"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b7aac32bdcd84c25af86e9003b7b09b6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d95d9f1b43e7480aa5f25badb200c065",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Rice Recipe 1"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * vegetable oil\n",
" * green onion\n",
" * ginger\n",
" * rice\n",
" * butter\n",
" * vegetable broth\n",
" * chicken broth\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | cut green onion, chop ginger and mix it with rice, butter, chicken broth, vegetable broth and vegetable oil. Then cook it. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "73d9539a3162463fbad736504777b526",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "731fa0aa2d244c9da21ccb00a7faad07",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Rice Recipe 2"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * cabbage\n",
" * rice\n",
" * green onion\n",
" * water\n",
" * pea\n",
" * egg\n",
" * chicken broth\n",
" * salt\n",
" * chicken soup\n",
" * tomato\n",
" * mushroom soup\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | Mix pea, mushroom soup, rice, chicken broth, salt and water. Then simmer it. |\n",
"| 2 | cut green onion and mix it with chicken soup. Then heat it. |\n",
"| 3 | cut cabbage, mash egg, cut tomato and mix it together with the results of step 1 and step 2. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "184a9ad86c56426ebfb2c5aad3fc30fe",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2c131cc9bf2544508182b118ee0638a2",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Rice Recipe 3"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * rice\n",
" * water\n",
" * celery\n",
" * chicken soup\n",
" * onion\n",
" * chicken\n",
" * soy sauce\n",
" * olive oil\n",
" * paprika\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | dice onion, cut chicken, dice celery and mix it with water, rice, soy sauce, paprika and olive oil. Then simmer it. |\n",
"| 2 | cook chicken soup and mix it together with the results of step 1. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d3a658352d19468b8bc8bad761de3bab",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "44e9385b8f1e4a5886ac05171106931e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Rice Recipe 4"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * green onion\n",
" * rice\n",
" * ground black pepper\n",
" * vinegar\n",
" * celery\n",
" * garlic clove\n",
" * tomato soup\n",
" * olive oil\n",
" * chicken stock\n",
" * tomato\n",
" * parsley\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | chop garlic clove, chop green onion, slice celery, brush tomato and mix it with chicken stock, parsley, vinegar, olive oil, rice, ground black pepper and tomato soup. Then heat it. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2d2a008b308e46c7ac1cdcb15eb683a9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2bf2b7ce8426490a9c3b2c787d9d9954",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Rice Recipe 5"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * rice\n",
" * clove garlic\n",
" * egg\n",
" * chicken broth\n",
" * saffron\n",
" * parsley\n",
" * sausage\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | beat and cut egg |\n",
"| 2 | slice clove garlic and mix it with sausage, saffron, chicken broth, parsley and rice. Then boil it. |\n",
"| 3 | Mix together the results of step 1 and step 2. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0db21948c69549faacba6c72bf10e4af",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "926747e94e434c74b9d685cf09cffa77",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Rice Recipe 6"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * rice\n",
" * carrot\n",
" * chicken broth\n",
" * onion\n",
" * saffron\n",
" * sausage\n",
" * kosher salt\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | chop and saute onion |\n",
"| 2 | slice carrot and mix it with kosher salt, rice, chicken broth, saffron and sausage and mix it together with the results of step 1. Then heat it. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "da108b0e8328436880442164a3ee8093",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2d50a77146154da7924154790f7fc1d8",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Rice Recipe 7"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * rice\n",
" * vegetable broth\n",
" * celery\n",
" * garlic clove\n",
" * water\n",
" * tomato\n",
" * saffron\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | chop celery, cut tomato, chop garlic clove and mix it with saffron, rice, vegetable broth and water. Then heat it. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fa8076cf2ace462d84050db33b11e9dd",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b7a0f57e78af418287dd9cc81db90e3b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/markdown": [
"### Rice Recipe 8"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * vegetable oil\n",
" * rice\n",
" * ground beef\n",
" * carrot\n",
" * onion\n",
" * soy sauce\n",
" * mushroom soup\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | grate carrot, peel onion and mix it with vegetable oil, mushroom soup, rice, ground beef and soy sauce. Then heat it. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fbc941a2a8464c799263119832250f04",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "cb6cd4db7a8045a58a69565b2feda5e5",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Warning: cannot find matching action node for mutation\n",
"\n"
]
},
{
"data": {
"text/markdown": [
"### Rice Recipe 9"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * green pepper\n",
" * rice\n",
" * green pea\n",
" * chicken broth\n",
" * salt\n",
" * onion\n",
" * parsley\n",
" * chicken breast\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | slice onion, chop chicken breast, chop parsley, chop green pepper and mix it with green pea, rice, chicken broth and salt. Then heat it. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "28960ce1e8b1446983eed4f3f64f2971",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='build initial population', max=75.0, style=ProgressStyle(…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "37f8c72c2c4a4893ab76bc69dd9b7fd5",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='run evolutionary cycles', max=35.0, style=ProgressStyle(d…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Warning: cannot mutate given node\n",
"\n"
]
},
{
"data": {
"text/markdown": [
"### Rice Recipe 10"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * garlic salt\n",
" * vegetable oil\n",
" * rice\n",
" * chicken broth\n",
" * onion\n",
" * tomato\n",
" * parsley\n",
" * sausage\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | cut onion, dice tomato and mix it with parsley, sausage, rice, garlic salt, vegetable oil and chicken broth. Then heat it. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"for i in range(10):\n",
"\n",
" p = EA.Population([\"rice\"],['rice'], min_additional=6, max_additional=11, n_population = 75, mutations=2)\n",
"\n",
" p.run(35)\n",
"\n",
" scores = [tree.score() for tree in p.population]\n",
"\n",
" ii = np.argsort(-np.array(scores))\n",
"\n",
" samples_i = EA.np.random.choice(ii[:1],1)\n",
"\n",
" samples = [p.population[i] for i in samples_i]\n",
"\n",
" for k, s in enumerate(samples):\n",
" display(EA.Markdown(f\"### Rice Recipe {i+1}\"))\n",
" display(s.root().dot())\n",
" display(s.root().to_instruction().to_markdown())\n",
" with open(f\"rice_{i}.md\", \"w\") as f:\n",
" f.write(s.root().to_instruction().to_markdown().data)\n",
" f.close()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(array(['heat', 'boil', 'cool', 'cook', 'bake', 'place', 'simmer', 'pour',\n",
" 'warm', 'refrigerate', 'drain', 'brown', 'chill', 'cut', 'blend',\n",
" 'beat', 'whisk', 'thicken', 'rinse', 'freeze', 'slice', 'soak',\n",
" 'spread', 'knead', 'fry', 'melt', 'whip', 'steam', 'grill', 'peel',\n",
" 'chop', 'break', 'brush', 'wash', 'open', 'burn', 'saute', 'steep',\n",
" 'skim', 'squeeze', 'wipe', 'mash', 'marinate', 'broil', 'thaw',\n",
" 'sour', 'crack', 'dice', 'grind', 'baste', 'mince', 'grate'],\n",
" dtype='