Something went wrong. Try again.
A functional toolkit for authoring resource-leveling algorithms — compose constraint and scoring blocks, enumerate feasible schedules
Something went wrong. Try again.
1.6 kB · 42 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243// SerialSGS — Search block.//// Wraps the greedy serial Schedule Generation Scheme as a registry-named// search so a run config can select the backend declaratively. Future// backends (CP-SAT, MiniZinc subprocess) register beside it under their own// versioned codes rather than forking the run API.
import { z } from "zod";
import { serialSGS } from "../level-core/search/serialSGS.ts";import type { Search } from "../level-core/types.ts";
import type { MiniZincFragment, SearchBlock } from "./types.ts";
export const SerialSGSInputSchema = z.object({});
export type SerialSGSInput = z.infer<typeof SerialSGSInputSchema>;
const SearchOutputSchema: z.ZodType<Search> = z.custom<Search>( (val): val is Search => typeof val === "object" && val !== null && typeof (val as Search).name === "string" && typeof (val as Search).run === "function",);
export const SerialSGSBlock: SearchBlock<SerialSGSInput> = { id: "SerialSGS", schema: { input: SerialSGSInputSchema, output: SearchOutputSchema }, apply: (): Search => serialSGS, toMiniZinc: (): MiniZincFragment => ({ // The search itself never lowers to MiniZinc — a MiniZinc backend // replaces it wholesale. Emitted as a comment so concatenated compiles // stay valid. text: `% search: greedy serial-SGS (in-process; not a MiniZinc construct)`, }), doc: { nl: "Greedy serial schedule-generation scheme: topological order, earliest feasible placement per task. Deterministic, single schedule per run.", pseudocode: "for task in topo order: place at earliest day satisfying precedence + caps", },};