public void ToFloatingPoint_NoArgs_Double() { RandomizationProvider.Current = Substitute.For <IRandomization> (); RandomizationProvider.Current.GetInt(0, 3).Returns(2); var target = new IntegerChromosome(0, 3); var actual = target.ToInteger(); Assert.AreEqual(2, actual); }
public void ToFloatingPoint_NoArgs_Double() { RandomizationProvider.Current = MockRepository.GenerateMock <IRandomization> (); RandomizationProvider.Current.Expect(r => r.GetInt(0, 3)).Return(2); var target = new IntegerChromosome(0, 3); var actual = target.ToInteger(); Assert.AreEqual(2, actual); }
public void ToInteger_NegativeValue_Integer() { RandomizationProvider.Current = Substitute.For <IRandomization>(); RandomizationProvider.Current.GetInt(0, 3).Returns(-2); var target = new IntegerChromosome(0, 3); Assert.AreEqual("11111111111111111111111111111110", target.ToString()); var actual = target.ToInteger(); Assert.AreEqual(-2, actual); }
void Example() { var i = new IntegerChromosome(3, 3); // 31 is the least significant bit // 0 is sign bit i.FlipGene(31); Console.WriteLine("I3: " + i.ToInteger()); var array = new int[1]; // most significant bit is the right most bit. // Last bit is sign bit var genes = new bool[] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false }; var bitArray = new BitArray(genes); bitArray.CopyTo(array, 0); Console.WriteLine(array[0]); }
public void Integer() { var target = new IntegerChromosome(0, 10); target.Clone(); target.CompareTo(new IntegerChromosome(0, 10)); target.CreateNew(); var x = target.Fitness; target.FlipGene(0); target.GenerateGene(0); target.GetGene(0); target.GetGenes(); target.GetHashCode(); var y = target.Length; target.ReplaceGene(0, new Gene(false)); target.ReplaceGenes(0, new Gene[] { new Gene(false), new Gene(true) }); target.Resize(20); target.ToInteger(); target.ToString(); }