Пример #1
0
        public void Compute(IMoBiSimulation simulation)
        {
            var buildConfiguration = _buildConfigurationFactory.CreateFromReferencesUsedIn(simulation.MoBiBuildConfiguration);

            buildConfiguration.ShowProgress = false;

            _logger.AddDebug("Creating new simulation from loaded building blocks");
            var results = _modelConstructor.CreateModelFrom(buildConfiguration, "BatchRun");

            if (results.IsInvalid)
            {
                _logger.AddWarning(results.ValidationResult.Messages.SelectMany(x => x.Details).ToString());
            }

            var newSimulation = new MoBiSimulation
            {
                BuildConfiguration = buildConfiguration,
                Model = results.Model,
                Id    = "Sim"
            };

            _context.Register(newSimulation);
            _logger.AddDebug("Running simulation");
            _simModelManager.RunSimulation(newSimulation);
        }
        public void FormulaParameter_InitialAssignmentCreationTest()
        {
            var simulation = _simulationFactory.Create();

            simulation.MoBiBuildConfiguration.SimulationSettings   = _simulationSettingsFactory.CreateDefault();
            simulation.MoBiBuildConfiguration.Observers            = IoC.Resolve <IMoBiContext>().Create <IObserverBuildingBlock>();
            simulation.MoBiBuildConfiguration.SpatialStructure     = _moBiProject.SpatialStructureCollection.FirstOrDefault();
            simulation.MoBiBuildConfiguration.ParameterStartValues = _moBiProject.ParametersStartValueBlockCollection.FirstOrDefault();
            simulation.MoBiBuildConfiguration.Reactions            = _moBiProject.ReactionBlockCollection.FirstOrDefault();
            simulation.MoBiBuildConfiguration.Molecules            = _moBiProject.MoleculeBlockCollection.FirstOrDefault();
            simulation.MoBiBuildConfiguration.PassiveTransports    = _moBiProject.PassiveTransportCollection.FirstOrDefault();
            simulation.MoBiBuildConfiguration.MoleculeStartValues  = _moBiProject.MoleculeStartValueBlockCollection.FirstOrDefault();
            simulation.MoBiBuildConfiguration.EventGroups          = _moBiProject.EventBlockCollection.FirstOrDefault();
            var buildConfiguration = _buildConfigurationFactory.CreateFromReferencesUsedIn(simulation.MoBiBuildConfiguration);
            var name   = Guid.NewGuid().ToString();
            var result = _modelConstructor.CreateModelFrom(buildConfiguration, name);

            result.State.ShouldBeEqualTo(ValidationState.Valid);
        }
Пример #3
0
 private IMoBiBuildConfiguration createBuildConfigurationUsingTemplates(IMoBiSimulation simulation, IBuildingBlock templateBuildingBlock)
 {
     return(_buildConfigurationFactory.CreateFromReferencesUsedIn(simulation.MoBiBuildConfiguration, templateBuildingBlock));
 }