setDomain() public method

public setDomain ( Variable var, Domain domain ) : void
var Variable
domain Domain
return void
Example #1
0
 public void restoreDomains(CSP csp)
 {
     foreach (Pair <Variable, Domain> pair in getSavedDomains())
     {
         csp.setDomain(pair.getFirst(), pair.getSecond());
     }
 }
Example #2
0
 /** 
  * 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();
 }
Example #3
0
        /**
         * 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());
        }
Example #4
0
 public void restoreDomains(CSP csp)
 {
     foreach (Pair<Variable, Domain> pair in getSavedDomains())
         csp.setDomain(pair.getFirst(), pair.getSecond());
 }