1. Introduction to constraint programming

In this chapter, we introduce Constraint Programming (CP) and the or-tools library and its core principles. We also present the content of this manual.


This chapter is divided in three parts. First, we introduce Constraint Programming by looking at an example of the solving process of our CP solver in the section The 4-Queens Problem. We give a brief definition of Constraint Programming in the section What is constraint programming? and show some practical problems where CP stands out in the section Real examples. Second, we lay some practical and theoretical foundations for the whole manual. A little bit of theory in the section A little bit of theory provides some theoretical backgrounds with interesting practical implications. If you don’t know how to tackle a problem, we introduce a (very) simple strategy (the three-stage method in the section The three-stage method: describe, model and solve) that can help you when confronted with a problem to solve. This method will be applied repeatedly in this manual. Another recurrent idea in this manual is to be aware of tradeoffs. This idea is the key to successful optimization and well worth the whole section It’s always a matter of tradeoffs. Finally, we outline the general principles of the library in the section The Google or-tools library and detail the content of this manual in the section The content of the manual.


  • None. Being open minded, relaxed and prepared to enjoy the or-tools library helps though.


Google or-tools
open source library

User's Manual

Google search



Tutorial examples


Part I: Basics
Part II: Customization
Part III: Routing
Part IV: Technicalities