Sha256: df75a3acafe19d9dd40a159cd8ad1cd597023e696cb47983598af0d2ef874109
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
#!/usr/bin/ruby module ConstraintSolver # Represents a constraint. To be used as a guidance to see which methods # constraints need to implement. class AbstractConstraint # Checks whether the constraint holds for the current assignments of the # involved variables. def holds? raise RuntimeError, "must implement holds?" end # Checks whether all variables involved in the constraint have values # assigned to them. def allAssigned? raise RuntimeError, "must implement allAssigned?" end # Checks whether the constraint includes variable. def include?(variable) raise RuntimeError, "must implement include?(variable)" end # Iterates over all the variables involved in the constraint. def each raise RuntimeError, "must implement each" end # Prunes the values from the domains of the involved variables that # cannot be assigned to the respective variables because the constraint # would be violated. Returns a list of the variables whose domains were # pruned, the number of times the constraint was checked, and whether a # domain wipeout occured. def revise raise RuntimeError, "must implement revise" end # Returns the cost of violating the constraint. This should be infinity # (or reasonably close to it) for hard constraints and a positive number # for soft constraints. def violationCost raise RuntimeError, "must implement violationCost" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ConstraintSolver-0.1 | lib/AbstractConstraint.rb |