Skip to main content

Documentation Roadmap

Setting up

Modeling the problem

The first step in using OptalCP is to model the problem. The central class for modeling is Model. The model is created by calling new Model(). All modeling is done using the functions of this class. See Model for a list of available modeling expressions and constraints and also for an example.

Solving the problem

Once the model is built, it can be solved by calling the function solve. Alternatively, the class Solver can be used to interact with the solver in more detail.

The result of the solving process is a SolveResult object. It contains the Solution object and also some statistics about the solving process.

Note that in the evaluation version of OptalCP, the Solution hides values of variables.


Parameters can be used to configure the solve process (e.g. to set the search type or time limit). Parameters can be also parsed from command line arguments using the function parseParameters or parseSomeParameters.


As solving process may take a while, the solver periodically prints information about the solving process on standard output. The log can be configured using Parameters or redirected to a stream.


The function benchmark can be used to measure the performance of the solver on the model (or multiple models), e.g. by running using multiple random seeds. The function returns a BenchmarkResult object that contains the results of the benchmark. Benchmark can be configured using BenchmarkParameters object. Functions parseBenchmarkParameters and parseSomeBenchmarkParameters can be used to parse the parameters from command line arguments.


Instead of solving the model, it is also possible to only propagate the constraints by calling propagate. The function returns a PropagationResult object that contains variable domains after propagation and also some statistics about the propagation.

Model serialization and conversions

The model can be converted into multiple formats:

  • Function model2json can be used to serialize the model into JSON format. The resulting JSON can be used to create the Model again using the function json2model.
  • Function model2txt can be used to serialize the model into a human-readable text format which is similar to the file format of IBM CP Optimizer. There is no guarantee, but often the resulting file can be used as input to IBM CP Optimizer.
  • Function model2js can be used to convert the model into JavaScript code.