views:

167

answers:

1

I have to solve a CSP logic problem using Java Constraints Library. For now I've managed to represent some constraints of the problem, most of them are based on "equals" and "not equals" binary constraints. My doubt is, how to represent an addition based constraint? Example:

  • variable1 belongs to DomainA
  • variable2 belongs to DomainB
  • variable3 belongs to DomainA
  • variable4 belongs to DomainB

Now the constraint:

  • The sum of variable1 and variable2 is greater than the sum of variable3 and variable4.

Observation: these variables represent money, so they can be added.

+1  A: 

Since Java Constraint Library uses only unary or binary constraints, we have to do Binarization of Constraints in order to represent n-ary constraints. We can also inherit existing relations classes in the library and define new compatible relations.

fjsj