예제 #1
0
 public CheckInDispatcher(ISimulationSettings simulationSettings, string nodeId, ITimerService timerService)
     : base(nodeId, timerService)
 {
     _simulationSettings = simulationSettings;
     SetUpQueues();
     SetUpTimers();
 }
예제 #2
0
파일: Simulator.cs 프로젝트: nabuk/IstLight
        public void RunAsync(SyncTickers syncTickers, StrategyBase strategy, ISimulationSettings settings)
        {
            if (syncTickers == null) throw new ArgumentNullException("syncTickers");
            if (strategy == null) throw new ArgumentNullException("strategy");
            if (settings == null) throw new ArgumentNullException("settings");

            if (IsBusy) throw new InvalidOperationException("Already running.");

            var asyncSimulationAlgorithm = new SimulationContextAsyncDecorator(SimulationContextFactory.CreateContext());
            cancelSimulation = () => asyncSimulationAlgorithm.Cancel();

            simulationTask = Task.Factory.StartNew(() =>
            {
                using (asyncSimulationAlgorithm)
                {
                    var runResult = base.SimulationAlgorithmFlow(asyncSimulationAlgorithm, syncTickers, strategy, settings);
                    lock (cancelRaceConditionSync) { cancelSimulation = delegate { }; }
                    EndInfo = new SimulationEndEventArgs
                    {
                        Error = runResult.Error,
                        Result = runResult.Value,
                        EndReason =
                            runResult.Error != null ? SimulationEndReason.Error :
                            runResult.Value != null ? SimulationEndReason.Completion :
                            SimulationEndReason.Cancellation
                    };
                    SimulationEnded(this, EndInfo);
                }
            });

            //while (simulationTask.Status < TaskStatus.Running) ;
        }
예제 #3
0
        private void checkChartTemplatesIn(ISimulationSettings simulationSettings)
        {
            var chartTemplates = simulationSettings.ChartTemplates.ToList();

            if (!referencesOldName(chartTemplates))
            {
                return;
            }

            var newChartTemplates = new List <CurveChartTemplate>();

            foreach (var chartTemplate in simulationSettings.ChartTemplates)
            {
                var newChartTemplate = chartTemplate;
                if (referencesOldName(chartTemplate))
                {
                    newChartTemplate = _cloneManager.Clone(chartTemplate);
                    foreach (var curveTemplate in newChartTemplate.Curves)
                    {
                        curveTemplate.xData.Path = stringReplace(curveTemplate.xData.Path);
                        curveTemplate.yData.Path = stringReplace(curveTemplate.yData.Path);
                    }
                }
                newChartTemplates.Add(newChartTemplate);
            }

            _changes.Add(simulationSettings, _buildingBlock, new ReplaceBuildingBlockTemplatesCommand(simulationSettings, newChartTemplates));
        }
 protected override void Context()
 {
     base.Context();
     _simulationSettings = new SimulationSettings();
     _simulationSettings.OutputSelections.AddOutput(new QuantitySelection($"A|B|{_oldName}", QuantityType.Drug));
     _simulationSettings.OutputSelections.AddOutput(new QuantitySelection("A|B|C", QuantityType.Drug));
 }
 public Dispatcher(string nodeId, ITimerTracker timeService, ISimulationSettings simulationSettings) : base(nodeId, timeService)
 {
     _simulationSettings = simulationSettings;
     checkins            = new List <ICheckInDesk>();
     checkinQueues       = new List <Queue <Baggage> >();
     SetupFlightTimers();
 }
예제 #6
0
        public static bool CanSynchronize(IReadOnlyList<Ticker> tickers, ISimulationSettings settings, out string error)
        {
            if (tickers == null) throw new ArgumentNullException("tickers");
            if (settings == null) throw new ArgumentNullException("settings");

            if (tickers.Count == 0)
            {
                error = "There must be least one ticker.";
                return false;
            }

            if (tickers.Select(t => t.Name.ToLowerInvariant()).GroupBy(name => name).Count() < tickers.Count)
            {
                error = "Ticker names must be unique.";
                return false;
            }

            if (settings.Get<SimulationRangeSetting>().Type == SimulationRangeType.Common &&
                tickers.Select(t => t.From).Max() > tickers.Select(t => t.To).Min())
            {
                error = "Tickers do not have common range.";
                return false;
            }

            if (settings.Get<CommissionSetting>().Value < 0)
            {
                error = "Commission cannot be negative.";
                return false;
            }

            if (settings.Get<CommissionSetting>().Type == CommissionType.Percent &&
                settings.Get<CommissionSetting>().Value >= 100)
            {
                error = "Commission of percentage type must be smaller than 100 %.";
                return false;
            }

            if (settings.Get<SimulationRangeSetting>().Type == SimulationRangeType.FromToDates &&
                settings.Get<SimulationRangeSetting>().From > settings.Get<SimulationRangeSetting>().To)
            {
                error = "Simulation range is invalid.";
                return false;
            }

            if (settings.Get<InitialEquitySetting>().Value < 1)
            {
                error = "Initial equity cannot be smaller than 1.";
                return false;
            }

            if (settings.Get<SimulationRangeSetting>().Type == SimulationRangeType.FromToDates &&
                tickers.All(t => t.From > settings.Get<SimulationRangeSetting>().To || t.To < settings.Get<SimulationRangeSetting>().From))
            {
                error = "No quotes matching specified simulation time range.";
                return false;
            }

            error = null;
            return true;
        }
        public ICommand AddOuputIntervalTo(ISimulationSettings simulationSettings, IMoBiSimulation simulation)
        {
            var schema   = simulationSettings.OutputSchema;
            var interval = _outputIntervalFactory.CreateDefault();

            interval.Name = _containerTask.CreateUniqueName(schema, interval.Name);
            return(getAddCommand(schema, interval, simulationSettings, simulation).Run(_context));
        }
        protected override void Context()
        {
            base.Context();
            _chartTemplate = new CurveChartTemplate().WithName("name");
            _buildingBlock = new SimulationSettings();

            sut = new AddChartTemplateToBuildingBlockCommand(_chartTemplate, _buildingBlock);
        }
        public ReplaceBuildingBlockTemplatesCommand(ISimulationSettings simulationSettings, IEnumerable <CurveChartTemplate> newTemplates)
        {
            _simulationSettings = simulationSettings;
            _newTemplates       = newTemplates;

            ObjectType  = ObjectTypes.ChartTemplate;
            CommandType = AppConstants.Commands.EditCommand;
            Description = AppConstants.Commands.EditChartTemplateInBuildingBlock(simulationSettings.Name);
        }
예제 #10
0
 public IObjectBaseDTO MapFrom(ISimulationSettings input)
 {
     return(new ObjectBaseDTO
     {
         Id = AppConstants.SimulationSettingsId,
         Icon = ApplicationIcons.Settings.IconName,
         Name = AppConstants.Captions.SimulationSettings,
     });
 }
        protected override void Context()
        {
            base.Context();
            _simulation       = A.Fake <Simulation>().WithName("MyName");
            _simulation.Model = A.Fake <IModel>();
            _cloneSettings    = A.Fake <ISimulationSettings>();
            A.CallTo(() => _idGenerator.NewId()).Returns("id");

            A.CallTo(() => _cloneManagerForBuildingBlock.Clone(_simulation.SimulationSettings)).Returns(_cloneSettings);
        }
예제 #12
0
 public void SetSettings(ISimulationSettings settings)
 {
     _simulationSettings = settings;
     _simulationSettings.OutgoingFlights = _simulationSettings
                                           .OutgoingFlights.OrderBy(f => f.TimeToFlightSinceSimulationStart)
                                           .ToList();
     _simulationSettings.IncomingFlights = _simulationSettings
                                           .IncomingFlights
                                           .OrderBy(f => f.TimeToFlightSinceSimulationStart)
                                           .ToList();
 }
예제 #13
0
        private void rebind(ISimulationSettings simulationSettings)
        {
            var chartTemplatesToEdit = simulationSettings.ChartTemplates.Select(x =>
            {
                var curveChartTemplate = _cloneManager.Clone(x);
                // setting IsDefault is not part of general cloning and is done when cloning the set only
                curveChartTemplate.IsDefault = x.IsDefault;
                return(curveChartTemplate);
            });

            _chartTemplateManagerPresenter.EditTemplates(chartTemplatesToEdit.OrderBy(x => x.Name));
        }
 protected override void Context()
 {
     base.Context();
     _simulationSettings = new SimulationSettings();
     _curveChartTemplate = new CurveChartTemplate();
     _simulationSettings.AddChartTemplate(_curveChartTemplate);
     _curveChartTemplate.Curves.Add(new CurveTemplate
     {
         xData = { Path = "A|B|D" },
         yData = { Path = "C|D|E" }
     });
 }
        protected override void Context()
        {
            _view = A.Fake <IEditChartTemplateManagerView>();
            _chartTemplateManagerPresenter = A.Fake <IChartTemplateManagerPresenter>();
            _chartTemplatingTask           = A.Fake <IChartTemplatingTask>();
            _cloneManager       = A.Fake <ICloneManager>();
            _simulationSettings = A.Fake <ISimulationSettings>();

            sut = new EditChartTemplateManagerPresenter(_view, _chartTemplateManagerPresenter, _cloneManager, _chartTemplatingTask);
            sut.InitializeWith(A.Fake <ICommandCollector>());
            sut.Edit(_simulationSettings);
        }
예제 #16
0
        public TransactionProcessor(
            IQuoteContext quoteContext,
            Account account,
            ISimulationSettings settings)
        {
            this.quoteContext = quoteContext;
            this.account = account;

            this.delay = settings.Get<TradeDelaySetting>();
            this.commission = settings.Get<CommissionSetting>();

            this.avgPrice = new double[quoteContext.TickerCount];
        }
        public ICommand RemoveOuputInterval(OutputInterval outputInterval, ISimulationSettings simulationSettings, IMoBiSimulation simulation)
        {
            var schema = simulationSettings.OutputSchema;

            if (schema.Intervals.Count() > 1)
            {
                return(getRemoveCommand(schema, outputInterval, simulationSettings, simulation).Run(_context));
            }
            else
            {
                throw new MoBiException(AppConstants.Exceptions.CanNotRemoveLastItem);
            }
        }
        protected override void Context()
        {
            base.Context();
            _simulationSettings = new SimulationSettings();
            _curveChartTemplate = new CurveChartTemplate();
            _simulationSettings.AddChartTemplate(_curveChartTemplate);
            _curveTemplate = new CurveTemplate
            {
                xData = { Path = $"A|B|{_oldName}" },
                yData = { Path = $"C|D|{_oldName}" },
            };
            _curveChartTemplate.Curves.Add(_curveTemplate);

            A.CallTo(() => _cloneManager.Clone(_curveChartTemplate)).Returns(_curveChartTemplate);
        }
예제 #19
0
        //Initialization
        void Awake()
        {
            simulationSettings = Camera.main.GetComponent <ISimulationSettings>();

            var values = (SettingType[])Enum.GetValues(typeof(SettingType));

            //Initialize setting sliders
            foreach (var v in values)
            {
                var setting = Instantiate(settingPrefab, settingsParent).GetComponent <ISetting>();
                setting.type            = v;
                setting.OnSettingChange = OnSettingChange;
                setting.DisplayHint     = DisplayContext;
                setting.Initialize(GetSettingValue(v));
            }
        }
예제 #20
0
        private void checkOutputSelectionIn(ISimulationSettings simulationSettings)
        {
            var outputSelections = simulationSettings.OutputSelections;

            if (!referencesOldName(outputSelections))
            {
                return;
            }

            var newOutputSelection = outputSelections.Clone();

            foreach (var outputUsingOldName in outputsReferencingOldName(newOutputSelection))
            {
                newOutputSelection.RemoveOutput(outputUsingOldName);
                newOutputSelection.AddOutput(new QuantitySelection(stringReplace(outputUsingOldName.Path), outputUsingOldName.QuantityType));
            }

            _changes.Add(outputSelections, _buildingBlock, new UpdateOutputSelectionInBuildingBlockCommand(newOutputSelection, simulationSettings));
        }
예제 #21
0
 protected override void Context()
 {
     _view = A.Fake <IEditOutputSchemaView>();
     _simulationSettingsTask = A.Fake <ISimulationSettingsTask>();
     _outputIntervalToOutputIntervalDTOMapper = A.Fake <IOutputIntervalToOutputIntervalDTOMapper>();
     _simulationToEdit            = A.Fake <IndividualSimulation>();
     _commandRegister             = A.Fake <ICommandCollector>();
     _simulationToEdit.Properties = A.Fake <SimulationProperties>();
     _outputSchema      = A.Fake <OutputSchema>();
     _simulationSetting = A.Fake <ISimulationSettings>();
     _simulationToEdit.SimulationSettings = _simulationSetting;
     A.CallTo(() => _simulationSetting.OutputSchema).Returns(_outputSchema);
     _allIntervals = new List <OutputInterval>();
     _editParameterPresenterTask = A.Fake <IEditParameterPresenterTask>();
     _context = A.Fake <IExecutionContext>();
     A.CallTo(() => _outputSchema.Intervals).Returns(_allIntervals);
     sut = new EditOutputSchemaPresenter(_view, _outputIntervalToOutputIntervalDTOMapper, _simulationSettingsTask, _editParameterPresenterTask, _context);
     sut.InitializeWith(_commandRegister);
 }
        public override void Execute(IMoBiContext context)
        {
            var allCommands = new List <IMoBiCommand>();

            //add the required commands
            _simulationSettings.ChartTemplates.Each(t => allCommands.Add(new RemoveChartTemplateFromBuildingBlockCommand(t, _simulationSettings)));
            _newTemplates.Each(t => allCommands.Add(new AddChartTemplateToBuildingBlockCommand(t, _simulationSettings)));

            //hide from the history browser ( only if at least two command)
            if (allCommands.Count >= 2)
            {
                allCommands.Each(x => x.Visible = false);
            }

            AddRange(allCommands);

            //now execute all commands
            base.Execute(context);

            //clear references
            _simulationSettings = null;
            _newTemplates       = null;
        }
        public static StatisticsData CalculateStatistics(ISimulationSettings simulationSettings)
        {
            var baggage = Baggage.AllBaggage;

            var statisticsData = new StatisticsData();

            try
            {
                SetDispatchedTimes(statisticsData, baggage);
                SetCollectedTimes(statisticsData, baggage);
                SetPscSucceededAndFailed(statisticsData, baggage);
                SetAscSucceededAndFailed(statisticsData, baggage);
                SetFlightDelays(statisticsData, baggage);
                SetTransferredBagsCount(statisticsData, baggage);
                SetBsuRelatedStatistics(statisticsData, baggage);
                SetTransportingTimeRelatedData(statisticsData, baggage);
            }
            catch (Exception e)
            {
            }

            return(statisticsData);
        }
예제 #24
0
 protected override void Context()
 {
     base.Context();
     _project = A.Fake <IMoBiProject>();
     _objectBaseRepository      = A.Fake <IWithIdRepository>();
     _spatialStructure          = A.Fake <IMoBiSpatialStructure>();
     _simulationSettings        = A.Fake <ISimulationSettings>();
     _moBiReactionBuildingBlock = A.Fake <IMoBiReactionBuildingBlock>();
     _moleculeBuildingBlock     = A.Fake <IMoleculeBuildingBlock>();
     A.CallTo(() => _context.CurrentProject).Returns(_project);
     A.CallTo(() => _context.Create <IMoleculeBuildingBlock>()).Returns(_moleculeBuildingBlock);
     A.CallTo(() => _context.Create <IMoBiReactionBuildingBlock>()).Returns(_moBiReactionBuildingBlock);
     A.CallTo(() => _spatialStructureFactory.CreateDefault(AppConstants.DefaultNames.SpatialStructure)).Returns(_spatialStructure);
     A.CallTo(() => _simulationSettingsFactory.CreateDefault()).Returns(_simulationSettings);
     _topContainer = A.Fake <IContainer>();
     A.CallTo(() => _context.Create <IContainer>()).Returns(_topContainer);
     _passiveTransportBuildingBlock = A.Fake <IPassiveTransportBuildingBlock>();
     A.CallTo(() => _context.Create <IPassiveTransportBuildingBlock>()).Returns(_passiveTransportBuildingBlock);
     _observerBuildingBlock = A.Fake <IObserverBuildingBlock>();
     A.CallTo(() => _context.Create <IObserverBuildingBlock>()).Returns(_observerBuildingBlock);
     _eventGroupBuildingBlock = A.Fake <IEventGroupBuildingBlock>();
     A.CallTo(() => _context.Create <IEventGroupBuildingBlock>()).Returns(_eventGroupBuildingBlock);
     A.CallTo(() => _context.ObjectRepository).Returns(_objectBaseRepository);
 }
예제 #25
0
        bool ISimulationContext.Initialize(SyncTickers syncTickers, StrategyBase strategy, ISimulationSettings settings)
        {
            this.strategy = strategy;
            this.settings = settings;
            this.syncTickers = syncTickers;
            this.account = new Account(settings.Get<InitialEquitySetting>().Value);
            this.strategy.QuoteContext = this.quoteContext = new QuoteContext(syncTickers);
            this.transactionProcessor = new TransactionProcessor(quoteContext, account, settings);
            this.strategy.WalletContext = this.walletContext = new WalletContext(quoteContext, account, transactionProcessor);

            this.resultQuotes = new List<SimulationResultQuote>();

            return strategy.Initialize();
        }
예제 #26
0
 public void Visit(ISimulationSettings simulationSettings)
 {
     checkBuildingBlock(simulationSettings);
     checkOutputSelectionIn(simulationSettings);
     checkChartTemplatesIn(simulationSettings);
 }
 public RemoveOutputIntervalCommand(OutputSchema schema, OutputInterval interval, ISimulationSettings simulationSettings) : base(schema, interval, simulationSettings)
 {
     CommandType = AppConstants.Commands.DeleteCommand;
     Description = AppConstants.Commands.RemoveOutputIntervalFrom(simulationSettings.Name);
 }
 public AddOutputIntervalCommand(OutputSchema schema, OutputInterval interval, ISimulationSettings simulationSettings) : base(schema, interval, simulationSettings)
 {
     CommandType = AppConstants.Commands.AddCommand;
     Description = AppConstants.Commands.AddOutputIntervalTo(simulationSettings.Name);
 }
예제 #29
0
 public void AddSimulationConfiguration(ISimulationSettings simulationSettings)
 {
     addSolverSettings(simulationSettings.Solver);
     addOutputSchema(simulationSettings.OutputSchema);
     RandomSeed = simulationSettings.RandomSeed;
 }
예제 #30
0
        protected override Task Context()
        {
            _solverSettingsMapper               = A.Fake <SolverSettingsMapper>();
            _outputSchemaMapper                 = A.Fake <OutputSchemaMapper>();
            _outputSelectionMapper              = A.Fake <OutputSelectionsMapper>();
            _parameterMapper                    = A.Fake <ParameterMapper>();
            _compoundPropertiesMapper           = A.Fake <CompoundPropertiesMapper>();
            _advancedParameterMapper            = A.Fake <AdvancedParameterMapper>();
            _eventMappingMapper                 = A.Fake <EventMappingMapper>();
            _observerSetMappingMapper           = A.Fake <ObserverSetMappingMapper>();
            _curveChartMapper                   = A.Fake <SimulationTimeProfileChartMapper>();
            _processMappingMapper               = A.Fake <ProcessMappingMapper>();
            _simulationFactory                  = A.Fake <ISimulationFactory>();
            _executionContext                   = A.Fake <IExecutionContext>();
            _simulationModelCreator             = A.Fake <ISimulationModelCreator>();
            _simulationBuildingBlockUpdater     = A.Fake <ISimulationBuildingBlockUpdater>();
            _modelPropertiesTask                = A.Fake <IModelPropertiesTask>();
            _simulationRunner                   = A.Fake <ISimulationRunner>();
            _populationAnalysisChartMapper      = A.Fake <PopulationAnalysisChartMapper>();
            _simulationParameterOriginIdUpdater = A.Fake <ISimulationParameterOriginIdUpdater>();
            _logger             = A.Fake <ILogger>();
            _containerTask      = A.Fake <IContainerTask>();
            _entityPathResolver = A.Fake <IEntityPathResolver>();

            sut = new SimulationMapper(_solverSettingsMapper, _outputSchemaMapper,
                                       _outputSelectionMapper, _compoundPropertiesMapper, _parameterMapper,
                                       _advancedParameterMapper, _eventMappingMapper, _observerSetMappingMapper, _curveChartMapper,
                                       _populationAnalysisChartMapper, _processMappingMapper,
                                       _simulationFactory, _executionContext, _simulationModelCreator,
                                       _simulationBuildingBlockUpdater, _modelPropertiesTask,
                                       _simulationRunner, _simulationParameterOriginIdUpdater,
                                       _logger, _containerTask, _entityPathResolver
                                       );

            _project    = new PKSimProject();
            _individual = new Individual {
                Name = "IND", Id = "IND"
            };
            _compound = new Compound {
                Name = "COMP", Id = "COMP"
            };
            _observerSet = new ObserverSet {
                Name = "OBS_SET", Id = "OBS_SET"
            };
            _protocol = new SimpleProtocol {
                Name = "PROT", Id = "PROT"
            };
            _inductionProcess = new InductionProcess().WithName("Interaction process");
            _compound.AddProcess(_inductionProcess);


            _event = new PKSimEvent {
                Name = "Event"
            };
            _population = new RandomPopulation()
            {
                Name = "POP"
            };
            _observedData = new DataRepository("OBS_ID").WithName("OBS");
            _project.AddBuildingBlock(_individual);
            _project.AddBuildingBlock(_compound);
            _project.AddBuildingBlock(_event);
            _project.AddBuildingBlock(_population);
            _project.AddBuildingBlock(_observerSet);
            _project.AddObservedData(_observedData);

            _simulationProperties = new SimulationProperties
            {
                ModelProperties = new ModelProperties
                {
                    ModelConfiguration = new ModelConfiguration {
                        ModelName = "4Comp"
                    }
                }
            };
            _interactionSelection = new InteractionSelection {
                ProcessName = _inductionProcess.Name
            };
            _noInteractionSelection = new InteractionSelection {
                MoleculeName = "CYP2D6"
            };

            _simulationProperties.InteractionProperties.AddInteraction(_interactionSelection);
            _simulationProperties.InteractionProperties.AddInteraction(_noInteractionSelection);

            _settings      = new SimulationSettings();
            _rootContainer = new Container().WithName("Sim");
            _model         = new OSPSuite.Core.Domain.Model {
                Root = _rootContainer
            };

            _individualSimulation = new IndividualSimulation
            {
                Name               = "S1",
                Properties         = _simulationProperties,
                SimulationSettings = _settings,
                Description        = "Simulation Description",
                Model              = _model
            };

            _simulationTimeProfile         = new SimulationTimeProfileChart();
            _snapshotSimulationTimeProfile = new CurveChart();
            _individualSimulation.AddAnalysis(_simulationTimeProfile);

            A.CallTo(() => _curveChartMapper.MapToSnapshot(_simulationTimeProfile)).Returns(_snapshotSimulationTimeProfile);


            _populationSimulation = new PopulationSimulation
            {
                Properties         = _simulationProperties,
                SimulationSettings = _settings,
                Model = _model
            };

            _advancedParameterCollection       = new AdvancedParameterCollection();
            _populationSimulationAnalysisChart = new BoxWhiskerAnalysisChart();
            _populationSimulation.SetAdvancedParameters(_advancedParameterCollection);
            _populationSimulation.AddAnalysis(_populationSimulationAnalysisChart);
            _populationSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndTemplateId", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _individual
            });

            _snapshotPopulationAnalysisChart = new Snapshots.PopulationAnalysisChart();

            A.CallTo(() => _populationAnalysisChartMapper.MapToSnapshot(_populationSimulationAnalysisChart)).Returns(_snapshotPopulationAnalysisChart);

            _snapshotInteraction = new CompoundProcessSelection();
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_interactionSelection)).Returns(_snapshotInteraction);
            _snapshotInteraction.CompoundName = _compound.Name;
            _snapshotInteraction.Name         = _inductionProcess.Name;

            _noSelectionSnapshotInteraction = new CompoundProcessSelection();
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_noInteractionSelection)).Returns(_noSelectionSnapshotInteraction);
            _noSelectionSnapshotInteraction.MoleculeName = _noInteractionSelection.MoleculeName;

            _compoundProperties         = new CompoundProperties();
            _snapshotCompoundProperties = new Snapshots.CompoundProperties {
                Name = _compound.Name
            };
            _individualSimulation.Properties.AddCompoundProperties(_compoundProperties);

            _eventMapping = new EventMapping();
            _individualSimulation.EventProperties.AddEventMapping(_eventMapping);

            _observerSetMapping = new ObserverSetMapping();
            _individualSimulation.ObserverSetProperties.AddObserverSetMapping(_observerSetMapping);

            A.CallTo(() => _compoundPropertiesMapper.MapToSnapshot(_compoundProperties, _project)).Returns(_snapshotCompoundProperties);


            _eventSelection = new EventSelection
            {
                Name = _event.Name,
            };

            _observerSetSelection = new ObserverSetSelection
            {
                Name = _observerSet.Name,
            };

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndTemplateId", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _individual,

                Altered = true
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("CompTemplateId", PKSimBuildingBlockType.Compound)
            {
                BuildingBlock = _compound
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("ProtTemplateId", PKSimBuildingBlockType.Protocol)
            {
                BuildingBlock = _protocol
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("ObserveSetTemplateId", PKSimBuildingBlockType.ObserverSet)
            {
                BuildingBlock = _observerSet
            });

            _populationSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("PopTemplateId", PKSimBuildingBlockType.Population)
            {
                BuildingBlock = _population
            });


            _individualSimulation.AddUsedObservedData(_observedData);

            A.CallTo(() => _eventMappingMapper.MapToSnapshot(_eventMapping, _project)).Returns(_eventSelection);
            A.CallTo(() => _observerSetMappingMapper.MapToSnapshot(_observerSetMapping, _project)).Returns(_observerSetSelection);

            _outputSelectionSnapshot = new OutputSelections();
            A.CallTo(() => _outputSelectionMapper.MapToSnapshot(_individualSimulation.OutputSelections)).Returns(_outputSelectionSnapshot);

            A.CallTo(() => _processMappingMapper.MapToModel(_snapshotInteraction, _inductionProcess)).Returns(_interactionSelection);

            return(_completed);
        }
        private IMoBiCommand getRemoveCommand(OutputSchema schema, OutputInterval interval, ISimulationSettings simulationSettings, IMoBiSimulation simulation)
        {
            if (simulation == null)
            {
                return(new RemoveOutputIntervalCommand(schema, interval, simulationSettings));
            }

            return(new RemoveOutputIntervalFromSimulationCommand(schema, interval, simulation));
        }
        private IMoBiCommand getAddCommand(OutputSchema schema, OutputInterval interval, ISimulationSettings simulationSettings, IMoBiSimulation simulation)
        {
            if (simulation == null)
            {
                return(new AddOutputIntervalCommand(schema, interval, simulationSettings));
            }

            return(new AddOutputIntervalInSimulationCommand(schema, interval, simulation));
        }
예제 #33
0
            public MultiTickerSynchronizer(IReadOnlyList<Ticker> tickers, ISimulationSettings settings)
            {
                this.tickers = tickers;
                this.settings = settings;

                this.stepSpan = settings.Get<PeriodSetting>().Type.ToTimeSpan();

                var range = settings.Get<SimulationRangeSetting>();
                if (range.Type == SimulationRangeType.Common)
                {
                    this.from = tickers.Select(t => t.From).Max();
                    this.to = tickers.Select(t => t.To).Min();
                }
                else
                {
                    this.from = Max(range.From.Date, tickers.Select(t => t.From).Min());
                    this.to = range.To.Date + (TimeSpan.FromDays(1) - TimeSpan.FromTicks(1));
                }

                //currentDate = this.from;
            }
예제 #34
0
        public static SyncTickers Synchronize(IReadOnlyList<Ticker> tickers, ISimulationSettings settings)
        {
            if (tickers == null) throw new ArgumentNullException("tickers");
            if (settings == null) throw new ArgumentNullException("settings");

            string error = null;
            if (!CanSynchronize(tickers, settings, out error)) throw new ArgumentException(error);

            return new MultiTickerSynchronizer(tickers, settings).Sync();
        }
 public void Visit(ISimulationSettings objToVisit)
 {
     retrieveTask(objToVisit);
 }
예제 #36
0
        public void SetSettings(ISimulationSettings settings)
        {
            var _simulationSettings = settings;

            _simulationSettings.Flights = _simulationSettings.Flights.OrderBy(f => f.DipartureTime).ToList();
        }