Beispiel #1
0
        private MChessOptions SetOptions(EnvironmentVars pce)
        {
            var mco = new MChessOptions();

            // real arguments override whatever we hacked in with properties
            mco.PCT                     = pce.M_PCT;
            mco.PCT_VB                  = pce.M_VB_PCT;
            mco.DeRandomizedPCT         = pce.M_DeRandomizedPCT;
            mco.PCT_num_of_runs         = pce.M_num_of_runs;
            mco.varLabels               = pce.VarLabels;
            mco.PCT_bug_depth           = pce.M_bug_depth;
            mco.var_bound               = pce.M_var_bound;
            mco.PCT_seed                = pce.M_pct_seed;
            mco.breakOnAssert           = pce.Breaks.Contains("a");
            mco.breakOnDeadlock         = pce.Breaks.Contains("d");
            mco.breakOnPreemptions      = pce.Breaks.Contains("p");
            mco.breakAfterPreemptions   = pce.Breaks.Contains("P");
            mco.breakOnContextSwitch    = pce.Breaks.Contains("c");
            mco.breakAfterContextSwitch = pce.Breaks.Contains("C");
            mco.breakOnTimeout          = pce.Breaks.Contains("t");
            mco.breakOnTaskResume       = pce.Breaks.Contains("f");
            mco.breakOnRace             = pce.Breaks.Contains("r");

            mco.checkObservations     = pce.CheckObservations;
            mco.loadSchedule          = (pce.LoadSchedule || pce.Continue);
            mco.delayBound            = pce.MaxDelays;
            mco.preemptionBound       = pce.MaxPreemptions;
            mco.observationMode       = pce.ObservationMode;
            mco.enumerateObservations = pce.EnumerateObservations;
            mco.finesse              = pce.Finesse;
            mco.logging              = pce.Logging;
            mco.xmlCommandline       = pce.XmlCommandline;
            mco.maxExecutions        = pce.MaxExecs;
            mco.maxChessTime         = pce.MaxChessTime;
            mco.maxExecTime          = pce.MaxExecTime;
            mco.maxStackSize         = pce.MaxExecSteps;
            mco.monitorVolatiles     = pce.MonitorVolatile;
            mco.monitorAccesses      = pce.MonitorAccesses;
            mco.monitorCctors        = pce.MonitorCCTOR;
            mco.outputPrefix         = pce.OutputPrefix;
            mco.preemptionVars       = pce.PreemptionVars;
            mco.preemptAccesses      = pce.PreemptAccesses;
            mco.trace                = pce.PrintTrace;
            mco.processorCount       = pce.ProcessorCount;
            mco.showProgress         = pce.ShowProgress;
            mco.sober                = pce.Sober;
            mco.soberTargetrace      = pce.Targetrace;
            mco.loadScheduleFile     = pce.SchedFile;
            mco.recordPreemptMethods = pce.LoadSchedule && !pce.Continue;
            mco.tolerateDeadlock     = pce.TolerateDeadlock;
            // Best-first search options
            mco.doDpor    = pce.Dpor;
            mco.bounded   = pce.Bounded;
            mco.bestFirst = pce.BestFirst;
            if (pce.BestFirst)
            {
                if (pce.Bounded || !pce.Dpor)
                {
                    if (pce.PrioritizeMethods.Count > 0)
                    {
                        // if we're prioritizing methods, add that to the priority function
                        mco.bestFirstPriority = "wdpor_method";
                    }
                    else
                    {
                        mco.bestFirstPriority = "wdpor";
                    }
                }
                else
                {
                    if (pce.PrioritizeMethods.Count > 0)
                    {
                        // if we're prioritizing methods, add that to the priority function
                        mco.bestFirstPriority = "wdpor_pb_method";
                    }
                    else
                    {
                        mco.bestFirstPriority = "wdpor_pb";
                    }
                }
            }

            // TODO: CHECK THIS
            // ??? for load-schedule, we default to max_executions=1
            if (pce.LoadSchedule)
            {
                mco.maxExecutions = 1;
            }

            // Use Reflection to go through the various public members of MChessChessOptions
            // use TryGetProperty to see if we have a property of the particular name
            // convert the value to the proper type (bool, int, string)
            foreach (FieldInfo fi in typeof(MChessOptions).GetFields())
            {
                string res;
                if (pce.TryGetProperty(fi.Name, out res))
                {
                    setField(fi, mco, res);
                }
                // convert camlCase to deprecated, underscores
                string underscored = "";
                for (int i = 0; i < fi.Name.Length; i++)
                {
                    if (char.IsLetter(fi.Name, i) && (char.IsUpper(fi.Name, i)))
                    {
                        underscored += ("_" + char.ToLower(fi.Name[i]));
                    }
                    else
                    {
                        underscored += fi.Name[i];
                    }
                }
                if (pce.TryGetProperty(underscored, out res))
                {
                    setField(fi, mco, res);
                }
            }
            return(mco);
        }