3 ms·
If you have a problem where you need to find a solution that satisfies a set of constraints, or maximises it in some ways. Then you could use constraint solvers
by didibus 8y ago
If you have a problem where you need to find a solution that satisfies a set of constraints, or maximises it in some ways. Then you could use constraint solvers to do it.
Those are normally combinatorics related problems/solutions.
A sudoku is a good example of such a problem. You need to find a combination of numbers that satisfy the sudoku constraints.
In general, it is a search optimization. You have a finite set of possible solutions. In sudoku, that would be every combination of integers 1 to 9 given the set of empty squares in the grid.
You could loop over each possible combination, and try them one by one until you find one that satisfies the sudoku constraints (the rules of sudoku in this case). But, this is pretty slow, and generating the set of all combination on its own can be tricky.
A constraint solver helps you to do that, and possibly do it in a way that is smart about which combination it tries first, to arrive at a solution faster.
Generally, it requires some kind of language where you teach it the problem, and define the constraints, in a way that it can solve it for you.