/// <summary>Creates a new <see cref="State"/> object. /// </summary> /// <param name="classification">The classification of the result.</param> /// <param name="root">The estimated root of the specific algorithm.</param> /// <param name="functionValue">The function value at <paramref name="root"/>; should be almost <c>0.0</c>.</param> /// <param name="evaluationsNeeded">The number of function evaluations needed by the algorithm to reach the desired accuracy.</param> /// <param name="iterationsNeeded">The number of iterations needed by the algorithm to reach the desired accuracy.</param> /// <param name="details">Additional details in its <see cref="InfoOutputProperty"/> representation.</param> /// <returns>A <see cref="State"/> object that represents the state of a specific calculation.</returns> public static State Create(EquationSolverErrorClassification classification, double root, double functionValue, int evaluationsNeeded = Int32.MaxValue, int iterationsNeeded = Int32.MaxValue, params InfoOutputProperty[] details) { var properties = new List <InfoOutputProperty>() { InfoOutputProperty.Create("Root", root), InfoOutputProperty.Create("FunctionValue", functionValue) }; if (details != null) { properties.AddRange(details); } return(new State(classification, properties, evaluationsNeeded, iterationsNeeded)); }
/// <summary>Initializes a new instance of the <see cref="State"/> class. /// </summary> /// <param name="classification">The classification of the result.</param> /// <param name="evaluationsNeeded">The number of function evaluations needed by the algorithm to reach the desired accuracy.</param> /// <param name="iterationsNeeded">The number of iterations needed by the algorithm to reach the desired accuracy.</param> protected internal State(EquationSolverErrorClassification classification, int evaluationsNeeded = Int32.MaxValue, int iterationsNeeded = Int32.MaxValue) { Classification = classification; EvaluationsNeeded = evaluationsNeeded; IterationsNeeded = iterationsNeeded; InfoOutputDetailLevel = InfoOutputDetailLevel.Full; var strBuilder = new StringBuilder(); strBuilder.AppendFormat("{0}", Classification); if (iterationsNeeded < Int32.MaxValue) { strBuilder.AppendFormat("; Iterations needed: {0}", iterationsNeeded); } if (evaluationsNeeded < Int32.MaxValue) { strBuilder.AppendFormat("; Evaluations needed: {0}", evaluationsNeeded); } m_StringRepresentation = strBuilder.ToString(); m_InfoOutputPackageAction = null; }
/// <summary>Initializes a new instance of the <see cref="State"/> class. /// </summary> /// <param name="classification">The classification of the result.</param> /// <param name="details">Additional details in its <see cref="InfoOutputProperty"/> representation.</param> /// <param name="evaluationsNeeded">The number of function evaluations needed by the algorithm to reach the desired accuracy.</param> /// <param name="iterationsNeeded">The number of iterations needed by the algorithm to reach the desired accuracy.</param> protected internal State(EquationSolverErrorClassification classification, IEnumerable <InfoOutputProperty> details, int evaluationsNeeded = Int32.MaxValue, int iterationsNeeded = Int32.MaxValue) { Classification = classification; EvaluationsNeeded = evaluationsNeeded; IterationsNeeded = iterationsNeeded; InfoOutputDetailLevel = InfoOutputDetailLevel.Full; var strBuilder = new StringBuilder(); strBuilder.AppendFormat("{0}", Classification); if (details != null) { foreach (var property in details) { strBuilder.AppendFormat("; {0}: {1}", property.Name.String, property.Value); } m_InfoOutputPackageAction = infoOutputPackage => { foreach (var property in details) { infoOutputPackage.Add(property); } }; } if (iterationsNeeded < Int32.MaxValue) { strBuilder.AppendFormat("; Iterations needed: {0}", iterationsNeeded); } if (evaluationsNeeded < Int32.MaxValue) { strBuilder.AppendFormat("; Evaluations needed: {0}", evaluationsNeeded); } m_StringRepresentation = strBuilder.ToString(); }
/// <summary>Creates a new <see cref="State"/> object. /// </summary> /// <param name="classification">The classification of the result.</param> /// <param name="evaluationsNeeded">The number of function evaluations needed by the algorithm to reach the desired accuracy.</param> /// <param name="iterationsNeeded">The number of iterations needed by the algorithm to reach the desired accuracy.</param> /// <param name="details">Additional details in its <see cref="InfoOutputProperty"/> representation.</param> /// <returns>A <see cref="State"/> object that represents the state of a specific calculation.</returns> public static State Create(EquationSolverErrorClassification classification, int evaluationsNeeded = Int32.MaxValue, int iterationsNeeded = Int32.MaxValue, params InfoOutputProperty[] details) { return(new State(classification, details, evaluationsNeeded, iterationsNeeded)); }
/// <summary>Creates a new <see cref="State"/> object. /// </summary> /// <param name="classification">The classification of the result.</param> /// <returns>A <see cref="State"/> object that represents the state of a specific calculation.</returns> public static State Create(EquationSolverErrorClassification classification) { return(new State(classification)); }