Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
 public override void AddFactor(Factor f)
 {
     AddInput(f.Inputs.First());
 }
Exemplo n.º 4
0
 public abstract void AddFactor(Factor f);
Exemplo n.º 5
0
 public Product(Factor f)
 {
     AddFactor(f);
 }