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.2
30: */
31: public class TestInferenceEngine12 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 TestInferenceEngine12(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.PLUS,
54: new Integer(1), lfs.cplx(IntArithmetic.TIMES,
55: "x", "y")))));
56: }
57:
58: /**
59: * Get the expected number.
60: * @return the name of the person
61: */
62: int getExpectedNumber() {
63: return 85;
64: }
65:
66: /**
67: * Get a description of this test case.
68: * This is used by the <code>org.mandarax.demo</code>
69: * package to display the test cases.
70: * @return a brief description of the test case
71: */
72: public String getDescription() {
73: return "Testing complex terms in result sets";
74: }
75:
76: /**
77: * Get the query.
78: * @return a query
79: */
80: public Query getQuery() {
81: return lfs.query(lfs.fact(P3, QUERY_VARIABLE), "a query");
82: }
83:
84: }
|