Esempio n. 1
0
        /// <summary>
        /// return z1 subset a_LU(z2)
        /// iff there exist x, y such that
        /// z1_0x ≥ (≤, -U_x) && z2_yx ≺ z1_yx && z2_yx + (≺, -L_y) ≺ z1_0x
        /// No need to check the simple case where dbm is empty since these dbm are created from TAConfiguratino.MakeOneMove
        /// </summary>
        /// <param name="z1"></param>
        /// <param name="z2"></param>
        /// <param name="currentState"></param>
        /// <returns></returns>
        private static bool IsSimSubset(NewDBM z1, NewDBM z2, bool isLocalbased, string[] currentState)
        {
            //
            int dim = NewDBM.dim;

            for (int x = 1; x < dim; x++)
            {
                int minusUpperX = -GetUpper(x, isLocalbased, currentState);

                if (IsLessEqual(minusUpperX, LessThanEqual, z1.matrix[x], z1.isLessThans[x]))
                {
                    for (int y = 1; y < dim; y++)
                    {
                        if (x != y)
                        {
                            int index = y * dim + x;
                            //TODO TKN: 2 variables must different and not zero-clock
                            if (IsLessThan(z2.matrix[index], z2.isLessThans[index], z1.matrix[index], z1.isLessThans[index]) &&
                                IsSumLessThan(z2.matrix[index], z2.isLessThans[index], -GetLower(y, isLocalbased, currentState), LessThan, z1.matrix[x], z1.isLessThans[x]))
                            {
                                return(false);
                            }
                        }
                    }
                }
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// If this is true, the current valution can simulate all the valuation in the future
        /// </summary>
        /// <param name="valuation"></param>
        /// <param name="currentState"></param>
        /// <returns></returns>
        public static bool AllClockGreaterThanLower(int[] valuation, string[] currentState)
        {
            for (int i = 1; i < valuation.Length; i++)
            {
                if (valuation[i] <= NewDBM.GetLower(i, true, currentState))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// Return true if valution2 simulates valuation1
        /// </summary>
        /// <param name="valuation1"></param>
        /// <param name="valuation2"></param>
        /// <param name="currentState">All the clocks in the same process. currentState is the state of this process</param>
        /// <returns></returns>
        public static bool IsLUSimulated(int[] valuation1, int[] valuation2, string currentState)
        {
            for (int i = 1; i < valuation1.Length; i++)
            {
                if (!IsLUSimulated(valuation1[i], valuation2[i], NewDBM.GetLower(i, true, currentState), NewDBM.GetUpper(i, true, currentState)))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Check dbm1 is a subset of dbm2;
        /// </summary>
        /// <param name="dbm1"></param>
        /// <param name="dbm2"></param>
        /// <returns></returns>
        public static bool IsSubSet(NewDBM dbm1, NewDBM dbm2)
        {
            int dim = NewDBM.dim;

            for (int i = 0; i < dim; i++)
            {
                for (int j = 0; j < dim; j++)
                {
                    int index = i * dim + j;
                    if (i != j && !IsLessEqual(dbm1.matrix[index], dbm1.isLessThans[index], dbm2.matrix[index], dbm2.isLessThans[index]))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Esempio n. 5
0
 public static bool IsLocallySimSubset(NewDBM z1, NewDBM z2, string[] currentStates)
 {
     return(IsSimSubset(z1, z2, true, currentStates));
 }
Esempio n. 6
0
 public static bool IsGloballySimSubset(NewDBM z1, NewDBM z2)
 {
     return(IsSimSubset(z1, z2, false, null));
 }