public static IChromosomeUint ToChromosomeUint(this ChromosomeUintToJson chromosomeUintToJson)
 {
     return(ChromosomeUint.Make
            (
                sequence: chromosomeUintToJson.Sequence,
                maxVal: chromosomeUintToJson.MaxVal
            ));
 }
        public void ConvertChromosomeUintTest()
        {
            const uint maxVal         = 25;
            const int  sequenceLength = 100;

            IReadOnlyList <uint> sequence = Enumerable.Range(0, (int)maxVal).Select(t => (uint)t)
                                            .Repeat().Take(sequenceLength).ToList();

            var chromosomeUint = ChromosomeUint.Make
                                 (
                sequence: sequence,
                maxVal: maxVal
                                 );

            var serialized = chromosomeUint.ToJsonString();

            var newChromosomeUint = serialized.ToChromosomeUint();

            Assert.AreEqual(newChromosomeUint.MaxVal, maxVal);
            Assert.IsTrue(newChromosomeUint.Sequence.IsSameAs(sequence));
        }
Esempio n. 3
0
 protected void OnConvertToGenomesCommand()
 {
     foreach (var sorterVm in SorterGridVm.SorterVms)
     {
         SorterGenomeGridVm.SorterGenomeVms.Add
         (
             new SorterGenomeVm
             (
                 SorterGenome.Make
                 (
                     guid: sorterVm.Guid,
                     parentGuid: Guid.Empty,
                     chromosome: ChromosomeUint.Make
                     (
                         sequence: sorterVm.Sorter.KeyPairs.Select(kp => (uint)kp.Index).ToArray(),
                         maxVal: (uint)KeyPairRepository.KeyPairSetSizeForKeyCount(sorterVm.Sorter.KeyCount)
                     ),
                     keyCount: sorterVm.Sorter.KeyCount,
                     keyPairCount: sorterVm.Sorter.KeyPairCount
                 )
             )
         );
     }
 }