score-optimize actuator/storage/platform allocation, enforce structural feasibility

The saved composite score previously came from a requirement-solve that
only satisfied the platform's physical performance floor, not the
domain's actual weighted score -- a smaller/cheaper build could always
score higher by hand. _decide_masses now jointly searches platform,
actuator, and storage mass (coarse-to-fine grid, no external deps) to
maximize the domain's real weighted composite score, with the
requirement floor as a lower bound rather than the final answer.

Platform mass specifically was previously fixed at a geometric-mean
representative value, which could be too little structure to carry its
own required actuator+storage (reusing CARGO_KG_PER_STRUCTURAL_KG, the
existing structure-carries-N-times-its-mass ratio, applied to a
platform carrying its own powertrain instead of cargo). Growing
platform mass also raises that structural ceiling, so it has to be
searched jointly rather than fixed or bounded independently.

Because power_density/range_fuel/cost_efficiency are all per-kg
ratios, none of them naturally penalize a build whose absolute mass
exceeds its own platform's declared ceiling -- a Piston Engine sized
for a Hyperloop could still score well on a Light Personal Vehicle.
Pass 2 now detects genuine infeasibility (no platform mass within its
own declared ceiling can structurally carry the required floor) and
saves it as a per-domain block instead of a misleadingly good score.

Also adds an explore-panel warning (not a hard block, since exploration
is intentionally loose) when a manually-dragged slider build exceeds
the platform's mass ceiling or structural carrying capacity.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-15 18:59:20 -05:00
parent 76f460499a
commit d871635779
6 changed files with 742 additions and 139 deletions

View File

@@ -4,11 +4,25 @@ from __future__ import annotations
from flask import Blueprint, flash, redirect, render_template, request, url_for
from physcom.engine.constraint_resolver import ConstraintResolver
from physcom.engine.pipeline import Pipeline
from physcom.engine.scorer import Scorer
from physcom_web.app import get_repo
bp = Blueprint("results", __name__, url_prefix="/results")
def _run_evaluate(repo, domain, combo, platform_mass=None, actuator_mass=None, storage_mass=None):
"""Purely exploratory -- never writes to the DB. Returns None if this
combo has no free mass allocation to explore (see
Pipeline.evaluate_allocation's docstring)."""
pipeline = Pipeline(repo, ConstraintResolver(), Scorer(domain))
return pipeline.evaluate_allocation(
combo, domain,
platform_mass=platform_mass, actuator_mass=actuator_mass, storage_mass=storage_mass,
)
@bp.route("/")
def results_index():
repo = get_repo()
@@ -62,6 +76,7 @@ def result_detail(domain_name: str, combo_id: int):
flash("No results for this combination in this domain.", "error")
return redirect(url_for("results.results_domain", domain_name=domain_name))
scores = repo.get_combination_scores(combo_id, domain.id)
explore_result = _run_evaluate(repo, domain, combo)
return render_template(
"results/detail.html",
@@ -69,6 +84,40 @@ def result_detail(domain_name: str, combo_id: int):
combo=combo,
result=result,
scores=scores,
explore_result=explore_result,
)
@bp.route("/<domain_name>/<int:combo_id>/explore", methods=["POST"])
def explore(domain_name: str, combo_id: int):
"""Live, purely exploratory re-evaluation for an explicit platform/
actuator/storage mass choice -- never touches stored data. Returns an
HTMX partial."""
repo = get_repo()
domain = repo.get_domain(domain_name)
combo = repo.get_combination(combo_id) if domain else None
if not domain or not combo:
return "", 404
def _mass(field: str) -> float | None:
raw = request.form.get(field)
if raw is None:
return None
try:
return float(raw)
except ValueError:
return None
explore_result = _run_evaluate(
repo, domain, combo,
platform_mass=_mass("platform_mass"),
actuator_mass=_mass("actuator_mass"),
storage_mass=_mass("storage_mass"),
)
return render_template(
"results/_explore_result.html",
domain=domain,
explore_result=explore_result,
)