Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom constraint OR-Tools // Constraint programming

I am working on a geometry problem with the OR-Tools constraint programming tools.

Could one of you tell me the procedure to create a custom constraint? I dont really understand demon, model visitor behavior...

Also, can any type of constraint be inserted?

Thank you in advance

like image 384
Ella Avatar asked Jan 08 '18 08:01

Ella


1 Answers

To write a constraint, you need to understand that during search, variables are not instantiated (domain is reduced to a single value). Therefore, calling Value() does not work.

You can access the current domain (min, max, list of possible values, and then you can write deduction rule from there).

See https://github.com/google/or-tools/blob/stable/examples/cpp/dobble_ls.cc.

Now, the CP solver is replaced by the CP-SAT solver, which does not allow writing custom constraints. In that case, maybe you can express you constraints with boolean logic, and arithmetic operators.

like image 172
Laurent Perron Avatar answered Oct 22 '22 19:10

Laurent Perron