예제 #1
0
 public BkwdNCommsGraphBuilder(
     MEAPContext meapContext,
     SortedDictionary <long, LinkedList <long> > nodeToCommoditiesMap,
     long kStep,
     FwdBkwdNCommsGraphPair fwdBkwdNCommsGraphPair)
 {
     this.meapContext          = meapContext;
     this.CPLTMInfo            = meapContext.MEAPSharedContext.CPLTMInfo;
     this.nodeToCommoditiesMap = nodeToCommoditiesMap;
     this.kStep = kStep;
     this.bkwdNestedCommsGraph     = fwdBkwdNCommsGraphPair.BkwdNestedCommsGraph;
     this.bkwdCFGNodeToNCGNodesMap = fwdBkwdNCommsGraphPair.BkwdCFGNodeToNCGNodesMap;
     this.bkwdNCGEdgeToCFGEdgeMap  = fwdBkwdNCommsGraphPair.BkwdNCGEdgeToCFGEdgeMap;
 }
        public override void CheckNCGNodesHaveTheSameSymbol(MEAPContext meapContext)
        {
            log.Info("CheckNCGNodesHaveTheSameSymbolFrom");

            foreach (KeyValuePair <long, FwdBkwdNCommsGraphPair> ncgItemPair in
                     meapContext.muToNestedCommsGraphPair)
            {
                NCGraphType bkwdNestedCommsGraph = ncgItemPair.Value.BkwdNestedCommsGraph;

                foreach (KeyValuePair <long, DAGNode> ncgNodeItemPair in bkwdNestedCommsGraph.NodeEnumeration)
                {
                    long    uNCGNodeId = ncgNodeItemPair.Key;
                    DAGNode uNCGNode   = ncgNodeItemPair.Value;

                    if (!meapContext.Commodities.TryGetValue(uNCGNodeId, out Commodity? uComm))
                    {
                        continue;
                    }

                    long            uNodeId   = uComm.tNodeId;
                    ComputationStep uCompStep = meapContext.TArbSeqCFG.IdToNodeInfoMap[uNodeId].CompStep;

                    bool firstEdge = true;
                    int  sTo       = OneTapeTuringMachine.blankSymbol;

                    foreach (DAGEdge e in uNCGNode.InEdges)
                    {
                        long            vNCGNodeId = e.FromNode.Id;
                        Commodity       vComm      = meapContext.Commodities[vNCGNodeId];
                        long            vNodeId    = vComm.tNodeId;
                        ComputationStep vCompStep  = meapContext.TArbSeqCFG.IdToNodeInfoMap[vNodeId].CompStep;

                        if (vNodeId == meapContext.TArbSeqCFG.GetSinkNodeId())
                        {
                            continue;
                        }

                        if (firstEdge)
                        {
                            sTo       = vCompStep.s;
                            firstEdge = false;
                        }
                        else
                        {
                            Ensure.That(vCompStep.s).Is(sTo);
                        }
                    }
                }
            }
        }
        public override void CheckTASGNodesHaveTheSameSymbol(MEAPContext meapContext)
        {
            log.Info("CheckTASGNodesHaveTheSameSymbolFrom");

            foreach (KeyValuePair <long, DAGNode> itemPair in meapContext.TArbSeqCFG.NodeEnumeration)
            {
                long uNodeId = itemPair.Key;

                if (uNodeId == meapContext.TArbSeqCFG.GetSourceNodeId())
                {
                    continue;
                }

                DAGNode         uNode     = itemPair.Value;
                ComputationStep uCompStep = meapContext.TArbSeqCFG.IdToNodeInfoMap[uNodeId].CompStep;

                bool firstEdge = true;
                int  sTo       = OneTapeTuringMachine.blankSymbol;

                foreach (DAGEdge e in uNode.OutEdges)
                {
                    long            vNodeId   = e.ToNode.Id;
                    ComputationStep vCompStep = meapContext.TArbSeqCFG.IdToNodeInfoMap[vNodeId].CompStep;

                    if (vNodeId == meapContext.TArbSeqCFG.GetSinkNodeId())
                    {
                        continue;
                    }

                    if (firstEdge)
                    {
                        sTo       = vCompStep.s;
                        firstEdge = false;
                    }
                    else
                    {
                        Ensure.That(vCompStep.s).Is(sTo);
                    }
                }
            }
        }
 public NCGJointNodesBuilder(MEAPContext meapContext)
 {
     this.CPLTMInfo   = meapContext.MEAPSharedContext.CPLTMInfo;
     this.meapContext = meapContext;
 }
 public NestedCommsGraphBuilder(MEAPContext meapContext)
 {
     this.CPLTMInfo   = meapContext.MEAPSharedContext.CPLTMInfo;
     this.meapContext = meapContext;
 }