Method: ConstraintSolver::AllDifferentConstraint#initialize

Defined in:
lib/AllDifferentConstraint.rb

#initialize(variables, violationCost = 1) ⇒ AllDifferentConstraint

Initialises a new all different constraint. The constructor takes the list of variables that must be different as an argument. Optionally, a cost for violating the constraint can be specified.



16
17
18
19
20
21
22
# File 'lib/AllDifferentConstraint.rb', line 16

def initialize(variables, violationCost=1)
    if variables.empty? or variables.size == 1
  raise ArgumentError, "List of variables must contain at least two elements!"
    end
    @variables = variables
    @violationCost = violationCost
end