compactify() public method

public compactify ( ) : DomainRestoreInfo
return DomainRestoreInfo
Example #1
0
 /** 
  * Makes a CSP consisting of binary constraints arc-consistent.
  * @return An object which indicates success/failure and contains
  * data to undo the operation.
  */
 public DomainRestoreInfo reduceDomains(CSP csp)
 {
     DomainRestoreInfo result = new DomainRestoreInfo();
     FIFOQueue<Variable> queue = new FIFOQueue<Variable>();
     foreach (Variable var in csp.getVariables())
         queue.Add(var);
     reduceDomains(queue, csp, result);
     return result.compactify();
 }
Example #2
0
        /**
         * Makes a CSP consisting of binary constraints arc-consistent.
         * @return An object which indicates success/failure and contains
         * data to undo the operation.
         */
        public DomainRestoreInfo reduceDomains(CSP csp)
        {
            DomainRestoreInfo    result = new DomainRestoreInfo();
            FIFOQueue <Variable> queue  = new FIFOQueue <Variable>();

            foreach (Variable var in csp.getVariables())
            {
                queue.Add(var);
            }
            reduceDomains(queue, csp, result);
            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
 /** 
  * 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();
 }