public IEnumerable <Var> Apply(CSP <Var, Val> csp, IEnumerable <Var> vars) { var result = new List <Var>(); var maxDegree = -1; foreach (var var in vars) { var degree = csp.GetConstraints(var).Count(); if (degree > maxDegree) { result.Clear(); maxDegree = degree; } if (degree == maxDegree) { result.Add(var); } } return(result); }
public virtual IEnumerable <Var> Apply(CSP <Var, Val> csp, IEnumerable <Var> vars) { var result = new List <Var>(); var minValues = int.MaxValue; foreach (var var in vars) { var values = csp.GetDomain(var).Count(); if (values < minValues) { result.Clear(); minValues = values; } if (values == minValues) { result.Add(var); } } return(result); }
public bool IsSolution(CSP <Var, Val> csp) { return(IsConsistent(csp.Constraints) && IsComplete(csp.Variables)); }
private IInferenceLog <Var, Val> Inference(CSP <Var, Val> csp, Assignment <Var, Val> assignment, Var var) { return((InferenceStrategy != null) ? InferenceStrategy.Apply(csp, assignment, var) : new EmptyLog <Var, Val>()); }
private IEnumerable <Val> OrderDomainValues(CSP <Var, Val> csp, Assignment <Var, Val> assignment, Var var) { return((ValueOrderingStrategy != null) ? ValueOrderingStrategy.Apply(csp, assignment, var) : csp.GetDomain(var)); }
public override IEnumerable <Var> Apply(CSP <Var, Val> csp, IEnumerable <Var> vars) { return(_deg.Apply(csp, _mrv.Apply(csp, vars))); }
public static IVariableSelectionStrategy <Var, Val> MrvDeg <Var, Val>(CSP <Var, Val> csp, List <Var> vars) where Var : Variable { return(new MrvDegHeuristic <Var, Val>()); }