diff --git a/Dynamic/Identification/ClosedLoopUnitIdentifier.cs b/Dynamic/Identification/ClosedLoopUnitIdentifier.cs index e5765cb..5715c2d 100644 --- a/Dynamic/Identification/ClosedLoopUnitIdentifier.cs +++ b/Dynamic/Identification/ClosedLoopUnitIdentifier.cs @@ -94,6 +94,9 @@ public class ClosedLoopUnitIdentifier } } // set "indicestoignore" to exclude values outside ymin/ymax_fit and umin_fit,u_max_fit + // + // dataSet.DetermineIndicesToIgnore(fittingSpecs); + // this variable holds the "newest" unit model run and is updated // over multiple runs, and as it improves, the @@ -296,6 +299,19 @@ public class ClosedLoopUnitIdentifier identUnitModel.modelParameters.Fitting.WasAbleToIdentify = true; identUnitModel.modelParameters.Fitting.StartTime = dataSet.Times.First(); identUnitModel.modelParameters.Fitting.EndTime = dataSet.Times.Last(); + identUnitModel.modelParameters.Fitting.TimeBase_s = dataSet.GetTimeBase(); + + var uMaxList = new List(); + var uMinList = new List(); + + for (int i = 0; i < dataSet.U.GetNColumns(); i++) + { + uMaxList.Add(vec.Max(dataSet.U.GetColumn(i))); + uMinList.Add(vec.Min(dataSet.U.GetColumn(i))); + } + identUnitModel.modelParameters.Fitting.Umax = uMaxList.ToArray(); + identUnitModel.modelParameters.Fitting.Umin = uMinList.ToArray(); + if (wasGainGlobalSearchDone) { identUnitModel.modelParameters.Fitting.SolverID = "ClosedLoop/w gain global search/2 step"; @@ -303,6 +319,9 @@ public class ClosedLoopUnitIdentifier else identUnitModel.modelParameters.Fitting.SolverID = "ClosedLoop local (NO global search)"; identUnitModel.modelParameters.Fitting.NFittingTotalDataPoints = dataSet.GetNumDataPoints(); + identUnitModel.modelParameters.Fitting.NFittingBadDataPoints = dataSet.IndicesToIgnore.Count(); + + } // closed-loop simulation, adds U_sim and Y_sim to "dataset" { diff --git a/Dynamic/Identification/FittingInfo.cs b/Dynamic/Identification/FittingInfo.cs index 77804e3..a6d06ae 100644 --- a/Dynamic/Identification/FittingInfo.cs +++ b/Dynamic/Identification/FittingInfo.cs @@ -32,6 +32,38 @@ public class FittingInfo /// public string SolverID { get; set; } + + /// + /// A score that is 100% if model describes all variations + /// and 0% if model is no better at describing variation than the flat average line. + /// Negative if the model is worse than a flat average line. + /// + + public double FitScorePrc { get; set; } + + + /// + /// Number of bad data points ignored during fitting + /// + /// + public double NFittingBadDataPoints { get; set; } + + /// + /// Number of total data points (good and bad) available for fitting + /// + public double NFittingTotalDataPoints { get; set; } + + /// + /// Start time of fitting data set + /// + public DateTime StartTime { get; set; } + + /// + /// End time of fitting data set + /// + public DateTime EndTime { get; set; } + + /// /// The value of the R2 or root mean square of fitting,higher is better (used to choose among models) /// @@ -65,53 +97,22 @@ public class FittingInfo public double ObjFunValAbs { get; set; } - /// - /// A score that is 100% if model describes all variations - /// and 0% if model is no better at describing variation than the flat average line. - /// Negative if the model is worse than a flat average line. - /// - - public double FitScorePrc { get; set; } - - /// - /// Number of bad data points ignored during fitting - /// - /// - - public double NFittingBadDataPoints { get; set; } - - /// - /// Number of total data points (good and bad) available for fitting - /// - public double NFittingTotalDataPoints { get; set; } - - /// - /// Start time of fitting data set + /// The time base of the fitting dataset (model can still be run on other timebases) /// - public DateTime StartTime { get; set; } - /// - /// End time of fitting data set - /// - public DateTime EndTime { get; set; } + public double TimeBase_s; - /// - /// The maximum value of u seen in the data set - /// - public double[] Umax; /// /// The minimum value of u seen in the data set /// public double[] Umin; - /// - /// The time base of the fitting dataset (model can still be run on other timebases) + /// The maximum value of u seen in the data set /// - - public double TimeBase_s; + public double[] Umax; /// diff --git a/TimeSeriesAnalysis.csproj b/TimeSeriesAnalysis.csproj index 6d336de..fbb760c 100644 --- a/TimeSeriesAnalysis.csproj +++ b/TimeSeriesAnalysis.csproj @@ -14,7 +14,7 @@ False https://github.com/equinor/TimeSeriesAnalysis.git readme.md - 1.3.33 + 1.3.34 Equinor Equinor true