Files
lucidia-main/tests/test_substrate_optimizer.py
Alexa Amundson bedcb98b24 Add 68 tests, CI pipeline, and proprietary license
- 21 tests for LucidiaAI (sentiment, response, memory persistence)
- 40 tests for lucidia_logic (Trinary, psi_prime, breath functions, all symbolic math)
- 7 tests for substrate_performance_optimizer
- GitHub Actions CI with Python 3.10/3.11/3.12 matrix
- Replace MIT license with BlackRoad OS proprietary
- Add CI badge and Python badge to README

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

RoadChain-SHA2048: 7ecced90454ac8af
RoadChain-Identity: alexa@sovereign
RoadChain-Full: 7ecced90454ac8af8796eba2e76e1c5a6325fe9f492446eb54b56c4967b8955222421e5b00932b26094a72046729c7d82ed51c60c71c2c47eec4215b89f18db8c4ec918630872f503511798b6233c352deb7caff00c3abf9d73939562db633a6ea4e47c46b3ff3be3822a8d94168be530ee2d3817a9f579b83bce735d43e1f579c7a5eae728824163cb4443ad00a93881c1915c87111c9ca130ae4f196a47ed68707b1ea4cab0d995ea546544cc83120a260f2e4f409b2a9d8a12603d0b4556c389caf25c906e58b982ff300dcc8a8425cc5f1e1e640c96602dd3ed5c88131f5fc790aa4a721d89a079db244a1c57297a4d56e9dbde75a8fc25539e15560213c
2026-03-09 23:17:42 -05:00

66 lines
2.2 KiB
Python

"""Tests for lucidia.substrate_performance_optimizer."""
import pytest
from lucidia.substrate_performance_optimizer import optimize_substrate_selection
class TestOptimizeSubstrateSelection:
def setup_method(self):
self.task = {"complexity": 0.9}
self.energy = {"chemical": 1.2, "quantum": 0.7, "electronic": 1.0}
self.time = {"chemical": 2.0, "quantum": 1.1, "electronic": 1.3}
self.switch = {"chemical": 0.4, "quantum": 0.2, "electronic": 0.1}
def test_selects_lowest_cost(self):
best, cost = optimize_substrate_selection(
self.task, self.energy, self.time, self.switch
)
assert best == "quantum"
def test_cost_formula(self):
_, cost = optimize_substrate_selection(
self.task, self.energy, self.time, self.switch, lambda_weight=0.5
)
expected = 0.7 * 1.1 * (1 + 0.5 * 0.2)
assert abs(cost - expected) < 1e-10
def test_lambda_zero_ignores_penalty(self):
best, cost = optimize_substrate_selection(
self.task, self.energy, self.time, self.switch, lambda_weight=0.0
)
expected = 0.7 * 1.1 * 1.0
assert abs(cost - expected) < 1e-10
def test_high_lambda_penalizes_switching(self):
best, _ = optimize_substrate_selection(
self.task,
{"a": 1.0, "b": 1.0},
{"a": 1.0, "b": 1.0},
{"a": 0.0, "b": 10.0},
lambda_weight=1.0,
)
assert best == "a"
def test_single_substrate(self):
best, cost = optimize_substrate_selection(
{}, {"only": 2.0}, {"only": 3.0}, {"only": 0.5}, lambda_weight=1.0
)
assert best == "only"
assert abs(cost - 2.0 * 3.0 * 1.5) < 1e-10
def test_equal_costs_returns_one(self):
best, _ = optimize_substrate_selection(
{}, {"a": 1.0, "b": 1.0}, {"a": 1.0, "b": 1.0}, {"a": 0.0, "b": 0.0}
)
assert best in ("a", "b")
def test_returns_tuple(self):
result = optimize_substrate_selection(
self.task, self.energy, self.time, self.switch
)
assert isinstance(result, tuple)
assert len(result) == 2
assert isinstance(result[0], str)
assert isinstance(result[1], float)