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)); }
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())); }
public DiceController( IProbabilityCalculator probabilityCalculator) { _probabilityCalculator = probabilityCalculator; }