private void addFavoriteParametersTo(ParameterIdentification parameterIdentification, ISimulation simulation)
        {
            var allParameters   = _entitiesInSimulationRetriever.ParametersFrom(simulation);
            var parametersToAdd = _favoriteRepository.All()
                                  .Select(path => allParameters[path])
                                  .Where(p => p != null);

            AddParametersTo(parameterIdentification, parametersToAdd);
        }
Пример #2
0
        public async Task <PopulationRunResults> RunPopulationAsync(IModelCoreSimulation simulation, RunOptions runOptions, DataTable populationData, DataTable agingData = null, DataTable initialValues = null)
        {
            try
            {
                var numberOfCoresToUse = runOptions.NumberOfCoresToUse;
                if (numberOfCoresToUse < 1)
                {
                    numberOfCoresToUse = 1;
                }

                _populationDataSplitter  = new PopulationDataSplitter(numberOfCoresToUse, populationData, agingData, initialValues);
                _cancellationTokenSource = new CancellationTokenSource();
                _populationRunResults    = new PopulationRunResults();

                _numberOfSimulationsToRun     = _populationDataSplitter.NumberOfIndividuals;
                _numberOfProcessedSimulations = 0;

                _simulationName = simulation.Name;
                _parameterCache = _entitiesInSimulationRetriever.ParametersFrom(simulation);

                //create simmodel-XML
                var simulationExport = await CreateSimulationExportAsync(simulation, SimModelExportMode.Optimized);

                //Starts one task per core
                var tasks = Enumerable.Range(0, numberOfCoresToUse)
                            .Select(coreIndex => runSimulation(coreIndex, simulationExport, _cancellationTokenSource.Token)).ToList();

                await Task.WhenAll(tasks);

                //all tasks are completed. Can return results

                _populationRunResults.SynchronizeResults();

                return(_populationRunResults);
            }
            finally
            {
                _populationRunResults   = null;
                _populationDataSplitter = null;
                _parameterCache         = null;
                RaiseTerminated(this, EventArgs.Empty);
            }
        }
        protected override void Context()
        {
            _entitiesInSimulationRetriever = A.Fake <IEntitiesInSimulationRetriever>();
            _view = A.Fake <ISimulationParametersView>();
            _simulationParameterSelectionDTOMapper = A.Fake <IQuantityToSimulationParameterSelectionDTOMapper>();
            _groupRepository   = A.Fake <IGroupRepository>();
            _parameterSelector = A.Fake <IParameterAnalysableParameterSelector>();

            sut = new SimulationParametersPresenter(_view, _entitiesInSimulationRetriever, _simulationParameterSelectionDTOMapper, _groupRepository, _parameterSelector);

            _allParameters           = new PathCacheForSpecs <IParameter>();
            _parameterIdentification = new ParameterIdentification();
            _simulation = A.Fake <ISimulation>();
            _parameterIdentification.AddSimulation(_simulation);
            A.CallTo(() => _entitiesInSimulationRetriever.ParametersFrom(_simulation, A <Func <IParameter, bool> > ._)).Returns(_allParameters);

            A.CallTo(() => _view.BindTo(A <IEnumerable <SimulationParameterSelectionDTO> > ._))
            .Invokes(x => _allQuantitySelectionDTO = x.GetArgument <IEnumerable <SimulationParameterSelectionDTO> >(0));
        }
 private void addSimulationParameters(ISimulation simulation)
 {
     _allParameterDTOs.AddRange(_entitiesInSimulationRetriever.ParametersFrom(simulation, parameterCanBeUsedInParameterAnalysable)
                                .Select(p => _simulationParameterSelectionDTOMapper.MapFrom(simulation, p)));
 }