示例#1
0
文件: Trainers.cs 项目: wintonpc/Quqe
        static Tuple2 <int> GetDataWindowOffsetAndSize(int count, Chromosome chrom)
        {
            int offset = MathEx.Clamp(0, count - 1, (int)(chrom.TrainingOffsetPct * count));
            int size   = MathEx.Clamp(1, count - offset, (int)(chrom.TrainingSizePct * count));

            return(Tuple2.Create(offset, size));
        }
示例#2
0
        public static Tuple2 <T> SelectTwoAccordingToQuality <T>(IList <T> items, Func <T, double> quality)
        {
            var possibleFirsts  = items;
            var first           = SelectOneAccordingToQuality(possibleFirsts, quality);
            var possibleSeconds = items.Except(Lists.Create(first)).ToList();
            var second          = SelectOneAccordingToQuality(possibleSeconds, quality);

            return(Tuple2.Create(first, second));
        }
示例#3
0
        internal static Tuple2 <Chromosome> CrossOverChromosomes(Chromosome a, Chromosome b)
        {
            Debug.Assert(a.NetworkType == b.NetworkType);
            Debug.Assert(a.OrderInMixture == b.OrderInMixture);

            Func <Gene, Gene, Tuple2 <Gene> > crossGenes = (x, y) => {
                Debug.Assert(x.Name == y.Name);
                return(QuqeUtil.WithProb(0.5) ? Tuple2.Create(x, y) : Tuple2.Create(y, x));
            };

            return(CrossOver(a.Genes, b.Genes, crossGenes, genes => new Chromosome(a.NetworkType, genes, a.OrderInMixture)));
        }