protected override PatternedSelections <LegSelections> GetPatternedSelections(IReadOnlyList <LegSelections> legs)
        {
            var result   = new FectaPatternedSelections(legs);
            var usedBins = new HashSet <int>();

            foreach (var leg in Pool.Legs) //Legs should be prepared in leg order when building the Pool model
            {
                var legOrder        = leg.LegOrder;
                var selCnt          = result[legOrder].Capacity;
                var validSelections = leg.Selections.Where(s => s.Probability > 0).ToArray();
                if (selCnt > 2 && legOrder > 1)
                {
                    var binsInPreviousLeg = result[legOrder - 1].Bins;
                    result[legOrder].AddRange(validSelections.Where(s => binsInPreviousLeg.Contains(s.Bin)));
                }

                var additionalSelections = SmartPickHelper.GetGoodSelections(
                    validSelections.Where(s => !usedBins.Contains(s.Bin)), selCnt - result[legOrder].Count).ToArray();

                result[legOrder].AddRange(additionalSelections);

                additionalSelections.ToList().ForEach(sel => { usedBins.Add(sel.Bin); });
            }

            return(result);
        }
Beispiel #2
0
        protected virtual PatternedSelections <T> GetPatternedSelections(IReadOnlyList <T> legs)
        {
            var result = new PatternedSelections <T>(legs);

            foreach (var leg in Pool.Legs)
            {
                var legOrder            = leg.LegOrder;
                var availableSelections = leg.Selections.Where(s => s.Probability > 0);
                var selCnt = result[legOrder].Capacity;
                var additionalSelections = SmartPickHelper.GetGoodSelections(availableSelections, selCnt);
                result[legOrder].AddRange(additionalSelections);
            }

            return(result);
        }
        private Line GenerateNewLine()
        {
            var line  = new int[Pool.Legs.Length];
            var probs = 1d;

            foreach (var leg in Pool.Legs)
            {
                var legOrder = leg.LegOrder;
                var legSels  = leg.Selections.Where(s => !line.Contains(s.Bin));
                var sel      = SmartPickHelper.GetGoodSelections(legSels, 1).First();
                line[legOrder - 1] = sel.Bin;
                probs *= sel.Probability;
            }

            return(new Line(line, probs));
        }