public setDomain ( |
||
var | ||
domain | Domain | |
return | void |
public void restoreDomains(CSP csp) { foreach (Pair <Variable, Domain> pair in getSavedDomains()) { csp.setDomain(pair.getFirst(), pair.getSecond()); } }
/** * Reduces the domain of the specified variable to the specified * value and reestablishes arc-consistency. It is assumed that the * provided CSP is arc-consistent before the call. * @return An object which indicates success/failure and contains * data to undo the operation. */ public DomainRestoreInfo reduceDomains(Variable var, Object value, CSP csp) { DomainRestoreInfo result = new DomainRestoreInfo(); Domain domain = csp.getDomain(var); if (domain.contains(value)) { if (domain.Count > 1) { FIFOQueue<Variable> queue = new FIFOQueue<Variable>(); queue.Add(var); result.storeDomainFor(var, domain); csp.setDomain(var, new Domain(new Object[] { value })); reduceDomains(queue, csp, result); } } else { result.setEmptyDomainFound(true); } return result.compactify(); }
/** * Reduces the domain of the specified variable to the specified * value and reestablishes arc-consistency. It is assumed that the * provided CSP is arc-consistent before the call. * @return An object which indicates success/failure and contains * data to undo the operation. */ public DomainRestoreInfo reduceDomains(Variable var, Object value, CSP csp) { DomainRestoreInfo result = new DomainRestoreInfo(); Domain domain = csp.getDomain(var); if (domain.contains(value)) { if (domain.Count > 1) { FIFOQueue <Variable> queue = new FIFOQueue <Variable>(); queue.Add(var); result.storeDomainFor(var, domain); csp.setDomain(var, new Domain(new Object[] { value })); reduceDomains(queue, csp, result); } } else { result.setEmptyDomainFound(true); } return(result.compactify()); }
public void restoreDomains(CSP csp) { foreach (Pair<Variable, Domain> pair in getSavedDomains()) csp.setDomain(pair.getFirst(), pair.getSecond()); }