Exemplo n.º 1
0
 ISatisfactionRate GetESR(GoalRefinement goalRefinement)
 {
     if (goalRefinement.RefinementPattern == RefinementPattern.Milestone
         | goalRefinement.RefinementPattern == RefinementPattern.IntroduceGuard
         | goalRefinement.RefinementPattern == RefinementPattern.DivideAndConquer
         | goalRefinement.RefinementPattern == RefinementPattern.Unmonitorability
         | goalRefinement.RefinementPattern == RefinementPattern.Uncontrollability)
     {
         var subGoalSR = ComputeProductRefineeSatisfactionRate(goalRefinement.SubGoalIdentifiers,
                                                               x => GetESR(_model.Goal(x)));
         var domPropSR = ComputeProductRefineeSatisfactionRate(goalRefinement.DomainPropertyIdentifiers,
                                                               x => GetESR(_model.DomainProperty(x)));
         var domHypSR = ComputeProductRefineeSatisfactionRate(goalRefinement.DomainHypothesisIdentifiers,
                                                              x => GetESR(_model.DomainHypothesis(x)));
         return(subGoalSR.Product(domPropSR).Product(domHypSR));
     }
     else if (goalRefinement.RefinementPattern == RefinementPattern.Case)
     {
         var subGoalSR = ComputeRefineeSatisfactionRate(goalRefinement.SubGoalIdentifiers,
                                                        x => GetESR(_model.Goal(x)));
         var domPropSR = ComputeRefineeSatisfactionRate(goalRefinement.DomainPropertyIdentifiers,
                                                        x => GetESR(_model.DomainProperty(x)));
         var domHypSR = ComputeRefineeSatisfactionRate(goalRefinement.DomainHypothesisIdentifiers,
                                                       x => GetESR(_model.DomainHypothesis(x)));
         return((DoubleSatisfactionRate)subGoalSR.Sum(domPropSR).Sum(domHypSR));
     }
     else
     {
         throw new PropagationException(PropagationException.PATTERN_NOT_SUPPORTED + $" ({goalRefinement.RefinementPattern})");
     }
 }