예제 #1
0
        /**
         * Construct a clause from the given literals. Note: literals the are always
         * 'False' (i.e. False or ~True) are not added to the instantiated clause.
         *
         * @param literals
         */
        public Clause(ICollection <Literal> literals)
        {
            foreach (Literal l in literals)
            {
                if (l.isAlwaysFalse())
                {
                    // Don't add literals of the form
                    // False | ~True
                    continue;
                }
                if (this.literals.Add(l))
                {
                    // Only add to caches if not already added
                    if (l.isPositiveLiteral())
                    {
                        this.cachedPositiveSymbols.Add(l.getAtomicSentence());
                    }
                    else
                    {
                        this.cachedNegativeSymbols.Add(l.getAtomicSentence());
                    }
                }
            }

            cachedSymbols.AddAll(cachedPositiveSymbols);
            cachedSymbols.AddAll(cachedNegativeSymbols);

            // Make immutable
            this.literals         = CollectionFactory.CreateReadOnlySet <Literal>(this.literals);
            cachedSymbols         = CollectionFactory.CreateReadOnlySet <PropositionSymbol>(cachedSymbols);
            cachedPositiveSymbols = CollectionFactory.CreateReadOnlySet <PropositionSymbol>(cachedPositiveSymbols);
            cachedNegativeSymbols = CollectionFactory.CreateReadOnlySet <PropositionSymbol>(cachedNegativeSymbols);
        }
예제 #2
0
 public ISet <Clause> getFactors()
 {
     if (null == factors)
     {
         calculateFactors(null);
     }
     return(CollectionFactory.CreateReadOnlySet <Clause>(factors));
 }
예제 #3
0
 public ISet <Clause> getNonTrivialFactors()
 {
     if (null == nonTrivialFactors)
     {
         calculateFactors(null);
     }
     return(CollectionFactory.CreateReadOnlySet <Clause>(nonTrivialFactors));
 }
예제 #4
0
        protected void addChild(INode childNode)
        {
            children = CollectionFactory.CreateSet <INode>(children);

            children.Add(childNode);

            children = CollectionFactory.CreateReadOnlySet <INode>(children);
        }
예제 #5
0
 static BooleanDomain()
 {
     // Keep consistent order
     _possibleValues = CollectionFactory.CreateSet <bool>();
     _possibleValues.Add(true);
     _possibleValues.Add(false);
     // Ensure cannot be modified
     _possibleValues = CollectionFactory.CreateReadOnlySet <bool>(_possibleValues);
 }
예제 #6
0
        public FiniteIntegerDomain(params int[] pValues)
        {
            // Keep consistent order
            possibleValues = CollectionFactory.CreateSet <int>();
            foreach (int v in pValues)
            {
                possibleValues.Add(v);
            }
            // Ensure cannot be modified
            possibleValues = CollectionFactory.CreateReadOnlySet <int>(possibleValues);

            indexPossibleValues(possibleValues);
        }
예제 #7
0
        public ArbitraryTokenDomain(bool ordered, params object[] pValues)
        {
            this.ordered = ordered;
            // Keep consistent order
            possibleValues = CollectionFactory.CreateSet <object>();
            foreach (object v in pValues)
            {
                possibleValues.Add(v);
            }
            // Ensure cannot be modified
            possibleValues = CollectionFactory.CreateReadOnlySet <object>(possibleValues);

            indexPossibleValues(possibleValues);
        }
        public FullJointDistributionModel(double[] values, params IRandomVariable[] vars)
        {
            if (null == vars)
            {
                throw new IllegalArgumentException("Random Variables describing the model's representation of the World need to be specified.");
            }

            distribution = new ProbabilityTable(values, vars);

            representation = CollectionFactory.CreateSet <IRandomVariable>();
            for (int i = 0; i < vars.Length; ++i)
            {
                representation.Add(vars[i]);
            }
            representation = CollectionFactory.CreateReadOnlySet <IRandomVariable>(representation);
        }
예제 #9
0
 public AbstractNode(IRandomVariable var, params INode[] parents)
 {
     if (null == var)
     {
         throw new IllegalArgumentException("Random Variable for Node must be specified.");
     }
     this.variable = var;
     this.parents  = CollectionFactory.CreateSet <INode>();
     if (null != parents)
     {
         foreach (INode p in parents)
         {
             ((AbstractNode)p).addChild(this);
             this.parents.Add(p);
         }
     }
     this.parents  = CollectionFactory.CreateReadOnlySet <INode>(this.parents);
     this.children = CollectionFactory.CreateReadOnlySet <INode>(CollectionFactory.CreateSet <INode>());
 }
예제 #10
0
        //
        // START-ProbabilityDistribution

        public ISet <IRandomVariable> getFor()
        {
            return(CollectionFactory.CreateReadOnlySet <IRandomVariable>(randomVarInfo.GetKeys()));
        }
예제 #11
0
 /**
  * Constructor.
  *
  * @param conjunctionOfClauses
  *            a collection of clauses that represent a conjunction.
  */
 public ConjunctionOfClauses(ICollection <Clause> conjunctionOfClauses)
 {
     this.clauses.AddAll(conjunctionOfClauses);
     // Make immutable
     this.clauses = CollectionFactory.CreateReadOnlySet <Clause>(this.clauses);
 }
예제 #12
0
 public ISet <PropositionSymbol> getAssignedSymbols()
 {
     return(CollectionFactory.CreateReadOnlySet <PropositionSymbol>(assignments.GetKeys()));
 }
 /// <summary>
 /// Returns an unmodifiable view of the object's key set
 /// </summary>
 /// <returns>an unmodifiable view of the object's key set</returns>
 public virtual ISet <object> GetKeys()
 {
     return(CollectionFactory.CreateReadOnlySet <object>(attributes.GetKeys()));
 }
예제 #14
0
 public ISet <Literal> getLiterals()
 {
     return(CollectionFactory.CreateReadOnlySet <Literal>(literals));
 }
예제 #15
0
 public ISet <Clause> getAllClauses()
 {
     return(CollectionFactory.CreateReadOnlySet <Clause>(clauses));
 }
예제 #16
0
 /// <summary>
 /// Get a set of the actual actions.
 /// </summary>
 /// <returns>a set of the actual actions.</returns>
 public static ISet <CellWorldAction> Actions()
 {
     return(CollectionFactory.CreateReadOnlySet <CellWorldAction>(_actions));
 }