Skip to content

Add subchunk_agg_check_rev8 with deterministic MC precompute and off-axis gain lookup#4

Draft
nicklasorte wants to merge 1 commit intomainfrom
codex/create-optimized-matlab-files-for-monte-carlo-9o7tp2
Draft

Add subchunk_agg_check_rev8 with deterministic MC precompute and off-axis gain lookup#4
nicklasorte wants to merge 1 commit intomainfrom
codex/create-optimized-matlab-files-for-monte-carlo-9o7tp2

Conversation

@nicklasorte
Copy link
Copy Markdown
Owner

Motivation

  • Remove hot-path RNG reseeding and repeated per-azimuth antenna-pattern reconstruction to accelerate Monte Carlo aggregation while preserving deterministic behavior.
  • Batch RNG draws and precompute azimuth-dependent antenna gains so the MC × azimuth hot path uses matrix math instead of repeated interpolation/rotation.
  • Preserve function signature, output shape, NaN behavior and per-iteration seed identity for reproducibility.

Description

  • Added a drop-in top-level optimized path subchunk_agg_check_rev8.m that keeps the same function signature as the existing subchunk_agg_check_rev7.m and preserves output shape and NaN handling.
  • Deterministic RNG decoupling: precomputes rand_pr_all, rand_eirp_all, and rand_clutter_all in subchunk_agg_check_rev8.m using the original per-iteration seed identities (rand_seed1 + mc_iter, +1, +2) so each MC draw maps to the same identity as before.
  • Azimuth vectorization: precomputes an off_axis_gain_matrix(num_bs, num_sim_azi) by computing relative azimuth rel_az = mod(bs_azimuth - sim_azimuth,360) once and performing nearest-neighbor lookup on a deduplicated antenna-pattern azimuth axis, eliminating repeated circshift/unique/nearestpoint operations in the MC hot path.
  • RNG-free helper revisions: added helpers that accept precomputed random inputs and avoid internal rng calls: monte_carlo_Pr_dBm_rev2_app.m, monte_carlo_super_bs_eirp_dist_rev5.m, and monte_carlo_clutter_rev3_app.m.
  • Chunked aggregation: performs MC computations in batch form and aggregates across azimuth in chunks (configurable chunk size azi_chunk) to avoid memory blow-up while removing the inner per-azimuth reconstruction loop.
  • Validation helper: added validate_subchunk_agg_check_rev8_rev1.m to run side-by-side comparisons and timing between rev7 and rev8, checking size equality, NaN pattern equality, max/mean absolute differences, reproducibility, and percent speedup.
  • Engineering constraints honored: no existing .m files were modified, the rev numbering pattern was followed (new helper names use incremented revisions), no parfor was introduced, and deterministic mapping to old seeds is preserved.

Testing

  • Automated checks performed in this environment were limited to file-level verification and environment inspection, including printing the new files and checking for a MATLAB/Octave runtime; those checks succeeded at the file level.
  • Runtime-based automated tests (numerical equivalence and timing) were not executed here because the environment lacks a MATLAB/Octave runtime (octave --version returned no binary).
  • A validator script validate_subchunk_agg_check_rev8_rev1.m was included and will perform automated numerical equivalence, NaN-pattern, reproducibility, and runtime comparisons when run in a MATLAB/Octave environment.

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