/// <summary> /// The state. /// </summary> /// <param name="chain"> /// The chain. /// </param> /// <param name="alphabet"> /// The alphabet. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public override bool State(ComplexChain chain, FrequencyDictionary alphabet) { double current = Distortion(chain, alphabet); if (Value > current) { Value = current; this.chain = chain.Clone(); this.alphabet = alphabet.Clone(); ThresholdToStop.SaveBest(); } return ThresholdToStop.Distance > ThresholdVariator.Precision; }
/// <summary> /// The state. /// </summary> /// <param name="chain"> /// The chain. /// </param> /// <param name="alphabet"> /// The alphabet. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public override bool State(ComplexChain chain, FrequencyDictionary alphabet) { double currentDistortion = depth.Calculate(chain, chain.Anchor); // - calculate(gamutDeep, chain); if (Math.Abs(currentDistortion) > Value) { this.chain = chain.Clone(); this.alphabet = alphabet.Clone(); ThresholdToStop.SaveBest(); Value = currentDistortion; } return ThresholdToStop.Distance > ThresholdVariator.Precision; }
/// <summary> /// The state. /// </summary> /// <param name="chain"> /// The chain. /// </param> /// <param name="alphabet"> /// The alphabet. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public override bool State(ComplexChain chain, FrequencyDictionary alphabet) { double distortion = Distortion(chain, alphabet); if (Math.Abs(Value) > Math.Abs(distortion)) { this.chain = chain.Clone(); this.alphabet = alphabet.Clone(); Value = distortion; ThresholdToStop.SaveBest(); } return ThresholdToStop.Distance > ThresholdVariator.Precision; }
/// <summary> /// The initialize method. /// </summary> /// <param name="chain"> /// The chain. /// </param> /// <param name="windowLength"> /// The window length. /// </param> /// <param name="step"> /// The step. /// </param> private void Initialize(ComplexChain chain, int windowLength, int step) { try { int chainLength = chain.GetLength(); if ((chainLength < windowLength) || (windowLength == 0) || ((step < 1) || (step > chainLength))) { throw new Exception(); } } catch (Exception) { } this.chain = chain.Clone(); this.windowLength = windowLength; this.step = step; CursorPosition = -step; CalculateMaxShifts(); }
/// <summary> /// The update. /// </summary> /// <param name="chain"> /// The chain. /// </param> /// <param name="alphabet"> /// The alphabet. /// </param> private void Update(ComplexChain chain, FrequencyDictionary alphabet) { double dist = TheoryVolume(chain, alphabet) - alphabet.Count; if (Math.Abs(Value) > Math.Abs(dist)) { this.alphabet = alphabet.Clone(); this.chain = chain.Clone(); Value = dist; ThresholdToStop.SaveBest(); } }