public float VolitionValue(Name step, Name targ, Name mode, KB m_Kb) { if (m_Kb.Perspective == targ) { return(-1); } var targetSub = new Substitution(Target, new ComplexValue(targ)); var constraints = new SubstitutionSet(); constraints.AddSubstitution(targetSub); float total = Single.NegativeInfinity; // List<SubstitutionSet> resultingConstraints = new List<SubstitutionSet>(); if (step == this.Steps.FirstOrDefault()) { var resultingConstraints = StartingConditions.FirstOrDefault()?.Unify(m_Kb, m_Kb.Perspective, new[] { constraints }).ToList(); if (StartingConditions.Count() > 1) { int counter = 0; foreach (var c in StartingConditions) // For instance SI([x]) >= 40 { if (counter == 0) { continue; } resultingConstraints = c.Unify(m_Kb, m_Kb.Perspective, resultingConstraints).ToList(); // Whats the sub here [x]/John } } if (!resultingConstraints.Any()) { return(total); } foreach (var res in resultingConstraints) { if (resultingConstraints.Any()) // Assuming all Starting COnditions match lets go into the Influence Rules { foreach (var constraint in resultingConstraints) // var condition = c.ToString(); { var contraintVolitionValue = .0f; // var certainty = res.FindMinimumCertainty(); // How do I ask SI(John) >= 40 and get its certainty //total += certainty; List <InfluenceRule> influenceRuleList; if (mode.IsUniversal) { influenceRuleList = this.InfluenceRules; } else { influenceRuleList = this.InfluenceRules.FindAll(x => x.Mode == mode); } foreach (var inf in influenceRuleList) { var toSum = inf.EvaluateInfluenceRule(m_Kb, constraint); contraintVolitionValue += toSum; } if (contraintVolitionValue > total) { total = contraintVolitionValue; } } } } //What if the step is beyond the first one, we should not consider Starting Conditions, or any conditions at all, only the influence rules } else { var volVal = .0f; List <InfluenceRule> influenceRuleList; if (mode.IsUniversal) { influenceRuleList = this.InfluenceRules; } else { influenceRuleList = this.InfluenceRules.FindAll(x => x.Mode == mode); } foreach (var inf in influenceRuleList) { var toSum = inf.EvaluateInfluenceRule(m_Kb, constraints); volVal += toSum; } if (volVal > total) { total = volVal; } } return(total); }