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