larvaworld.lib.model.modules.module_modes
Attributes
Classes
Module Contents
- class larvaworld.lib.model.modules.module_modes.BrainModule(**kwargs: Any)
Bases:
larvaworld.lib.param.NestedConf- ModeShortNames
- mID
- color
- dict
- excluded
- default_dict
- property parent_class
- property modes
- property short_modes
- get_class(mode: str)
- build_module(conf: Any, **kwargs: Any)
- module_conf(mode: str | None = None, include_mode: bool = True, **kwargs: Any)
- module_objects(mode: str | None = None, excluded: list[Any] | None = None)
- module_pars(**kwargs: Any)
- as_entry(d: larvaworld.lib.util.AttrDict)
- class larvaworld.lib.model.modules.module_modes.BrainModuleDB(**kwargs: Any)
Bases:
larvaworld.lib.param.NestedConf- BrainModuleModes
- BrainModuleColors
- LocoModsBasic
- LocoMods
- SensorMods
- BrainMods
- brainDB
- mod_modes(k: str, short: bool = False)
- build_module(mID: str | None = None, conf: Any | None = None, **kwargs: Any)
- build_modules(mIDs: list[str], conf: larvaworld.lib.util.AttrDict, **kwargs: Any)
- build_locomodules(conf: larvaworld.lib.util.AttrDict, **kwargs: Any)
- build_sensormodules(conf: larvaworld.lib.util.AttrDict, **kwargs: Any)
- module_conf(mID: str | None = None, mode: str | None = None, as_entry: bool = True, **kwargs: Any)
- module_objects(mID: str | None = None, mode: str | None = None, as_entry: bool = True, **kwargs: Any)
- modules_objects(mIDs: list[str], conf: larvaworld.lib.util.AttrDict, as_entry: bool = True, **kwargs: Any)
- module_pars(**kwargs: Any)
- modules_pars(**kwargs: Any)
- brainConf(ms: larvaworld.lib.util.AttrDict = AttrDict(), mkws: larvaworld.lib.util.AttrDict = AttrDict())
- mcolor(k: str)
- mod_combs(ks: larvaworld.lib.util.SuperList, short: bool = False, to_return: str = 'yield')
- parent_class(k: str)
- get_memory_class(mode: str, modality: str)
- memory_kws(mode: str = 'RL', modality: str = 'olfaction', as_entry: bool = True, **kwargs: Any)
- build_memory_module(conf: larvaworld.lib.util.AttrDict, **kwargs: Any)
- detect_brainconf_modes(m: larvaworld.lib.util.AttrDict)
- class larvaworld.lib.model.modules.module_modes.LarvaModuleDB(**kwargs: Any)
Bases:
BrainModuleDB- LarvaModuleColors
- ModuleColorDict
- LarvaModsBasic
- LarvaModsOptional
- LarvaMods
- AllModules
- LarvaModsConfDict
- LarvaModsDefaultDict
- sensorimotor_kws(**kwargs: Any)
- energetics_kws(gut_kws: larvaworld.lib.util.AttrDict = AttrDict(), DEB_kws: larvaworld.lib.util.AttrDict = AttrDict())
- body_kws(**kwargs: Any)
- physics_kws(**kwargs: Any)
- Box2D_kws(**kwargs: Any)
- larvaConf(ms: larvaworld.lib.util.AttrDict = AttrDict(), mkws: larvaworld.lib.util.AttrDict = AttrDict())
- larvaworld.lib.model.modules.module_modes.moduleDB
- class larvaworld.lib.model.modules.module_modes.SpaceDict(**kwargs)
Bases:
larvaworld.lib.param.NestedConf- base_model
- space_mkeys
- Pmutation
- Cmutation
- init_mode
- mConf0
- space_objs
- space_ks
- parclasses
- build()
- obj_attr(k, flat=True)
- obj_min_max_value(p)
- property defaults
- parclass(p)
- 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
- 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.
- create_first_generation(N)