{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-06-12T13:17:35.276820Z",
     "start_time": "2024-06-12T13:17:26.933026700Z"
    }
   },
   "outputs": [],
   "source": [
    "import jax, jax.numpy as jnp\n",
    "\n",
    "from algorithm.neat import *\n",
    "from algorithm.neat.genome.advance import AdvanceInitialize\n",
    "from algorithm.neat.gene.node.default_without_response import NodeGeneWithoutResponse\n",
    "from utils.graph import topological_sort_python\n",
    "from tensorneat.utils import ACT, AGG\n",
    "\n",
    "genome = AdvanceInitialize(\n",
    "    num_inputs=16,\n",
    "    num_outputs=4,\n",
    "    hidden_cnt=8,\n",
    "    max_nodes=50,\n",
    "    max_conns=500,\n",
    "    node_gene=NodeGeneWithoutResponse(\n",
    "        # activation_default=ACT.tanh,\n",
    "        aggregation_default=AGG.sum,\n",
    "        # activation_options=(ACT.tanh,),\n",
    "        aggregation_options=(AGG.sum,),\n",
    "    )\n",
    ")\n",
    "\n",
    "state = genome.setup()\n",
    "\n",
    "randkey = jax.random.PRNGKey(42)\n",
    "nodes, conns = genome.initialize(state, randkey)\n",
    "\n",
    "network = genome.network_dict(state, nodes, conns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 640x480 with 1 Axes>",
      "image/png": "[encoded data, 195428 characters]"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "genome.visualize(network)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-06-12T13:17:41.982558700Z",
     "start_time": "2024-06-12T13:17:40.624699800Z"
    }
   },
   "id": "5e48b58bc6e6a486"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   },
   "id": "922647ca01533416"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
