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