/ concept-collection / fastandaccurate
Sign in
concept-collection / fastandaccurate
fastandaccurate / src / harness / sweep.ts
34 lines · 1.0 KBBlameHistoryRaw
1// A work-precision sweep: run one solver across its resolution list on
2// one instance, reporting each point as it lands.
4import { runPoint, type MatlabSources, type RunPoint } from "./runner";
5import type { Laplace2dInstance } from "../problems/laplace2d/spec";
6import type { SolverManifest } from "../solvers";
8export interface SweepOptions {
9 instance: Laplace2dInstance;
10 solver: SolverManifest;
11 sources: MatlabSources;
12 repeats?: number;
13 /** Restrict the sweep to n values <= this (for quick runs). */
14 maxN?: number;
15 onPoint?: (point: RunPoint, index: number, total: number) => void;
18export function runSweep(opts: SweepOptions): RunPoint[] {
19 const ns = opts.solver.sweepN.filter(
20 (n) => opts.maxN === undefined || n <= opts.maxN
21 );
22 const points: RunPoint[] = [];
23 ns.forEach((n, i) => {
24 const p = runPoint({
25 instance: opts.instance,
26 n,
27 repeats: opts.repeats ?? 5,
28 sources: opts.sources,
29 });
30 points.push(p);
31 opts.onPoint?.(p, i, ns.length);
32 });
33 return points;
moveopenescclose