Skip to main content

Function: solve

solve(model, params?, warmStart?, log?): Promise<SolveResult>

Solve the provided model and return the result.


modelModelThe model to solve.
params?ParametersThe parameters to use for solving.
warmStart?SolutionThe solution to start with.
log?null | WritableStreamThe stream to which the solver output (log, trace and warnings) should be redirected. When undefined then the output is printed on standard output. When null then the output is suppressed.



The result of the solve.


This function is asynchronous and returns a promise. Use e.g. await to wait for the result. When an error occurs then the returned promise is rejected and standard Error object is returned.

If warmStart parameter is specified then the solver will start with the given solution. The solution must be compatible with the model otherwise an error is raised. The solver will take advantage of the solution to speed up the search: it will search only for better solutions (if it is a minimization or maximization problem). The solver may also try to improve the provided solution by Large Neighborhood Search.

To communicate asynchronously with the solver use class Solver instead. E.g. to process every solution found, or to send external solutions to the solver

For an example of using this function see Model.