getAssignedSymbols() public method

public getAssignedSymbols ( ) : ReadOnlyCollection
return ReadOnlyCollection
Example #1
0
        private SymbolValuePair findUnitClause(List <Sentence> clauseList, Model model,
                                               List <Symbol> symbols)
        {
            for (int i = 0; i < clauseList.Count; i++)
            {
                Sentence clause = (Sentence)clauseList[i];
                if ((clause is Symbol) &&
                    (!(model.getAssignedSymbols().Contains(clause))))
                {
                    // System.Console.WriteLine("found unit clause - assigning");
                    return(new SymbolValuePair(new Symbol(((Symbol)clause)
                                                          .getValue()), true));
                }

                if (clause is UnarySentence)
                {
                    UnarySentence sentence = (UnarySentence)clause;
                    Sentence      negated  = sentence.getNegated();
                    if ((negated is Symbol) &&
                        (!(model.getAssignedSymbols().Contains(negated))))
                    {
                        // System.Console.WriteLine("found unit clause type 2 -
                        // assigning");
                        return(new SymbolValuePair(new Symbol(((Symbol)negated)
                                                              .getValue()), false));
                    }
                }
            }

            return(new SymbolValuePair());// failed to find any unit clause;
        }
Example #2
0
        public SymbolValuePair findPureSymbolValuePair(List<Sentence> clauseList,
                Model model, List<Symbol> symbols)
        {
            List<Sentence> _clausesWithNonTrueValues = clausesWithNonTrueValues(clauseList,
                    model);
            Sentence nonTrueClauses = LogicUtils.chainWith("AND",
                    _clausesWithNonTrueValues);
            // System.Console.WriteLine("Unsatisfied clauses = "
            // + clausesWithNonTrueValues.Count);
            List<Symbol> symbolsAlreadyAssigned = new List<Symbol>( model.getAssignedSymbols());

            // debug
            // List symList = asList(symbolsAlreadyAssigned);
            //
            // System.Console.WriteLine(" assignedSymbols = " + symList.Count);
            // if (symList.Count == 52) {
            // System.Console.WriteLine("untrue clauses = " + clausesWithNonTrueValues);
            // System.Console.WriteLine("model= " + model);
            // }

            // debug
            List<Symbol> purePositiveSymbols = SetOps
                    .difference(new SymbolClassifier()
                            .getPurePositiveSymbolsIn(nonTrueClauses),
                            symbolsAlreadyAssigned);

            List<Symbol> pureNegativeSymbols = SetOps
                    .difference(new SymbolClassifier()
                            .getPureNegativeSymbolsIn(nonTrueClauses),
                            symbolsAlreadyAssigned);
            // if none found return "not found
            if ((purePositiveSymbols.Count == 0)
                    && (pureNegativeSymbols.Count == 0))
            {
                return new SymbolValuePair();// automatically set to null values
            }
            else
            {
                if (purePositiveSymbols.Count > 0)
                {
                    Symbol symbol =purePositiveSymbols[0];
                    if (pureNegativeSymbols.Contains(symbol))
                    {
                        throw new ApplicationException("Symbol " + symbol.getValue()
                                + "misclassified");
                    }
                    return new SymbolValuePair(symbol, true);
                }
                else
                {
                    Symbol symbol = new Symbol((pureNegativeSymbols[0])
                            .getValue());
                    if (purePositiveSymbols.Contains(symbol))
                    {
                        throw new ApplicationException("Symbol " + symbol.getValue()
                                + "misclassified");
                    }
                    return new SymbolValuePair(symbol, false);
                }
            }
        }
Example #3
0
        private SymbolValuePair findUnitClause(List<Sentence> clauseList, Model model,
                List<Symbol> symbols)
        {
            for (int i = 0; i < clauseList.Count; i++)
            {
                Sentence clause = (Sentence)clauseList[i];
                if ((clause is Symbol)
                        && (!(model.getAssignedSymbols().Contains(clause))))
                {
                    // System.Console.WriteLine("found unit clause - assigning");
                    return new SymbolValuePair(new Symbol(((Symbol)clause)
                            .getValue()), true);
                }

                if (clause is UnarySentence)
                {
                    UnarySentence sentence = (UnarySentence)clause;
                    Sentence negated = sentence.getNegated();
                    if ((negated is Symbol)
                            && (!(model.getAssignedSymbols().Contains(negated))))
                    {
                        // System.Console.WriteLine("found unit clause type 2 -
                        // assigning");
                        return new SymbolValuePair(new Symbol(((Symbol)negated)
                                .getValue()), false);
                    }
                }

            }

            return new SymbolValuePair();// failed to find any unit clause;

        }
Example #4
0
        public SymbolValuePair findPureSymbolValuePair(List <Sentence> clauseList,
                                                       Model model, List <Symbol> symbols)
        {
            List <Sentence> _clausesWithNonTrueValues = clausesWithNonTrueValues(clauseList,
                                                                                 model);
            Sentence nonTrueClauses = LogicUtils.chainWith("AND",
                                                           _clausesWithNonTrueValues);
            // System.Console.WriteLine("Unsatisfied clauses = "
            // + clausesWithNonTrueValues.Count);
            List <Symbol> symbolsAlreadyAssigned = new List <Symbol>(model.getAssignedSymbols());

            // debug
            // List symList = asList(symbolsAlreadyAssigned);
            //
            // System.Console.WriteLine(" assignedSymbols = " + symList.Count);
            // if (symList.Count == 52) {
            // System.Console.WriteLine("untrue clauses = " + clausesWithNonTrueValues);
            // System.Console.WriteLine("model= " + model);
            // }

            // debug
            List <Symbol> purePositiveSymbols = SetOps
                                                .difference(new SymbolClassifier()
                                                            .getPurePositiveSymbolsIn(nonTrueClauses),
                                                            symbolsAlreadyAssigned);

            List <Symbol> pureNegativeSymbols = SetOps
                                                .difference(new SymbolClassifier()
                                                            .getPureNegativeSymbolsIn(nonTrueClauses),
                                                            symbolsAlreadyAssigned);

            // if none found return "not found
            if ((purePositiveSymbols.Count == 0) &&
                (pureNegativeSymbols.Count == 0))
            {
                return(new SymbolValuePair());// automatically set to null values
            }
            else
            {
                if (purePositiveSymbols.Count > 0)
                {
                    Symbol symbol = purePositiveSymbols[0];
                    if (pureNegativeSymbols.Contains(symbol))
                    {
                        throw new ApplicationException("Symbol " + symbol.getValue()
                                                       + "misclassified");
                    }
                    return(new SymbolValuePair(symbol, true));
                }
                else
                {
                    Symbol symbol = new Symbol((pureNegativeSymbols[0])
                                               .getValue());
                    if (purePositiveSymbols.Contains(symbol))
                    {
                        throw new ApplicationException("Symbol " + symbol.getValue()
                                                       + "misclassified");
                    }
                    return(new SymbolValuePair(symbol, false));
                }
            }
        }