示例#1
0
        public override void AddFactor(Factor f)
        {
            var z = f as SimpleFactor;
            if (null == z)
            {
                throw new ArgumentException("expected VariableFactor.");
            }

            if (IsConstant)
            {
                return;
            }
            else if (f.IsConstant)
            {
                //SetConstant(f.Constant);
                throw new NotImplementedException();
            }

            var sb = new StringBuilder();
            sb.AppendFormat("factor addition {0} + {1}", this, f);

            // combine inverters
            for (int j = 0; j < Variable.Cardinality; ++j)
            {
                // contained in left set?
                var f1 = !_invert[j];

                // contained in right set?
                var f2 = !z._invert[j];

                if (f1 && f2)
                {
                    _invert[j] = false;
                }
                else
                {
                    _invert[j] = true;
                }
            }

            CheckZero();

            sb.AppendFormat(" ==> {0}", this);
            Trace("{0}", sb);
        }
示例#2
0
        public void AddFactor(Factor f1)
        {
            if(_zero)
            {
                // ignore
                return;
            }

            Factor f0;
            if (!_map.TryGetValue(f1.Group, out f0))
            {
                _map[f1.Group] = f1;
            }
            else
            {
                // factor for the same group already exists in the product
                f0.AddFactor(f1);
            }
        }
示例#3
0
 public override void AddFactor(Factor f)
 {
     AddInput(f.Inputs.First());
 }
示例#4
0
文件: Factor.cs 项目: thomas13335/smg
 public abstract void AddFactor(Factor f);
示例#5
0
 public Product(Factor f)
 {
     AddFactor(f);
 }