2.8. Summary

This chapter helped you make your first steps with the CP solver. We used the Cryptarithmetic Puzzle Problem to illustrate the basic working of the solver. Basically, we saw how:

  • a mathematical model is designed (variables and constraints through factory methods);
  • the solver simplifies memory management (the solver takes ownership of (almost) all objects and deletes them when it doesn’t need them anymore);
  • the search is defined (through one (or more) DecisionBuilders);
  • the solving process is launched (NewSearch, NextSolution() and EndSearch() or Solve());
  • solution values are collected (through SolutionCollectors);
  • all or the best solution is collected (again through SolutionCollectors);
  • solutions are stored (through SolutionCollectors and Assigments);
  • parameters are passed to the solver (use of Google’s gflags on the command line, with a SolverParameters struct given to a solver and through SearchMonitors that guides the search).

These are the building blocks to use the CP solver. All these concepts were just touched and will be detailed with care in the next chapters.

Google or-tools
open source library

User's Manual

Google search



Tutorial examples

Current chapter

2. First steps with or-tools: cryptarithmetic puzzles

Previous section

2.7. Other supported languages

Next section

3. Using objectives in constraint programming: the Golomb Ruler Problem