예제 #1
0
파일: PrtImplMachine.cs 프로젝트: up1/P
 public PrtImplMachine() : base()
 {
     this.maxBufferSize = 0;
     this.doAssume      = false;
     this.eventQueue    = new PrtEventBuffer();
     this.receiveSet    = new HashSet <PrtValue>();
 }
예제 #2
0
        public PrtEventBuffer CloneAndResolve(StateImpl s)
        {
            PrtEventBuffer x = Clone();

            x.Resolve(s);
            return(x);
        }
예제 #3
0
        public PrtEventBuffer Clone()
        {
            var clonedVal = new PrtEventBuffer();

            foreach (var ev in this.events)
            {
                clonedVal.events.Add(ev.Clone());
            }
            return(clonedVal);
        }
예제 #4
0
 public PrtImplMachine(StateImpl app, int maxBuff) : base()
 {
     this.instanceNumber = this.NextInstanceNumber(app);
     this.eventQueue     = new PrtEventBuffer();
     this.receiveSet     = new HashSet <PrtValue>();
     this.maxBufferSize  = maxBuff;
     this.stateImpl      = app;
     //Push the start state function on the funStack.
     PrtPushState(StartState);
 }
예제 #5
0
파일: PrtImplMachine.cs 프로젝트: up1/P
 public PrtImplMachine(StateImpl app, int maxBuff, bool assume) : base()
 {
     this.instanceNumber = this.NextInstanceNumber(app);
     this.eventQueue     = new PrtEventBuffer();
     this.receiveSet     = new HashSet <PrtValue>();
     this.maxBufferSize  = maxBuff;
     this.doAssume       = assume;
     this.stateImpl      = app;
     this.self           = new PrtInterfaceValue(this, new List <PrtEventValue>());
     //Push the start state function on the funStack.
     PrtPushState(StartState);
 }
예제 #6
0
        public PrtEventBuffer Clone()
        {
            var clonedVal = new PrtEventBuffer();

            foreach (PrtEventNode ev in events)
            {
                clonedVal.events.Add(ev.Clone());
            }

            clonedVal.concrete = concrete;

            return(clonedVal);
        }
예제 #7
0
        /// <summary>
        /// Compute the abstract successors caused by updating the queue of <paramref name="currIndex"/> machine.
        ///
        /// </summary>
        /// <param name="currIndex">The index for the machine about to explore</param>
        /// <param name="abstract_succs"></param>
        /// <param name="abstract_succs_SW"></param>
        void CollectAbstractSuccessorsFromList(int currIndex, HashSet <int> abstract_succs, StreamWriter abstract_succs_SW)
        {
            List <PrtEventNode> preDequeEvents = ImplMachines[currIndex].eventQueue.events; // pre-dequeue events list

            var  choiceVector = new List <bool>();
            bool more;

            do
            {
                StateImpl           succ           = (StateImpl)Clone();
                PrtImplMachine      machineOfSucc  = succ.ImplMachines[currIndex]; // the machine of successor indexing in currIndex
                PrtEventBuffer      queueOfMachine = machineOfSucc.eventQueue;     // the message queue of successor machine
                List <PrtEventNode> queueEvents    = queueOfMachine.events;        // the events list of successor machine

                more = machineOfSucc.PrtRunStateMachineNextChoice(choiceVector);
                Debug.Assert(preDequeEvents.Count - queueOfMachine.Size() <= 1); // we have dequeued at most one event
                /// If dequeing was unsuccessful, then there is nothing left to do.
                /// No more nondeterministic choices to try
                if (preDequeEvents.Count == queueOfMachine.Size() || succ.CheckFailure(0)) //
                {
                    return;                                                                //
                }
                int          idxOfEventDequeuedFromSuffix = Math.Max(PrtEventBuffer.idxOfLastDequeuedEvent, PrtEventBuffer.p);
                PrtEventNode eventDequeuedFromSuffix      = preDequeEvents[idxOfEventDequeuedFromSuffix];

                /// <remarks>Choice 1: </remarks> The eventDequeuedFromSuffix, aka the last dequeued event, existed
                /// exactly once in the concrete suffix.
                /// Then it is gone after the dequeue, in both abstract and concrete. The new state abstract is valid.
                succ.AddToAbstractSuccessorsIfInvSat(currIndex, this, abstract_succs, abstract_succs_SW);

                ///  <remarks>Choice 1: </remarks> The eventDequeuedFromSuffix, aka the last dequeued event, existed
                ///  >= twice in concrete suffix.
                ///  We need to find all positions where to re-introduce it in the abstract queue, and try them all
                ///  non-deterministically.
                for (int pos = idxOfEventDequeuedFromSuffix; pos < queueOfMachine.Size(); ++pos)
                {
                    // insert eventDequeuedFromSuffix at position pos (push the rest to the right)
                    queueEvents.Insert(pos, eventDequeuedFromSuffix);
                    succ.AddToAbstractSuccessorsIfInvSat(currIndex, this, abstract_succs, abstract_succs_SW);
                    queueEvents.RemoveAt(pos);            // restore previous state
                }
                queueEvents.Add(eventDequeuedFromSuffix); // finally, insert eventDequeuedFromSuffix at end
                succ.AddToAbstractSuccessorsIfInvSat(currIndex, this, abstract_succs, abstract_succs_SW);
            } while (more);
        }