Example #1
0
        public override IHsmModelHolder Select(List <int> sequence, List <IHsmModelHolder> models)
        {
            IDictionary <IHsmModelHolder, double> probabilitiesByModels = models.ToDictionary(m => m, m => {
                IProbabilityCalculator probabilityCalculator = probabilityCalculatorFactory.CreateProbabilityCalculator(m.Model, sequence);
                return(probabilityCalculator.Calculate());
            });

            return(selectionCriterion.Apply(probabilitiesByModels));
        }
        public override IHsmModelHolder Select(List <int> sequence, List <IHsmModelHolder> models)
        {
            IEnumerable <List <int> >             segments = splitList(sequence, segmentSize);
            IDictionary <IHsmModelHolder, double> probabilitiesByModels = models.ToDictionary(m => m, m => {
                List <double> probabilities = segments.Select(s =>
                {
                    IProbabilityCalculator probabilityCalculator = probabilityCalculatorFactory.CreateProbabilityCalculator(m.Model, s);
                    return(probabilityCalculator.Calculate());
                }).ToList();
                return(probabilities.Average());
            });

            return(selectionCriterion.Apply(probabilitiesByModels));
        }
Example #3
0
        public EvaluationResult Evaluate(string jsonModel, List <int> sequence)
        {
            IHsmModel  model     = _jsonModelFactory.CreateModel(jsonModel);
            IValidator validator = _validatorFactory.CreateModelValidator(model);

            validator.Validate();

            if (validator.HasErrors())
            {
                return(EvaluationResult.Failure(validator.GetErrors()));
            }

            IProbabilityCalculator probabilityCalculator = _probabilityCalculatorFactory.CreateProbabilityCalculator(model, sequence);

            return(EvaluationResult.Success(probabilityCalculator.Calculate()));
        }
Example #4
0
 public DiceController(
     IProbabilityCalculator probabilityCalculator)
 {
     _probabilityCalculator = probabilityCalculator;
 }