Ejemplo n.º 1
0
        private void startSimulationRun(IMoBiSimulation simulation)
        {
            _simulation = simulation;
            _context.PublishEvent(new SimulationRunStartedEvent());
            _context.PublishEvent(new ProgressInitEvent(100, AppConstants.SimulationRun));
            _simModelManager = _simModelManagerFactory.Create();

            try
            {
                addEvents();
                updatePersistableFor(simulation);
                var results = _simModelManager.RunSimulation(_simulation);
                _simulation.HasChanged = true;
                showWarningsIfAny(results);

                if (results.Success)
                {
                    _displayUnitUpdater.UpdateDisplayUnitsIn(results.Results);
                    copyResultsToSimulation(results, _simulation);
                }

                addCommand(getSimulationResultLabel(results));
            }
            finally
            {
                removeEvents();
                _context.PublishEvent(new SimulationRunFinishedEvent(_simulation));
                _simulation = null;
            }
        }
Ejemplo n.º 2
0
 protected override void Context()
 {
     base.Context();
     _modelConstructor            = IoC.Resolve <IModelConstructor>();
     _simModelManager             = IoC.Resolve <ISimModelManager>();
     _context                     = IoC.Resolve <IMoBiContext>();
     _calculationMethodRepository = IoC.Resolve <ICoreCalculationMethodRepository>();
     _buildConfiguration          = createBuildConfiguration();
 }
Ejemplo n.º 3
0
 protected override void Context()
 {
     base.Context();
     _modelConstructor   = IoC.Resolve <IModelConstructor>();
     _simModelManager    = IoC.Resolve <ISimModelManager>();
     _buildConfiguration = IoC.Resolve <IBuildConfigurationFactory>().CreateFromReferencesUsedIn(_project.Simulations.Last().MoBiBuildConfiguration);
     _buildConfiguration.ShowProgress = false;
     _context = IoC.Resolve <IMoBiContext>();
 }
Ejemplo n.º 4
0
 public SimulationBatchRunner(IBatchLogger logger, IModelConstructor modelConstructor, IBuildConfigurationFactory buildConfigurationFactory,
                              IMoBiContext context, ISimModelManager simModelManager)
 {
     _logger                    = logger;
     _modelConstructor          = modelConstructor;
     _buildConfigurationFactory = buildConfigurationFactory;
     _context                   = context;
     _simModelManager           = simModelManager;
 }
Ejemplo n.º 5
0
 protected override void Context()
 {
     _simModelManager             = A.Fake <ISimModelManager>();
     _simulationPersitableUpdater = A.Fake <ISimulationPersistableUpdater>();
     _populationRunner            = A.Fake <IPopulationRunner>();
     _populationTask           = A.Fake <IPopulationTask>();
     _progressManager          = A.Fake <IProgressManager>();
     _simulationResultsCreator = new SimulationResultsCreator();
     sut = new SimulationRunner(_simModelManager, _populationRunner, _simulationResultsCreator, _simulationPersitableUpdater, _populationTask,
                                _progressManager);
 }
Ejemplo n.º 6
0
 public IndividualSimulationEngine(ISimModelManager simModelManager, IProgressManager progressManager,
                                   ISimulationResultsSynchronizer simulationResultsSynchronizer,
                                   IEventPublisher eventPublisher, ISimulationToModelCoreSimulationMapper modelCoreSimulationMapper)
 {
     _simModelManager = simModelManager;
     _progressManager = progressManager;
     _simulationResultsSynchronizer = simulationResultsSynchronizer;
     _eventPublisher              = eventPublisher;
     _modelCoreSimulationMapper   = modelCoreSimulationMapper;
     _simModelManager.Terminated += terminated;
 }
Ejemplo n.º 7
0
 protected override void Context()
 {
     _simModelManager  = A.Fake <ISimModelManager>();
     _progressUpdater  = A.Fake <IProgressUpdater>();
     _progressManager  = A.Fake <IProgressManager>();
     _eventPublisher   = A.Fake <IEventPublisher>();
     _exceptionManager = A.Fake <IExceptionManager>();
     _simulationResultsSynchronizer = A.Fake <ISimulationResultsSynchronizer>();
     _modelCoreSimulationMapper     = A.Fake <ISimulationToModelCoreSimulationMapper>();
     _simulationPersistableUpdater  = A.Fake <ISimulationPersistableUpdater>();
     A.CallTo(() => _progressManager.Create()).Returns(_progressUpdater);
     sut = new IndividualSimulationEngine(_simModelManager, _progressManager, _simulationResultsSynchronizer,
                                          _eventPublisher, _exceptionManager, _modelCoreSimulationMapper, _simulationPersistableUpdater);
 }
Ejemplo n.º 8
0
 public SimulationRunner(
     ISimModelManager simModelManager,
     IPopulationRunner populationRunner,
     ISimulationResultsCreator simulationResultsCreator,
     ISimulationPersistableUpdater simulationPersistableUpdater,
     IPopulationTask populationTask,
     IProgressManager progressManager)
 {
     _simModelManager              = simModelManager;
     _populationRunner             = populationRunner;
     _simulationResultsCreator     = simulationResultsCreator;
     _simulationPersistableUpdater = simulationPersistableUpdater;
     _populationTask  = populationTask;
     _progressManager = progressManager;
 }
        protected override Task Context()
        {
            _simModelManager = A.Fake <ISimModelManager>();
            _progressUpdater = A.Fake <IProgressUpdater>();
            _progressManager = A.Fake <IProgressManager>();
            _eventPublisher  = A.Fake <IEventPublisher>();
            _simulationResultsSynchronizer = A.Fake <ISimulationResultsSynchronizer>();
            _modelCoreSimulationMapper     = A.Fake <ISimulationToModelCoreSimulationMapper>();

            sut = new IndividualSimulationEngine(_simModelManager, _progressManager, _simulationResultsSynchronizer,
                                                 _eventPublisher, _modelCoreSimulationMapper);

            A.CallTo(() => _progressManager.Create()).Returns(_progressUpdater);
            _simulationRunOption = new SimulationRunOptions {
                RaiseEvents = true
            };
            return(_completed);
        }
Ejemplo n.º 10
0
        protected override void Context()
        {
            base.Context();
            _simulation       = new MoBiSimulation();
            _simModelManager  = A.Fake <ISimModelManager>();
            _outputSelections = new OutputSelections();
            _drug             = new MoleculeBuilder().WithName("DRUG");
            _drug.AddParameter(new Parameter().WithName(AppConstants.Parameters.MOLECULAR_WEIGHT).WithFormula(new ConstantFormula(400)));
            _outputSelections.AddOutput(new QuantitySelection("A", QuantityType.Drug));
            _simulation.BuildConfiguration = new MoBiBuildConfiguration
            {
                SimulationSettings = new SimulationSettings
                {
                    OutputSelections = _outputSelections
                },
                Molecules = new MoleculeBuildingBlock
                {
                    _drug
                }
            };

            A.CallTo(() => _simModelManagerFactory.Create()).Returns(_simModelManager);
            _oldResults         = new DataRepository("OLD");
            _simulation.Results = _oldResults;

            _newResults        = new DataRepository("NEW");
            _simulationResults = new SimulationRunResults(success: true, warnings: Enumerable.Empty <SolverWarning>(), results: _newResults);
            A.CallTo(() => _simModelManager.RunSimulation(_simulation)).Returns(_simulationResults);
            var baseGrid = new BaseGrid("Time", DomainHelperForSpecs.TimeDimension);

            _concentrationColumn = new DataColumn("Drug", DomainHelperForSpecs.ConcentrationDimension, baseGrid);
            _fractionColumn      = new DataColumn("Fraction", DomainHelperForSpecs.FractionDimension, baseGrid);
            _newResults.Add(_concentrationColumn);
            _newResults.Add(_fractionColumn);
            A.CallTo(() => _keyPathMapper.MoleculeNameFrom(_concentrationColumn)).Returns(_drug.Name);
        }
Ejemplo n.º 11
0
        protected override void Context()
        {
            var entityPathFactory = new EntityPathResolverForSpecs();

            _objectPathFactory   = new ObjectPathFactory(new AliasCreator());
            _simulation          = A.Fake <IModelCoreSimulation>().WithName("Sim");
            _simModelManager     = A.Fake <ISimModelManager>();
            _containerTask       = A.Fake <IContainerTask>();
            _options             = new ScaleDivisorOptions();
            _moleculeAmountCache = new PathCache <IMoleculeAmount>(entityPathFactory);
            var rootContainer = new ARootContainer().WithName(_simulation.Name)
                                .WithContainerType(ContainerType.Simulation);

            _simulation.Model.Root = rootContainer;
            _moleculeAmount1       = new MoleculeAmount().WithName("M1");
            _moleculeAmount2       = new MoleculeAmount().WithName("M2");

            rootContainer.Add(_moleculeAmount1);
            rootContainer.Add(_moleculeAmount2);

            _moleculeAmountCache.Add(_moleculeAmount1);
            _moleculeAmountCache.Add(_moleculeAmount2);

            _molecule1Path = entityPathFactory.PathFor(_moleculeAmount1);
            _molecule2Path = entityPathFactory.PathFor(_moleculeAmount2);

            _originalResults    = new DataRepository();
            _simulation.Results = _originalResults;

            var baseGrid = new BaseGrid("Time", Constants.Dimension.NO_DIMENSION)
            {
                Values = new[] { 0f, 1f, 2f, 3f }
            };

            _originalDataColumn = new DataColumn("M1", Constants.Dimension.NO_DIMENSION, baseGrid)
            {
                Values = new[] { 0f, 10f, 20f, 30f }
            };
            _originalDataColumn.QuantityInfo.Path = _objectPathFactory.CreateAbsoluteObjectPath(_moleculeAmount1);
            _originalResults.Add(_originalDataColumn);

            A.CallTo(_containerTask).WithReturnType <PathCache <IMoleculeAmount> >().Returns(_moleculeAmountCache);
            var simResults = new DataRepository();
            var baseGrid2  = new BaseGrid("Time", Constants.Dimension.NO_DIMENSION)
            {
                Values = new[] { 0f, 1f, 2f, 3f }
            };
            var res1 = new DataColumn("M1", Constants.Dimension.NO_DIMENSION, baseGrid2)
            {
                Values = new[] { 0f, 10f, 20f, 30f }
            };

            res1.QuantityInfo.Path = _objectPathFactory.CreateAbsoluteObjectPath(_moleculeAmount1);
            simResults.Add(res1);

            var res2 = new DataColumn("M2", Constants.Dimension.NO_DIMENSION, baseGrid2)
            {
                Values = new[] { 0f, 11f, 12f, 13f }
            };

            res2.QuantityInfo.Path = _objectPathFactory.CreateAbsoluteObjectPath(_moleculeAmount2);
            simResults.Add(res2);

            var simulationRunResults = new SimulationRunResults(true, Enumerable.Empty <ISolverWarning>(), simResults);

            A.CallTo(() => _simModelManager.RunSimulation(_simulation)).Returns(simulationRunResults);
            sut = new ScaleDivisorCalculator(_simModelManager, _containerTask, _objectPathFactory);
        }
Ejemplo n.º 12
0
 public ScaleDivisorCalculator(ISimModelManager simModelManager, IContainerTask containerTask, IObjectPathFactory objectPathFactory)
 {
     _simModelManager   = simModelManager;
     _containerTask     = containerTask;
     _objectPathFactory = objectPathFactory;
 }