/ proof-of-concept / plate-dynamics-lab
Sign in
proof-of-concept / plate-dynamics-lab
plate-dynamics-lab / packages / core / src / methods / registry.ts
23 lines · 983 BBlameHistoryRaw
1import type { ProblemSpec } from "../spec/types";
2import type { MethodDefinition } from "./types";
3import { FD_METHOD } from "./fd";
5export const METHODS: MethodDefinition[] = [FD_METHOD];
7export function getMethod(id: string): MethodDefinition {
8 const m = METHODS.find((x) => x.id === id);
9 if (!m) throw new Error(`unknown method ${id}`);
10 return m;
13/** Reasons the method cannot run this spec, in plain words; empty when it can. */
14export function methodBlockers(method: MethodDefinition, spec: ProblemSpec): string[] {
15 const out: string[] = [];
16 if (!method.supports.shape.includes(spec.plate.shape))
17 out.push(`${method.name} has no ${spec.plate.shape} solution`);
18 if (!method.supports.mount.includes(spec.mount.type))
19 out.push(`${method.name} cannot handle the ${spec.mount.type} mount`);
20 if (!method.supports.excitation.includes(spec.excitation.type))
21 out.push(`${method.name} cannot handle the ${spec.excitation.type} excitation`);
22 return out;
↑↓ move↵openescclose