public override int GetHashCode() { int hashCode = System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(this); if (Terms.Any()) { foreach (var term in Terms) { hashCode = Term.CombineHashCodes(hashCode, term.GetHashCode()); } } return(hashCode); }
internal bool MentionsAll(List <BoundVar> vars) { return(vars.All(x => Terms.Any(term => term.Variables.Contains(x)))); }
public bool IsTermsEmpty() => Terms == null || Terms.Any() == false;
public bool HasTerm(int id) => Terms.Any(a => a.Id == id);
public int ApplyDecomposition(Decomposition decomp) { var numUnBoundArgs = 0; subSteps = decomp.SubSteps; subOrderings = decomp.SubOrderings; subLinks = decomp.SubLinks; // For each variable term, find and substitute decomp term foreach (var term in Terms) { var decompTerm = decomp.Terms.FirstOrDefault(dterm => term.Variable.Equals(dterm.Variable)); if (decompTerm == null) { numUnBoundArgs++; // need to pick some object to substitute. Any will do. continue; } AddBinding(term.Variable, decompTerm.Constant); } // Check Equality Constraints if (!NonEqualTermsAreNonequal()) { return(-1); } // Also add bindings to Initial and Goal step. foreach (var effect in InitialStep.Effects) { foreach (var term in effect.Terms) { var compTerm = Terms.FirstOrDefault(cterm => term.Variable.Equals(cterm.Variable)); if (compTerm == null) { throw new System.Exception(); } term.Constant = compTerm.Constant; } } foreach (var precon in GoalStep.Preconditions) { foreach (var term in precon.Terms) { var compTerm = Terms.FirstOrDefault(cterm => term.Variable.Equals(cterm.Variable)); if (compTerm == null) { throw new System.Exception(); } term.Constant = compTerm.Constant; } } var unlistedDecompTerms = decomp.Terms.Where(dt => !Terms.Any(t => dt.Equals(t))); foreach (var udt in unlistedDecompTerms) { Terms.Add(udt); } //foreach(var substep in SubSteps) //{ // foreach(var precon in substep.Preconditions) // { // if (substep.OpenConditions.Contains(precon)) // { // if (InitialStep.Effects.Contains(precon)) // { // SubLinks.Add(new CausalLink<IPlanStep>(precon, InitialStep, substep)); // } // } // } //} return(numUnBoundArgs); }