Microsoft.Zing.FrontierNode.GetTraversalInfo C# (CSharp) Méthode

GetTraversalInfo() public méthode

public GetTraversalInfo ( StateImpl InitialState, int threadId ) : TraversalInfo
InitialState StateImpl
threadId int
Résultat TraversalInfo
        public TraversalInfo GetTraversalInfo(StateImpl InitialState, int threadId)
        {
            TraversalInfo retTraversalInfo = GetTraversalInfoForTrace(TheTrace, threadId, (StateImpl)InitialState.Clone(threadId));
            retTraversalInfo.zBounds = Bounds;
            if (ZingerConfiguration.DoDelayBounding)
            {
                retTraversalInfo.ZingDBSchedState = schedulerState;
            }
            else if (ZingerConfiguration.DoPreemptionBounding)
            {
                retTraversalInfo.preemptionBounding = preemptionBounding.Clone();
            }
            retTraversalInfo.IsFingerPrinted = true;
            return retTraversalInfo;
        }

Usage Example

        protected override void SearchStateSpace(object obj)
        {
            int myThreadId = (int)obj;
            int numberOfSchedulesExplored = 0;

            //frontier
            FrontierNode startfN = new FrontierNode(StartStateTraversalInfo);
            TraversalInfo startState = startfN.GetTraversalInfo(StartStateStateImpl, myThreadId);
            var statesExplored = new HashSet<Fingerprint>();
            while (numberOfSchedulesExplored < ZingerConfiguration.MaxSchedulesPerIteration)
            {
                //increment the schedule count
                numberOfSchedulesExplored++;
                ZingerStats.IncrementNumberOfSchedules();
                //random walk always starts from the start state ( no frontier ).
                TraversalInfo currentState = startState.Clone();
                statesExplored.Clear();
                while (currentState.CurrentDepth < ZingerConfiguration.MaxDepthPerSchedule)
                {
                    //kil the exploration if bug found
                    //Check if cancelation token triggered
                    if (CancelTokenZingExplorer.IsCancellationRequested)
                    {
                        //some task found bug and hence cancelling this task
                        return;
                    }

                    ZingerStats.MaxDepth = Math.Max(ZingerStats.MaxDepth, currentState.CurrentDepth);

                    //Check if the DFS Stack Overflow has occured.
                    if (currentState.CurrentDepth > ZingerConfiguration.BoundDFSStackLength)
                    {

                        //update the safety traces
                        SafetyErrors.Add(currentState.GenerateNonCompactTrace());
                        // return value
                        this.lastErrorFound = ZingerResult.DFSStackOverFlowError;

                        throw new ZingerDFSStackOverFlow();
                    }

                    TraversalInfo nextSuccessor = currentState.GetNextSuccessorUniformRandomly();

                    ZingerStats.IncrementTransitionsCount();
                    ZingerStats.IncrementStatesCount();
                    if (nextSuccessor == null)
                    {
                        break;
                    }

                    //check if the next step is entered through a accepting transition
                    if(nextSuccessor.IsAcceptingState && nextSuccessor.IsFingerPrinted && statesExplored.Contains(nextSuccessor.Fingerprint))
                    //if (nextSuccessor.IsFingerPrinted && statesExplored.Contains(nextSuccessor.Fingerprint))
                    {
                        AcceptingCycles.Add(nextSuccessor.GenerateNonCompactTrace());
                        lastErrorFound = ZingerResult.AcceptanceCyleFound;
                        if (ZingerConfiguration.StopOnError)
                            throw new ZingerAcceptingCycleFound();
                    }

                    //add the current state in the set.
                    if(nextSuccessor.IsFingerPrinted) statesExplored.Add(nextSuccessor.Fingerprint);

                    TerminalState terminalState = nextSuccessor as TerminalState;
                    if (terminalState != null)
                    {
                        if (terminalState.IsErroneousTI)
                        {
                            lock (SafetyErrors)
                            {
                                // bugs found
                                SafetyErrors.Add(nextSuccessor.GenerateNonCompactTrace());
                                this.lastErrorFound = nextSuccessor.ErrorCode;
                            }

                            if (ZingerConfiguration.StopOnError)
                            {
                                CancelTokenZingExplorer.Cancel(true);
                                throw nextSuccessor.Exception;
                            }
                        }

                        break;
                    }

                    currentState = nextSuccessor;
                }
            }
        }
All Usage Examples Of Microsoft.Zing.FrontierNode::GetTraversalInfo