import type { ProblemSpec } from "../spec/types"; import type { MethodDefinition } from "./types"; import { FD_METHOD } from "./fd"; export const METHODS: MethodDefinition[] = [FD_METHOD]; export function getMethod(id: string): MethodDefinition { const m = METHODS.find((x) => x.id === id); if (!m) throw new Error(`unknown method ${id}`); return m; } /** Reasons the method cannot run this spec, in plain words; empty when it can. */ export function methodBlockers(method: MethodDefinition, spec: ProblemSpec): string[] { const out: string[] = []; if (!method.supports.shape.includes(spec.plate.shape)) out.push(`${method.name} has no ${spec.plate.shape} solution`); if (!method.supports.mount.includes(spec.mount.type)) out.push(`${method.name} cannot handle the ${spec.mount.type} mount`); if (!method.supports.excitation.includes(spec.excitation.type)) out.push(`${method.name} cannot handle the ${spec.excitation.type} excitation`); return out; }