01: /*
02: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package test.org.mandarax.reference;
19:
20: import org.mandarax.kernel.InferenceEngine;
21: import org.mandarax.kernel.KnowledgeBase;
22: import org.mandarax.kernel.Query;
23:
24: /**
25: * Simple test using familiy relationships. No functions, no loop checking.
26: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
27: * @version 3.4 <7 March 05>
28: * @since 1.1
29: */
30: public class TestInferenceEngine1 extends TestInferenceEngine {
31:
32: /**
33: * Constructor.
34: * @param aKnowledgeBase a new, uninitialized knowledge base that will be used
35: * @param anInferenceEngine the inference engine that will be tested
36: */
37: public TestInferenceEngine1(KnowledgeBase aKnowledgeBase,
38: InferenceEngine anInferenceEngine) {
39: super (aKnowledgeBase, anInferenceEngine);
40: }
41:
42: /**
43: * Add facts and rules to the knowledge base.
44: * @param knowledge org.mandarax.kernel.KnowledgeBase
45: */
46: public void feedKnowledgeBase(KnowledgeBase knowledge) {
47: knowledge.removeAll();
48: knowledge.add(Person.getRule("isGrandFatherOf", "x", "z",
49: "isFatherOf", "y", "z", "isFatherOf", "x", "y"));
50: knowledge.add(Person.getRule("isOncleOf", "x", "z",
51: "isFatherOf", "y", "z", "isBrotherOf", "x", "y"));
52: knowledge.add(Person.getRule("isOncleOf", "x", "z",
53: "isGrandFatherOf", "y", "z", "isBrotherOf", "x", "y"));
54: knowledge.add(Person.getRule("isGrandFatherOf", "z", "x",
55: "isFatherOf", "y", "x", "isFatherOf", "z", "y"));
56: knowledge.add(Person.getFact("isFatherOf", "Jens", "Max"));
57: knowledge.add(Person.getFact("isFatherOf", "Klaus", "Jens"));
58: knowledge.add(Person.getFact("isBrotherOf", "Lutz", "Klaus"));
59: }
60:
61: /**
62: * Get a description of this test case.
63: * This is used by the <code>org.mandarax.demo</code>
64: * package to display the test cases.
65: * @return a brief description of the test case
66: */
67: public String getDescription() {
68: return "Simple test using familiy relationships.\nNo functions, no loop checking.";
69: }
70:
71: /**
72: * Get the name of the person we are looking for.
73: * More precisely, this is the name of the person expected to
74: * replace the query variable as a result of the query.
75: * @return the name of the person
76: */
77: String getPersonName() {
78: return "Lutz";
79: }
80:
81: /**
82: * Get the query.
83: * @return a query
84: */
85: public Query getQuery() {
86: return Person.getQuery("isOncleOf", QUERY_VARIABLE, "Max");
87: }
88: }
|