Beispiel #1
0
        /// <summary>Loads the number of threads. </summary>
        public static int DetermineThreads(Output output, IParameterDatabase parameters, IParameter threadParameter)
        {
            var thread = 1;
            var tmp_s  = parameters.GetString(threadParameter, null);

            if (tmp_s == null)
            // uh oh
            {
                output.Fatal("Threads number must exist.", threadParameter, null);
            }
            else if (V_THREADS_AUTO.ToUpper().Equals(tmp_s.ToUpper()))
            {
            }
            else
            {
                try
                {
                    thread = parameters.GetInt(threadParameter, null);
                }
                catch (FormatException)
                {
                    output.Fatal("Invalid, non-integer threads value (" + thread + ")", threadParameter, null);
                }
            }
            return(thread);
        }
Beispiel #2
0
        /// <summary>
        /// Loads a random generator seed.  First, the seed is loaded from the seedParameter.  If the parameter
        /// is V_SEED_TIME, the seed is set to the currentTime value.  Then the seed is incremented by the offset.
        /// This method is broken out of initialize(...) primarily to share code with ec.eval.MasterProblem.
        /// </summary>
        public static int DetermineSeed(Output output, IParameterDatabase parameters, IParameter seedParameter, long currentTime, int offset, bool auto)
        {
            var seed = 1; // have to initialize to make the compiler happy

            try
            {
                seed = parameters.GetInt(seedParameter, null);
            }
            catch (FormatException)
            {
                output.Fatal("Invalid, non-integer seed value (" + seed + ")", seedParameter, null);
            }
            return(seed + offset);
        }
Beispiel #3
0
        /// <summary>
        /// Loads the number of threads.
        /// </summary>
        public static int DetermineThreads(Output output, IParameterDatabase parameters, IParameter threadParameter)
        {
            var thread = 1;
            var tmp_s  = parameters.GetString(threadParameter, null);

            if (tmp_s == null)
            // uh oh
            {
                output.Fatal("Threads number must exist.", threadParameter, null);
            }
            else if (V_THREADS_AUTO.ToUpper().Equals(tmp_s.ToUpper()))
            {
                var runtime = Process.GetCurrentProcess();
                try
                {
                    return(Environment.ProcessorCount);
                }
                catch (Exception)
                {
                    output.Fatal("Whoa! Problem getting processor count.", threadParameter, null);
                }
            }
            else
            {
                try
                {
                    thread = parameters.GetInt(threadParameter, null);
                    if (thread <= 0)
                    {
                        output.Fatal("Threads value must be > 0", threadParameter, null);
                    }
                }
                catch (FormatException)
                {
                    output.Fatal("Invalid, non-integer threads value (" + thread + ")", threadParameter, null);
                }
            }
            return(thread);
        }
Beispiel #4
0
        /// <summary>
        /// Loads a random generator seed.  First, the seed is loaded from the seedParameter.  If the parameter
        /// is V_SEED_TIME, the seed is set to the currentTime value.  Then the seed is incremented by the offset.
        /// This method is broken out of initialize(...) primarily to share code with ec.eval.MasterProblem.
        /// </summary>
        public static int DetermineSeed(Output output, IParameterDatabase parameters, IParameter seedParameter, long currentTime, int offset, bool auto)
        {
            var seed  = 1; // have to initialize to make the compiler happy
            var tmp_s = parameters.GetString(seedParameter, null);

            if (tmp_s == null && !auto)
            // uh oh
            {
                output.Fatal("Seed must exist.", seedParameter, null);
            }
            //else if (V_SEED_TIME.Equals(tmp_s, StringComparison.InvariantCultureIgnoreCase) || (tmp_s == null && auto))
            else if (tmp_s == null && auto || V_SEED_TIME.Equals(tmp_s, StringComparison.InvariantCultureIgnoreCase)) // BRS : Just flipped
            {
                if (tmp_s == null && auto)                                                                            // BRS : What?
                {
                    output.WarnOnce("Using automatic determination number of threads, but not all seeds are defined."
                                    + "\nThe rest will be defined using the wall clock time.");
                }
                seed = (int)currentTime; // using low-order bits so it's probably okay
                if (seed == 0)
                {
                    output.Fatal("Whoa! This Java version is returning 0 for currentTimeMillis(), which ain't right."
                                 + " This means you can't use '" + V_SEED_TIME + "' as a seed ", seedParameter, null);
                }
            }
            else
            {
                try
                {
                    seed = parameters.GetInt(seedParameter, null);
                }
                catch (FormatException)
                {
                    output.Fatal("Invalid, non-integer seed value (" + seed + ")", seedParameter, null);
                }
            }
            return(seed + offset);
        }