Fix mass extraction + db close order + nan handling

- Journal now extracts p173 mass expression and writes _temp_mass.txt
- history.get_study_summary() called before history.close()
- Optuna nan rejection: fallback to INFEASIBLE_MASS penalty
- pyNastran warning 'nx 2512 not supported' is harmless (reads fine)
This commit is contained in:
2026-02-11 16:29:45 +00:00
parent 0229ce53bb
commit 93a5508c07
2 changed files with 33 additions and 2 deletions

View File

@@ -255,6 +255,12 @@ def evaluate_trial(
)
history.export_csv() # Live update CSV after each trial
# Optuna rejects nan — use INFEASIBLE_MASS as fallback
import math
if math.isnan(nx_result.mass):
logger.warning("Trial %d: mass is NaN (extraction failed), using penalty value", trial_num)
return INFEASIBLE_MASS
return nx_result.mass
@@ -542,10 +548,10 @@ def run_study(args: argparse.Namespace) -> None:
# Cleanup
solver.close()
# Final history export + summary
history.close()
# Final history summary (before close!)
hist_summary = history.get_study_summary(study_name)
logger.info("History DB: %d total records across all studies", hist_summary["total"])
history.close()
def _progress_callback(study: optuna.Study, trial: optuna.trial.FrozenTrial) -> None: