{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Simulation environment configuration\n", "\n", "Configuring the environment" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load_ext param.ipython\n", "from param.ipython import ParamPager\n", "import panel as pn" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Initialize the larvaworld registry. This loads some components from disc and builds the rest on the fly." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from larvaworld.lib import reg" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We will start with the *EnvConf* class which supports environment configurations\n", "\n", "Stored instances of the *EnvConf* class are available through the configuration registry.\n", "\n", "The registry is retrieved from a dictionary of registry objects by the *Env* key." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Env_reg = reg.conf.Env" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Each environment configuration is stored in the registry's dictionary under a unique ID.\n", "\n", "Let's print the IDs" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "EnvIDs = Env_reg.confIDs\n", "print(f\"The IDs of the stored environment configurations are :{EnvIDs}\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# The configuration IDs are the keys. They correspond to a nested dictionary :\n", "envID = EnvIDs[0]\n", "env_entry = Env_reg.getID(envID)\n", "print(f\"The environment configuration stored under ID {envID} is :\")\n", "env_entry.print()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "from larvaworld.lib.reg.generators import EnvConf\n", "\n", "%params EnvConf" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's generate a new instance" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "env_new = EnvConf()\n", "\n", "%params env_new" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "reg.conf.Trial.getID(\"default\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "larvaworld_venv_new", "language": "python", "name": "larvaworld_venv_new" }, "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.10.12" } }, "nbformat": 4, "nbformat_minor": 4 }