Skip to main content

Type Alias: SolveResult

SolveResult = { actualWorkers: number; boundTime?: number; cpu: string; duration: number; memoryUsed: number; nbBranches: number; nbConstraints: number; nbFails: number; nbIntervalVars: number; nbIntVars: number; nbLNSSteps: number; nbRestarts: number; nbSolutions: number; objective?: ObjectiveValue; objectiveBound?: ObjectiveValue; objectiveBoundHistory: ObjectiveBoundEntry[]; objectiveHistory: ObjectiveEntry[]; objectiveSense: "minimize" | "maximize" | undefined; proof: boolean; solution?: Solution; solutionTime?: number; solutionValid?: true; solver: string; }

Holds the solution, objective, statistics, and solve status after solving.

Remarks​

The result returned by Model.solve or Solver.solve.

Contains comprehensive information about the solve:

Solution data:

Solve statistics:

History tracking:

Example​

import * as CP from "optalcp";

const model = new CP.Model();
// ... build model ...

const result = await model.solve();

if (result.solution !== undefined) {
console.log(`Found solution with objective ${result.objective}`);
console.log(`Best solution found at ${result.solutionTime.toFixed(2)}s`);
if (result.proof) {
console.log("Solution is optimal!");
}
} else {
if (result.proof) {
console.log("Problem is infeasible");
} else {
console.log("No solution found within time limit");
}
}

Properties​

actualWorkers​

actualWorkers: number

Number of worker threads actually used during solving.

Returns​

Worker count.

Remarks​

This is the actual number of workers used by the solver, which may differ from the requested Parameters.nbWorkers if that parameter was not specified (auto-detect) or if the system has fewer cores than requested.


boundTime?​

optional boundTime?: number

Time of the last objective bound improvement.

Returns​

The time in seconds, or None if no bound was proved.

Remarks​

The time is measured from the start of the solve, in seconds.

Returns None when no bound was proved during the solve.


cpu​

cpu: string

CPU name detected by the solver.

Returns​

CPU model name.

Remarks​

Contains the CPU model name as detected by the operating system.


duration​

duration: number

Total duration of the solve in seconds.

Returns​

Seconds elapsed.


memoryUsed​

memoryUsed: number

Memory used by the solver in bytes.

Returns​

Bytes used.


nbBranches​

nbBranches: number

Total number of branches explored during the solve.

Returns​

Branch count.


nbConstraints​

nbConstraints: number

Number of constraints in the model.

Returns​

Constraint count.


nbFails​

nbFails: number

Total number of failures encountered during the solve.

Returns​

Failure count.


nbIntervalVars​

nbIntervalVars: number

Number of interval variables in the model.

Returns​

Interval variable count.


nbIntVars​

nbIntVars: number

Number of integer variables in the model.

Returns​

Integer variable count.


nbLNSSteps​

nbLNSSteps: number

Total number of Large Neighborhood Search steps.

Returns​

LNS step count.


nbRestarts​

nbRestarts: number

Total number of restarts performed during the solve.

Returns​

Restart count.


nbSolutions​

nbSolutions: number

Number of solutions found during the solve.

Returns​

Solution count.


objective?​

optional objective?: ObjectiveValue

Best objective value found (for optimization problems).

Returns​

The objective value, or None if not applicable.

Remarks​

The value is None when:

  • No objective was specified in the model (no Model.minimize or Model.maximize call).
  • No solution was found.
  • The objective expression has an absent value in the best solution.

objectiveBound?​

optional objectiveBound?: ObjectiveValue

Proved bound on the objective value.

Returns​

The objective bound, or None if no bound was proved.

Remarks​

For minimization problems, this is a lower bound: the solver proved that no solution exists with an objective value less than this bound.

For maximization problems, this is an upper bound: the solver proved that no solution exists with an objective value greater than this bound.

The value is None when no bound was proved or for satisfaction problems.


objectiveBoundHistory​

objectiveBoundHistory: ObjectiveBoundEntry[]

History of objective bound improvements during the solve.

Returns​

Sequence of bound entries, one per bound improvement.

Remarks​

Returns a sequence of ObjectiveBoundEntry objects, one for each bound improvement proved during the solve.

Each entry contains:

For minimization problems, these are lower bounds. For maximization problems, these are upper bounds. The entries are ordered chronologically by solve time.


objectiveHistory​

objectiveHistory: ObjectiveEntry[]

History of objective value improvements during the solve.

Returns​

Sequence of objective entries, one per solution found.

Remarks​

Returns a sequence of ObjectiveEntry objects, one for each solution found during the solve.

Each entry contains:

The entries are ordered chronologically by solve time.


objectiveSense​

objectiveSense: "minimize" | "maximize" | undefined

Objective direction.

Returns​

'minimize', 'maximize', or None for satisfaction problems.

Remarks​

Indicates whether the model was a minimization problem, maximization problem, or a satisfaction problem (no objective).


proof​

proof: boolean

Whether the solve ended with a proof (optimality or infeasibility).

Returns​

True if the solve completed with a proof.

Remarks​

When True, the solver has either:

When False, the solve was interrupted (e.g., by time limit) before a proof could be established.


solution?​

optional solution?: Solution

The best solution found during the solve.

Returns​

The best solution, or None if no solution was found.

Remarks​

For optimization problems, this is the solution with the best objective value. For satisfaction problems, this is the last solution found.

Returns None when no solution was found (the problem may be infeasible or the solve was interrupted before finding any solution).


solutionTime?​

optional solutionTime?: number

Time when the best solution was found.

Returns​

The time in seconds, or None if no solution was found.

Remarks​

The time is measured from the start of the solve, in seconds.

Returns None when no solution was found.


solutionValid?​

optional solutionValid?: true

Whether the best solution was verified.

Returns​

True if verified, None if verification was not performed.

Remarks​

When parameter Parameters.verifySolutions is set to True (the default), the solver verifies all solutions found. The verification checks that all constraints in the model are satisfied and that the objective value is computed correctly.

Possible values:

  • None - verification was not performed (parameter was not set)
  • True - the solution was verified and correct

The value can never be False because, in that case, the solver would stop with an error.


solver​

solver: string

Solver name and version string.

Returns​

The solver identification string.

Remarks​

Contains the solver name followed by its version number.