Documentation Roadmap
For installation instructions, see Installation.
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 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 variable values.
Parameters
Parameters can be used to configure the solving process (e.g., to set the search type or time limit). Parameters can also be parsed from command line arguments using the function parseParameters or parseSomeParameters.
Log
As the 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.
Benchmarking
The function benchmark can be used to measure the performance of the solver on the model (or multiple models), e.g., by running with multiple random seeds. The function returns a BenchmarkResult object containing the benchmark results. Benchmark can be configured using BenchmarkParameters object. Functions parseBenchmarkParameters and parseSomeBenchmarkParameters can be used to parse the parameters from command line arguments.
Model serialization and conversions
The model can be converted into multiple formats:
- Function problem2json can be used to serialize the model into JSON format. The resulting JSON can be used to create the Model again using the function json2problem.
- Function problem2txt can serialize the model into a human-readable text format similar to IBM CP Optimizer's file format. There is no guarantee, but often, the resulting file can be used as input to IBM CP Optimizer.
- The function problem2js can convert the model into JavaScript code.
Examples
You can find code and data for many benchmark problems in the public GitHub repository optalcp-benchmarks.