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: import org.mandarax.lib.math.IntArithmetic;
24:
25: /**
26: * Tests functions in result set with the result (term) being fully instanciated.
27: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
28: * @version 3.4 <7 March 05>
29: * @since 1.9.1
30: */
31: public class TestInferenceEngine11 extends TestInferenceEngineUseMath {
32:
33: /**
34: * Constructor.
35: * @param aKnowledgeBase a new, uninitialized knowledge base that will be used
36: * @param anInferenceEngine the inference engine that will be tested
37: */
38: public TestInferenceEngine11(KnowledgeBase aKnowledgeBase,
39: InferenceEngine anInferenceEngine) {
40: super (aKnowledgeBase, anInferenceEngine);
41: }
42:
43: /**
44: * Add facts and rules to the knowledge base.
45: * @param knowledge org.mandarax.kernel.KnowledgeBase
46: */
47: public void feedKnowledgeBase(KnowledgeBase knowledge) {
48: knowledge.removeAll();
49:
50: knowledge.add(lfs.fact(P1, new Integer(42)));
51: knowledge.add(lfs.fact(P2, new Integer(2)));
52: knowledge.add(lfs.rule(lfs.fact(P1, "x"), lfs.fact(P2, "y"),
53: lfs.fact(P3, lfs.cplx(IntArithmetic.TIMES, "x", "y"))));
54: }
55:
56: /**
57: * Get the expected number.
58: * @return the name of the person
59: */
60: int getExpectedNumber() {
61: return 84;
62: }
63:
64: /**
65: * Get a description of this test case.
66: * This is used by the <code>org.mandarax.demo</code>
67: * package to display the test cases.
68: * @return a brief description of the test case
69: */
70: public String getDescription() {
71: return "Testing complex terms in result sets";
72: }
73:
74: /**
75: * Get the query.
76: * @return a query
77: */
78: public Query getQuery() {
79: return lfs.query(lfs.fact(P3, QUERY_VARIABLE), "a query");
80: }
81:
82: }
|