CSP<V, D> class
An instance of a constraint satisfaction problem.
A CSP framework is modeled as a set of variables that can be assigned within a range called a domain.
var doug = Guest('Doug', dislikes: ['artichoke']);
var patrick = Guest('Patrick', dislikes: ['bananas']);
var susan = Guest('Susan', dislikes: ['broccoli']);
var variables = [doug, patrick, susan];
var meals = ['artichoke', 'bananas', 'broccoli'];
var domains = {
doug: meals,
patrick: meals,
susan: meals,
};
var csp = CSP<Guest, String>(variables, domains);
csp.addConstraint(AvoidDislikes(variables));
var result = csp.backtrackingSearch();
print(result);
Constructors
Properties
-
constraints
→ Map<
V, List< Constraint< >V, D> > -
final
-
domains
→ Map<
V, List< D> > -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
variables
→ List<
V> -
final
Methods
-
addConstraint(
Constraint< V, D> constraint) → void - Adds a constraint to be used when finding a solution.
-
backtrackingSearch(
[Map< V, D> assignment = const {}]) → Map<V, D> ? - Runs a recursive backtracking search for a solution that satisfies all of the constraints. The constraints are satisfied when isConsistent returns true.
-
isConsistent(
V variable, Map< V, D> assignment) → bool - Checks whether the value assignment is consistent by checking it against all constraints for the given variable.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited