UNPKG

solver-core-compute

Version:

Shared solver library for floorplan optimization - compatible with Node.js and Deno

200 lines (199 loc) 7.05 kB
/** * IO Contract for Solver API * TypeScript types and validation for SolveRequest/SolveResponse */ import { z } from 'zod'; export declare const PositionSchema: z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; width: z.ZodNumber; height: z.ZodNumber; rotation: z.ZodOptional<z.ZodNumber>; }, z.core.$strip>; export declare const ConstraintSchema: z.ZodObject<{ type: z.ZodEnum<{ overlap: "overlap"; boundary: "boundary"; aspect_ratio: "aspect_ratio"; proximity: "proximity"; alignment: "alignment"; min_clearance: "min_clearance"; work_triangle: "work_triangle"; }>; params: z.ZodAny; id: z.ZodOptional<z.ZodString>; weight: z.ZodOptional<z.ZodNumber>; }, z.core.$strip>; export declare const SolveRequestSchema: z.ZodObject<{ positions: z.ZodArray<z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; width: z.ZodNumber; height: z.ZodNumber; rotation: z.ZodOptional<z.ZodNumber>; }, z.core.$strip>>; constraints: z.ZodArray<z.ZodObject<{ type: z.ZodEnum<{ overlap: "overlap"; boundary: "boundary"; aspect_ratio: "aspect_ratio"; proximity: "proximity"; alignment: "alignment"; min_clearance: "min_clearance"; work_triangle: "work_triangle"; }>; params: z.ZodAny; id: z.ZodOptional<z.ZodString>; weight: z.ZodOptional<z.ZodNumber>; }, z.core.$strip>>; options: z.ZodOptional<z.ZodObject<{ algorithm: z.ZodOptional<z.ZodEnum<{ parallel: "parallel"; hybrid: "hybrid"; adaptive: "adaptive"; sa: "sa"; ga: "ga"; ls: "ls"; }>>; timeout: z.ZodOptional<z.ZodNumber>; gridSize: z.ZodOptional<z.ZodNumber>; maxIterations: z.ZodOptional<z.ZodNumber>; useParallel: z.ZodOptional<z.ZodBoolean>; useMultiObjective: z.ZodOptional<z.ZodBoolean>; randomSeed: z.ZodOptional<z.ZodNumber>; }, z.core.$strip>>; metadata: z.ZodOptional<z.ZodObject<{ requestId: z.ZodOptional<z.ZodString>; timestamp: z.ZodOptional<z.ZodNumber>; userId: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; }, z.core.$strip>; export type SolveRequest = z.infer<typeof SolveRequestSchema>; export declare const ViolationSchema: z.ZodObject<{ constraintId: z.ZodOptional<z.ZodString>; constraintType: z.ZodString; positions: z.ZodArray<z.ZodAny>; penalty: z.ZodNumber; description: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export type Violation = z.infer<typeof ViolationSchema>; export declare const ConstraintEvaluationSchema: z.ZodObject<{ totalConstraints: z.ZodNumber; satisfied: z.ZodNumber; violated: z.ZodNumber; violations: z.ZodArray<z.ZodObject<{ constraintId: z.ZodOptional<z.ZodString>; constraintType: z.ZodString; positions: z.ZodArray<z.ZodAny>; penalty: z.ZodNumber; description: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; }, z.core.$strip>; export type ConstraintEvaluation = z.infer<typeof ConstraintEvaluationSchema>; export declare const SolutionSchema: z.ZodObject<{ positions: z.ZodArray<z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; width: z.ZodNumber; height: z.ZodNumber; rotation: z.ZodOptional<z.ZodNumber>; }, z.core.$strip>>; score: z.ZodNumber; violations: z.ZodNumber; algorithm: z.ZodString; executionTime: z.ZodNumber; iterations: z.ZodNumber; convergenceData: z.ZodOptional<z.ZodObject<{ initialScore: z.ZodNumber; finalScore: z.ZodNumber; improvement: z.ZodNumber; }, z.core.$strip>>; }, z.core.$strip>; export type IOSolution = z.infer<typeof SolutionSchema>; export declare const SolveResponseSchema: z.ZodObject<{ success: z.ZodBoolean; solutions: z.ZodArray<z.ZodObject<{ positions: z.ZodArray<z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; width: z.ZodNumber; height: z.ZodNumber; rotation: z.ZodOptional<z.ZodNumber>; }, z.core.$strip>>; score: z.ZodNumber; violations: z.ZodNumber; algorithm: z.ZodString; executionTime: z.ZodNumber; iterations: z.ZodNumber; convergenceData: z.ZodOptional<z.ZodObject<{ initialScore: z.ZodNumber; finalScore: z.ZodNumber; improvement: z.ZodNumber; }, z.core.$strip>>; }, z.core.$strip>>; bestSolution: z.ZodOptional<z.ZodObject<{ positions: z.ZodArray<z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; width: z.ZodNumber; height: z.ZodNumber; rotation: z.ZodOptional<z.ZodNumber>; }, z.core.$strip>>; score: z.ZodNumber; violations: z.ZodNumber; algorithm: z.ZodString; executionTime: z.ZodNumber; iterations: z.ZodNumber; convergenceData: z.ZodOptional<z.ZodObject<{ initialScore: z.ZodNumber; finalScore: z.ZodNumber; improvement: z.ZodNumber; }, z.core.$strip>>; }, z.core.$strip>>; metadata: z.ZodObject<{ requestId: z.ZodOptional<z.ZodString>; timestamp: z.ZodNumber; solver: z.ZodString; totalTime: z.ZodNumber; iterations: z.ZodNumber; }, z.core.$strip>; constraintEvaluation: z.ZodOptional<z.ZodObject<{ totalConstraints: z.ZodNumber; satisfied: z.ZodNumber; violated: z.ZodNumber; violations: z.ZodArray<z.ZodObject<{ constraintId: z.ZodOptional<z.ZodString>; constraintType: z.ZodString; positions: z.ZodArray<z.ZodAny>; penalty: z.ZodNumber; description: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; }, z.core.$strip>>; errors: z.ZodOptional<z.ZodArray<z.ZodObject<{ code: z.ZodString; message: z.ZodString; details: z.ZodOptional<z.ZodAny>; }, z.core.$strip>>>; warnings: z.ZodOptional<z.ZodArray<z.ZodString>>; }, z.core.$strip>; export type { IOSolution as Solution }; export type SolveResponse = z.infer<typeof SolveResponseSchema>; /** * Validate SolveRequest input * Throws ZodError if validation fails */ export declare function validateSolveRequest(input: unknown): SolveRequest; /** * Validate SolveResponse output * Throws ZodError if validation fails */ export declare function validateSolveResponse(output: unknown): SolveResponse; /** * Validate input and output around solver call */ export declare function validateIO<TInput, TOutput>(input: TInput, output: TOutput, context?: string): { input: SolveRequest; output: SolveResponse; }; export declare function isValidSolveRequest(obj: unknown): obj is SolveRequest; export declare function isValidSolveResponse(obj: unknown): obj is SolveResponse;