public DPLLResultHolder ParallelSAT() { CNF cnf = new CNF(); cnf.ReadFormula(new StreamReader(file)); DPLL dpll = new DPLL(); return(dpll.SatisfiableParallel(cnf)); }
public Output(string method, string content) { ProcessContent(content); switch (method.ToLower()) { case "dpll": DPLL = new DPLL(); break; case "rs": DPLL = new ResolutionBasedSolver(); break; default: GetInferenceEngine(method); break; } }
/** * Create a Knowledge Base that contains the atemporal "wumpus physics" and * temporal rules with time zero. * * @param dpll * the dpll implementation to use for answering 'ask' queries. * @param caveXandYDimensions * x and y dimensions of the wumpus world's cave. * */ public WumpusKnowledgeBase(DPLL dpll, int caveXandYDimensions) : base() { this.dpll = dpll; this.caveXDimension = caveXandYDimensions; this.caveYDimension = caveXandYDimensions; // // 7.7.1 - The current state of the World // The agent knows that the starting square contains no pit tell(new ComplexSentence(Connective.NOT, newSymbol(PIT, 1, 1))); // and no wumpus. tell(new ComplexSentence(Connective.NOT, newSymbol(WUMPUS, 1, 1))); // Atemporal rules about breeze and stench // For each square, the agent knows that the square is breezy // if and only if a neighboring square has a pit; and a square // is smelly if and only if a neighboring square has a wumpus. for (int y = 1; y <= caveYDimension; y++) { for (int x = 1; x <= caveXDimension; x++) { ICollection <Sentence> pitsIn = CollectionFactory.CreateQueue <Sentence>(); ICollection <Sentence> wumpsIn = CollectionFactory.CreateQueue <Sentence>(); if (x > 1) { // West room exists pitsIn.Add(newSymbol(PIT, x - 1, y)); wumpsIn.Add(newSymbol(WUMPUS, x - 1, y)); } if (y < caveYDimension) { // North room exists pitsIn.Add(newSymbol(PIT, x, y + 1)); wumpsIn.Add(newSymbol(WUMPUS, x, y + 1)); } if (x < caveXDimension) { // East room exists pitsIn.Add(newSymbol(PIT, x + 1, y)); wumpsIn.Add(newSymbol(WUMPUS, x + 1, y)); } if (y > 1) { // South room exists pitsIn.Add(newSymbol(PIT, x, y - 1)); wumpsIn.Add(newSymbol(WUMPUS, x, y - 1)); } tell(new ComplexSentence(newSymbol(BREEZE, x, y), Connective.BICONDITIONAL, Sentence.newDisjunction(pitsIn))); tell(new ComplexSentence(newSymbol(STENCH, x, y), Connective.BICONDITIONAL, Sentence.newDisjunction(wumpsIn))); } } // The agent also knows there is exactly one wumpus. This is represented // in two parts. First, we have to say that there is at least one wumpus ICollection <Sentence> wumpsAtLeast = CollectionFactory.CreateQueue <Sentence>(); for (int x = 1; x <= caveXDimension; x++) { for (int y = 1; y <= caveYDimension; y++) { wumpsAtLeast.Add(newSymbol(WUMPUS, x, y)); } } tell(Sentence.newDisjunction(wumpsAtLeast)); // Then, we have to say that there is at most one wumpus. // For each pair of locations, we add a sentence saying // that at least one of them must be wumpus-free. int numRooms = (caveXDimension * caveYDimension); for (int i = 0; i < numRooms; i++) { for (int j = i + 1; j < numRooms; j++) { tell(new ComplexSentence(Connective.OR, new ComplexSentence(Connective.NOT, newSymbol(WUMPUS, (i / caveXDimension) + 1, (i % caveYDimension) + 1)), new ComplexSentence(Connective.NOT, newSymbol(WUMPUS, (j / caveXDimension) + 1, (j % caveYDimension) + 1)))); } } }
public void setUp() { parser = new PEParser(); dpll = new DPLL(); }
public DPLLTest() { this.dpll = new DPLLSatisfiable(); this.parser = new PLParser(); }