Skip to content

Add OrcaFlex + PyGAD GA workflow for black-box ED optimization#1

Open
9474285 wants to merge 1 commit intomasterfrom
codex/implement-ga-optimization-for-orcaflex-model
Open

Add OrcaFlex + PyGAD GA workflow for black-box ED optimization#1
9474285 wants to merge 1 commit intomasterfrom
codex/implement-ga-optimization-for-orcaflex-model

Conversation

@9474285
Copy link
Owner

@9474285 9474285 commented Feb 11, 2026

Motivation

  • Provide a reusable Python workflow to run OrcaFlex 10.3 simulations from Python and perform a single-run genetic-algorithm (GA) optimization of Turret parameters for emergency-deployment (ED) cases.
  • Support evaluation-by-blackbox: modify model, run full dynamic simulation, extract full-time-domain Von Mises stress, and use the maximum as the optimization objective/constraint.

Description

  • Added config.py to centralize model path, object/result names, variable bounds, GA settings, damping-mode options (same, fixed_axial, separate), and helpers build_gene_space / decode_solution for gene ordering and decoding.
  • Added orcaflex_runner.py which encapsulates OrcFxAPI usage: loads base.dat, updates Turret mass, centre-of-mass Z, sets geometry to three equal cylinder segments, writes added-mass/damping (with resilient attribute lookup), calls CalculateStatics() and RunSimulation(), snapshots simulation, and returns an EvalResult (stress or error).
  • Added metrics.py to robustly extract a line time history for Von Mises Stress, take the time-series maximum, and convert units to MPa when appropriate.
  • Added run_ga.py as the GA driver using pygad.GA: constructs gene space from config.py, decodes solutions to parameters, evaluates each candidate via OrcaFlexRunner, computes a penalized fitness (minimize max_t(stress) -> maximize 1/(stress+penalty)), logs per-evaluation records, prints per-eval and per-generation summaries, and writes results/best_solution.json and results/eval_log.csv.
  • Engineering details: each evaluation gets an isolated run directory under results/cases, failed simulations are converted to a very poor fitness via an infinite-stress/large-penalty mapping, and damping writing supports configurable modes (same/fixed/separate).

Testing

  • Performed static sanity check by compiling the new modules with python -m py_compile config.py metrics.py orcaflex_runner.py run_ga.py, which completed successfully.
  • The code paths that interact with OrcFxAPI and runtime extraction were written defensively and will raise/return penalized results on OrcaFlex runtime errors; those runtime behaviors were not executed during compile-time validation.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant