Bardo.Models (Bardo v0.1.0)

View Source

Models for evolutionary computation data structures.

This module provides functions for creating and manipulating the various data structures used in the Bardo system. It includes model definitions for experiments, populations, species, and other components of the evolutionary computation framework.

Summary

Functions

Create an actuator model.

Create an agent model.

Create a champion model.

Create a cortex model.

Delete a model from storage.

Check if a model exists in storage.

Create an experiment model.

Create a fitness model.

Create a genotype model.

Get a value from a nested map using a path of keys.

List all models of a given type.

Create a morphology model.

Create a neuron model.

Create a population model.

Create a population status model.

Read a model from storage by ID and type.

Create a result model.

Create a scape model.

Create a sensor model.

Set a value or values in a model.

Create a specie model.

Create a stat model.

Create a substrate model.

Create a topology summary model.

Create a trace model.

Write a model to storage.

Functions

actuator(data)

@spec actuator(map()) :: map()

Create an actuator model.

Takes a map with actuator configuration and returns a model that can be stored in the database.

agent(data)

@spec agent(map()) :: map()

Create an agent model.

Takes a map with agent configuration and returns a model that can be stored in the database.

champion(data)

@spec champion(map()) :: map()

Create a champion model.

Takes a map with champion data and returns a model that can be stored in the database.

cortex(data)

@spec cortex(map()) :: map()

Create a cortex model.

Takes a map with cortex configuration and returns a model that can be stored in the database.

delete(id, type)

@spec delete(atom() | binary(), atom()) :: :ok | {:error, term()}

Delete a model from storage.

Parameters

  • id - The ID of the model to delete
  • type - The type of the model (e.g. :experiment, :population, etc.)

Returns

  • :ok - If the model was deleted successfully
  • {:error, reason} - If there was an error deleting the model

exists?(id, type)

@spec exists?(atom() | binary(), atom()) :: boolean()

Check if a model exists in storage.

Parameters

  • id - The ID of the model to check
  • type - The type of the model (e.g. :experiment, :population, etc.)

Returns

  • true - If the model exists
  • false - If the model does not exist

experiment(data)

@spec experiment(map()) :: map()

Create an experiment model.

Takes a map with experiment configuration and returns a model that can be stored in the database.

fitness(data)

@spec fitness(map()) :: map()

Create a fitness model.

Takes a map with fitness data and returns a model that can be stored in the database.

genotype(data)

@spec genotype(map()) :: map()

Create a genotype model.

Takes a map with genotype configuration and returns a model that can be stored in the database.

get(map, path, default \\ :not_found)

@spec get(map(), atom() | [atom()], any()) :: any()

Get a value from a nested map using a path of keys.

Parameters

  • map - The map to get the value from
  • path - A key or list of keys to traverse
  • default - Optional default value if the path is not found

Returns

  • The value at the path, or the default value if not found

Examples

# Simple key access
iex> Models.get(%{a: 1}, :a)
1

# Nested map access
iex> Models.get(%{a: %{b: 2}}, [:a, :b])
2

# Access with default
iex> Models.get(%{a: 1}, :b, :not_found)
:not_found

list(type)

@spec list(atom()) :: [map()]

List all models of a given type.

Parameters

  • type - The type of models to list

Returns

  • [models] - List of models, or empty list if none found

morphology(data)

@spec morphology(map()) :: map()

Create a morphology model.

Takes a map with morphology configuration and returns a model that can be stored in the database.

neuron(data)

@spec neuron(map()) :: map()

Create a neuron model.

Takes a map with neuron configuration and returns a model that can be stored in the database.

population(data)

@spec population(map()) :: map()

Create a population model.

Takes a map with population configuration and returns a model that can be stored in the database.

population_status(data)

@spec population_status(map()) :: map()

Create a population status model.

read(id, type)

@spec read(atom() | binary(), atom()) :: {:ok, map()} | {:error, term()}

Read a model from storage by ID and type.

Parameters

  • id - The ID of the model to read
  • type - The type of the model (e.g. :experiment, :population, etc.)

Returns

  • {:ok, model} - If the model was found
  • {:error, reason} - If the model was not found or there was an error

result(data)

@spec result(map()) :: map()

Create a result model.

Takes a map with result data and returns a model that can be stored in the database.

scape(data)

@spec scape(map()) :: map()

Create a scape model.

Takes a map with scape configuration and returns a model that can be stored in the database.

sensor(data)

@spec sensor(map()) :: map()

Create a sensor model.

Takes a map with sensor configuration and returns a model that can be stored in the database.

set(key_value, model)

@spec set({atom(), any()} | [{atom(), any()}], map()) :: map()

Set a value or values in a model.

Parameters

  • key_value - A tuple {key, value} or a list of tuples to set
  • model - The model to update

Returns

  • The updated model with the new values

Examples

# Set a single value
iex> set({:a, 2}, %{data: %{a: 1}})
%{data: %{a: 2}}

# Set multiple values
iex> set([{:a, 2}, {:b, 3}], %{data: %{a: 1}})
%{data: %{a: 2, b: 3}}

specie(data)

@spec specie(map()) :: map()

Create a specie model.

stat(data)

@spec stat(map()) :: map()

Create a stat model.

Takes a map with statistics data and returns a model that can be stored in the database.

substrate(data)

@spec substrate(map()) :: map()

Create a substrate model.

Takes a map with substrate configuration and returns a model that can be stored in the database.

topology_summary(data)

@spec topology_summary(map()) :: map()

Create a topology summary model.

Takes a map with topology data and returns a model that can be stored in the database.

trace(data)

@spec trace(map()) :: map()

Create a trace model.

Takes a map with trace data and returns a model that can be stored in the database.

write(model, type, id)

@spec write(map(), atom(), atom() | binary()) :: :ok | {:error, term()}

Write a model to storage.

Parameters

  • model - The model to write
  • type - The type of the model
  • id - The ID of the model

Returns

  • :ok - If the model was written successfully
  • {:error, reason} - If there was an error writing the model