public void TestKeyPairsCount() { Assert.AreEqual ( KeyPairRepository.KeyPairsForKeyCount(KeyPairRepository.MaxKeyCount).Count(), KeyPairRepository.KeyPairSetSizeForKeyCount(KeyPairRepository.MaxKeyCount) ); }
public void ConvertSorterTest() { const int keyCount = 16; const int sequenceLength = 100; var keyPairSet = KeyPairRepository.KeyPairSet(keyCount); var guid = Guid.NewGuid(); var keyPairs = Enumerable.Range(0, KeyPairRepository.KeyPairSetSizeForKeyCount(keyCount)) .Select(i => keyPairSet[i]) .ToArray(); var sorter = keyPairs.ToSorter(guid: guid, keyCount: keyCount); var serialized = JsonConvert.SerializeObject(sorter.ToJsonAdapter(), Formatting.Indented); var newSorter = serialized.ToSorter(); Assert.AreEqual(newSorter.Guid, guid); Assert.AreEqual(newSorter.KeyCount, keyCount); Assert.IsTrue(newSorter.KeyPairs.IsSameAs(keyPairs)); }
public static ISorterGenome ToSorterGenome( this IRando randy, int keyCount, int keyPairCount) { var keyPairSetSize = (uint)KeyPairRepository.KeyPairSetSizeForKeyCount(keyCount); return(new SorterGenomeImpl ( guid: randy.NextGuid(), parentGuid: Guid.Empty, chromosome: randy .ToUintEnumerator(keyPairSetSize) .Take(keyPairCount) .ToList() .ToChromosomeUint ( maxVal: keyPairSetSize ), keyCount: keyCount, keyPairCount: keyPairCount )); }
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 ) ) ); } }
protected ArraySwitchSet(int keyCount) { _keyCount = keyCount; _switchFuncs = new Func <T, Tuple <T, bool> > [KeyPairRepository.KeyPairSetSizeForKeyCount(KeyCount)]; MakeSwitchFuncs(); }