Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
596220a
Create l_system_decoding.py
omoulin Sep 25, 2025
729e441
Update l_system_decoding.py
omoulin Sep 25, 2025
b57d60d
Update l_system_decoding.py
omoulin Sep 26, 2025
1452dab
Update l_system_decoding.py
omoulin Sep 26, 2025
dc85b69
Update l_system_decoding.py
omoulin Sep 26, 2025
a88310d
Update l_system_decoding.py
omoulin Sep 26, 2025
1931e80
Update l_system_decoding.py
omoulin Sep 26, 2025
50290fa
Merge branch 'ci-group:main' into main
omoulin Sep 26, 2025
1f4685d
Create l_system_genetic_utils.py
omoulin Sep 27, 2025
dbef957
Merge branch 'main' of https://github.com/DavidePasero/ariel
omoulin Sep 27, 2025
7a4db65
Merge branch 'ci-group:main' into main
omoulin Sep 27, 2025
07a2fe5
updated l-system decoder and mutation
omoulin Sep 30, 2025
c5085c8
Merge branch 'ci-group:main' into main
DavidePasero Oct 1, 2025
840d381
Added basic tree genome + conversion to digraph
DavidePasero Oct 1, 2025
b55ffdd
tree node refinement
Oct 1, 2025
8367cf0
tree node refinement
Oct 1, 2025
632464f
Added crossover for trees and helper methods
DavidePasero Oct 1, 2025
81414f4
fix the IDs copy pls
Oct 1, 2025
3b3cd9d
Added tree decoder to NetworkX graph, fixed replacement of node bug, …
DavidePasero Oct 1, 2025
12248c8
Merge pull request #1 from DavidePasero/feature/tree_genome
Coluding Oct 1, 2025
1d78642
Revert "Added basic tree genome + conversion to digraph"
Coluding Oct 2, 2025
bd05aa1
Merge pull request #2 from DavidePasero/revert-1-feature/tree_genome
Coluding Oct 2, 2025
da2f606
new tree generators added, mutator WIP
Oct 2, 2025
7f2c589
Added integer mutator, added random treenode creation, fixed some typ…
DavidePasero Oct 2, 2025
97f5531
updated mutation, not finished
Oct 4, 2025
df368f0
mutation completed ... far more complex than before :)
Oct 4, 2025
dc23abd
fixed some bugs
omoulin Oct 7, 2025
025e17f
Finalized tree genotype implementation + test cases: tree_genome.py, …
DavidePasero Oct 9, 2025
a9250c3
Modified TreeGenerator
DavidePasero Oct 9, 2025
105796d
Modified TreeMutator
DavidePasero Oct 9, 2025
20367bf
Modified TreeCrossover
DavidePasero Oct 9, 2025
a1cfdb7
Create l_system_crossover.py
omoulin Oct 10, 2025
0a53c13
update
omoulin Oct 13, 2025
100b019
updated
omoulin Oct 15, 2025
b7739e6
updated
Oct 21, 2025
9a3ca3a
New l-system genotype
omoulin Oct 23, 2025
3f2fac5
new l-system
omoulin Oct 23, 2025
f96c611
New l-system with EC functions
omoulin Oct 24, 2025
b919749
updated l-system fully functional
omoulin Oct 25, 2025
436c0ac
added a more granular lsystem crossover (genes level and not rules le…
omoulin Oct 25, 2025
6dd4eb8
added morphological descriptor and example script for tree genome
Oct 27, 2025
0818e2d
Untested evolution script
DavidePasero Oct 28, 2025
bf88ec7
Created EA for a generic genome
DavidePasero Oct 29, 2025
83ddbe7
Adding an upper class for Evoluationary Computing
omoulin Oct 30, 2025
d097661
Update l_system_genotype.py
omoulin Oct 30, 2025
d393e22
Evolution now works for a generic genotype
DavidePasero Oct 30, 2025
82b3d35
First main merge
DavidePasero Nov 3, 2025
65df189
Merged Lsystem within new ec logic
DavidePasero Nov 4, 2025
c0086b9
Merged and code refactored
DavidePasero Nov 4, 2025
022bdc1
Refactored circular import
DavidePasero Nov 4, 2025
26aa86d
Create individual for lsystem as well
DavidePasero Nov 5, 2025
e4284ae
Better config, better merged code
DavidePasero Nov 5, 2025
6cbb72e
Lsystem finally integrated
DavidePasero Nov 5, 2025
cafdff4
added dashboard
Nov 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ cython_debug/
### VSCODE ######################################################################
.vscode
.vscode/*
.idea/*
.idea
.idea*
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
Expand Down Expand Up @@ -263,3 +266,6 @@ RECYCLE.BIN/
*.msp
# Windows shortcuts
*.lnk


CLAUDE.md
615 changes: 0 additions & 615 deletions docs/source/ea_intro/ea_example.ipynb

This file was deleted.

Binary file modified examples/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/0_render_single_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def main() -> None:
data = mujoco.MjData(model)

# Render a single frame
single_frame_renderer(model, data, steps=10_000)
single_frame_renderer(model, data, steps=10_000, save=True)


if __name__ == "__main__":
Expand Down
Empty file added examples/__init__.py
Empty file.
133 changes: 133 additions & 0 deletions examples/_display_robot_from_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
"""TODO(jmdm): description of script.

Author: jmdm
Date: 2025-06-25
Py Ver: 3.12
OS: macOS Sequoia 15.3.1
Hardware: M4 Pro
Status: Completed ✅
"""

# Standard library
from pathlib import Path
from typing import TYPE_CHECKING, Any

# Third-party libraries
import mujoco
import numpy as np
from mujoco import viewer
from rich.console import Console

# Local libraries
from ariel.body_phenotypes.robogen_lite.config import (
NUM_OF_FACES,
NUM_OF_ROTATIONS,
NUM_OF_TYPES_OF_MODULES,
)
from ariel.body_phenotypes.robogen_lite.constructor import (
construct_mjspec_from_graph,
)
from ariel.body_phenotypes.robogen_lite.decoders.l_system_genotype import (
load_graph_from_json,
)


from ariel.body_phenotypes.robogen_lite.modules.core import CoreModule
from ariel.simulation.environments import SimpleFlatWorld
from ariel.utils.renderers import single_frame_renderer

if TYPE_CHECKING:
from networkx import DiGraph


# Global constants
SCRIPT_NAME = __file__.split("/")[-1][:-3]
CWD = Path.cwd()
DATA = Path(CWD / "__data__" / SCRIPT_NAME)
DATA.mkdir(exist_ok=True)
SEED = 40

# Global functions
console = Console()
RNG = np.random.default_rng(SEED)


def main() -> None:
"""Entry point."""

graph_parent1 = load_graph_from_json("parent1.json")
graph_parent2 = load_graph_from_json("parent2.json")
graph_parent1_mutated = load_graph_from_json("parent1-mutated.json")
graph_parent2_mutated = load_graph_from_json("parent2-mutated.json")
graph_offspring1 = load_graph_from_json("offspring1.json")
graph_offspring2 = load_graph_from_json("offspring2.json")
graph_offspring3 = load_graph_from_json("offspring3.json")
graph_offspring4 = load_graph_from_json("offspring4.json")

# Construct the robot from the graph
core_parent1 = construct_mjspec_from_graph(graph_parent1)
core_parent2 = construct_mjspec_from_graph(graph_parent2)
core_parent1_mutated = construct_mjspec_from_graph(graph_parent1_mutated)
core_parent2_mutated = construct_mjspec_from_graph(graph_parent2_mutated)
core_offspring1 = construct_mjspec_from_graph(graph_offspring1)
core_offspring2 = construct_mjspec_from_graph(graph_offspring2)
core_offspring3 = construct_mjspec_from_graph(graph_offspring3)
core_offspring4 = construct_mjspec_from_graph(graph_offspring4)
# Simulate the robot
run(core_parent1, with_viewer=True)
run(core_parent2, with_viewer=True)
run(core_parent1_mutated, with_viewer=True)
run(core_parent2_mutated, with_viewer=True)
run(core_offspring1, with_viewer=True)
run(core_offspring2, with_viewer=True)
run(core_offspring3, with_viewer=True)
run(core_offspring4, with_viewer=True)

def run(
robot: CoreModule,
*,
with_viewer: bool = False,
) -> None:
"""Entry point."""
# MuJoCo configuration
viz_options = mujoco.MjvOption() # visualization of various elements

# Visualization of the corresponding model or decoration element
viz_options.flags[mujoco.mjtVisFlag.mjVIS_TRANSPARENT] = True
viz_options.flags[mujoco.mjtVisFlag.mjVIS_ACTUATOR] = True
viz_options.flags[mujoco.mjtVisFlag.mjVIS_BODYBVH] = True

# MuJoCo basics
world = SimpleFlatWorld()

# Set random colors for geoms
for i in range(len(robot.spec.geoms)):
robot.spec.geoms[i].rgba[-1] = 0.5
# Spawn the robot at the world
world.spawn(robot.spec)

# Compile the model
model = world.spec.compile()
data = mujoco.MjData(model)

# Save the model to XML
xml = world.spec.to_xml()
with (DATA / f"{SCRIPT_NAME}.xml").open("w", encoding="utf-8") as f:
f.write(xml)

# Number of actuators and DoFs
console.log(f"DoF (model.nv): {model.nv}, Actuators (model.nu): {model.nu}")

# Reset state and time of simulation
mujoco.mj_resetData(model, data)

# Render
single_frame_renderer(model, data, steps=10)

# View
if with_viewer:
viewer.launch(model=model, data=data)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions examples/_graph_to_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
HighProbabilityDecoder,
save_graph_as_json,
)
#from ariel.body_phenotypes.robogen_lite.morphology import Morphology
from ariel.body_phenotypes.robogen_lite.modules.core import CoreModule
from ariel.simulation.environments import SimpleFlatWorld
from ariel.utils.renderers import single_frame_renderer
Expand Down
70 changes: 70 additions & 0 deletions examples/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# =========================
# Evolutionary Algorithm — config.toml
# =========================

[run]
# Choose which genotype profile to use for this run.
# One of: "integers", "tree", "lsystem", "cppn"
genotype = "lsystem"

task = "evolve_to_copy"

[task.evolve_to_copy]
target_robot_path = "examples/target_robots/small_robot_8.json"

# =========================
# Global EC settings (match EASettings fields)
# =========================
[ec]
quiet = false
is_maximisation = true
first_generation_id = 0
num_of_generations = 100
target_population_size = 100

# =========================
# Data config
# =========================
[data]
# Paths can be absolute or relative to the working directory
output_folder = "__data__"
db_file_name = "database.db"
# db_handling modes: "delete" | "reuse" | "migrate" (adjust to your app’s enum)
db_handling = "delete"

# =========================
# Genotype registry
# Each genotype declares:
# - allowed_mutations / allowed_crossovers: for validation/help
# - defaults: operators used if not overridden in [run]
# - (Optional) operator params (e.g., rates, alphas)
# =========================

[genotypes.tree]
allowed_mutations = ["random_subtree_replacement"]
allowed_crossovers = ["koza_default", "normal"]

[genotypes.tree.defaults]
mutation = "random_subtree_replacement"
crossover = "koza_default"

[genotypes.tree.mutation.params]
max_subtree_depth = 2
branching_prob = 0.5

[genotypes.tree.crossover.params]
koza_internal_node_prob = 0.9

[genotypes.lsystem]
allowed_mutations = ["mutate_one_point_lsystem"]
allowed_crossovers = ["crossover_uniform_rules_lsystem", "crossover_uniform_genes_lsystem"]

[genotypes.lsystem.defaults]
mutation = "mutate_one_point_lsystem"
crossover = "crossover_uniform_rules_lsystem"

[genotypes.lsystem.mutation.params]
mutation_rate = 0.5

[genotypes.lsystem.crossover.params]
mutation_rate = 0.5
Loading