public void CloneTest() { string str = chain.ToString(); var alphabet1 = new FrequencyDictionary(str); var alphabet2 = new FrequencyDictionary(chain); FrequencyDictionary alphabet3 = alphabet2.Clone(); Assert.True(alphabet1.Equals(alphabet2) && alphabet3.Equals(alphabet1)); }
/// <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 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 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 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(); } }