private MpiObjectiveScores CalculateCatchmentScores(CatchmentDefinition catchment, SerializableDictionary <string, MpiTimeSeries>[] cellResults, MpiSysConfig sysConfig, int cellCount)
        {
            LumpedCatchmentObjectivesDefinition objDef = SerializationHelper.XmlDeserialize <LumpedCatchmentObjectivesDefinition>(new FileInfo(ObjectiveDefinitionFileName));

            objDef.CatchmentIdentifier = catchment.Id;

            PointTimeSeriesSimulationDictionaryAdapter catchmentTimeSeriesAdapter = new PointTimeSeriesSimulationDictionaryAdapter(AverageCellTimeSeries(cellResults, cellCount));

            catchmentTimeSeriesAdapter.SetPeriod(catchment.Cells[0].ModelRunDefinition.StartDate, catchment.Cells[0].ModelRunDefinition.EndDate);
            IClonableObjectiveEvaluator <MpiSysConfig> catchmentScoreEvaluator = new CatchmentStatisticsEvaluator <ICloneableSimulation, MpiSysConfig>(
                catchmentTimeSeriesAdapter,
                objDef.BuildAnalysis(),
                objDef.GetMaximizable(),
                objDef.GetObjectiveNames());

            return(new MpiObjectiveScores(catchmentScoreEvaluator.EvaluateScore(sysConfig)));
        }
        private CatchmentStatisticsEvaluator <ICloneableSimulation, MpiSysConfig> GetCatchmentStatisticsEvaluator(
            CatchmentDefinition catchment,
            PointTimeSeriesSimulationDictionaryAdapter catchmentTimeSeriesAdapter)
        {
            CatchmentStatisticsEvaluator <ICloneableSimulation, MpiSysConfig> catchmentScoreEvaluator;

            CatchmentStatisticsEvaluatorCache.TryGetValue(catchment.Id, out catchmentScoreEvaluator);
            if (catchmentScoreEvaluator == null)
            {
                LumpedCatchmentObjectivesDefinition objDef =
                    SerializationHelper.XmlDeserialize <LumpedCatchmentObjectivesDefinition>(new FileInfo(ObjectiveDefinitionFileName));
                objDef.CatchmentIdentifier = catchment.Id;
                catchmentScoreEvaluator    = new CatchmentStatisticsEvaluator <ICloneableSimulation, MpiSysConfig>(
                    catchmentTimeSeriesAdapter,
                    objDef.BuildAnalysis(),
                    objDef.GetMaximizable(),
                    objDef.GetObjectiveNames());

                CatchmentStatisticsEvaluatorCache.Add(catchment.Id, catchmentScoreEvaluator);
            }

            return(catchmentScoreEvaluator);
        }