From: <jen...@us...> - 2009-01-17 18:27:17
|
Revision: 1578 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1578&view=rev Author: jenslehmann Date: 2009-01-17 18:27:07 +0000 (Sat, 17 Jan 2009) Log Message: ----------- added option to configure horizontal expansion penalty (can be used to say whether the search should be more breadth or depth like) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/test/PelletPerformanceProblem.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -215,6 +215,7 @@ options.add(new DoubleConfigOption("negativeWeight", "Used to penalise errors on negative examples different from those of positive examples (lower = less importance for negatives).",1.0)); options.add(new DoubleConfigOption("startNodeBonus", "You can use this to give a heuristic bonus on the start node (= initially broader exploration of search space).",0.0)); options.add(new IntegerConfigOption("negationPenalty", "Penalty on negations (TODO: better explanation).", 0)); + options.add(CommonConfigOptions.getExpansionPenaltyFactor(0.02)); return options; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/MultiHeuristic.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -98,6 +98,7 @@ this.configurator = configurator; negativeWeight = configurator.getNegativeWeight(); startNodeBonus = configurator.getStartNodeBonus(); + expansionPenaltyFactor = configurator.getExpansionPenaltyFactor(); } // public MultiHeuristic(int nrOfPositiveExamples, int nrOfNegativeExamples, double expansionPenaltyFactor, double gainBonusFactor) { Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ExampleBasedROLComponentConfigurator.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -402,6 +402,15 @@ public int getNegationPenalty() { return (Integer) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "negationPenalty") ; } +/** +* expansionPenaltyFactor describes the reduction in heuristic score one is willing to accept for reducing the length of the concept by one. +* mandatory: false| reinit necessary: true +* default value: 0.02 +* @return double +**/ +public double getExpansionPenaltyFactor() { +return (Double) ComponentManager.getInstance().getConfigOptionValue(exampleBasedROLComponent, "expansionPenaltyFactor") ; +} /** * @param writeSearchTree specifies whether to write a search tree. @@ -745,6 +754,15 @@ ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "negationPenalty", negationPenalty); reinitNecessary = true; } +/** +* @param expansionPenaltyFactor describes the reduction in heuristic score one is willing to accept for reducing the length of the concept by one. +* mandatory: false| reinit necessary: true +* default value: 0.02 +**/ +public void setExpansionPenaltyFactor(double expansionPenaltyFactor) { +ComponentManager.getInstance().applyConfigEntry(exampleBasedROLComponent, "expansionPenaltyFactor", expansionPenaltyFactor); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/core/options/CommonConfigOptions.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -80,6 +80,11 @@ return option; } + public static DoubleConfigOption getExpansionPenaltyFactor(double defaultValue) { + DoubleConfigOption option = new DoubleConfigOption("expansionPenaltyFactor", "describes the reduction in heuristic score one is willing to accept for reducing the length of the concept by one", defaultValue); + return option; + } + public static StringConfigOption getReturnType() { return new StringConfigOption("returnType", "Specifies the type which the solution has to belong to (if already) known. This means we inform the learning algorithm that the solution is a subclass of this type."); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -252,7 +252,7 @@ public boolean hasTypeImpl(Description description, Individual individual) throws ReasoningMethodUnsupportedException { - // System.out.println(description + " " + individual); +// System.out.println(description + " " + individual); if (description instanceof NamedClass) { return classInstancesPos.get((NamedClass) description).contains(individual); @@ -366,7 +366,10 @@ int number = ((ObjectCardinalityRestriction) description).getNumber(); int nrOfFillers = 0; - SortedSet<Individual> roleFillers = opPos.get(op).get(individual); +// SortedSet<Individual> roleFillers = opPos.get(op).get(individual); + SortedSet<Individual> roleFillers = mapping.get(individual); +// System.out.println(roleFillers); + // special case: there are always at least zero fillers if (number == 0) { return true; @@ -384,7 +387,7 @@ if (nrOfFillers == number) { return true; } - // earyl abort: e.g. >= 10 hasStructure.Methyl; + // early abort: e.g. >= 10 hasStructure.Methyl; // if there are 11 fillers and 2 are not Methyl, the result // is false } else { Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -71,7 +71,12 @@ new File(dir).mkdir(); String example = "/home/jl/promotion/ontologien/galen2.owl"; - testOntology(dir, example, 100, 17); + + for(int i=10; i<17; i++) { + rand = new Random(2); + testOntology(dir, example, 100, i); + } + System.exit(0); /* TEST ON ARTIFICIAL ONTOLOGIES @@ -142,7 +147,7 @@ // log file name String name = ontFile.getName(); - String statFileName = name.substring(0, name.lastIndexOf(".")) + ".txt"; + String statFileName = name.substring(0, name.lastIndexOf(".")) + "_" + chainLength + ".txt"; File statFile = new File(statDir + statFileName); String statString = ""; @@ -221,6 +226,9 @@ statString += getMonitorData(MonitorFactory.getMonitor("disjointness reasoning", "ms.")); Files.createFile(statFile, statString); + + reasoner.releaseKB(); + cm.freeAllComponents(); } private static String getMonitorData(Monitor mon) { Added: trunk/src/dl-learner/org/dllearner/test/PelletPerformanceProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/PelletPerformanceProblem.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/PelletPerformanceProblem.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -0,0 +1,63 @@ +/** + * Copyright (C) 2007-2009, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.test; + +import java.io.File; +import java.net.URI; +import java.util.HashSet; +import java.util.Set; + +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.semanticweb.owl.apibinding.OWLManager; +import org.semanticweb.owl.inference.OWLReasoner; +import org.semanticweb.owl.inference.OWLReasonerException; +import org.semanticweb.owl.model.OWLOntology; +import org.semanticweb.owl.model.OWLOntologyCreationException; +import org.semanticweb.owl.model.OWLOntologyManager; + +/** + * @author Jens Lehmann + * + */ +public class PelletPerformanceProblem { + + public static void main(String[] args) throws OWLOntologyCreationException, OWLReasonerException { + Logger pelletLogger = Logger.getLogger("org.mindswap.pellet"); + pelletLogger.setLevel(Level.WARN); + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + + File f = new File("examples/epc/conf/sap_modell_komplett_2.owl"); + URI physicalURI = f.toURI(); + OWLOntology ontology = manager.loadOntologyFromPhysicalURI(physicalURI); + + Set<OWLOntology> ontologies = new HashSet<OWLOntology>(); + ontologies.add(ontology); + OWLReasoner reasoner = new org.mindswap.pellet.owlapi.Reasoner(manager); + reasoner.loadOntologies(ontologies); + System.out.println("ontology loaded"); + + reasoner.classify(); + System.out.println("ontology classified"); + reasoner.realise(); + System.out.println("ontology realised"); + } + +} Modified: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2009-01-16 16:24:44 UTC (rev 1577) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2009-01-17 18:27:07 UTC (rev 1578) @@ -38,6 +38,7 @@ import org.dllearner.kb.OWLFile; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; +import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.OWLAPIReasoner; import org.junit.Test; @@ -76,7 +77,7 @@ * Performs an instance checks on all reasoner components to verify that * they all return the correct result. */ - @Test +// @Test public void instanceCheckTest() { try { ComponentManager cm = ComponentManager.getInstance(); @@ -114,7 +115,7 @@ * @throws ComponentInitException * @throws ParseException */ - @Test +// @Test public void fastInstanceCheckTest() throws ComponentInitException, ParseException { String file = "examples/carcinogenesis/carcinogenesis.owl"; ComponentManager cm = ComponentManager.getInstance(); @@ -157,6 +158,28 @@ } } + @Test + public void fastInstanceCheck2() throws ComponentInitException, ParseException { + String file = "examples/epc/conf/sap_modell_komplett_2.owl"; + ComponentManager cm = ComponentManager.getInstance(); + KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); + try { + cm.applyConfigEntry(ks, "url", new File(file).toURI().toURL()); + } catch (MalformedURLException e) { + // should never happen + e.printStackTrace(); + } + ks.init(); + ReasonerComponent reasoner = cm.reasoner(FastInstanceChecker.class, ks); + reasoner.init(); + baseURI = reasoner.getBaseURI(); + + Description description = KBParser.parseConcept("(\"http://localhost/aris/sap_model.owl#EPC\" AND EXISTS \"http://localhost/aris/sap_model.owl#hasModelElements\".(\"http://localhost/aris/sap_model.owl#Event\" AND >= 2 \"http://localhost/aris/sap_model.owl#previousObjects\".TOP))"); + Individual ind = new Individual("http://localhost/aris/sap_model.owl#e4j0__6_____u__"); + boolean result = reasoner.hasType(description, ind); + System.out.println(result); + } + private List<Individual> getIndSet(String... inds) { List<Individual> individuals = new LinkedList<Individual>(); for(String ind : inds) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |