Пример #1
0
        /// <summary>
        /// Runs the Mode.
        /// </summary>
        /// <param name="args"></param>
        public override void Run( )
        {
            Out.WriteLine(Results.Header( ));

            // Make a proccessing thread for each processor.
            List <Thread> Threads     = new List <Thread>( );
            int           ThreadCount = Environment.ProcessorCount;

            if (maxThreads != 0 && maxThreads < ThreadCount)
            {
                ThreadCount = maxThreads;
            }
            for (int i = 0; i < ThreadCount; i++)
            {
                Thread t = new Thread(this.ThreadProcessor);
                t.Name = i.ToString( );
                Threads.Add(t);
            }

            // Setup the Queues for the processing threads to work with.
            ProcessingQueue = new Queue <ProcessingQueueElement>( );

            foreach (var Alg in Algorithms)
            {
                int computationLimit, clindex;
                for (computationLimit = computationLimitMin, clindex = 1;
                     computationLimit < computationLimitMax;
                     computationLimit = computationLimitMethod(computationLimit, clindex),
                     clindex++)
                {
                    ProcessingQueueElement e;
                    e.Algorithm           = Alg;
                    e.File                = file;
                    e.OptimalSolutionCost = opt;
                    e.ComputationLimit    = computationLimit;
                    ProcessingQueue.Enqueue(e);
                    if (!IsRealTime(Alg))
                    {
                        break;
                    }
                }
            }

            // Start the threads.
            foreach (Thread t in Threads)
            {
                t.Start( );
            }
        }
Пример #2
0
        /// <summary>
        /// Runs the Mode.
        /// </summary>
        /// <param name="args"></param>
        public override void Run(string[] args)
        {
            ParseArgs(args);
            Out.WriteLine(Results.Header( ));

            // Make a proccessing thread for each processor.
            List <Thread> Threads     = new List <Thread>( );
            int           ThreadCount = Environment.ProcessorCount;

            if (maxThreads != 0 && maxThreads < ThreadCount)
            {
                ThreadCount = maxThreads;
            }
            for (int i = 0; i < ThreadCount; i++)
            {
                Thread t = new Thread(this.ThreadProcessor);
                t.Name = i.ToString( );
                Threads.Add(t);
            }

            // Setup the Queues for the processing threads to work with.
            ProcessingQueue = new Queue <ProcessingQueueElement>( );
            var fQ =
                Files.GetFilesRecursive(dir).Where(
                    file => file.EndsWith(".gwmap") && !file.Contains("KEY"))
                .Take(IterationCountLimit != -1 ? IterationCountLimit : int.MaxValue);

            if (Shuffle)
            {
                fQ = fQ.Shuffle( );
            }

            FilesQueue = new Queue <string>(fQ);


            // Start the threads.
            foreach (Thread t in Threads)
            {
                t.Start( );
            }
        }