/** * @file src/main.ts * @description Core Solver class implementation * * Orchestrates the complete solving pipeline: * - Model parsing and validation * - Simplex algorithm for linear programming * - Branch-and-cut for mixed-integer programming * - Multi-objective optimization via Polyopt * - External solver delegation (e.g., lp_solve) */ import Tableau from "./tableau"; import Model from "./model"; import * as expressions from "./expressions"; import type { Model as ModelDefinition, SolveResult } from "./types/solver"; /** * Main solver class providing the public API for solving optimization problems. */ declare class Solver { Model: typeof Model; Tableau: typeof Tableau; Constraint: typeof expressions.Constraint; Variable: typeof expressions.Variable; Numeral: typeof expressions.Numeral; Term: typeof expressions.Term; External: import("./external/main").ExternalSolvers; ReformatLP: (model: any) => string | { opType: string; optimize: string; constraints: {}; variables: {}; }; branchAndCutService: import("./tableau/branch-and-cut").BranchAndCutService; branchAndCut: (tableau: Tableau) => void; lastSolvedModel: Model | null; /** * Select the appropriate branch-and-cut service based on model options. * * Enhanced strategies can be enabled via model.options: * - nodeSelection: 'best-first' | 'depth-first' | 'hybrid' * - branching: 'most-fractional' | 'pseudocost' | 'strong' * - useIncremental: true to use incremental state management (experimental) */ private selectBranchAndCutService; /** * Solve a linear or mixed-integer programming problem. * * @param model - Problem definition (JSON format or Model instance) * @param precision - Tolerance for integer constraints (default: 1e-9) * @param full - If true, return full Solution object; otherwise return simplified result * @param validate - If true, run model through validation functions * @returns Solution object or simplified result with variable values */ Solve<_TVariable extends string = string>(model: ModelDefinition | Model, precision?: number, full?: boolean, validate?: boolean): SolveResult | unknown; /** * Delegate solving to an external solver (e.g., lp_solve). */ private solveWithExternalSolver; /** * Build a simplified result object from a full solution. */ private buildSimplifiedResult; /** * Solve a multi-objective optimization problem. * * Returns a compromise solution using the mid-point formula between * individually optimized objectives. * * @example * const model = { * optimize: { profit: "max", risk: "min" }, * constraints: { budget: { max: 1000 } }, * variables: { ... } * }; * const result = solver.MultiObjective(model); */ MultiObjective(model: ModelDefinition): unknown; } declare const solver: Solver; export default solver;