protected void mapJGTTs(JI j, JGTTSD gttd, IEnumerable <GTT> jgtts)
 {
     foreach (var jgtt in jgtts)
     {
         mapJGTT(j, gttd, jgtt);
     }
 }
        protected sealed override void propagateUpGTTISources(JGTTSD gttd)
        {
            if (gttd.depth < 0 || gttd.depth >= maxDepth)
            {
                return;
            }
            var njgttsA = (from j in js select gttd.njgtts(j)).ToArray();

            foreach (var j in js)
            {
                var njgtts = njgttsA[j];
                if (!njgtts.Any() && !gttd.isDepthDownUpdated)
                {
                    continue;
                }
                foreach (var f in gttd.allSGFAs)
                {
                    var gti  = gttd.getSGFA(f);
                    var gtd  = getGTD(gti);
                    var jgts = universe.makeJGTs(j, f, njgtts);
                    mapJGTs(j, gtd, jgts);
                }
            }
            foreach (var f in new HashSet <Function>(from lgtt in gttd.lgtts from f in universe.getRGFAs(lgtt) select f))
            {
                var jgtsA = (from j in js select universe.makeJGTs(j, f, njgttsA[j])).ToArray();
                mapRGFA(f, gttd, jgtsA);
            }
        }
        private void mapRGFA(Function f, JGTTSD gttd, ISet <GT>[] jgtsA)
        {
            var   actual = jgtsA.All(jgts => jgts.Any());
            JGTSD gtd    = null;

            {
                GTI gti;
                if (gttd.tryGetSGFA(f, out gti))
                {
                    gtd = getGTD(gti);
                }
                else if (actual)
                {
                    gtd = mapGFA(f, gttd);
                    setDepth(gtd, gttd.depth + 1);
                }
            }
            if (gtd != null)
            {
                Debug.Assert(gtd.isFeasible);
                if (actual)
                {
                    setActual(gtd);
                }
                foreach (var j in js)
                {
                    mapJGTs(j, gtd, jgtsA[j]);
                }
                if (gtd.isAnyUpdated)
                {
                    enqueuePropagateGTI(gtd.gti);
                }
            }
        }
 private void mapJGTTsToGTTI(JI j, JGTTSD gttd, IEnumerable <GTT> jgtts)
 {
     foreach (var jgtt in jgtts)
     {
         mapJGTT(j, gttd, jgtt);
     }
 }
        /*public void mergeJECGTTs(JI j, JECGTT jecX, JECGTT jecY)
         * {
         *  if (jecX == jecY)
         *      return;
         *  JECGTT jecFrom, jecTo;
         *  if (jecX.index < jecY.index)
         *  {
         *      jecFrom = jecY;
         *      jecTo = jecX;
         *  }
         *  else
         *  {
         *      jecFrom = jecX;
         *      jecTo = jecY;
         *
         *  }
         *  Debug.Assert(jecFrom.index > jecTo.index);
         *  sources.mergeJECGTT(j, jecFrom, jecTo, enqueueMergeGTI, (jec1, jec2) => enqueueMergeJECGTT(j, jec1, jec2));
         * }*/
        #endregion merge

        #region propagate
        protected sealed override void completeNewGTTSources(JGTTSD gttd)
        {
            foreach (var j in js)
            {
                var ju    = pus[j];
                var jgtts = makeJGTTs(j, gttd.gtiT);// (from gti in gttd.gtis select new HashSet<GT>(getGTD(gti).jgts(j))).ToArray());
                mapJGTTs(j, gttd, jgtts);
            }
        }
        protected override sealed void propagateGTTINLGTTs(JGTTSD gttd)
        {
            var jgttsA = (from j in js select gttd.jgtts(j)).ToArray();

            foreach (var f in new HashSet <Function>(from nlgtt in gttd.nlts from rgfa in universe.getRGFAs(nlgtt) select rgfa))
            {
                var jgtsA = (from j in js select universe.makeJGTs(j, f, jgttsA[j])).ToArray();
                mapRGFA(f, gttd, jgtsA);
            }
            gttd.clearNLTs();
        }
Exemple #7
0
 public override void removeGTTDInt(JGTTSD gttd)
 {
     foreach (var j in js)
     {
         if (gttd.jecA[j].tis.Count == 1)
         {
             Debug.Assert(gttd.jecA[j].tis.First() == gttd.ti);
             removeJECTKeyInt(j, makeJECGTTKey(j, gttd.jecA[j].jecgtT));
         }
     }
     base.removeGTTDInt(gttd);
 }
        protected void mapJGTT(JI j, JGTTSD gttd, GTT jgtt)
        {
            var    jec0 = gttd.jec(j);
            JECGTT jec;

            if (gttSS.tryGetJTJEC(j, jgtt, out jec))
            {
            }  // Debug.Assert(jec == jec0);
            else
            {
                mapNewJGTTInt(j, jec0, jgtt);// sources.gtts.mapNewJT(j,jec0, jgtt);
            }
        }
        protected override void mergeSources(JGTTSD gttdFrom, JGTTSD gttdTo)
        {
            foreach (var j in js)
            {
                var jecFrom = gttdFrom.jec(j);
                var jecTo   = gttdTo.jec(j);
//                sources.mergeJECGTT(j,)
                Debug.Assert(jecFrom.jecgtT.SequenceEqual(jecTo.jecgtT));

                /*               if (!ReferenceEquals(jecFrom,jecTo))
                 *             {
                 *                 foreach (var jgtt in jecFrom.jts)
                 *                     sources.gtts.remapJTToJECInt(j, jgtt, jecTo);
                 *                 foreach (var gtti in jecFrom.tis)
                 *                     sources.gtts.remapTIToJECInt(j, getGTTD(gtti), jecTo);
                 *             }*/
                Debug.Assert(jecFrom == jecTo);
            }
            gttSS.mergeTDInt(gttdFrom, gttdTo);
        }
        private void mapRGTT(GTI[] gtiT, IEnumerable <GTT>[] jgttsA)
        {
            #region consistency
#if DEBUG
            Debug.Assert(gtiT.Length > 0);
            foreach (var gti in gtiT)
            {
                Debug.Assert(getGTD(gti).depth >= 0 && getGTD(gti).depth < maxDepth);
            }
#endif
            #endregion consistency
            if (jgttsA.Any(jgtts => !jgtts.Any()))
            {
                return;
            }
            JGTTSD gttd = null;
            GTTI   gtti;
            if (tryGetGTTIByGTIs(gtiT, out gtti))
            {
                gttd = getGTTD(gtti);
            }
            else
            {
                var jecgtTA = (from j in js select(from gti in gtiT select getGTD(gti).jecA[j]).ToArray()).ToArray();
                var jecgttA = (from j in js select sources.makeJECGTT(j, jecgtTA[j])).ToArray();
                gttd = mapJECGTTA(jecgttA);
                var d = (from gti in gtiT select getGTD(gti).depth).Max();
                setDepth(gttd, d);
                gtti = gttd.gtti;
            }
            Debug.Assert(gttd.isFeasible);
            setActual(gttd);
            foreach (var j in js)
            {
                mapJGTTs(j, gttd, jgttsA[j]);
            }
            if (gttd.isAnyUpdated)
            {
                enqueuePropagateGTTI(gtti);
            }
        }
 protected sealed override void propagateDownGTTISources(JGTTSD gttd)
 {
 }