Skip to content

Commit

Permalink
Refactor FunctionsData class and update hierarchy module imports and …
Browse files Browse the repository at this point in the history
…move examples to 51_pcthierarchy_examples
  • Loading branch information
perceptualrobots committed Dec 20, 2024
1 parent c560dff commit e1b4f2d
Show file tree
Hide file tree
Showing 7 changed files with 1,405 additions and 1,471 deletions.
43 changes: 43 additions & 0 deletions nbs/01_putils.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,49 @@
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#| export\n",
"class FunctionsData():\n",
" \"Data collected for a set of functions\"\n",
" def __init__(self):\n",
" self.data = {}\n",
" \n",
" def add_data(self, func):\n",
" name = func.get_name()\n",
" if name in self.data.keys():\n",
" self.data[name].append(func.get_value())\n",
" else:\n",
" dlist=[]\n",
" self.data[name]=dlist\n",
" self.data[name].append(func.get_value())\n",
" \n",
" def add_reward(self, func):\n",
" name = 'reward'\n",
" if name in self.data.keys():\n",
" self.data[name].append(func.get_reward())\n",
" else:\n",
" dlist=[]\n",
" self.data[name]=dlist\n",
" self.data[name].append(func.get_reward())\n",
" \n",
" def add_fitness(self, func):\n",
" name = 'fitness'\n",
" if name in self.data.keys():\n",
" self.data[name].append(func.get_fitness())\n",
" else:\n",
" dlist=[]\n",
" self.data[name]=dlist\n",
" self.data[name].append(func.get_fitness())\n",
"\n",
" def add_list(self, key, list):\n",
" self.data[key]= list"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Loading

0 comments on commit e1b4f2d

Please sign in to comment.