Let a genome decide, and report where each axis actually acts
M3.6 joins the M3 pieces: strategy_for derives a StrategyConfig from the metabolic budget, founders are pre-diverged variants admitted to the lineage archive, and evo-sim --ensemble runs them over a resource and temperature grid with every cell's seeds split in half and never merged. ADR-0029's driver is untouched, so the M2.6 fingerprint still holds. Nothing mutates during an episode, so NPC mutation stays open. Three things measurement found, kept rather than smoothed over. The report aggregates were default-initialized, leaving their scalar counters indeterminate. The resource level never reaches strategy derivation at all, so the header now says where each axis acts instead of claiming both shape a strategy. And the resource axis is not monotonic: a sweep peaks near 8000 femtograms and falls away on both sides, because only one consumer may bite a target per tick, so scarcity concentrates mass into individuals that reach the threshold while abundance spreads the same income too thin. The test asserts that an axis moves the outcome and never a direction; an earlier draft asserted a direction that held at two cells and the sweep disproves. Earning a birth at all required pinning the investment fraction to the schema floor, since intake scales with surface and investment with mass. That is a finding about the ADR-0031/0032 cost model, now the second priority in STATUS. Release 33/33, analysis, ASan 33/33 and clang-format all ran and passed here; no Clang or GCC compile happens on this host, so Linux CI is still the first result for this increment. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+127
-7
@@ -1,4 +1,5 @@
|
||||
#include "evo/processes/ecosystem.hpp"
|
||||
#include "evo/processes/ensemble.hpp"
|
||||
#include "evo/simulation/world.hpp"
|
||||
#include "evo/telemetry/sinks.hpp"
|
||||
|
||||
@@ -24,9 +25,12 @@ struct Options {
|
||||
std::uint64_t entities{8};
|
||||
std::uint64_t episodes{1};
|
||||
std::uint64_t tick_limit{2000};
|
||||
std::uint64_t seeds_per_cell{8};
|
||||
std::uint64_t strategies{3};
|
||||
std::filesystem::path load, save, output, metrics;
|
||||
bool verify_replay{};
|
||||
bool ecosystem{};
|
||||
bool ensemble{};
|
||||
bool help{};
|
||||
};
|
||||
|
||||
@@ -86,7 +90,9 @@ std::expected<Options, evo::Error> parse(int argc, char** argv) {
|
||||
bool initial_state_option = false;
|
||||
bool entities_option = false;
|
||||
bool ticks_option = false;
|
||||
bool episode_option = false;
|
||||
bool episodes_option = false;
|
||||
bool tick_limit_option = false;
|
||||
bool ensemble_option = false;
|
||||
for (int index = 1; index < argc; ++index) {
|
||||
const std::string_view key{argv[index]};
|
||||
if (key == "--help") {
|
||||
@@ -101,12 +107,16 @@ std::expected<Options, evo::Error> parse(int argc, char** argv) {
|
||||
options.ecosystem = true;
|
||||
continue;
|
||||
}
|
||||
if (key == "--ensemble") {
|
||||
options.ensemble = true;
|
||||
continue;
|
||||
}
|
||||
if (++index >= argc) {
|
||||
return std::unexpected{evo::Error::invalid_arguments};
|
||||
}
|
||||
const std::string_view value{argv[index]};
|
||||
if (key == "--seed" || key == "--ticks" || key == "--entities" || key == "--episodes" ||
|
||||
key == "--tick-limit") {
|
||||
key == "--tick-limit" || key == "--seeds-per-cell" || key == "--strategies") {
|
||||
const auto parsed = number(value);
|
||||
if (!parsed) {
|
||||
return std::unexpected{parsed.error()};
|
||||
@@ -120,10 +130,16 @@ std::expected<Options, evo::Error> parse(int argc, char** argv) {
|
||||
entities_option = true;
|
||||
} else if (key == "--episodes") {
|
||||
options.episodes = *parsed;
|
||||
episode_option = true;
|
||||
episodes_option = true;
|
||||
} else if (key == "--tick-limit") {
|
||||
options.tick_limit = *parsed;
|
||||
episode_option = true;
|
||||
tick_limit_option = true;
|
||||
} else if (key == "--seeds-per-cell") {
|
||||
options.seeds_per_cell = *parsed;
|
||||
ensemble_option = true;
|
||||
} else if (key == "--strategies") {
|
||||
options.strategies = *parsed;
|
||||
ensemble_option = true;
|
||||
} else {
|
||||
options.ticks = *parsed;
|
||||
ticks_option = true;
|
||||
@@ -148,11 +164,22 @@ std::expected<Options, evo::Error> parse(int argc, char** argv) {
|
||||
const bool proof_only = entities_option || ticks_option || options.verify_replay ||
|
||||
!options.load.empty() || !options.save.empty() ||
|
||||
!options.metrics.empty();
|
||||
if (options.ecosystem && options.ensemble) {
|
||||
return std::unexpected{evo::Error::invalid_arguments};
|
||||
}
|
||||
if (options.ecosystem) {
|
||||
if (proof_only || options.episodes == 0 || options.tick_limit == 0) {
|
||||
// Ensemble mode counts seeds per cell, not episodes, so --episodes here
|
||||
// would name a quantity this mode does not have.
|
||||
if (proof_only || ensemble_option || options.episodes == 0 || options.tick_limit == 0) {
|
||||
return std::unexpected{evo::Error::invalid_arguments};
|
||||
}
|
||||
} else if (episode_option) {
|
||||
} else if (options.ensemble) {
|
||||
if (proof_only || episodes_option || options.tick_limit == 0 ||
|
||||
options.seeds_per_cell < 2 || options.strategies == 0 ||
|
||||
options.strategies > evo::processes::max_strategies) {
|
||||
return std::unexpected{evo::Error::invalid_arguments};
|
||||
}
|
||||
} else if (episodes_option || tick_limit_option || ensemble_option) {
|
||||
return std::unexpected{evo::Error::invalid_arguments};
|
||||
}
|
||||
if (const auto valid = validate_paths(options); !valid) {
|
||||
@@ -283,10 +310,98 @@ std::expected<void, evo::Error> run_ecosystem(const Options& options) {
|
||||
return write_report(options, report.str());
|
||||
}
|
||||
|
||||
// The ensemble fixture, again CLI-local measurement input rather than a rule. The
|
||||
// ancestor's investment fraction sits at the schema floor because intake scales
|
||||
// with surface while investment scales with mass: at any larger fraction no
|
||||
// organism in this world can fund a birth from feeding within an episode, and the
|
||||
// resource axis would measure nothing. See ADR-0035.
|
||||
evo::biology::GenomeDraft ensemble_ancestor() {
|
||||
using evo::biology::Capability;
|
||||
evo::biology::GenomeDraft source;
|
||||
source.id = 1;
|
||||
source.origin_event = 1;
|
||||
source.development_version = 1;
|
||||
source.capabilities = {{Capability::energy_conversion, 400, 0},
|
||||
{Capability::membrane, 120, 0},
|
||||
{Capability::target_size, 2'000, 0},
|
||||
{Capability::ingestion, 1'000'000, 0},
|
||||
{Capability::reproduction, 1, 0}};
|
||||
return source;
|
||||
}
|
||||
|
||||
std::expected<void, evo::Error> run_ensemble_mode(const Options& options) {
|
||||
using namespace evo::processes;
|
||||
constexpr std::uint32_t reference_temperature = 293'150U;
|
||||
const auto ancestor = evo::biology::Genome::create(ensemble_ancestor());
|
||||
if (!ancestor) {
|
||||
return std::unexpected{evo::Error::invalid_arguments};
|
||||
}
|
||||
const auto founders =
|
||||
diverge_founders(*ancestor, static_cast<std::size_t>(options.strategies), options.seed);
|
||||
if (!founders) {
|
||||
return std::unexpected{evo::Error::invalid_arguments};
|
||||
}
|
||||
const ProducerConfig plants{{{50}, 1}, {50, 1}, 1000, {1}, bundle(1).matter};
|
||||
const EcosystemConfig world{plants, {10'000'000}, bundle(200).matter, {bundle(4)},
|
||||
800, 10, options.tick_limit};
|
||||
const EnsembleConfig plan{{{reference_temperature - 15'000U, 1'000},
|
||||
{reference_temperature, 1'000},
|
||||
{reference_temperature + 15'000U, 1'000},
|
||||
{reference_temperature, 8'000}},
|
||||
options.seeds_per_cell,
|
||||
options.tick_limit,
|
||||
300,
|
||||
10};
|
||||
evo::biology::LineageArchive archive;
|
||||
const auto measured = run_ensemble(archive, *founders, world, plan, options.seed);
|
||||
if (!measured) {
|
||||
return std::unexpected{evo::Error::invalid_arguments};
|
||||
}
|
||||
std::ostringstream report;
|
||||
report << "{\"rules_version\":" << evo::rules_version
|
||||
<< ",\"mode\":\"ensemble\",\"seed\":" << options.seed
|
||||
<< ",\"strategies\":" << founders->size()
|
||||
<< ",\"seeds_per_cell\":" << options.seeds_per_cell
|
||||
<< ",\"tick_limit\":" << options.tick_limit << ",\"episodes\":" << measured->episodes
|
||||
<< ",\"ticks\":" << measured->ticks
|
||||
<< ",\"archived_genomes\":" << measured->archived_genomes
|
||||
<< ",\"archived_organisms\":" << measured->archived_organisms << ",\"cells\":[";
|
||||
for (std::size_t index = 0; index < measured->cells.size(); ++index) {
|
||||
const auto& cell = measured->cells[index];
|
||||
report << (index == 0 ? "" : ",")
|
||||
<< "{\"temperature_millikelvin\":" << cell.cell.temperature_millikelvin
|
||||
<< ",\"nutrients\":" << cell.cell.nutrients << ",\"ticks\":" << cell.ticks
|
||||
<< ",\"extinctions\":" << cell.extinctions << ",\"halves\":[";
|
||||
// Both halves are reported, never merged: a difference that shows in one
|
||||
// and not the other is an artifact of the seeds. See ADR-0035.
|
||||
const std::array halves{&cell.first_half, &cell.second_half};
|
||||
for (std::size_t half = 0; half < halves.size(); ++half) {
|
||||
report << (half == 0 ? "[" : ",[");
|
||||
for (std::size_t which = 0; which < halves[half]->size(); ++which) {
|
||||
const auto& outcome = (*halves[half])[which];
|
||||
report << (which == 0 ? "" : ",") << "{\"genome\":" << outcome.genome
|
||||
<< ",\"episodes\":" << outcome.episodes << ",\"births\":" << outcome.births
|
||||
<< ",\"organisms\":" << outcome.organisms
|
||||
<< ",\"lived_ticks\":" << outcome.lived_ticks
|
||||
<< ",\"thermal_shortfall\":" << outcome.thermal_shortfall
|
||||
<< ",\"scheduled_lifespan\":" << outcome.scheduled_lifespan << "}";
|
||||
}
|
||||
report << "]";
|
||||
}
|
||||
report << "]}";
|
||||
}
|
||||
report << "],\"fingerprint\":\"" << std::hex << std::setfill('0') << std::setw(16)
|
||||
<< measured->fingerprint << std::dec << "\"}\n";
|
||||
return write_report(options, report.str());
|
||||
}
|
||||
|
||||
std::expected<void, evo::Error> run(const Options& options) {
|
||||
if (options.ecosystem) {
|
||||
return run_ecosystem(options);
|
||||
}
|
||||
if (options.ensemble) {
|
||||
return run_ensemble_mode(options);
|
||||
}
|
||||
auto loaded = initial_world(options);
|
||||
if (!loaded) {
|
||||
return std::unexpected{loaded.error()};
|
||||
@@ -378,9 +493,14 @@ int main(int argc, char** argv) try {
|
||||
" [--verify-replay] [--save FILE] [--output JSON] [--metrics FILE]\n"
|
||||
"evo-sim --ecosystem [--seed N] [--episodes N] [--tick-limit N]\n"
|
||||
" [--output JSON]\n"
|
||||
"evo-sim --ensemble [--seed N] [--seeds-per-cell N] [--strategies N]\n"
|
||||
" [--tick-limit N] [--output JSON]\n"
|
||||
"Synthetic proof. When loading, ticks are additional.\n"
|
||||
"Ecosystem mode measures seeded bounded episodes; it shares no state,\n"
|
||||
"snapshot or particle metric with the proof run.\n";
|
||||
"snapshot or particle metric with the proof run.\n"
|
||||
"Ensemble mode runs genome-derived strategies over a resource and\n"
|
||||
"temperature gradient, reporting each cell's two seed halves\n"
|
||||
"separately. Its numbers describe that fixture and nothing wider.\n";
|
||||
return 0;
|
||||
}
|
||||
const auto result = run(*options);
|
||||
|
||||
Reference in New Issue
Block a user