internal MuStarSigmaViewModel(IAppService appService, IAppSettings appSettings) { _appSettings = appSettings; PlotModel = new PlotModel { IsLegendVisible = false }; _horizontalAxis = new LinearAxis { Title = "µ*", Position = AxisPosition.Bottom }; PlotModel.Axes.Add(_horizontalAxis); _verticalAxis = new LinearAxis { Title = "σ", Position = AxisPosition.Left }; PlotModel.Axes.Add(_verticalAxis); PlotModel.ApplyThemeToPlotModelAndAxes(); _reactiveSafeInvoke = appService.GetReactiveSafeInvoke(); _subscriptions = new CompositeDisposable( _appSettings .GetWhenPropertyChanged() .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <string?>( ObserveAppSettingsPropertyChange ) ) ); }
internal Fast99MeasuresViewModel( IAppState appState, IAppService appService, IAppSettings appSettings, ModuleState moduleState, SensitivityDesigns sensitivityDesigns ) { _appState = appState; _appService = appService; _appSettings = appSettings; _moduleState = moduleState; _sensitivityDesigns = sensitivityDesigns; _simulation = appState.Target.AssertSome(); var independentVariable = _simulation.SimConfig.SimOutput.IndependentVariable; XUnits = independentVariable.Unit; RankParameters = ReactiveCommand.Create( HandleRankParameters, this.ObservableForProperty(vm => vm.IsReady, _ => IsReady) ); UseRankedParameters = ReactiveCommand.Create( HandleUseRankedParameters, this.ObservableForProperty(vm => vm.RankedParameterViewModels, _ => RankedParameterViewModels.Count > 0) ); ShareRankedParameters = ReactiveCommand.Create( HandleShareRankedParameters, this.ObservableForProperty(vm => vm.RankedParameterViewModels, _ => RankedParameterViewModels.Count > 0) ); PlotModel = new PlotModel() { LegendPosition = LegendPosition.RightMiddle, LegendPlacement = LegendPlacement.Outside }; PlotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = independentVariable.GetFQName() }); PlotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, }); _annotation = new RectangleAnnotation { Fill = OxyColor.FromAColor(120, OxyColors.SkyBlue), MinimumX = 0, MaximumX = 0 }; PlotModel.Annotations.Add(_annotation); PlotModel.MouseDown += HandlePlotModelMouseDown; PlotModel.MouseMove += HandlePlotModelMouseMove; PlotModel.MouseUp += HandlePlotModelMouseUp; PlotModel.ApplyThemeToPlotModelAndAxes(); _reactiveSafeInvoke = appService.GetReactiveSafeInvoke(); _subscriptions = new CompositeDisposable( moduleState .ObservableForProperty(ms => ms.SensitivityDesign) .Subscribe(ObserveModuleStateSensitivityDesign), moduleState.MeasuresState .ObservableForProperty(ms => ms.Fast99OutputMeasures) .Subscribe(ObserveMeasuresStateFast99OutputMeasures), moduleState.MeasuresState .ObservableForProperty(ms => ms.SelectedOutputName) .Subscribe(ObserveMeasuresStateSelectedOutputName), moduleState .ObservableForProperty(ms => ms.Ranking) .Subscribe(ObserveModuleStateRanking), this .ObservableForProperty(vm => vm.IsVisible) .Subscribe(ObserveIsVisible), this .ObservableForProperty(vm => vm.SelectedOutputName) .Subscribe(ObserveSelectedOutputName), this .ObservableForProperty(vm => vm.Fast99MeasureType) .Subscribe(ObserveFast99MeasureType), this .ObservableForProperty(vm => vm.XBeginText) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveXBeginText ) ), this .ObservableForProperty(vm => vm.XEndText) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveXEndText ) ), _appSettings .GetWhenPropertyChanged() .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <string?>( ObserveAppSettingsPropertyChange ) ) ); using (_reactiveSafeInvoke.SuspendedReactivity) { Populate(); PlotModel.InvalidatePlot(updateData: true); } }
internal LowryViewModel(IAppService appService, IAppSettings appSettings, LowryState lowryState) { _appService = appService; _appSettings = appSettings; _lowryState = lowryState; PlotModel = new PlotModel { Title = _lowryState.ChartTitle, IsLegendVisible = true, LegendPosition = LegendPosition.BottomRight }; PlotModel.MouseDown += HandlePlotModelMouseDown; _lowryStackAxis = new CategoryAxis { Position = AxisPosition.Bottom, Key = nameof(_lowryStackAxis), Title = _lowryState.XAxisTitle, Angle = -35, IsZoomEnabled = false, IsPanEnabled = false }; PlotModel.Axes.Add(_lowryStackAxis); _lowrySmokeAxis = new LinearAxis { Position = AxisPosition.Bottom, MinimumPadding = 0, MaximumPadding = 0.06, AbsoluteMinimum = 0, Minimum = 0, Key = nameof(_lowrySmokeAxis), IsAxisVisible = false, IsZoomEnabled = false, IsPanEnabled = false }; PlotModel.Axes.Add(_lowrySmokeAxis); _lowryVerticalAxis = new LinearAxis { Position = AxisPosition.Left, MinimumPadding = 0, MaximumPadding = 0.06, AbsoluteMinimum = 0, AbsoluteMaximum = 1.0, Minimum = 0.0, Maximum = 1.0, Title = _lowryState.YAxisTitle, IsZoomEnabled = false, IsPanEnabled = false }; PlotModel.Axes.Add(_lowryVerticalAxis); _mainEffectsSeries = new ColumnSeries { Title = "Main Effects", IsStacked = true, StrokeColor = OxyColors.Black, StrokeThickness = 1, FillColor = _lowryState.MainEffectsFillColor ?? OxyColors.ForestGreen, XAxisKey = nameof(_lowryStackAxis) }; _mainEffectsSeries.MouseDown += HandleMainEffectsSeriesMouseDown; PlotModel.Series.Add(_mainEffectsSeries); _interactionsSeries = new ColumnSeries { Title = "Interactions", IsStacked = true, StrokeColor = OxyColors.Black, StrokeThickness = 1, FillColor = _lowryState.InteractionsFillColor ?? OxyColors.DarkGoldenrod, XAxisKey = nameof(_lowryStackAxis) }; _interactionsSeries.MouseDown += HandleInteractionsSeriesMouseDown; PlotModel.Series.Add(_interactionsSeries); _smokeSeries = new AreaSeries { DataFieldX2 = "IndependentVar", DataFieldY2 = "Minimum", Fill = _lowryState.SmokeFill ?? OxyColors.LightBlue, Color = OxyColors.Red, MarkerFill = OxyColors.Transparent, StrokeThickness = 0, DataFieldX = "IndependentVar", DataFieldY = "Maximum", Title = "Maximum/Minimum", XAxisKey = nameof(_lowrySmokeAxis), RenderInLegend = false }; PlotModel.Series.Add(_smokeSeries); PlotModel.ApplyThemeToPlotModelAndAxes(); UpdateSize = ReactiveCommand.Create(HandleUpdateSize); ResetAxes = ReactiveCommand.Create(HandleResetAxes); ShowOptions = ReactiveCommand.Create(HandleShowOptions); ExportImage = ReactiveCommand.Create(HandleExportImage); _reactiveSafeInvoke = appService.GetReactiveSafeInvoke(); _subscriptions = new CompositeDisposable( _appSettings .GetWhenPropertyChanged() .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <string?>( ObserveAppSettingsPropertyChange ) ) ); }
internal SimulationViewModel(IAppState appState, IAppService appService, IAppSettings appSettings, ModuleState moduleState, EstimationDesigns estimationDesigns) { _appService = appService; _moduleState = moduleState; _estimationDesigns = estimationDesigns; _simulation = appState.Target.AssertSome("No simulation"); _simData = appState.SimData; _estimationDesign = moduleState.EstimationDesign; _chainStates = _moduleState.ChainStates; _reactiveSafeInvoke = appService.GetReactiveSafeInvoke(); StartIterating = ReactiveCommand.Create( HandleStartIterating, this.WhenAny(vm => vm.CanStartIterating, _ => CanStartIterating) ); StopIterating = ReactiveCommand.Create( HandleStopIterating, this.WhenAny(vm => vm.CanStopIterating, _ => CanStopIterating) ); ShowSettings = ReactiveCommand.Create( HandleShowSettings, this.WhenAny(vm => vm.CanShowSettings, _ => CanShowSettings) ); SetConvergenceRange = ReactiveCommand.Create( HandleSetConvergenceRange, this.WhenAny(vm => vm.CanSetConvergenceRange, _ => CanSetConvergenceRange) ); PlotModel = new PlotModel(); _horizontalAxis = new LinearAxis { Position = AxisPosition.Bottom, AbsoluteMinimum = 1d, Minimum = 1d, Title = "Iteration" }; PlotModel.Axes.Add(_horizontalAxis); _verticalAxis = new LinearAxis { Position = AxisPosition.Left }; PlotModel.Axes.Add(_verticalAxis); _posteriorAnnotation = new RectangleAnnotation { Fill = OxyColor.FromAColor(120, OxyColors.SkyBlue), MinimumX = 0, MaximumX = 0 }; PlotModel.Annotations.Add(_posteriorAnnotation); PlotModel.MouseDown += HandlePlotModelMouseDown; PlotModel.MouseMove += HandlePlotModelMouseMove; PlotModel.MouseUp += HandlePlotModelMouseUp; PlotModel.ApplyThemeToPlotModelAndAxes(); using (_reactiveSafeInvoke.SuspendedReactivity) { _posteriorBegin = _moduleState.PosteriorState?.BeginIteration; _posteriorEnd = _moduleState.PosteriorState?.EndIteration; PopulateControls(); PopulateChartData(); PopulateChart(); PopulatePosteriorAnnotation(); UpdateEnable(); } _subscriptions = new CompositeDisposable( appSettings .GetWhenPropertyChanged() .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <string?>(ObserveAppSettingsPropertyChange) ), _moduleState .ObservableForProperty(ms => ms.EstimationDesign) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveModuleStateEstimationDesign ) ), _moduleState .ObservableForProperty(ms => ms.ChainStates) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveModuleStateChainStates ) ), _moduleState .ObservableForProperty(ms => ms.PosteriorState) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveModuleStatePosteriorState ) ), this .ObservableForProperty(vm => vm.SelectedParameter) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveSelectedParameter ) ), this .ObservableForProperty(vm => vm.PosteriorBegin) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObservePosteriorBegin ) ), this .ObservableForProperty(vm => vm.PosteriorEnd) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObservePosteriorEnd ) ) ); }
internal PosteriorViewModel(IAppState appState, IAppService appService, IAppSettings appSettings, ModuleState moduleState) { _appState = appState; _moduleState = moduleState; _reactiveSafeInvoke = appService.GetReactiveSafeInvoke(); PlotModel = new PlotModel() { LegendPlacement = LegendPlacement.Inside, LegendPosition = LegendPosition.RightTop, LegendOrientation = LegendOrientation.Vertical }; _horizontalAxis = new LinearAxis { Position = AxisPosition.Bottom }; PlotModel.Axes.Add(_horizontalAxis); _leftVerticalAxis = new LinearAxis { Title = "Frequency", Position = AxisPosition.Left, Key = nameof(_leftVerticalAxis) }; PlotModel.Axes.Add(_leftVerticalAxis); _rightVerticalAxis = new LinearAxis { Title = "Probability", Position = AxisPosition.Right, Key = nameof(_rightVerticalAxis) }; PlotModel.Axes.Add(_rightVerticalAxis); PlotModel.ApplyThemeToPlotModelAndAxes(); using (_reactiveSafeInvoke.SuspendedReactivity) { _subscriptions = new CompositeDisposable( appSettings .GetWhenPropertyChanged() .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <string?>( ObserveAppSettingsPropertyChange ) ), moduleState .ObservableForProperty(ms => ms.EstimationDesign) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveModuleStateEstimationDesign ) ), moduleState .WhenAnyValue( ms => ms.ChainStates, ms => ms.PosteriorState ) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <(Arr <ChainState>, PosteriorState?)>( ObserveModuleStateEstimationDataChange ) ), this .ObservableForProperty(vm => vm.SelectedParameterName) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveSelectedParameterName ) ) ); if (CanConfigureControls) { PopulateControls(); } if (CanViewPosterior) { PopulatePosterior(); } } }
internal FitViewModel(IAppState appState, IAppService appService, IAppSettings appSettings, ModuleState moduleState) { _appState = appState; _moduleState = moduleState; _reactiveSafeInvoke = appService.GetReactiveSafeInvoke(); PlotModel = new PlotModel() { LegendPlacement = LegendPlacement.Inside, LegendPosition = LegendPosition.RightTop, LegendOrientation = LegendOrientation.Vertical }; var simulation = _appState.Target.AssertSome(); var output = simulation.SimConfig.SimOutput; var independentVariable = output.IndependentVariable; _horizontalAxis = new LinearAxis { Title = independentVariable.Name, Unit = independentVariable.Unit, Position = AxisPosition.Bottom }; PlotModel.Axes.Add(_horizontalAxis); _verticalAxis = new LinearAxis { Position = AxisPosition.Left }; PlotModel.Axes.Add(_verticalAxis); PlotModel.ApplyThemeToPlotModelAndAxes(); using (_reactiveSafeInvoke.SuspendedReactivity) { _subscriptions = new CompositeDisposable( appSettings .GetWhenPropertyChanged() .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <string?>( ObserveAppSettingsPropertyChange ) ), moduleState .ObservableForProperty(ms => ms.EstimationDesign) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveModuleStateEstimationDesign ) ), moduleState .WhenAnyValue( ms => ms.ChainStates, ms => ms.PosteriorState ) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <(Arr <ChainState>, PosteriorState?)>( ObserveModuleStateEstimationDataChange ) ), this .ObservableForProperty(vm => vm.SelectedOutputName) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveSelectedOutputName ) ) ); if (CanConfigureControls) { PopulateControls(); } if (CanViewFit) { PopulateChart(); } } }
internal TraceViewModel(IAppService appService, IAppSettings appSettings, TraceState traceState) { _appService = appService; _appSettings = appSettings; _traceState = traceState; _viewHeight = traceState.ViewHeight ?? 200.0; PlotModel = new PlotModel { Title = _traceState.ChartTitle, IsLegendVisible = false }; PlotModel.MouseDown += HandleTracePlotModelMouseDown; _traceHorizontalAxis = new LinearAxis { Position = AxisPosition.Bottom, MinimumPadding = 0, MaximumPadding = 0.06, AbsoluteMinimum = _traceState.HorizontalAxisAbsoluteMinimum, Minimum = _traceState.HorizontalAxisMinimum, AbsoluteMaximum = _traceState.HorizontalAxisAbsoluteMaximum, Maximum = _traceState.HorizontalAxisMaximum }; PlotModel.Axes.Add(_traceHorizontalAxis); _traceVerticalAxis = new LinearAxis { Position = AxisPosition.Left, MinimumPadding = 0, MaximumPadding = 0.06, AbsoluteMinimum = _traceState.VerticalAxisAbsoluteMinimum, Minimum = _traceState.VerticalAxisMinimum, AbsoluteMaximum = _traceState.VerticalAxisAbsoluteMaximum, Maximum = _traceState.VerticalAxisMaximum, Key = "output" }; PlotModel.Axes.Add(_traceVerticalAxis); _traceSeries = new LineSeries { MarkerType = MarkerType.Circle, MarkerFill = _traceState.MarkerFill ?? OxyColors.DodgerBlue, Color = _traceState.SeriesColor ?? OxyColors.DodgerBlue, InterpolationAlgorithm = InterpolationAlgorithms.CatmullRomSpline }; _traceSeries.MouseDown += HandleTraceMouseDown; PlotModel.Series.Add(_traceSeries); _verticalCursor = new LineAnnotation { Type = LineAnnotationType.Vertical }; _verticalCursor.MouseDown += HandleVerticalCursorMouseDown; _verticalCursor.MouseMove += HandleVerticalCursorMouseMove; _verticalCursor.MouseUp += HandleVerticalCursorMouseUp; PlotModel.Annotations.Add(_verticalCursor); PlotModel.ApplyThemeToPlotModelAndAxes(); ResetAxes = ReactiveCommand.Create(HandleResetAxes); ShowOptions = ReactiveCommand.Create(HandleShowOptions); _reactiveSafeInvoke = appService.GetReactiveSafeInvoke(); _subscriptions = new CompositeDisposable( _appSettings .GetWhenPropertyChanged() .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <string?>(ObserveAppSettingsPropertyChange) ), this .ObservableForProperty(vm => vm.ViewHeight) .Subscribe(_reactiveSafeInvoke.SuspendAndInvoke <object>(ObserveViewHeight)), this .ObservableForProperty(vm => vm.SelectedX) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveSelectedX ) ) ); }