Skip to main content

Function: problem2js()


problem2js(model: Model, params?: Parameters, warmStart?: Solution, log?: null | WritableStream): Promise<string | undefined>

Converts a problem into equivalent JavaScript code. The result is human readable.


modelModelThe model to be exported.
params?ParametersThe parameters to pass to the solver (they are included in the generated code).
warmStart?SolutionAn initial solution to start the solver with.
log?null | WritableStreamThe stream to which the solver output should be redirected.

When undefined then the output is printed to the standard output.

When null then the output is suppressed.


Promise<string | undefined>

A string containing the model in JavaScript format.


This function is experimental and the result is not guaranteed to be valid.

The result of this function can be stored in a file and executed using Node.js. It is meant as a way to export a model to a format that is executable, human readable, editable and independent of other libraries.

In case of an error this function returns a rejected promise.