public SimulationSettings(double modelSimTime, double stableStartTime, double startDiff, double respClose, SimulationParameter desired, SimulationParameter actual, SimulationParameter disturbance, ModelRegressionSettings regressionSettings)
 {
     this.ModelSimulationTime = modelSimTime;
     this.StableStartTime = stableStartTime;
     this.SmoothnessStartDifference = startDiff;
     this.ResponsivenessClose = respClose;
     this.DesiredVariable = desired;
     this.ActualVariable = actual;
     this.DisturbanceVariable = disturbance;
     this.RegressionSettings = regressionSettings;
 }
 public SimulationSettings()
 {
     DisturbanceVariable = new SimulationParameter("",SimulationParameterType.Disturbance, 0, 0);
     RegressionSettings = new ModelRegressionSettings();
 }
        private async void Validate_Click(object sender, RoutedEventArgs e)
        {
            double modelSimulationTime = (double)this.ModelSimulationTimeNumUpDown.Value;
            double desiredValueReachedTime = (double)this.DesiredValueReachedNumUpDown.Value;
            double desiredFrom = (double)this.DesiredValueFromNumUpDown.Value;
            double desiredTo = (double)this.DesiredValueToNumUpDown.Value;
            double actualFrom = (double)this.ActualValueFromNumUpDown.Value;
            double actualTo = (double)this.ActualValueToNumUpDown.Value;
            double disturbanceAmplitude = (double)this.DisturbanceValueToNumUpDown.Value;
            double smoothnessDiff = (double)this.SmoothnessStartDifferenceNumUpDown.Value;
            double responsivenessClose = (double)this.ResponsivenessCloseNumUpDown.Value;

            if (desiredValueReachedTime >= modelSimulationTime)
            {
                MessageBox.Show("Invalid desired value reached time. The desired value reached time cannot be greater or equal to the model simulation time.", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (desiredFrom >= desiredTo)
            {
                MessageBox.Show("Invalid desired value range", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (actualFrom >= actualTo)
            {
                MessageBox.Show("Invalid actual value range", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (actualFrom > desiredFrom)
            {
                MessageBox.Show("Invalid actual value range", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (smoothnessDiff > (Math.Abs(actualFrom - actualTo)/10))
            {
                MessageBox.Show("The value after which the smoothness measurement begins cannot be more than a tenth of the actual value range.", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (responsivenessClose > (Math.Abs(actualFrom - actualTo) / 20))
            {
                MessageBox.Show("The absolute difference between the actual and the desired value at which the responsiveness measurement ends cannot be more than a fifth of the actual value range.", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (String.IsNullOrWhiteSpace(this.DesiredValueNameTextBox.Text))
            {
                MessageBox.Show("Please specify the name of the desired variable.", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (String.IsNullOrWhiteSpace(this.ActualValueNameTextBox.Text))
            {
                MessageBox.Show("Please specify the name of the actual variable.", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (this.RefinedCandidatePointsNumUpDown.Value > 10)
            {
                MessageBox.Show("A maximum of 10 candidate points are allowed.", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            SimulationParameter desired = new SimulationParameter(this.DesiredValueNameTextBox.Text, SimulationParameterType.Desired, new decimal(desiredFrom), new decimal(desiredTo));
            SimulationParameter actual = new SimulationParameter(this.ActualValueNameTextBox.Text, SimulationParameterType.Actual, new decimal(actualFrom), new decimal(actualTo));
            SimulationParameter disturbance = new SimulationParameter(this.DisturbanceValueNameTextBox.Text, SimulationParameterType.Disturbance, new decimal(0), new decimal(disturbanceAmplitude));

            ModelRegressionSettings regressionSettings = new ModelRegressionSettings() { ModelQuality = (double)this.ModelQualityNumUpDown.Value, RefinedCandidatePoints = (int)this.RefinedCandidatePointsNumUpDown.Value, RefinementPoints = (int)this.RefinementSizeNumUpDown.Value, ValidationSetSize = (int)this.ValidationSetRandomPointsNumUpDown.Value, TrainingSetSizeEqualDistance = (int)this.TrainingSetPointsNumUpDown.Value, TrainingSetSizeRandom = (int)this.TrainingSetRandomPointsNumUpDown.Value };

            ModelSimulationSettings = new SimulationSettings(modelSimulationTime, desiredValueReachedTime, smoothnessDiff, responsivenessClose, desired, actual, disturbance, regressionSettings);

            progressController = await containingWindow.ShowProgressAsync("Please wait...", "Model compilation and simulation running");
            progressController.SetIndeterminate();
            
            TestFunctionality();
        }