コード例 #1
0
        private void MultiStdDevMutation(ref ESSolution offspring)
        {
            SafeDebug.AssertNotNull(offspring, "offspring != null");

            base.modelBuilder = base.context.CreateArithmeticModelBuilder(offspring.currentModel);

            double globalLearningRate = (double)1 / Math.Sqrt((double)2 * (double)base.context.Variables.Count <IArithmeticVariable>());
            double localLearningRate  = (double)1 / Math.Sqrt((double)2 * Math.Sqrt((double)base.context.Variables.Count <IArithmeticVariable>()));
            double overallT           = globalLearningRate * Gaussian(0, 1);
            int    index = 0;

            foreach (var variable in base.context.Variables)
            {
                Term   sum         = null;
                double ni          = overallT + localLearningRate * Gaussian(0, 1);
                double scaleFactor = offspring.GetStdDev(index) * Math.Exp(ni);
                offspring.SetStdDev(index, scaleFactor);
                bool success = TryAddDoubleToTerm(variable.Term, scaleFactor * Gaussian(0, 1), out sum);
                if (success)
                {
                    base.modelBuilder.TryAssign(variable, offspring.currentModel.GetValue(sum));
                }
                index++;
            }

            offspring.UpdateModel(base.modelBuilder.ToArithmeticModel());
        }
コード例 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ThreadExecutionMonitorDispatcher(IEventLog log, int threadIndex, IThreadMonitor callMonitor)
            : base(threadIndex)
        {
            SafeDebug.AssertNotNull(callMonitor, "callMonitor");

            this.log         = log;
            this.threadIndex = threadIndex;
            this.callMonitor = callMonitor;
            this.callStack   = new SafeLinkedList <CallFrame>();

            this.current = new CallFrame(default(ICallFrame), default(Method), 0); //fake caller.
            this.callStack.AddFirst(new SafeLinkedList <CallFrame> .Node(this.current));

            if (firstTime)
            {
                // get rid of all [T] from types and methods
                var env = MyEngine.EnvironmentVars;
                firstTime = false;
                foreach (var t in env.DontPreemptTypes)
                {
                    newDontPreemptTypes.Add(eliminateParameterizedTypes(t));
                }
                foreach (var m in env.DontPreemptMethods)
                {
                    newDontPreemptMethods.Add(eliminateParameterizedTypes(m));
                }
                foreach (var m in env.PrioritizeMethods)
                {
                    newPrioritizeMethods.Add(eliminateParameterizedTypes(m));
                }
            }
        }
コード例 #3
0
        public void AfterExecution(IPexComponent host, object data)
        {
            if (this.pmd.CurrentPUTMethod == null)
            {
                this.host.Log.LogWarning(WikiTopics.MissingWikiTopic, "PUTExploration",
                                         "Return, not current PUT method is set");
                WriteStopStatus();
                return;
            }

            SafeDebug.AssertNotNull(this.pmd.CurrentPUTMethod, "CurrentPUTMethod should be set by this time");
            var currPUTSignature = MethodOrFieldAnalyzer.GetMethodSignature(this.pmd.CurrentPUTMethod);

            if (this.pmd.AllExploredMethods.Contains(currPUTSignature))
            {
                this.host.Log.LogWarning(WikiTopics.MissingWikiTopic, "PUTExploration",
                                         "Ignoring the post processing of the PUT " + currPUTSignature + " since it is explored earlier!!!");
                WriteStopStatus();
                return;
            }

            //Add this to pending methods
            PexMePostProcessor ppp = new PexMePostProcessor(host);

            ppp.AfterExecution();
        }
コード例 #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="log">IEventLog</param>
 /// <param name="threadIndex">Thread index</param>
 /// <param name="callMonitor">IThreadMonitor</param>
 /// <param name="raceDetectionEngine">IRaceDetectionEngine</param>
 /// <param name="configuration">Configuration</param>
 public ThreadExecutionMonitorDispatcher(IEventLog log, int threadIndex,
                                         IThreadMonitor callMonitor, IRegisterRuntimeOperation raceDetectionEngine, Configuration configuration)
     : base(threadIndex)
 {
     SafeDebug.AssertNotNull(callMonitor, "callMonitor");
     this.ThreadIndex   = threadIndex;
     this.Configuration = configuration;
     this.DebugTrace    = new SafeList <string>();
     this.CallStack     = new SafeStack <Method>();
     this.Reporter      = raceDetectionEngine;
 }
コード例 #5
0
        private void SingleStdDevMutation(ref ESSolution offspring)
        {
            SafeDebug.AssertNotNull(offspring, "offspring != null");

            base.modelBuilder = base.context.CreateArithmeticModelBuilder(offspring.currentModel);

            double learningRate = (double)1 / Math.Sqrt((double)base.context.Variables.Count <IArithmeticVariable>());

            double stdDev = offspring.GetStdDev(0) * Math.Exp(learningRate * Gaussian(0, 1));

            offspring.SetStdDev(0, stdDev);
            foreach (var variable in base.context.Variables)
            {
                Term sum     = null;
                bool success = TryAddDoubleToTerm(variable.Term, stdDev * Gaussian(0, 1), out sum);
                if (success)
                {
                    base.modelBuilder.TryAssign(variable, offspring.currentModel.GetValue(sum));
                }
            }

            offspring.UpdateModel(base.modelBuilder.ToArithmeticModel());
        }
コード例 #6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="log">IEventLog</param>
        /// <param name="threadIndex">Thread index</param>
        /// <param name="callMonitor">IThreadMonitor</param>
        /// <param name="testingEngine">ITestingEngine</param>
        /// <param name="configuration">Configuration</param>
        public ThreadExecutionMonitorDispatcher(IEventLog log, int threadIndex,
                                                IThreadMonitor callMonitor, ITestingEngine testingEngine, Configuration configuration)
            : base(threadIndex)
        {
            SafeDebug.AssertNotNull(callMonitor, "callMonitor");

            this.ThreadIndex   = threadIndex;
            this.Configuration = configuration;

            this.ThreadTrace = new List <ThreadTrace>();
            this.DebugTrace  = new SafeList <string>();
            this.CallStack   = new SafeStack <Method>();

            this.IsDoHandlerCalled     = false;
            this.IsEntryActionCalled   = false;
            this.IsExitActionCalled    = false;
            this.IsAction              = false;
            this.RecordRW              = false;
            this.IsCreateMachineMethod = false;

            // Registers a callback to emit the thread trace. The callback
            // is invoked at the end of each testing iteration.
            testingEngine.RegisterPerIterationCallBack(EmitThreadTrace);
        }
コード例 #7
0
ファイル: MonitorManager.cs プロジェクト: wxdtony/PSharp
 /// <summary>
 /// Registers the thread monitor factory.
 /// </summary>
 /// <param name="monitorFactory">IThreadMonitorFactory</param>
 void IMonitorManager.RegisterThreadMonitorFactory(IThreadMonitorFactory monitorFactory)
 {
     SafeDebug.AssertNotNull(monitorFactory, "monitorFactory");
     this.ThreadMonitorManager.AddMonitorFactory(monitorFactory);
 }