protected override double GetProbability(BDDNode node, SamplingVector samplingVector, Dictionary <BDDNode, double> cache = null) { if (node.IsOne) { return(1.0); } if (node.IsZero) { return(0.0); } if (cache == null) { cache = new Dictionary <BDDNode, double> (); } else if (cache.TryGetValue(node, out double cached)) { return(cached); } if (_rmapping[node.Index] is GoalException exception) { var v = 0; double value = GetProbability(node.Low, samplingVector, cache) * (1 - v) + GetProbability(node.High, samplingVector, cache) * v; cache[node] = value; return(value); } else { return(base.GetProbability(node, samplingVector, cache)); } }
protected override double GetProbability(BDDNode node, SamplingVector samplingVector, Dictionary <BDDNode, double> cache = null) { if (node.IsOne) { return(1.0); } if (node.IsZero) { return(0.0); } if (cache == null) { cache = new Dictionary <BDDNode, double> (); } else if (cache.TryGetValue(node, out double cached)) { return(cached); } if (_rmapping[node.Index] is PrimitiveRefineeParameter <double> c) { double value = GetProbability(node.Low, samplingVector, cache) * (1 - c.Value) + GetProbability(node.High, samplingVector, cache) * c.Value; cache[node] = value; return(value); } else { return(base.GetProbability(node, samplingVector, cache)); } }
protected virtual double GetProbability(BDDNode node, SamplingVector samplingVector, Dictionary <BDDNode, double> cache = null) { if (node.IsOne) { return(1.0); } if (node.IsZero) { return(0.0); } if (cache == null) { cache = new Dictionary <BDDNode, double> (); } else if (cache.TryGetValue(node, out double cached)) { return(cached); } if (_rmapping[node.Index] is Obstacle obstacle) { //Console.WriteLine("Probability for " + obstacle.Identifier); //Console.WriteLine("Obstacle resolved: " + obstacle.Resolved); var v = samplingVector.ContainsKey(obstacle.Identifier) & !obstacle.Resolved ? samplingVector.Sample(obstacle) : 0; //Console.WriteLine(v); double value = GetProbability(node.Low, samplingVector, cache) * (1 - v) + GetProbability(node.High, samplingVector, cache) * v; cache[node] = value; return(value); } else if (_rmapping[node.Index] is DomainProperty domProp) { var v = samplingVector.ContainsKey(domProp.Identifier) ? samplingVector.Sample(domProp) : 0; double value = GetProbability(node.Low, samplingVector, cache) * (1 - v) + GetProbability(node.High, samplingVector, cache) * v; cache[node] = value; return(value); } else if (_rmapping[node.Index] is DomainHypothesis domHyp) { var v = samplingVector.ContainsKey(domHyp.Identifier) ? samplingVector.Sample(domHyp) : 0; double value = GetProbability(node.Low, samplingVector, cache) * (1 - v) + GetProbability(node.High, samplingVector, cache) * v; cache[node] = value; return(value); } else { throw new NotImplementedException("Type " + _rmapping[node.Index].GetType() + " is not yet supported."); } }
public virtual ISatisfactionRate GetESR(Goal goal) { ObstructionCaseSuperset os; if (!obstructionSupersets.ContainsKey(goal.Identifier)) { os = new ObstructionCaseSuperset(goal); } else { os = obstructionSupersets[goal.Identifier]; } var vector = new SamplingVector(_model); return(new DoubleSatisfactionRate(1.0 - os.GetProbability(vector))); }
public virtual ISatisfactionRate GetESR(Goal goal, IEnumerable <GoalException> activeResolutions) { ObstructionResolutionSuperset os; if (!obstructionSupersets.ContainsKey(goal.Identifier)) { os = new ObstructionResolutionSuperset(goal); } else { os = obstructionSupersets[goal.Identifier]; } var vector = new SamplingVector(_model); return(new DoubleSatisfactionRate(1.0 - os.GetProbability(vector, activeResolutions))); }
public ISatisfactionRate GetESR(Goal goal, IEnumerable <Obstacle> onlyObstacles) { ObstructionSuperset os; if (!obstructionSupersets.ContainsKey(goal.Identifier)) { os = new ObstructionSuperset(goal); } else { os = obstructionSupersets[goal.Identifier]; } var vector = new SamplingVector(_model, onlyObstacles?.Select(x => x.Identifier)?.ToHashSet()); var value = 1.0 - os.GetProbability(vector); return(new DoubleSatisfactionRate(value)); }
public virtual ISatisfactionRate GetESR(Goal goal) { ObstructionSuperset os; if (!obstructionSupersets.ContainsKey(goal.Identifier)) { //Console.WriteLine("Computing new OS for " + goal.Identifier); os = new ObstructionSuperset(goal); //Console.WriteLine("---"); //Console.WriteLine(os.ToDot()); //Console.WriteLine("---"); } else { os = obstructionSupersets[goal.Identifier]; } var vector = new SamplingVector(_model); double v = os.GetProbability(vector); //Console.WriteLine("Obstruction set probability: " + v); return(new DoubleSatisfactionRate(1.0 - v)); }
public virtual double GetProbability(SamplingVector samplingVector, IEnumerable <GoalException> activeExceptions) { return(GetProbability(_root, samplingVector, activeExceptions)); }
public virtual double GetProbability(SamplingVector samplingVector) { return(GetProbability(_root, samplingVector)); }