highs-js API reference
    Preparing search index...

    Interface Model

    Persistent model owning one native HiGHS instance. Methods are synchronous, copy inputs, and throw on validation/native errors unless explicitly noted. The caller must eventually dispose the model; garbage collection does not free the native instance and undisposed models leak Wasm memory. Prefer Highs.withModel(), using, or try/finally with dispose(). Returned strings and typed arrays remain usable after disposal. Value-returning methods record a native warning in lastCall when they do not return metadata directly.

    interface Model {
        disposed: boolean;
        info: InfoStore;
        lastCall: CallMetadata;
        options: OptionStore;
        raw: SymbolDisposable<RawModelApi>;
        addCol(
            cost: number,
            lower: number,
            upper: number,
            entries: SparseEntriesInput,
        ): CallMetadata;
        addCols(data: Omit<ColumnData, "count">): CallMetadata;
        addLinearObjective(objective: LinearObjectiveInput): CallMetadata;
        addRow(
            lower: number,
            upper: number,
            entries: SparseEntriesInput,
        ): CallMetadata;
        addRows(data: Omit<RowData, "count">): CallMetadata;
        addVar(lower: number, upper: number): CallMetadata;
        addVars(lower: NumberInput, upper: NumberInput): CallMetadata;
        changeCoefficient(row: number, col: number, value: number): CallMetadata;
        changeColBounds(index: number, lower: number, upper: number): CallMetadata;
        changeColCost(index: number, cost: number): CallMetadata;
        changeColIntegrality(index: number, type: VariableType): CallMetadata;
        changeColsBounds(
            selection: IndexSelection,
            lower: NumberInput,
            upper: NumberInput,
        ): CallMetadata;
        changeColsCost(selection: IndexSelection, costs: NumberInput): CallMetadata;
        changeColsIntegrality(
            selection: IndexSelection,
            types: Int32Array<ArrayBufferLike> | readonly VariableType[],
        ): CallMetadata;
        changeObjectiveOffset(offset: number): CallMetadata;
        changeObjectiveSense(sense: ObjectiveSense): CallMetadata;
        changeRowBounds(index: number, lower: number, upper: number): CallMetadata;
        changeRowsBounds(
            selection: IndexSelection,
            lower: NumberInput,
            upper: NumberInput,
        ): CallMetadata;
        clear(): CallMetadata;
        clearIntegrality(): CallMetadata;
        clearLinearObjectives(): CallMetadata;
        clearModel(): CallMetadata;
        clearSolver(): CallMetadata;
        crossover(input: SolutionInput): CallMetadata;
        deleteCols(selection: IndexSelection): CallMetadata;
        deleteRows(selection: IndexSelection): CallMetadata;
        dispose(): void;
        ensureColwise(): CallMetadata;
        ensureRowwise(): CallMetadata;
        exportModel(format: "lp"): string;
        exportModel(format: "mps"): Uint8Array;
        exportPresolvedModel(format: "lp"): string;
        exportPresolvedModel(format: "mps"): Uint8Array;
        exportSolution(pretty?: false): string;
        exportSolution(pretty: true): string;
        feasibilityRelaxation(input: FeasibilityRelaxationInput): CallMetadata;
        getBasicVariables(): Int32Array;
        getBasis(): Basis;
        getBasisInverseCol(col: number, sparse?: boolean): NumericVector;
        getBasisInverseRow(row: number, sparse?: boolean): NumericVector;
        getBasisSolve(rhs: NumberInput, sparse?: boolean): NumericVector;
        getBasisTransposeSolve(rhs: NumberInput, sparse?: boolean): NumericVector;
        getColByName(name: string): number;
        getColIntegrality(index: number): VariableType;
        getColName(index: number): string;
        getCols(selection: IndexSelection): ColumnData;
        getDimensions(): ModelDimensions;
        getDualRay(): NumericVector | undefined;
        getDualUnboundednessDirection(): NumericVector | undefined;
        getFixedLp(format?: MatrixFormat): DetachedModelData;
        getIis(): IisResult;
        getIisLp(format?: MatrixFormat): DetachedModelData;
        getLp(format?: MatrixFormat): DetachedModelData;
        getModel(format?: MatrixFormat): DetachedModelData;
        getModelStatus(): ModelStatusCode;
        getObjectiveOffset(): number;
        getObjectiveSense(): ObjectiveSense;
        getObjectiveValue(): number;
        getPresolvedColName(index: number): string;
        getPresolvedDimensions(): PresolvedDimensions;
        getPresolvedLp(format?: MatrixFormat): DetachedModelData;
        getPresolvedRowName(index: number): string;
        getPrimalRay(): NumericVector | undefined;
        getRanging(): RangingResult;
        getReducedColumn(col: number, sparse?: boolean): NumericVector;
        getReducedRow(row: number, sparse?: boolean): NumericVector;
        getRowByName(name: string): number;
        getRowName(index: number): string;
        getRows(selection: IndexSelection): RowData;
        getRunTime(): number;
        getSolution(): Solution;
        passColName(index: number, name: string): CallMetadata;
        passHessian(hessian: HessianInput): CallMetadata;
        passLinearObjectives(
            objectives: readonly LinearObjectiveInput[],
        ): CallMetadata;
        passModel(model: ModelData): CallMetadata;
        passModelName(name: string): CallMetadata;
        passRowName(index: number, name: string): CallMetadata;
        postsolve(input: PostsolveInput): CallMetadata;
        presolve(): CallMetadata;
        readModel(source: EncodedModel): CallMetadata;
        releaseMemory(): CallMetadata;
        run(callbacks?: HighsCallbackMap): RunResult;
        scaleCol(index: number, factor: number): CallMetadata;
        scaleRow(index: number, factor: number): CallMetadata;
        setBasis(basis?: BasisInput): CallMetadata;
        setLogicalBasis(): CallMetadata;
        setSolution(solution: SolutionInput | SparseSolutionInput): CallMetadata;
        zeroAllClocks(): CallMetadata;
    }
    Index
    disposed: boolean

    Whether dispose() has destroyed the owned native instance.

    info: InfoStore

    Solve-information facade scoped to this instance.

    lastCall: CallMetadata

    Metadata from the most recent successful throwing-wrapper operation.

    options: OptionStore

    Option facade scoped to this instance.

    Status-preserving view of the same native instance; disposing either view disposes both.

    • Appends copied CSR rows. Lower/upper lengths are equal, matrix numRows equals that length, and matrix numCols equals current model columns.

      Parameters

      Returns CallMetadata

    • Inserts, changes, or removes (value === 0) one matrix coefficient.

      Parameters

      • row: number
      • col: number
      • value: number

      Returns CallMetadata

    • Changes lower and upper bounds of one zero-based column.

      Parameters

      • index: number
      • lower: number
      • upper: number

      Returns CallMetadata

    • Changes one zero-based column's linear objective coefficient.

      Parameters

      • index: number
      • cost: number

      Returns CallMetadata

    • Changes lower and upper bounds of one zero-based row.

      Parameters

      • index: number
      • lower: number
      • upper: number

      Returns CallMetadata

    • Destroys shared native ownership; idempotent and invalidates raw, options, and info.

      Returns void

    • Serializes the current model to detached LP text via private temporary storage.

      Parameters

      • format: "lp"

      Returns string

    • Serializes the current model to detached MPS bytes via private temporary storage.

      Parameters

      • format: "mps"

      Returns Uint8Array

    • Serializes the last presolved model to LP text; call presolve() first.

      Parameters

      • format: "lp"

      Returns string

    • Serializes the presolved model to detached MPS bytes; call presolve() first.

      Parameters

      • format: "mps"

      Returns Uint8Array

    • Serializes current solution state as machine-readable text.

      Parameters

      • Optionalpretty: false

      Returns string

    • Serializes human-readable solution text; unavailable primal, dual, or basis fields are represented by the native pretty writer rather than rejected.

      Parameters

      • pretty: true

      Returns string

    • Solves a feasibility relaxation synchronously, then restores the original model and prior model status. The relaxation solution and objective value remain available; negative penalties prohibit their corresponding violation, local vectors override globals, and the retained basis is invalidated.

      Parameters

      Returns CallMetadata

    • Returns one identifier per basis row: columns use their zero-based index and a row activity/slack uses exactly -rowIndex - 1.

      Returns Int32Array

    • Copies current basis-status buffers. Inspect basis_validity; a solved MIP or an interior-point solve without crossover need not have a valid basis.

      Returns Basis

    • Returns one of numRows columns of square B^-1; col is a basis-matrix index.

      Parameters

      • col: number
      • Optionalsparse: boolean

      Returns NumericVector

    • Returns one of numRows rows of square B^-1; output length is numRows.

      Parameters

      • row: number
      • Optionalsparse: boolean

      Returns NumericVector

    • Resolves an exact column name to a zero-based index.

      Parameters

      • name: string

      Returns number

    • Returns the name of a zero-based column; throws for invalid index/status.

      Parameters

      • index: number

      Returns string

    • Returns a dual direction certifying primal infeasibility, possibly after an LP solve.

      Returns NumericVector | undefined

    • Attempts to compute an infeasible subsystem for an LP/QP or MIP relaxation. It may run multiple blocking solves. Empty indices mean none was found; limited/warning results may be candidates rather than proved irreducible IISs.

      Returns IisResult

    • Returns the constant objective offset.

      Returns number

    • Returns current objective value; meaningful only when a primal solution exists.

      Returns number

    • Returns a presolved column name by zero-based presolved index.

      Parameters

      • index: number

      Returns string

    • Returns a presolved row name by zero-based presolved index.

      Parameters

      • index: number

      Returns string

    • Returns one original model column of B^-1 A; output length is numRows.

      Parameters

      • col: number
      • Optionalsparse: boolean

      Returns NumericVector

    • Returns one row of B^-1 A; output length is numCols.

      Parameters

      • row: number
      • Optionalsparse: boolean

      Returns NumericVector

    • Resolves an exact row name to a zero-based index.

      Parameters

      • name: string

      Returns number

    • Returns the name of a zero-based row.

      Parameters

      • index: number

      Returns string

    • Returns cumulative wall-clock seconds spent in solver runs since the last clock reset.

      Returns number

    • Copies current solution buffers when model state permits the native query. This is not an availability guarantee: inspect model status plus the primal_solution_status and dual_solution_status info values.

      Returns Solution

    • Maps values in the current presolved model's ordering back to original model space. Vector lengths must match getPresolvedDimensions() and model mutation may invalidate presolve state. Read the recovered values with getSolution().

      Parameters

      Returns CallMetadata

    • Clears model and solver state, releases retained vector capacity, and resets native clocks. The native instance and its options remain reusable.

      Returns CallMetadata

    • Runs synchronously to termination, callback interruption, or a configured limit. Put long browser solves in a Web Worker so this blocking call does not freeze the UI. Supplied handlers are active only for this call and are removed in finally.

      During a handler, only controls on that event are reentrant. Every model/raw method, including queries and callback registration, throws. Event data is detached and can be retained or posted to another thread after the handler.

      Parameters

      Returns RunResult

    • Applies variable substitution x[index] = factor * xNew[index]: matrix coefficients and cost are multiplied by factor, while variable bounds are divided by it and reordered when it is negative. factor must be nonzero.

      Parameters

      • index: number
      • factor: number

      Returns CallMetadata

    • Multiplies one row's coefficients and bounds by a nonzero factor, reordering bounds if negative.

      Parameters

      • index: number
      • factor: number

      Returns CallMetadata