larvaworld.lib.model.modules.module_modes ========================================= .. py:module:: larvaworld.lib.model.modules.module_modes Attributes ---------- .. autoapisummary:: larvaworld.lib.model.modules.module_modes.moduleDB Classes ------- .. autoapisummary:: larvaworld.lib.model.modules.module_modes.BrainModule larvaworld.lib.model.modules.module_modes.BrainModuleDB larvaworld.lib.model.modules.module_modes.LarvaModuleDB larvaworld.lib.model.modules.module_modes.SpaceDict Module Contents --------------- .. py:class:: BrainModule(**kwargs: Any) Bases: :py:obj:`larvaworld.lib.param.NestedConf` .. py:attribute:: ModeShortNames .. py:attribute:: mID .. py:attribute:: color .. py:attribute:: dict .. py:attribute:: excluded .. py:attribute:: default_dict .. py:property:: parent_class .. py:property:: modes .. py:property:: short_modes .. py:method:: get_class(mode: str) .. py:method:: build_module(conf: Any, **kwargs: Any) .. py:method:: module_conf(mode: str | None = None, include_mode: bool = True, **kwargs: Any) .. py:method:: module_objects(mode: str | None = None, excluded: list[Any] | None = None) .. py:method:: module_pars(**kwargs: Any) .. py:method:: as_entry(d: larvaworld.lib.util.AttrDict) .. py:class:: BrainModuleDB(**kwargs: Any) Bases: :py:obj:`larvaworld.lib.param.NestedConf` .. py:attribute:: BrainModuleModes .. py:attribute:: BrainModuleColors .. py:attribute:: LocoModsBasic .. py:attribute:: LocoMods .. py:attribute:: SensorMods .. py:attribute:: BrainMods .. py:attribute:: brainDB .. py:method:: mod_modes(k: str, short: bool = False) .. py:method:: build_module(mID: str | None = None, conf: Any | None = None, **kwargs: Any) .. py:method:: build_modules(mIDs: list[str], conf: larvaworld.lib.util.AttrDict, **kwargs: Any) .. py:method:: build_locomodules(conf: larvaworld.lib.util.AttrDict, **kwargs: Any) .. py:method:: build_sensormodules(conf: larvaworld.lib.util.AttrDict, **kwargs: Any) .. py:method:: module_conf(mID: str | None = None, mode: str | None = None, as_entry: bool = True, **kwargs: Any) .. py:method:: module_objects(mID: str | None = None, mode: str | None = None, as_entry: bool = True, **kwargs: Any) .. py:method:: modules_objects(mIDs: list[str], conf: larvaworld.lib.util.AttrDict, as_entry: bool = True, **kwargs: Any) .. py:method:: module_pars(**kwargs: Any) .. py:method:: modules_pars(**kwargs: Any) .. py:method:: brainConf(ms: larvaworld.lib.util.AttrDict = AttrDict(), mkws: larvaworld.lib.util.AttrDict = AttrDict()) .. py:method:: mcolor(k: str) .. py:method:: mod_combs(ks: larvaworld.lib.util.SuperList, short: bool = False, to_return: str = 'yield') .. py:method:: parent_class(k: str) .. py:method:: get_memory_class(mode: str, modality: str) .. py:method:: memory_kws(mode: str = 'RL', modality: str = 'olfaction', as_entry: bool = True, **kwargs: Any) .. py:method:: build_memory_module(conf: larvaworld.lib.util.AttrDict, **kwargs: Any) .. py:method:: detect_brainconf_modes(m: larvaworld.lib.util.AttrDict) .. py:class:: LarvaModuleDB(**kwargs: Any) Bases: :py:obj:`BrainModuleDB` .. py:attribute:: LarvaModuleColors .. py:attribute:: ModuleColorDict .. py:attribute:: LarvaModsBasic .. py:attribute:: LarvaModsOptional .. py:attribute:: LarvaMods .. py:attribute:: AllModules .. py:attribute:: LarvaModsConfDict .. py:attribute:: LarvaModsDefaultDict .. py:method:: sensorimotor_kws(**kwargs: Any) .. py:method:: energetics_kws(gut_kws: larvaworld.lib.util.AttrDict = AttrDict(), DEB_kws: larvaworld.lib.util.AttrDict = AttrDict()) .. py:method:: body_kws(**kwargs: Any) .. py:method:: physics_kws(**kwargs: Any) .. py:method:: Box2D_kws(**kwargs: Any) .. py:method:: larvaConf(ms: larvaworld.lib.util.AttrDict = AttrDict(), mkws: larvaworld.lib.util.AttrDict = AttrDict()) .. py:data:: moduleDB .. py:class:: SpaceDict(**kwargs) Bases: :py:obj:`larvaworld.lib.param.NestedConf` .. py:attribute:: base_model .. py:attribute:: space_mkeys .. py:attribute:: Pmutation .. py:attribute:: Cmutation .. py:attribute:: init_mode .. py:attribute:: mConf0 .. py:attribute:: space_objs .. py:attribute:: space_ks .. py:attribute:: parclasses .. py:method:: build() .. py:method:: obj_attr(k, flat=True) .. py:method:: obj_min_max_value(p) .. py:property:: defaults .. py:method:: parclass(p) .. py:method:: randomize() -> larvaworld.lib.util.AttrDict Randomizes the values of the parameters in the model based on their types. This method iterates over the parameters defined in `self.space_ks` and assigns new random values to them based on their respective classes (`self.parclasses`). The new values are chosen according to the following rules: - If the parameter class is "Selector", a random object from `obj.objects` is chosen. - If the parameter class is "Boolean", a random boolean value (True or False) is chosen. - If the parameter class is "Dict", the parameter is skipped. - If the parameter class is "Range", two random values within the bounds are chosen and clipped. - If the parameter class is "Integer", a random integer within the bounds is chosen and clipped. - For other parameter classes, a random float within the bounds is chosen and clipped. The bounds for the random values are determined by `obj.bounds` or `self.obj_min_max_value(p)`. Returns: None .. py:method:: mutate(g: larvaworld.lib.util.AttrDict) -> larvaworld.lib.util.AttrDict Mutates the given genome `g` based on predefined mutation probabilities and rules. Args: g (dict): The genome to be mutated. It is a dictionary where keys are parameter names and values are their corresponding values. Returns: dict: The mutated genome. Mutation Rules: - For parameters classified as "Selector", a random choice from the available objects is selected. - For parameters classified as "Boolean", a random boolean value is selected. - For parameters classified as "Dict", no mutation is performed. - For other parameters: - If the parameter has a defined step, the mutation range is calculated as step * 5. - If the parameter has defined bounds, the mutation range is calculated as half the difference between the bounds. - The mutation is applied using a Gaussian distribution with the calculated standard deviation. - For "Range" parameters, each bound is mutated separately and clipped to the original bounds. - For "Integer" parameters, the mutated value is converted to an integer and cropped to the original bounds. - For other types, the mutated value is cropped to the original bounds. .. py:method:: create_first_generation(N)