public List <SniperInfo> FindAll()
        {
            TrackemonSession session = FindSessionId();

            if (session == null || !session.validate())
            {
                session = FindSessionId();
                if (session == null)
                {
                    Log.Debug("Trackemon: No valid session found!");
                    return(null);
                }
            }
            List <SniperInfo> list = new List <SniperInfo>();

            IEnumerable <List <PokemonId> > pokemonTypeIdPartitions = Partitioner.Partition(pokemonIdsToFind, 5);

            foreach (List <PokemonId> partition in pokemonTypeIdPartitions)
            {
                List <SniperInfo> resultList = findSubSetOfPokemon(partition, session);
                if (resultList != null)
                {
                    list.AddRange(resultList);
                }
            }

            return(list);
        }
예제 #2
0
        public void partitioning_a_list_of_four_items_by_two_produces_a_partition_of_size_two()
        {
            Partitioner partitioner = new Partitioner(2);
            var         partition   = partitioner.Partition(_sharesList);

            Assert.AreEqual(2, partition.Size);
        }
예제 #3
0
 public void partition(JArray input)
 {
     // Partition the input
     foreach (var tuple in input)
     {
         int chosenReducer = Partitioner.Partition(tuple [0], NumberReducers);
         partitions [chosenReducer].Add(tuple);
     }
 }
예제 #4
0
        private static void PerformTestPartitionSizes(int absoluteBeamWidth, int tokenListSize, bool tokenListLarger)
        {
            var random      = new Random((int)Java.CurrentTimeMillis());
            var partitioner = new Partitioner();

            var parent = new Token(null, 0);
            var tokens = new Token[tokenListSize];

            for (var i = 0; i < tokens.Length; i++)
            {
                var logTotalScore = (float)random.NextDouble();
                tokens[i] = new Token(parent, null, logTotalScore, 0.0f, 0.0f, i);
            }

            var r = partitioner.Partition(tokens, tokens.Length, absoluteBeamWidth);

            if (tokenListLarger)
            {
                Assert.AreEqual(r, absoluteBeamWidth - 1);
            }
            else
            {
                Assert.AreEqual(r, tokenListSize - 1);
            }

            var firstList = new List <Token>();

            if (r >= 0)
            {
                var lowestScore = tokens[r].Score;

                for (var i = 0; i <= r; i++)
                {
                    Assert.IsTrue(tokens[i].Score >= lowestScore);
                    firstList.Add(tokens[i]);
                }
                for (var i = r + 1; i < tokens.Length; i++)
                {
                    Assert.IsTrue(lowestScore > tokens[i].Score);
                }


                firstList.Sort(new ScoreableComparator());

                var secondList = Arrays.AsList(tokens);
                secondList.Sort(new ScoreableComparator());


                for (int i = 0; i < firstList.Count; i++)
                {
                    var t1 = firstList[i];
                    var t2 = secondList[i];
                    Assert.AreEqual(t1, t2);
                }
            }
        }
예제 #5
0
        public void Partitioning_a_list_of_two_items_by_one_produces_a_partition_of_size_two()
        {
            List <Share> sharesList = CreateSharesListOfSize(2);

            Partitioner partitioner = new Partitioner(1);
            Partition   partition   = partitioner.Partition(sharesList);

            System.Diagnostics.Debug.WriteLine(string.Format("The inside of Size is: {0}", partition.Size.ToString()));
            Assert.AreEqual(2, partition.Size);
        }
예제 #6
0
        public static IEnumerable <IEnumerable <T> > Partition <T>(this IEnumerable <T> @this, int partitionSize, bool sharedEnumerator)
        {
            if (sharedEnumerator)
            {
                var partitioner = new Partitioner <T>(partitionSize);
                return(partitioner.Partition(@this));
            }

            return(InnerPartition(@this, partitionSize));
        }
예제 #7
0
        public void Partition_Orders()
        {
            int p;
            var tokens      = new Token[100000];
            var partitioner = new Partitioner();

            for (var i = 0; i < 100000; i++)
            {
                tokens[i] = new Token(null, null, 1 - i, 0, 0, 0);
            }
            p = partitioner.Partition(tokens, 100000, 3000);
            Assert.AreEqual(p, 2999);
            TestSorted(tokens, p);

            for (var i = 0; i < 100000; i++)
            {
                tokens[i] = new Token(null, null, i, 0, 0, 0);
            }
            p = partitioner.Partition(tokens, 100000, 3000);
            Assert.AreEqual(p, 2999);
            TestSorted(tokens, p);

            for (var i = 0; i < 100000; i++)
            {
                tokens[i] = new Token(null, null, 0, 0, 0, 0);
            }
            p = partitioner.Partition(tokens, 100000, 3000);
            Assert.AreEqual(p, 2999);
            TestSorted(tokens, p);

            for (var i = 0; i < 100000; i++)
            {
                tokens[i] = new Token(null, null, (float)Java.Random(), 0, 0, 0);
            }
            p = partitioner.Partition(tokens, 100000, 3000);
            Assert.AreEqual(p, 2999);
            TestSorted(tokens, p);
        }
예제 #8
0
        public void Partition()
        {
            try
            {
                Partitioner p = new Partitioner(Hierarchy, this);
                p.Partition(SelectedTreeNode);

                AllocateIds();

                IsModified = true;
            }
            catch (Exception e)
            {
                throw new DsmException("Matrix partitioning error", e);
            }
        }
예제 #9
0
        public void Partitioning_a_list_of_one_item_by_one_produces_a_partition_of_size_one()
        {
            List <Share> sharesList = new List <Share>();

            Share shareOne = new Share();

            shareOne.Maximum = 100;
            shareOne.Minimum = 13;
            sharesList.Add(shareOne);
            sharesList.Add(new Share()
            {
                Maximum = 50, Minimum = 10
            });

            Partitioner partitioner = new Partitioner(1);
            var         partition   = partitioner.Partition(sharesList);

            Assert.AreEqual(2, partition.Size);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="stepExecution"></param>
        /// <param name="gridSize"></param>
        /// <returns></returns>
        private IDictionary <string, ExecutionContext> GetContexts(StepExecution stepExecution, int gridSize)
        {
            ExecutionContext context = stepExecution.ExecutionContext;
            string           key     = "SimpleStepExecutionSplitter.GRID_SIZE";

            // If this is a restart we must retain the same grid size, ignoring the
            // one passed in...
            int splitSize = (int)context.GetLong(key, gridSize);

            context.PutLong(key, splitSize);

            IDictionary <string, ExecutionContext> result;

            if (context.Dirty)
            {
                // The context changed so we didn't already know the partitions
                JobRepository.UpdateExecutionContext(stepExecution);
                result = Partitioner.Partition(splitSize);
            }
            else
            {
                if (Partitioner is IPartitionNameProvider)
                {
                    result = new Dictionary <string, ExecutionContext>();
                    ICollection <string> names = ((IPartitionNameProvider)Partitioner).GetPartitionNames(splitSize);
                    foreach (string name in names)
                    {
                        // We need to return the same keys as the original (failed)
                        // execution, but the execution contexts will be discarded
                        // so they can be empty.
                        result.Add(name, new ExecutionContext());
                    }
                }
                else
                {
                    // If no names are provided, grab the partition again.
                    result = Partitioner.Partition(splitSize);
                }
            }

            return(result);
        }
예제 #11
0
 private void PatitionButton_MouseUp(object sender, MouseButtonEventArgs e)
 {
     Partitioner.Partition();
 }