示例#1
0
        public static Multiset operator -(Multiset ms1, Multiset ms2)
        {
            Multiset ms = new Multiset();

            ms.Add(ms1).Subtract(ms2);
            return(ms);
        }
示例#2
0
 /// <summary>
 /// Performes a reference change to a new non-null multiset of objects; aka, shallow copy
 /// </summary>
 /// <param name="newMultiset"></param>
 public void ReplaceMultiset(Multiset newMultiset)
 {
     if (newMultiset == null)
     {
         throw new ArgumentNullException("newMultiset");
     }
     Multiset = newMultiset;
 }
 public InstanceBlueprint(MType mt, Multiset ms)
 {
     if (mt == null)
     {
         throw new ArgumentNullException("mt", "MType cannot be null");
     }
     mtype    = mt;
     multiset = ms;
 }
示例#4
0
        public Multiset Add(Multiset multiset)
        {
            foreach (KeyValuePair <string, int> kv in multiset)
            {
                Add(kv.Key, kv.Value);
            }

            return(this);
        }
示例#5
0
        public Multiset Subtract(Multiset multiset)
        {
            foreach (KeyValuePair <string, int> kv in multiset)
            {
                Subtract(kv.Key, kv.Value);
            }

            return(this);
        }
示例#6
0
        public Multiset Clone()
        {
            Multiset clone = new Multiset();

            foreach (KeyValuePair <string, int> kv in ms)
            {
                clone.Add(kv.Key, kv.Value);
            }

            return(clone);
        }
示例#7
0
        public bool IsSatisfiedBy(Multiset multiset)
        {
            if (op == BinaryGuardOperator.AND)
            {
                return(lhs.IsSatisfiedBy(multiset) && rhs.IsSatisfiedBy(multiset));
            }
            else if (op == BinaryGuardOperator.OR)
            {
                return(lhs.IsSatisfiedBy(multiset) || rhs.IsSatisfiedBy(multiset));
            }

            return(false);
        }
示例#8
0
        public bool Contains(Multiset multiset)
        {
            foreach (KeyValuePair <string, int> kv in multiset)
            {
                //assume multisets are normalised
                int v = 0;
                ms.TryGetValue(kv.Key, out v);

                if (v < kv.Value)
                {
                    return(false);
                }
            }
            return(true);
        }
示例#9
0
        public bool IsDisjointFrom(Multiset multiset)
        {
            foreach (KeyValuePair <string, int> kv in ms)
            {
                int x = 0;
                if (multiset.ms.TryGetValue(kv.Key, out x))
                {
                    if (x > 0)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
示例#10
0
        public virtual bool IsSatisfiedBy(Multiset multiset)
        {
            switch (op)
            {
            case RelationalOperator.EQUAL: {
                foreach (KeyValuePair <string, int> kv in ms)
                {
                    if (kv.Value != multiset[kv.Key])
                    {
                        return(false);
                    }
                }
                return(true);
            }

            case RelationalOperator.GEQ: {
                foreach (KeyValuePair <string, int> kv in ms)
                {
                    if (kv.Value > multiset[kv.Key])
                    {
                        return(false);
                    }
                }
                return(true);
            }

            case RelationalOperator.GT: {
                foreach (KeyValuePair <string, int> kv in ms)
                {
                    if (kv.Value >= multiset[kv.Key])
                    {
                        return(false);
                    }
                }
                return(true);
            }

            case RelationalOperator.LEQ: {
                foreach (KeyValuePair <string, int> kv in ms)
                {
                    if (kv.Value < multiset[kv.Key])
                    {
                        return(false);
                    }
                }
                return(true);
            }

            case RelationalOperator.LT: {
                foreach (KeyValuePair <string, int> kv in ms)
                {
                    if (kv.Value <= multiset[kv.Key])
                    {
                        return(false);
                    }
                }
                return(true);
            }

            case RelationalOperator.NOT_EQUAL: {
                foreach (KeyValuePair <string, int> kv in ms)
                {
                    if (kv.Value == multiset[kv.Key])
                    {
                        return(false);
                    }
                }
                return(true);
            }
            }
            return(false);
        }
示例#11
0
 public BasicGuard(Multiset multiset, RelationalOperator op)
 {
     Multiset = multiset;
     Operator = op;
 }
示例#12
0
 public DissolutionRule(Multiset ms)
     : this()
 {
     lhs = ms;
 }
示例#13
0
 public static LinkRule LinkCreate(Multiset ms, IInstanceIdentifier tar)
 {
     return(new LinkRule(RuleType.LINK_CREATION, ms, tar));
 }
示例#14
0
 public DivisionRule(Multiset ms) : base(ms)
 {
     rhs  = new List <InstanceBlueprint>();
     type = RuleType.MEMBRANE_DIVISION;
 }
示例#15
0
 public RewritingRule()
     : base()
 {
     type = RuleType.MULTISET_REWRITING;
     rhs  = new Multiset();
 }
示例#16
0
 public MInstance(Multiset ms) : base()
 {
     multiset    = ms;
     connections = new List <MInstance>();
 }
示例#17
0
 public bool Equals(Multiset multiset)
 {
     return(Contains(multiset) && multiset.Contains(this));
 }
示例#18
0
 public void AddRhs(Multiset ms)
 {
     rhs.Add(ms);
 }
 public TargetedMultiset(IInstanceIdentifier identifier)
 {
     multiset = new Multiset();
     target   = identifier;
 }
示例#20
0
 private LinkRule(RuleType t, Multiset ms, IInstanceIdentifier tar)
     : base(ms)
 {
     type   = t;
     Target = tar;
 }
 public TargetedMultiset(InstanceIdentifier identifier, Multiset multiset)
 {
     Target   = identifier;
     Multiset = multiset;
 }
示例#22
0
 public static LinkRule LinkDestroy(Multiset ms, IInstanceIdentifier tar)
 {
     return(new LinkRule(RuleType.LINK_DESTRUCTION, ms, tar));
 }
 public TypeTargetedMultiset(MType mtype, Multiset multiset) :
     base(new InstanceIdentifier(InstanceIndicator.TYPE, mtype.Name), multiset)
 {
     MType = mtype;
 }
示例#24
0
 public ConsumerRule(Multiset ms)
     : base(RuleType.CONSUMER)
 {
     lhs = ms;
 }
示例#25
0
 public bool IsSatisfiedBy(Multiset multiset)
 {
     return(!operand.IsSatisfiedBy(multiset));
 }