From: <lor...@us...> - 2010-08-04 10:59:50
|
Revision: 2234 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2234&view=rev Author: lorenz_b Date: 2010-08-04 10:59:43 +0000 (Wed, 04 Aug 2010) Log Message: ----------- Added unit test to compare reasoners. Added first test example for reasoner tests. Updated Fact++ lib. Added maxExpressionsTest option to CELOE. Modified Paths: -------------- trunk/doc/configOptions.txt trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java Added Paths: ----------- trunk/examples/testReasoners/ trunk/examples/testReasoners/father.owl trunk/examples/testReasoners/test.conf trunk/lib/fact/FaCTpp-OWLAPI-v1.4.0.1.jar trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTest.java Removed Paths: ------------- trunk/lib/fact/factplusplus-1.3.1.jar Modified: trunk/doc/configOptions.txt =================================================================== --- trunk/doc/configOptions.txt 2010-08-03 21:54:14 UTC (rev 2233) +++ trunk/doc/configOptions.txt 2010-08-04 10:59:43 UTC (rev 2234) @@ -558,6 +558,12 @@ default value: 10 conf file usage: celoe.maxNrOfResults = 10; +option name: maxClassDescriptionTests +description: The maximum number of candidate hypothesis the algorithm is allowed to test (0 = no limit). The algorithm will stop afterwards. (The real number of tests can be slightly higher, because this criterion usually won't be checked after each single test.) +allowed values: int +default value: 0 +conf file usage: celoe.maxClassDescriptionTests = 0; + option name: singleSuggestionMode description: Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples. allowed values: boolean Added: trunk/examples/testReasoners/father.owl =================================================================== --- trunk/examples/testReasoners/father.owl (rev 0) +++ trunk/examples/testReasoners/father.owl 2010-08-04 10:59:43 UTC (rev 2234) @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<rdf:RDF + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:xsd="http://www.w3.org/2001/XMLSchema#" + xmlns="http://example.com/father#" + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" + xmlns:owl="http://www.w3.org/2002/07/owl#" + xml:base="http://example.com/father"> + <owl:Ontology rdf:about=""/> + <owl:Class rdf:ID="female"/> + <owl:Class rdf:ID="male"> + <owl:equivalentClass> + <owl:Class> + <owl:complementOf rdf:resource="#female"/> + </owl:Class> + </owl:equivalentClass> + </owl:Class> + <owl:ObjectProperty rdf:ID="hasChild"/> + <male rdf:ID="markus"> + <hasChild> + <female rdf:ID="anna"> + <hasChild> + <male rdf:ID="heinz"/> + </hasChild> + </female> + </hasChild> + </male> + <male rdf:ID="stefan"> + <hasChild rdf:resource="#markus"/> + </male> + <female rdf:ID="michelle"/> + <male rdf:ID="martin"> + <hasChild rdf:resource="#heinz"/> + </male> +</rdf:RDF> Added: trunk/examples/testReasoners/test.conf =================================================================== --- trunk/examples/testReasoners/test.conf (rev 0) +++ trunk/examples/testReasoners/test.conf 2010-08-04 10:59:43 UTC (rev 2234) @@ -0,0 +1,17 @@ +//import("family-benchmark/family-benchmark.owl"); +import("father.owl"); + +problem = classLearning; +//classLearning.classToDescribe = "http://www.benchmark.org/family#Female"; +classLearning.classToDescribe = "http://example.com/father#female"; +classLearning.useApproximations = true; +classLearning.type = equivalence; +classLearning.accuracyMethod = standard; +classLearning.checkConsistency = false; + +algorithm = celoe; +celoe.useNegation = false; +celoe.maxClassDescriptionTests = 10000; +celoe.maxExecutionTimeInSeconds = 0; +celoe.noisePercentage = 5.0; +celoe.maxNrOfResults = 10; \ No newline at end of file Added: trunk/lib/fact/FaCTpp-OWLAPI-v1.4.0.1.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/fact/FaCTpp-OWLAPI-v1.4.0.1.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: trunk/lib/fact/factplusplus-1.3.1.jar =================================================================== (Binary files differ) Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-08-03 21:54:14 UTC (rev 2233) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-08-04 10:59:43 UTC (rev 2234) @@ -173,6 +173,7 @@ options.add(CommonConfigOptions.getNoisePercentage()); options.add(CommonConfigOptions.getMaxDepth(7)); options.add(CommonConfigOptions.maxNrOfResults(10)); + options.add(CommonConfigOptions.maxClassDescriptionTests()); options.add(new BooleanConfigOption("singleSuggestionMode", "Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.", false)); options.add(CommonConfigOptions.getInstanceBasedDisjoints()); options.add(new BooleanConfigOption("filterDescriptionsFollowingFromKB", "If true, then the results will not contain suggestions, which already follow logically from the knowledge base. Be careful, since this requires a potentially expensive consistency check for candidate solutions.", false)); @@ -671,7 +672,10 @@ } private boolean terminationCriteriaSatisfied() { - return stop || ((System.nanoTime() - nanoStartTime) >= (configurator.getMaxExecutionTimeInSeconds()*1000000000l)); + return + stop || + (configurator.getMaxClassDescriptionTests() != 0 && (expressionTests >= configurator.getMaxClassDescriptionTests())) || + (configurator.getMaxExecutionTimeInSeconds() != 0 && ((System.nanoTime() - nanoStartTime) >= (configurator.getMaxExecutionTimeInSeconds()*1000000000l))); } private void reset() { Modified: trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2010-08-03 21:54:14 UTC (rev 2233) +++ trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2010-08-04 10:59:43 UTC (rev 2234) @@ -182,6 +182,15 @@ return (Integer) ComponentManager.getInstance().getConfigOptionValue(cELOE, "maxNrOfResults") ; } /** +* maxClassDescriptionTests The maximum number of candidate hypothesis the algorithm is allowed to test (0 = no limit). The algorithm will stop afterwards. (The real number of tests can be slightly higher, because this criterion usually won't be checked after each single test.). +* mandatory: false| reinit necessary: true +* default value: 0 +* @return int +**/ +public int getMaxClassDescriptionTests() { +return (Integer) ComponentManager.getInstance().getConfigOptionValue(cELOE, "maxClassDescriptionTests") ; +} +/** * singleSuggestionMode Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.. * mandatory: false| reinit necessary: true * default value: false @@ -372,6 +381,15 @@ reinitNecessary = true; } /** +* @param maxClassDescriptionTests The maximum number of candidate hypothesis the algorithm is allowed to test (0 = no limit). The algorithm will stop afterwards. (The real number of tests can be slightly higher, because this criterion usually won't be checked after each single test.). +* mandatory: false| reinit necessary: true +* default value: 0 +**/ +public void setMaxClassDescriptionTests(int maxClassDescriptionTests) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "maxClassDescriptionTests", maxClassDescriptionTests); +reinitNecessary = true; +} +/** * @param singleSuggestionMode Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.. * mandatory: false| reinit necessary: true * default value: false Added: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTest.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTest.java 2010-08-04 10:59:43 UTC (rev 2234) @@ -0,0 +1,116 @@ +package org.dllearner.test.junit; + +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import org.dllearner.cli.Start; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.parser.ParseException; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.utilities.owl.ConceptComparator; +import org.junit.Test; + +public class ReasonerTest { + + private ConceptComparator comparator = new ConceptComparator(); + + @Test + public void compareReasoners() throws FileNotFoundException, ComponentInitException, ParseException{ + + ComponentManager cm = ComponentManager.getInstance(); + Start start; + FastInstanceChecker reasoner; + LearningProblem lp; + LearningAlgorithm la; + KnowledgeSource ks; + + for(File conf : getTestConfigFiles()){ + start = new Start(conf); + lp = start.getLearningProblem(); + la = start.getLearningAlgorithm(); + ks = start.getSources().iterator().next(); + + TreeSet<? extends EvaluatedDescription> result = new TreeSet<EvaluatedDescription>(); + + for(String type : getReasonerTypes()){ + System.out.println("Using " + type + " reasoner..."); + try { + reasoner = cm.reasoner(FastInstanceChecker.class, ks); + reasoner.getConfigurator().setReasonerType(type); + reasoner.init(); + + lp.changeReasonerComponent(reasoner); + lp.init(); + + la.init(); + la.start(); + if(!result.isEmpty()){ + assertTrue(compareTreeSets(la.getCurrentlyBestEvaluatedDescriptions(), result)); + } + + result = la.getCurrentlyBestEvaluatedDescriptions(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + } + + } + + private Set<File> getTestConfigFiles(){ + Set<File> files = new HashSet<File>(); + File directory = new File("examples" + File.separator + "testReasoners"); + for(File file : directory.listFiles()){ + if(file.toString().endsWith(".conf")){ + files.add(file); + } + } + return files; + } + + private List<String> getReasonerTypes(){ + List<String> reasonerTypes = new LinkedList<String>(); + reasonerTypes.add("pellet"); + reasonerTypes.add("hermit"); + reasonerTypes.add("fact"); + + return reasonerTypes; + } + + public boolean compareTreeSets(TreeSet<? extends EvaluatedDescription> tree1, TreeSet<? extends EvaluatedDescription> tree2){ + boolean equal = true; + + List<? extends EvaluatedDescription> list1 = new ArrayList<EvaluatedDescription>(tree1); + List<? extends EvaluatedDescription> list2 = new ArrayList<EvaluatedDescription>(tree2); + + EvaluatedDescription d1; + EvaluatedDescription d2; + for(int i = 0; i < list1.size(); i++){ + d1 = list1.get(i); + d2 = list2.get(i); + if(!(comparator.compare(d1.getDescription(), d2.getDescription()) == 0) && + d1.getAccuracy() == d2.getAccuracy()){ + equal = false; + break; + } + } + + return equal; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |