From: <jen...@us...> - 2009-02-26 15:29:35
|
Revision: 1634 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1634&view=rev Author: jenslehmann Date: 2009-02-26 15:29:25 +0000 (Thu, 26 Feb 2009) Log Message: ----------- computation of current min and max horizontal expansion in OE algorithm Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-02-25 16:52:45 UTC (rev 1633) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-02-26 15:29:25 UTC (rev 1634) @@ -80,6 +80,7 @@ // all nodes in the search tree (used for selecting most promising node) private TreeSet<OENode> nodes; + private OEHeuristicRuntime heuristic = new OEHeuristicRuntime(); // root of search tree private OENode startNode; // the class with which we start the refinement process @@ -107,6 +108,8 @@ // statistical variables private int descriptionTests = 0; + private int minHorizExp = 0; + private int maxHorizExp = 0; @Override public Configurator getConfigurator() { @@ -262,20 +265,16 @@ if(length > horizExp && refinement.getDepth() <= maxDepth) { Monitor mon2 = MonitorFactory.start("addNode"); - boolean added = addNode(refinement, nextNode); +// boolean added = + addNode(refinement, nextNode); mon2.stop(); - - // if refinements have the same length, we apply the operator again - // (descending the subsumption hierarchy) - if(added && length == horizExp) { - // ... refine node (first check whether we need this as there will - // the penalty for longer descriptions will be quite hard anyway) - } } } + updateMinMaxHorizExp(nextNode); + // Anzahl Schleifendurchläufe loop++; } @@ -481,7 +480,7 @@ private void reset() { // set all values back to their default values (used for running // the algorithm more than once) - nodes = new TreeSet<OENode>(new OEHeuristicRuntime()); + nodes = new TreeSet<OENode>(heuristic); descriptions = new TreeSet<Description>(new ConceptComparator()); bestEvaluatedDescriptions.getSet().clear(); descriptionTests = 0; @@ -521,4 +520,43 @@ } return str; } + + private void updateMinMaxHorizExp(OENode node) { + int newHorizExp = node.getHorizontalExpansion(); + + // update maximum value + maxHorizExp = Math.max(maxHorizExp, newHorizExp); + + // we just expanded a node with minimum horizontal expansion; + // we need to check whether it was the last one + if(minHorizExp == newHorizExp - 1) { + + // the best accuracy that a node can achieve + double scoreThreshold = heuristic.getNodeScore(node) + 1 - node.getAccuracy(); + + for(OENode n : nodes.descendingSet()) { + if(n != node) { + if(n.getHorizontalExpansion() == minHorizExp) { + // we can stop instantly when another node with min. + return; + } + if(heuristic.getNodeScore(n) < scoreThreshold) { + // we can stop traversing nodes when their score is too low + break; + } + } + } + + // inc. minimum since we found no other node which also has min. horiz. exp. + minHorizExp++; + } + } + + public int getMaximumHorizontalExpansion() { + return maxHorizExp; + } + + public int getMinimumHorizontalExpansion() { + return minHorizExp; + } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java 2009-02-25 16:52:45 UTC (rev 1633) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/OEHeuristicRuntime.java 2009-02-26 15:29:25 UTC (rev 1634) @@ -72,5 +72,9 @@ // penalty for having many child nodes (stuck prevention) score -= node.getRefinementCount() * nodeRefinementPenalty; return score; + } + + public double getExpansionPenaltyFactor() { + return expansionPenaltyFactor; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |