Ejemplo n.º 1
0
        public IParameterValueCache CreatePopulation(PopulationSettings matlabPopulationSettings, IEnumerable <MoleculeOntogeny> moleculeOntogenies)
        {
            var populationSettings = _populationSettingsMapper.MapFrom(matlabPopulationSettings);
            var population         = _randomPopulationFactory.CreateFor(populationSettings, new CancellationToken()).Result;

            foreach (var moleculeOntogeny in moleculeOntogenies)
            {
                var allOntogeniesForSpecies = _ontogenyRepository.AllFor(matlabPopulationSettings.Individual.OriginData.Species).ToList();
                if (!allOntogeniesForSpecies.Any())
                {
                    continue;
                }

                var ontogeny = allOntogeniesForSpecies.FindByName(moleculeOntogeny.Ontogeny);
                if (ontogeny == null)
                {
                    continue;
                }

                var molecule = _individualEnzymeFactory.CreateEmpty().WithName(moleculeOntogeny.Molecule);
                molecule.Ontogeny = ontogeny;

                population.AddMolecule(molecule);
            }

            _ontogenyVariabilityUpdater.UpdateAllOntogenies(population);

            return(population.IndividualPropertiesCache);
        }
Ejemplo n.º 2
0
        public IParameterValueCache CreatePopulation(PopulationSettings matlabPopulationSettings, IEnumerable <string> moleculeNames)
        {
            var populationSettings = _populationSettingsMapper.MapFrom(matlabPopulationSettings);
            var population         = _randomPopulationFactory.CreateFor(populationSettings, new CancellationToken()).Result;

            return(population.IndividualPropertiesCache);
        }
        public CreatePopulationResults CreatePopulation(PopulationCharacteristics populationCharacteristics)
        {
            var populationSettings = _populationSettingsMapper.MapToModel(populationCharacteristics, new SnapshotContext()).Result;

            validate(populationSettings);
            var population = _randomPopulationFactory.CreateFor(populationSettings, new CancellationToken(), seed: populationCharacteristics.Seed).Result;

            foreach (var moleculeOntogeny in populationCharacteristics.MoleculeOntogenies)
            {
                var allOntogeniesForSpecies = _ontogenyRepository.AllFor(populationCharacteristics.Individual.OriginData.Species);
                if (!allOntogeniesForSpecies.Any())
                {
                    continue;
                }

                var ontogeny = allOntogeniesForSpecies.FindByName(moleculeOntogeny.Ontogeny);
                if (ontogeny == null)
                {
                    continue;
                }

                var molecule = _individualEnzymeFactory.CreateEmpty().WithName(moleculeOntogeny.Molecule);
                molecule.Ontogeny = ontogeny;

                population.AddMolecule(molecule);
            }

            _ontogenyVariabilityUpdater.UpdateAllOntogenies(population);

            return(new CreatePopulationResults(population.IndividualValuesCache, population.Seed));
        }
        public override async Task <ModelPopulation> MapToModel(SnapshotPopulation snapshot, SnapshotContext snapshotContext)
        {
            var randomPopulationSettings = await _randomPopulationSettingsMapper.MapToModel(snapshot.Settings, snapshotContext);

            //Do not add default molecule variability as this will be loaded from snapshot
            var population = await _randomPopulationFactory.CreateFor(randomPopulationSettings, CancellationToken.None, snapshot.Seed, addMoleculeParametersVariability : false);

            MapSnapshotPropertiesToModel(snapshot, population);
            await _advancedParameterMapper.MapToModel(snapshot.AdvancedParameters, population, snapshotContext);

            return(population);
        }
Ejemplo n.º 5
0
        public async void CreatePopulation()
        {
            _view.CreatingPopulation = true;
            _cancelationTokenSource  = new CancellationTokenSource();
            try
            {
                Population = await _randomPopulationFactory.CreateFor(_populationSettingsMapper.MapFrom(_populationSettingsDTO), _cancelationTokenSource.Token);

                PopulationCreated = true;
                raisePopulationCreationFinish(success: true);
            }
            catch (OperationCanceledException)
            {
                raisePopulationCreationFinish(success: false);
            }
            finally
            {
                _view.CreatingPopulation = false;
            }
        }