Esempio n. 1
0
        public DBM AddUrgency()
        {
            DBM toReturn = this.Clone();

            toReturn.AddConstraint(Matrix.Count - 1, TimerOperationType.LessThanOrEqualTo, 0);
            return(toReturn);
        }
Esempio n. 2
0
        public static DBM ReturnUrgentDBM(DBM dbm1, DBM dbm2)
        {
            if (dbm1.IsUrgent())
            {
                return(dbm1);
            }

            return(dbm2);
        }
Esempio n. 3
0
        /// <summary>
        /// Return a cloned DBM which contains only active timers
        /// </summary>
        /// <param name="activeTimer"></param>
        /// <returns></returns>
        public DBM CleanAndRename(Dictionary <int, int> mapping, int clockCounter)
        {
            Debug.Assert(this.IsCanonicalForm);
            DBM        toReturn  = new DBM();
            List <int> newClocks = new List <int>();

            for (int i = 1; i <= clockCounter; i++)
            {
                toReturn.Matrix[0].Add(0);
                List <int> newRow = new List <int>();
                for (int j = 0; j <= clockCounter; j++)
                {
                    newRow.Add(0);
                }
                toReturn.Matrix.Add(newRow);

                if (!mapping.ContainsValue(i))
                {
                    newClocks.Add(i);
                }
            }

            foreach (KeyValuePair <int, int> keyValuePair in mapping)
            {
                toReturn.Matrix[0][keyValuePair.Value] = Matrix[0][keyValuePair.Key];
                toReturn.Matrix[keyValuePair.Value][0] = Matrix[keyValuePair.Key][0];

                foreach (int newClock in newClocks)
                {
                    toReturn.Matrix[newClock][keyValuePair.Value] = Matrix[0][keyValuePair.Key];
                    toReturn.Matrix[keyValuePair.Value][newClock] = Matrix[keyValuePair.Key][0];
                }

                foreach (KeyValuePair <int, int> valuePair in mapping)
                {
                    toReturn.Matrix[valuePair.Value][keyValuePair.Value] = Matrix[valuePair.Key][keyValuePair.Key];
                    toReturn.Matrix[keyValuePair.Value][valuePair.Value] = Matrix[keyValuePair.Key][valuePair.Key];
                }
            }

            return(toReturn);
        }
Esempio n. 4
0
        /// <summary>
        /// Return a cloned DBM which contains only active timers
        /// </summary>
        /// <param name="activeTimer"></param>
        /// <returns></returns>
        public DBM CleanAndRename(Dictionary<int,int> mapping, int clockCounter)
        {
            Debug.Assert(this.IsCanonicalForm); 
            DBM toReturn = new DBM();
            List<int> newClocks = new List<int>();

            for (int i = 1; i <= clockCounter; i++)
            {             
                toReturn.Matrix[0].Add(0);
                List<int> newRow = new List<int>();
                for (int j = 0; j <= clockCounter; j++)
                {
                    newRow.Add(0);
                }
                toReturn.Matrix.Add(newRow);

                if (!mapping.ContainsValue(i))
                {
                    newClocks.Add(i);
                }
            }

            foreach (KeyValuePair<int, int> keyValuePair in mapping)
            {
                toReturn.Matrix[0][keyValuePair.Value] = Matrix[0][keyValuePair.Key];
                toReturn.Matrix[keyValuePair.Value][0] = Matrix[keyValuePair.Key][0];

                foreach (int newClock in newClocks)
                {
                    toReturn.Matrix[newClock][keyValuePair.Value] = Matrix[0][keyValuePair.Key];
                    toReturn.Matrix[keyValuePair.Value][newClock] = Matrix[keyValuePair.Key][0];
                }

                foreach (KeyValuePair<int, int> valuePair in mapping)
                {
                    toReturn.Matrix[valuePair.Value][keyValuePair.Value] = Matrix[valuePair.Key][keyValuePair.Key];
                    toReturn.Matrix[keyValuePair.Value][valuePair.Value] = Matrix[keyValuePair.Key][valuePair.Key];                    
                }
            }

            return toReturn;
        }
Esempio n. 5
0
        public static DBM ReturnUrgentDBM(DBM dbm1, DBM dbm2)
        {
            if (dbm1.IsUrgent())
            {
                return dbm1;
            }

            return dbm2;
        }