
aima.core.search.csp.CSP Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
package aima.core.search.csp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
/**
* Artificial Intelligence A Modern Approach (3rd Ed.): Section 6.1, Page 202.
*
* A constraint satisfaction problem or CSP consists of three components, X, D,
* and C:
*
* - X is a set of variables, {X1, ... ,Xn}.
* - D is a set of domains, {D1, ... ,Dn}, one for each variable.
* - C is a set of constraints that specify allowable combinations of values.
*
*
* @author Ruediger Lunde
*/
public class CSP {
private List variables;
private List domains;
private List constraints;
/** Lookup, which maps a variable to its index in the list of variables. */
private Hashtable varIndexHash;
/**
* Constraint network. Maps variables to those constraints in which they
* participate.
*/
private Hashtable> cnet;
private CSP() {
}
/** Creates a new CSP for a fixed set of variables. */
public CSP(List vars) {
variables = new ArrayList(vars.size());
domains = new ArrayList(vars.size());
constraints = new ArrayList();
varIndexHash = new Hashtable();
cnet = new Hashtable>();
Domain emptyDomain = new Domain(new ArrayList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy