From: <jen...@us...> - 2009-01-26 13:15:30
|
Revision: 1583 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1583&view=rev Author: jenslehmann Date: 2009-01-26 11:55:26 +0000 (Mon, 26 Jan 2009) Log Message: ----------- benchmarks with monitoring mostly deactivated Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2009-01-25 19:16:38 UTC (rev 1582) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionNode.java 2009-01-26 11:55:26 UTC (rev 1583) @@ -137,7 +137,7 @@ tree.addNodeToLevel(this, level); // simulation update - Monitor mon = MonitorFactory.start("simulation update"); +// Monitor mon = MonitorFactory.start("simulation update"); // the nodes, which need to be updated Set<ELDescriptionNode> update = new HashSet<ELDescriptionNode>(); @@ -188,7 +188,7 @@ // apply updates recursively top-down tree.updateSimulation(update); - mon.stop(); +// mon.stop(); // add all classes in label for(NamedClass nc : label) { @@ -350,7 +350,7 @@ // simulation update when extending or refining label // (same in both cases) private void labelSimulationUpdate() { - Monitor mon = MonitorFactory.start("simulation update"); +// Monitor mon = MonitorFactory.start("simulation update"); // compute the nodes, which need to be updated Set<ELDescriptionNode> update = new HashSet<ELDescriptionNode>(); @@ -411,13 +411,13 @@ // apply updates recursively top-down tree.updateSimulation(update); - mon.stop(); +// mon.stop(); } public void refineEdge(int edgeNumber, ObjectProperty op) { edges.get(edgeNumber).setLabel(op); - Monitor mon = MonitorFactory.start("simulation update"); +// Monitor mon = MonitorFactory.start("simulation update"); // compute the nodes, which need to be updated Set<ELDescriptionNode> update = new HashSet<ELDescriptionNode>(); update.add(this); @@ -451,7 +451,7 @@ // apply updates recursively top-down tree.updateSimulation(update); - mon.stop(); +// mon.stop(); } /** Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2009-01-25 19:16:38 UTC (rev 1582) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2009-01-26 11:55:26 UTC (rev 1583) @@ -42,9 +42,6 @@ import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.UnsupportedLanguageException; -import com.jamonapi.Monitor; -import com.jamonapi.MonitorFactory; - /** * Represents an EL description tree. Unlike {@link ELDescriptionNode}, this is * a tree-wide structure, i.e. it does not implement the tree structure itself, @@ -467,7 +464,7 @@ @Override @SuppressWarnings("unchecked") public ELDescriptionTree clone() { - Monitor mon = MonitorFactory.start("tree clone"); +// Monitor mon = MonitorFactory.start("tree clone"); // clone "global" tree ELDescriptionTree treeClone = new ELDescriptionTree(rs); @@ -553,7 +550,7 @@ treeClone.levelNodeMapping.put(i, newNodes); } - mon.stop(); +// mon.stop(); return treeClone; } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-25 19:16:38 UTC (rev 1582) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/ELDown2.java 2009-01-26 11:55:26 UTC (rev 1583) @@ -51,8 +51,8 @@ import org.dllearner.core.owl.Thing; import org.dllearner.utilities.Helper; -import com.jamonapi.Monitor; -import com.jamonapi.MonitorFactory; +//import com.jamonapi.Monitor; +//import com.jamonapi.MonitorFactory; /** * EL downward refinement operator constructed by Jens Lehmann @@ -168,7 +168,7 @@ // operation 1: label extension private List<ELDescriptionTree> extendLabel(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { - Monitor mon = MonitorFactory.start("extend label"); +// Monitor mon = MonitorFactory.start("extend label"); List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); // the index is the range of role in the edge pointing to the parent of this node @@ -193,13 +193,13 @@ } } - mon.stop(); +// mon.stop(); return refinements; } // operation 2: label refinement private List<ELDescriptionTree> refineLabel(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { - Monitor mon = MonitorFactory.start("refine label"); +// Monitor mon = MonitorFactory.start("refine label"); List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); // loop through all classes in label @@ -220,13 +220,13 @@ } } } - mon.stop(); +// mon.stop(); return refinements; } // operation 3: refine edge private List<ELDescriptionTree> refineEdge(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { - Monitor mon = MonitorFactory.start("refine edge"); +// Monitor mon = MonitorFactory.start("refine edge"); List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); for(int edgeNumber = 0; edgeNumber < v.getEdges().size(); edgeNumber++) { @@ -251,13 +251,13 @@ } } } - mon.stop(); +// mon.stop(); return refinements; } // operation 4: attach tree private Collection<ELDescriptionTree> attachSubtree(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { - Monitor mon = MonitorFactory.start("attach tree"); +// Monitor mon = MonitorFactory.start("attach tree"); List<ELDescriptionTree> refinements = new LinkedList<ELDescriptionTree>(); // compute the set of most general roles such that the domain of each role is not disjoint @@ -311,7 +311,7 @@ // we check equivalence by a minimality test (TODO: can we still do this?) boolean minimal = mergedTree.isMinimal(); - MonitorFactory.add("as.minimal", "boolean", minimal ? 1 : 0); +// MonitorFactory.add("as.minimal", "boolean", minimal ? 1 : 0); if(minimal) { logger.trace("Merged tree is minimal, i.e. not equivalent."); // it is not equivalent, i.e. we found a refinement @@ -321,7 +321,7 @@ // perform complex check in merged tree boolean check = asCheck(wClone); logger.trace("Result of complex check: " + check); - MonitorFactory.add("as.check", "boolean", check ? 1 : 0); +// MonitorFactory.add("as.check", "boolean", check ? 1 : 0); if(check) { // refine property @@ -331,9 +331,9 @@ // refine tree using recursive operator call logger.trace("Recursive Call"); // do not monitor recursive calls (counts time twice or more) - mon.stop(); +// mon.stop(); List<ELDescriptionTree> recRefs = refine(tp); - mon.start(); +// mon.start(); logger.trace("Recursive Call Done"); for(ELDescriptionTree tpp : recRefs) { m.add(new ELDescriptionEdge(r, tpp.getRootNode())); @@ -344,13 +344,13 @@ logger.trace("M: " + m); } } - mon.stop(); +// mon.stop(); return refinements; } // new version of as private Collection<ELDescriptionTree> attachSubtree2(ELDescriptionTree tree, ELDescriptionNode v, int[] position) { - Monitor mon = MonitorFactory.start("attach tree"); +// Monitor mon = MonitorFactory.start("attach tree"); Set<ELDescriptionTree> refinements = new TreeSet<ELDescriptionTree>(treeComp); // create and initialise M @@ -401,13 +401,13 @@ ELDescriptionNode w = tpp.getNode(wPosition); boolean minimal = tpp.isMinimal(); - MonitorFactory.add("as.minimal", "boolean", minimal ? 1 : 0); +// MonitorFactory.add("as.minimal", "boolean", minimal ? 1 : 0); if(minimal) { refinements.add(tpp); // logger.trace("tree is minimal; added to T"); } else { boolean check = asCheck(w); - MonitorFactory.add("as.check", "boolean", check ? 1 : 0); +// MonitorFactory.add("as.check", "boolean", check ? 1 : 0); // logger.trace("tree is not minimal; result of complex check: " + check); if(check) { @@ -429,11 +429,11 @@ if(rppSet.size() != 0) { // recursive call - mon.stop(); +// mon.stop(); // logger.trace("recursive call start"); List<ELDescriptionTree> recRefs = refine(tp); // logger.trace("recursive call end"); - mon.start(); +// mon.start(); for(ELDescriptionTree tStar : recRefs) { m.add(new TreeAndRoleSet(tStar, rppSet)); @@ -443,14 +443,14 @@ } - mon.stop(); +// mon.stop(); return refinements; } // create a new tree which is obtained by attaching the new tree at the given node in the tree via role r private ELDescriptionTree mergeTrees(ELDescriptionTree tree, ELDescriptionNode node, int[] position, ObjectProperty r, ELDescriptionTree newTree) { - Monitor mon = MonitorFactory.start("as.merge trees"); +// Monitor mon = MonitorFactory.start("as.merge trees"); // System.out.println("merge start"); // System.out.println(tree); // System.out.println(newTree); @@ -497,13 +497,13 @@ // mon2.stop(); - mon.stop(); +// mon.stop(); return mergedTree; } // TODO: variables have been renamed in article public boolean asCheck(ELDescriptionNode v) { - Monitor mon = MonitorFactory.start("as.complex check"); +// Monitor mon = MonitorFactory.start("as.complex check"); // System.out.println("asCheck: " + v.getTree().toSimulationString()); // find all edges up to the root node @@ -541,7 +541,7 @@ } } - mon.stop(); +// mon.stop(); return true; } Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-25 19:16:38 UTC (rev 1582) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/ELOperatorBenchmark.java 2009-01-26 11:55:26 UTC (rev 1583) @@ -86,43 +86,45 @@ "cton", // is ok at length 8 "earthrealm2", - // cannot even be read "fma_owl_dl_component_1.4.0", - // ontology file seems broken "iso_19115", - // ontology file seems broken "nci", // is ok at length 8 "process", - // takes too long to read in "pto", // is ok at length 8 "tambis", // ontology file seems broken "thesaurus", // is ok at length 8 - "transportation" + "transportation", + // takes too long to read in + "pto", + // ontology file seems broken "iso_19115", + // ontology file seems broken "nci", + // cannot even be read + "fma_owl_dl_component_1.4.0" }; for(String ont : onts) { String file = base + ont + ".owl"; rand = new Random(1); - testOntology(statDir, file, 100, 8); + testOntology(statDir, file, 100, 7); } // artificial ontology tests // - + /* // number of concepts and roles int[] conceptCounts = new int[] { 5, 10, 50, 100 }; //, 500, 1000 }; int[] roleCounts = new int[] { 5, 10, 50, 100, 500, 1000}; - base = "/home/jl/downloads/uni-leipzig/OTAGen-v1/generated/generated_"; + String base = "/home/jl/downloads/uni-leipzig/OTAGen-v1/generated/generated_"; // loop through all artificial ontologies for(int conceptCount : conceptCounts) { for(int roleCount : roleCounts) { String file = base + "c" + conceptCount + "_r" + roleCount + ".owl"; rand = new Random(1); - testOntology(statDir, file, 100, 9); + testOntology(statDir, file, 100, 7); } } System.exit(0); - + */ /* // number of applications of operator @@ -190,6 +192,7 @@ File statFile = new File(statDir + statFileName); String statString = ""; + int refinementMaxSizeOverall = 0; MonitorFactory.reset(); for(int loop = 0; loop < nrOfChains; loop++) { @@ -216,18 +219,32 @@ int sizeSum = 0; for(ELDescriptionTree tree : refinements) { // System.out.println(" " + tree.toDescriptionString()); - sizeSum += tree.getSize(); + int size = tree.getSize(); + sizeSum += size; + refinementMaxSizeOverall = Math.max(size, refinementMaxSizeOverall); } MonitorFactory.add("refinement size", "count", sizeSum/(double)refinements.size()); MonitorFactory.add("refinement size increase", "count", (sizeSum-refinements.size()*currTree.getSize())/(double)refinements.size()); System.out.println(" [has " + refinements.size() + " refinements]"); - // pick a refinement randomly (which is kind of slow for a set, but - // this does not matter here) + + // pick a refinement randomly - this has the disadvantage that we have huge + // variations over different runs int index = rand.nextInt(refinements.size()); -// currTree = new ArrayList<ELDescriptionTree>(refinements).get(index); currTree = refinements.get(index); + + // we pick a/the median of the refinements as next refinement +// ELDescriptionTreeComparator treeComp = new ELDescriptionTreeComparator(); +// TreeSet<ELDescriptionTree> refinementsSet = new TreeSet<ELDescriptionTree>(treeComp); +// refinementsSet.addAll(refinements); +// List<ELDescriptionTree> refinementList = new LinkedList<ELDescriptionTree>(refinements); + // sort by size (first criterion of comparator) +// Collections.sort(refinementList, treeComp); +// currTree = refinementList.get((int)(refinementList.size()*0.5)); +// System.out.println(rand.nextGaussian()); +// currTree = refinementList.get((int)(refinementList.size()*rand.nextGaussian())); + MonitorFactory.add("picked refinement size", "count", currTree.getSize()); } System.out.println("operator time: " + runtime.prettyPrint("ms")); @@ -246,23 +263,26 @@ statString += getMonitorDataCount(MonitorFactory.getMonitor("refinement count", "count")); statString += getMonitorDataCount(MonitorFactory.getMonitor("refinement size", "count")); + statString += "refinement max size overall: " + refinementMaxSizeOverall + "\n"; statString += getMonitorDataCount(MonitorFactory.getMonitor("picked refinement size", "count")); statString += getMonitorDataCount(MonitorFactory.getMonitor("refinement size increase", "count")); statString += "\n"; - statString += getMonitorData(MonitorFactory.getMonitor("extend label", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("refine label", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("refine edge", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("attach tree", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("as.merge trees", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("as.complex check", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("extend label", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("refine label", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("refine edge", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("attach tree", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("as.merge trees", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("as.complex check", "ms.")); // statString += getMonitorData(MonitorFactory.getMonitor("as.tmp", "ms.")); // statString += getMonitorData(MonitorFactory.getMonitor("el.tmp", "ms.")); - statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.minimal", "boolean")); - statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.check", "boolean")); - statString += getMonitorData(MonitorFactory.getMonitor("tree clone", "ms.")); - statString += getMonitorData(MonitorFactory.getMonitor("simulation update", "ms.")); +// statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.minimal", "boolean")); +// statString += getMonitorDataBoolean(MonitorFactory.getMonitor("as.check", "boolean")); +// statString += getMonitorData(MonitorFactory.getMonitor("tree clone", "ms.")); +// statString += getMonitorData(MonitorFactory.getMonitor("simulation update", "ms.")); statString += getMonitorData(MonitorFactory.getMonitor("disjointness reasoning", "ms.")); + double reasoningPercentage = 100 * MonitorFactory.getMonitor("disjointness reasoning", "ms.").getTotal()/MonitorFactory.getMonitor("operator application time", "ms.").getTotal(); + statString += "disjointness reasoning percentage: " + df.format(reasoningPercentage) + "%\n"; Files.createFile(statFile, statString); @@ -278,6 +298,7 @@ return mon.getLabel() + ": av " + df.format(mon.getAvg()) + " (stddev " + df.format(mon.getStdDev()) + ", min " + df.format(mon.getMin()) + ", max " + df.format(mon.getMax()) + ", " + df.format(mon.getTotal()) + " total, " + (int)mon.getHits() + " hits)\n"; } + @SuppressWarnings("unused") private static String getMonitorDataBoolean(Monitor mon) { return mon.getLabel() + ": " + df.format(mon.getAvg()*100) + "%\n"; } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-25 19:16:38 UTC (rev 1582) +++ trunk/src/dl-learner/org/dllearner/test/junit/ELDownTests.java 2009-01-26 11:55:26 UTC (rev 1583) @@ -66,6 +66,7 @@ */ public class ELDownTests { + @SuppressWarnings("unused") private static Logger logger = Logger.getLogger(ELDownTests.class); /** Modified: trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-01-25 19:16:38 UTC (rev 1582) +++ trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-01-26 11:55:26 UTC (rev 1583) @@ -36,7 +36,7 @@ */ public final class TestOntologies { - public enum TestOntology { EMPTY, SIMPLE, SIMPLE_NO_DR, SIMPLE_NO_DISJOINT, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES }; + public enum TestOntology { EMPTY, SIMPLE, SIMPLE_NO_DR, SIMPLE_NO_DISJOINT, SIMPLE_NO_DR_DISJOINT, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES }; public static ReasonerComponent getTestOntology(TestOntology ont) { String kbString = ""; @@ -70,6 +70,12 @@ kbString += "bird SUB animal.\n"; kbString += "cat SUB animal.\n"; kbString += "human SUB TOP.\n"; + } else if(ont.equals(TestOntology.SIMPLE_NO_DR_DISJOINT)) { + kbString += "Subrole(hasChild, has).\n"; + kbString += "Subrole(hasPet, has).\n"; + kbString += "bird SUB animal.\n"; + kbString += "cat SUB animal.\n"; + kbString += "human SUB TOP.\n"; } else if(ont.equals(TestOntology.SIMPLE2)) { kbString += "Subrole(r2,r3).\n"; kbString += "a1 SUB TOP.\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |