示例#1
0
        private bool Revise(Variable xi, Variable xj, IConstraint constraint,
                            CSProblem csp, DomainRestoreInfo info)
        {
            bool revised    = false;
            var  assignment = new Assignment();

            foreach (object vValue in csp.GetDomain(xi))
            {
                assignment.SetAssignment(xi, vValue);
                bool vValueOk = false;
                foreach (var nValue in csp.GetDomain(xj))
                {
                    assignment.SetAssignment(xj, nValue);
                    if (constraint.IsSatisfiedWith(assignment))
                    {
                        vValueOk = true;
                        break;
                    }
                }
                if (!vValueOk)
                {
                    info.StoreDomainFor(xi, csp.GetDomain(xi));
                    csp.RemoveValueFromDomain(xi, vValue);
                    revised = true;
                }
            }
            return(revised);
        }
示例#2
0
        private bool Revise(Variable var, IConstraint constraint,
                            Assignment assignment, CSProblem csp, DomainRestoreInfo info)
        {
            bool revised = false;

            foreach (object value in csp.GetDomain(var))
            {
                assignment.SetAssignment(var, value);
                if (!constraint.IsSatisfiedWith(assignment))
                {
                    info.StoreDomainFor(var, csp.GetDomain(var));
                    csp.RemoveValueFromDomain(var, value);
                    revised = true;
                }
                assignment.RemoveAssignment(var);
            }
            return(revised);
        }
示例#3
0
        private bool Revise(Var var, IConstraint <Var, Val> constraint, Assignment <Var, Val> assignment,
                            CSP <Var, Val> csp, DomainLog <Var, Val> log)
        {
            bool revised = false;

            foreach (var value in csp.GetDomain(var))
            {
                assignment.Add(var, value);
                if (!constraint.IsSatisfiedWith(assignment))
                {
                    log.StoreDomainFor(var, csp.GetDomain(var));
                    csp.RemoveValueFromDomain(var, value);
                    revised = true;
                }
                assignment.Remove(var);
            }

            return(revised);
        }