Skip to content

Commit

Permalink
- re-arranging fiting info to have most important members first
Browse files Browse the repository at this point in the history
- closedloopidentifier now tries to set some more fitting info
  • Loading branch information
Steinar Elgsæter committed Nov 22, 2024
1 parent aa3674c commit f442db3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 36 deletions.
19 changes: 19 additions & 0 deletions Dynamic/Identification/ClosedLoopUnitIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -296,13 +299,29 @@ 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<double>();
var uMinList = new List<double>();

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";
}
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"
{
Expand Down
71 changes: 36 additions & 35 deletions Dynamic/Identification/FittingInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,38 @@ public class FittingInfo
/// </summary>
public string SolverID { get; set; }


/// <summary>
/// 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.
/// </summary>

public double FitScorePrc { get; set; }


/// <summary>
/// Number of bad data points ignored during fitting
/// </summary>
///
public double NFittingBadDataPoints { get; set; }

/// <summary>
/// Number of total data points (good and bad) available for fitting
/// </summary>
public double NFittingTotalDataPoints { get; set; }

/// <summary>
/// Start time of fitting data set
/// </summary>
public DateTime StartTime { get; set; }

/// <summary>
/// End time of fitting data set
/// </summary>
public DateTime EndTime { get; set; }


/// <summary>
/// The value of the R2 or root mean square of fitting,higher is better (used to choose among models)
/// <para>
Expand Down Expand Up @@ -65,53 +97,22 @@ public class FittingInfo

public double ObjFunValAbs { get; set; }


/// <summary>
/// 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.
/// </summary>

public double FitScorePrc { get; set; }

/// <summary>
/// Number of bad data points ignored during fitting
/// </summary>
///

public double NFittingBadDataPoints { get; set; }

/// <summary>
/// Number of total data points (good and bad) available for fitting
/// </summary>
public double NFittingTotalDataPoints { get; set; }

/// <summary>
/// Start time of fitting data set
/// The time base of the fitting dataset (model can still be run on other timebases)
/// </summary>
public DateTime StartTime { get; set; }

/// <summary>
/// End time of fitting data set
/// </summary>
public DateTime EndTime { get; set; }
public double TimeBase_s;

/// <summary>
/// The maximum value of u seen in the data set
/// </summary>
public double[] Umax;

/// <summary>
/// The minimum value of u seen in the data set
/// </summary>
public double[] Umin;


/// <summary>
/// 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
/// </summary>

public double TimeBase_s;
public double[] Umax;


/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion TimeSeriesAnalysis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<RunAnalyzersDuringLiveAnalysis>False</RunAnalyzersDuringLiveAnalysis>
<RepositoryUrl>https://github.com/equinor/TimeSeriesAnalysis.git</RepositoryUrl>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<Version>1.3.33</Version>
<Version>1.3.34</Version>
<Company>Equinor</Company>
<Authors>Equinor</Authors>
<IncludeSymbols>true</IncludeSymbols>
Expand Down

0 comments on commit f442db3

Please sign in to comment.