1import type { MethodDefinition } from "./types";
2import { MODAL_METHOD } from "./modal";
3import { FD_METHOD } from "./fd";
4import { IMPLICIT_METHOD } from "./implicit";
5import type { ProblemSpec } from "../spec/types";
7export const METHODS: MethodDefinition[] = [MODAL_METHOD, FD_METHOD, IMPLICIT_METHOD];
9export function getMethod(id: string): MethodDefinition {
10 const m = METHODS.find((x) => x.id === id);
11 if (!m) throw new Error(`unknown method ${id}`);
12 return m;
13}
15/** Reasons a method cannot run on a spec (empty when it can). */
16export function methodBlockers(method: MethodDefinition, spec: ProblemSpec): string[] {
17 const out: string[] = [];
18 if (!method.supports.bc.includes(spec.bc))
19 out.push(
20 `${method.name} does not support ${spec.bc} edges (supports: ${method.supports.bc.join(", ")}).`,
21 );
22 if (!method.supports.excitation.includes(spec.excitation.type))
23 out.push(`${method.name} does not support the ${spec.excitation.type} excitation.`);
24 return out;
25}