private static void PrintResults(double[] c, int errorCode, alglib.lsfitreport report) { if (errorCode == 2) // fitting successfully { Console.WriteLine("fitting coefficients: {0}", ToTokenSeparatedString <double>(c, ", ")); // EXPECTED: [1.5] //Console.WriteLine(); Console.WriteLine("{0,8:N5} R2 non-adjusted coefficient of determination (non-weighted)", report.r2); Console.WriteLine("{0,8:N5} RMSError rms error on the(X, Y).", report.rmserror); Console.WriteLine("{0,8:N5} AvgError average error on the(X, Y).", report.avgerror); Console.WriteLine("{0,8:N5} AvgRelError average relative error on the non-zero Y", report.avgrelerror); Console.WriteLine("{0,8:N5} MaxError maximum error NON-WEIGHTED ERRORS ARE CALCULATED", report.maxerror); Console.WriteLine("{0,8:N5} WRMSError weighted rms error on the(X, Y).", report.wrmserror); } else { Console.WriteLine("fitting returns error code {0}", errorCode); Console.WriteLine("-8 optimizer detected NAN/INF in the target function and/or gradient"); Console.WriteLine("-7 gradient verification failed."); Console.WriteLine("-3 inconsistent constraints"); Console.WriteLine(" 2 relative step is no more than EpsX."); Console.WriteLine(" 5 MaxIts steps was taken"); Console.WriteLine(" 7 stopping conditions are too stringent, further improvement is impossible"); } //Console.WriteLine(); }
/// <summary> /// Constructor. /// </summary> /// <param name="report">Report from algorithm</param> /// <param name="didConverge"></param> public SolverReport(alglib.lsfitreport report, bool didConverge) { //see notes at bottom from Alglib website AverageError = report.avgerror; DidConverge = didConverge; IterationCount = report.iterationscount; MaxError = report.maxerror; PerPointNoise = report.noise; RmsError = report.rmserror; RSquared = report.r2; WeightedRmsError = report.wrmserror; }