Sat 27 May 2006
Constraint Based Development
Posted by dkaz under Math, Programming, Process
My current work assignment feels a bit like a Sudoku puzzle - as additional functional and technical requirements trickle in, I’m forced to go back to the drawing board on parts of my solution. Check out Wikipedia’s definition of Constraint Satisfaction Problems to see where I’m coming from:
Constraint satisfaction problems or CSPs are mathematical problems where one must find states or objects that satisfy a number of constraints or criteria. CSPs are the subject of intense research in both artificial intelligence and operations research. Many CSPs require a combination of heuristics and combinatorial search methods to be solved in a reasonable time.
Examples of constraint satisfaction problems:
* Eight queens puzzle
* Map coloring problem
* Sudoku
* Boolean satisfiability
I’ve also studyied up Wikipedia’s definition of Backtracking for further inspiration:
Essentially, the idea [of Backtracking] is to try each possibility until you get the right one. It is a depth-first search of the set of solutions. During the search, if you try an alternative that doesn’t work, you backtrack to the choice point, the place which presented you with different alternatives, and you try the next alternative. When you have exhausted the alternatives, you return to the previous choice point and try the next alternative there. If there are no more choice points, the search fails .
This is usually achieved in a recursive function whereby each instance takes one more variable and alternatively assigns all the available values to it, keeping the one that is consistent with subsequent recursive calls. Backtracking is similar to a depth-first search but uses even less space, keeping just one current solution state and updating it.
In order to speed up the search, when a value is selected, before making the recursive call, the algorithm either deletes that value from conflicting unassigned domains (forward checking) or checks all the constraints to see what other values this newly-assigned value excludes (constraint propagation).
Several heuristics are common to speed up the process. Because the variables can be processed in any order, it is generally efficient to try the most constrained ones first (i.e. the ones with fewest value options) as this prunes the search tree early (maximizes the impact of the current early choice).
Of particular interest here is the last sentence - start where things are MOST DEFINED.

August 6th, 2007 at 11:06 am
I have to say, that I could not agree with you in 100% regarding , but it’s just my opinion, which could be wrong