//Methods /// <inheritdoc/> protected override void Check() { if (NumOfAttempts < 1) { throw new ArgumentException($"Invalid NumOfAttempts {NumOfAttempts.ToString(CultureInfo.InvariantCulture)}. NumOfAttempts must be GE to 1.", "NumOfAttempts"); } if (NumOfAttemptEpochs < 1) { throw new ArgumentException($"Invalid NumOfAttemptEpochs {NumOfAttemptEpochs.ToString(CultureInfo.InvariantCulture)}. NumOfAttemptEpochs must be GE to 1.", "NumOfAttemptEpochs"); } if (NoiseZeroMargin < 0 || NoiseZeroMargin >= 1) { throw new ArgumentException($"Invalid NoiseZeroMargin {NoiseZeroMargin.ToString(CultureInfo.InvariantCulture)}. NoiseZeroMargin must be GE to 0 and LT 1.", "NoiseZeroMargin"); } return; }
//Methods /// <summary> /// Checks consistency /// </summary> protected override void Check() { if (NumOfAttempts < 1) { throw new ArgumentException($"Invalid NumOfAttempts {NumOfAttempts.ToString(CultureInfo.InvariantCulture)}. NumOfAttempts must be GE to 1.", "NumOfAttempts"); } if (NumOfAttemptEpochs < 1) { throw new ArgumentException($"Invalid NumOfAttemptEpochs {NumOfAttemptEpochs.ToString(CultureInfo.InvariantCulture)}. NumOfAttemptEpochs must be GE to 1.", "NumOfAttemptEpochs"); } if (ZeroTolerance < 0 || ZeroTolerance >= 1) { throw new ArgumentException($"Invalid ZeroTolerance {ZeroTolerance.ToString(CultureInfo.InvariantCulture)}. ZeroTolerance must be GE to 0 and LT 1.", "ZeroTolerance"); } if (PositiveEta <= 1) { throw new ArgumentException($"Invalid PositiveEta {PositiveEta.ToString(CultureInfo.InvariantCulture)}. PositiveEta must be GT 1.", "PositiveEta"); } if (NegativeEta < 0 || NegativeEta >= 1) { throw new ArgumentException($"Invalid NegativeEta {NegativeEta.ToString(CultureInfo.InvariantCulture)}. NegativeEta must be GE to 0 and LT 1.", "NegativeEta"); } if (IniDelta < 0) { throw new ArgumentException($"Invalid IniDelta {IniDelta.ToString(CultureInfo.InvariantCulture)}. IniDelta must be GE to 0.", "IniDelta"); } if (MinDelta < 0) { throw new ArgumentException($"Invalid MinDelta {MinDelta.ToString(CultureInfo.InvariantCulture)}. MinDelta must be GE to 0.", "MinDelta"); } if (MaxDelta < 0) { throw new ArgumentException($"Invalid MinDelta {MaxDelta.ToString(CultureInfo.InvariantCulture)}. MaxDelta must be GE to 0.", "MaxDelta"); } if (MaxDelta <= MinDelta) { throw new ArgumentException($"Invalid MinDelta or MaxDelta. MaxDelta must be GT MinDelta.", "MaxDelta/MinDelta"); } return; }
//Methods /// <inheritdoc/> protected override void Check() { if (NumOfAttempts < 1) { throw new ArgumentException($"Invalid NumOfAttempts {NumOfAttempts.ToString(CultureInfo.InvariantCulture)}. NumOfAttempts must be GE to 1.", "NumOfAttempts"); } if (NumOfAttemptEpochs < 1) { throw new ArgumentException($"Invalid NumOfAttemptEpochs {NumOfAttemptEpochs.ToString(CultureInfo.InvariantCulture)}. NumOfAttemptEpochs must be GE to 1.", "NumOfAttemptEpochs"); } if (IniLR < 0 || IniLR >= 1) { throw new ArgumentException($"Invalid IniLR {IniLR.ToString(CultureInfo.InvariantCulture)}. IniLR must be GE to 0 and LT 1.", "IniLR"); } if (IncLR <= 1) { throw new ArgumentException($"Invalid IncLR {IncLR.ToString(CultureInfo.InvariantCulture)}. IncLR must be GT 1.", "IncLR"); } if (DecLR < 0 || DecLR >= 1) { throw new ArgumentException($"Invalid DecLR {DecLR.ToString(CultureInfo.InvariantCulture)}. DecLR must be GE to 0 and LT 1.", "DecLR"); } if (MinLR < 0 || MinLR >= 1) { throw new ArgumentException($"Invalid MinLR {MinLR.ToString(CultureInfo.InvariantCulture)}. MinLR must be GE to 0 and LT 1.", "MinLR"); } if (MaxLR < 0 || MaxLR >= 1) { throw new ArgumentException($"Invalid MaxLR {MaxLR.ToString(CultureInfo.InvariantCulture)}. MaxLR must be GE to 0 and LT 1.", "MaxLR"); } if (MaxLR <= MinLR) { throw new ArgumentException($"Invalid MinLR or MaxLR. MaxLR must be GT MinLR.", "MaxLR/MinLR"); } return; }
/// <inheritdoc/> public override XElement GetXml(string rootElemName, bool suppressDefaults) { XElement rootElem = new XElement(rootElemName, new XAttribute("attempts", NumOfAttempts.ToString(CultureInfo.InvariantCulture)), new XAttribute("attemptEpochs", NumOfAttemptEpochs.ToString(CultureInfo.InvariantCulture))); if (!suppressDefaults || !IsDefaultNoiseZeroMargin) { rootElem.Add(new XAttribute("noiseZeroMargin", NoiseZeroMargin.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultNoiseSeeker) { rootElem.Add(NoiseFinderCfg.GetXml("noise", suppressDefaults)); } Validate(rootElem, XsdTypeName); return(rootElem); }
/// <summary> /// Generates xml element containing the settings. /// </summary> /// <param name="rootElemName">Name to be used as a name of the root element.</param> /// <param name="suppressDefaults">Specifies whether to ommit optional nodes having set default values</param> /// <returns>XElement containing the settings</returns> public override XElement GetXml(string rootElemName, bool suppressDefaults) { XElement rootElem = new XElement(rootElemName, new XAttribute("attempts", NumOfAttempts.ToString(CultureInfo.InvariantCulture)), new XAttribute("attemptEpochs", NumOfAttemptEpochs.ToString(CultureInfo.InvariantCulture))); if (!suppressDefaults || !IsDefaultZeroTolerance) { rootElem.Add(new XAttribute("zeroTolerance", ZeroTolerance.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultPositiveEta) { rootElem.Add(new XAttribute("positiveEta", PositiveEta.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultNegativeEta) { rootElem.Add(new XAttribute("negativeEta", NegativeEta.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultIniDelta) { rootElem.Add(new XAttribute("iniDelta", IniDelta.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultMinDelta) { rootElem.Add(new XAttribute("minDelta", MinDelta.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultMaxDelta) { rootElem.Add(new XAttribute("maxDelta", MaxDelta.ToString(CultureInfo.InvariantCulture))); } Validate(rootElem, XsdTypeName); return(rootElem); }
/// <inheritdoc/> public override XElement GetXml(string rootElemName, bool suppressDefaults) { XElement rootElem = new XElement(rootElemName, new XAttribute("attempts", NumOfAttempts.ToString(CultureInfo.InvariantCulture)), new XAttribute("attemptEpochs", NumOfAttemptEpochs.ToString(CultureInfo.InvariantCulture))); if (!suppressDefaults || !IsDefaultIniLR) { rootElem.Add(new XAttribute("iniLR", IniLR.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultIncLR) { rootElem.Add(new XAttribute("incLR", IncLR.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultDecLR) { rootElem.Add(new XAttribute("decLR", DecLR.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultMinLR) { rootElem.Add(new XAttribute("minLR", MinLR.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultMaxLR) { rootElem.Add(new XAttribute("maxLR", MaxLR.ToString(CultureInfo.InvariantCulture))); } Validate(rootElem, XsdTypeName); return(rootElem); }