From: <tc...@us...> - 2012-05-17 03:10:07
|
Revision: 3715 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3715&view=rev Author: tcanvn Date: 2012-05-17 03:09:57 +0000 (Thu, 17 May 2012) Log Message: ----------- change the PADCEL algorithm's name (PADCEL --> ParCEL). Package name, examples, CLI and test units have been updated Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/refinementoperators/RhoDRDown2008.java trunk/interfaces/src/main/java/org/dllearner/cli/CLI.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELAbstract.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELComplenessComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELCompletenessComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELCorrectnessComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELCoverageGreedyReducer.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELCoveredNegativeExampleComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELDefaultHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELDefinitionGenerationTimeComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELDefinitionLengthComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELDefinitionLengthReducer.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELEvaluationResult.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELExtraNode.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELGenerationTimeReducer.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELImprovedCovegareGreedyReducer.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELNode.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELOntologyUtil.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELPosNegLP.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELReducer.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELRefinementOperatorFactory.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELRefinementOperatorPool.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELScore.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELStringUtilities.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELTaskComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELWorker.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELWorkerMat.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELWorkerThreadFactory.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELearnerMBean.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/ParCELearnerMat.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/split/ trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/split/ParCELDoubleSplitterAbstract.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/split/ParCELDoubleSplitterV1.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/split/ValueCount.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCEL/split/ValuesSet.java trunk/components-core/src/main/java/org/dllearner/algorithms/ParCELEx/ trunk/components-core/src/main/java/org/dllearner/algorithms/ParCELEx/ParCELExAbstract.java trunk/examples/carcinogenesis/carcinogenesis_parcel.conf trunk/examples/family-benchmark/Aunt_parcel.conf trunk/examples/family-benchmark/Brother_parcel.conf trunk/examples/family-benchmark/Cousin_parcel.conf trunk/examples/family-benchmark/Daughter_parcel.conf trunk/examples/family-benchmark/Father_parcel.conf trunk/examples/family-benchmark/Grandson_parcel.conf trunk/examples/family-benchmark/Uncle_parcel.conf trunk/examples/forte/uncle_owl_large_parcel.conf trunk/examples/moral_reasoner/moral_all_examples_simple_owl_parcel.conf trunk/examples/poker/straight_owl_parcel.conf trunk/examples/showering-duration/uca1_150_parcel.conf trunk/examples/showering-duration/uca2_300_parcel.conf trunk/interfaces/src/main/java/org/dllearner/cli/ParCELCrossValidation.java trunk/interfaces/src/test/java/org/dllearner/cli/ParCELCLITestAbstract.java trunk/interfaces/src/test/java/org/dllearner/cli/ParCELCarcinoGenesisTest.java trunk/interfaces/src/test/java/org/dllearner/cli/ParCELFamilyBenchmarkTest.java trunk/interfaces/src/test/java/org/dllearner/cli/ParCELMultiExamplesTest.java Removed Paths: ------------- trunk/components-core/src/main/java/nz/ac/massey/abd/ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELAbstract.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELComplenessComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCompletenessComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCorrectnessComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCoverageGreedyReducer.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCoveredNegativeExampleComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefaultHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefinitionGenerationTimeComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefinitionLengthComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefinitionLengthReducer.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELEvaluationResult.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELExtraNode.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELGenerationTimeReducer.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELHeuristic.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELImprovedCovegareGreedyReducer.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELNode.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELOntologyUtil.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELPosNegLP.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELReducer.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELRefinementOperatorFactory.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELRefinementOperatorPool.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELScore.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELStringUtilities.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELTaskComparator.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELWorker.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELWorkerThreadFactory.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELearner.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELearnerMBean.java trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/split/ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCELEx/ trunk/examples/carcinogenesis/carcinogenesis_padcel.conf trunk/examples/family-benchmark/Aunt_padcel.conf trunk/examples/family-benchmark/Brother_padcel.conf trunk/examples/family-benchmark/Cousin_padcel.conf trunk/examples/family-benchmark/Daughter_padcel.conf trunk/examples/family-benchmark/Father_padcel.conf trunk/examples/family-benchmark/Grandson_padcel.conf trunk/examples/family-benchmark/Uncle_padcel.conf trunk/examples/forte/uncle_owl_large_padcel.conf trunk/examples/moral_reasoner/moral_all_examples_simple_owl_padcel.conf trunk/examples/poker/straight_owl_padcel.conf trunk/examples/showering-duration/uca1_150_padcel.conf trunk/examples/showering-duration/uca2_300_padcel.conf trunk/interfaces/src/main/java/org/dllearner/cli/PADCELCrossValidation.java trunk/interfaces/src/test/java/org/dllearner/cli/PADCELCLITestAbstract.java trunk/interfaces/src/test/java/org/dllearner/cli/PADCELCarcinoGenesisTest.java trunk/interfaces/src/test/java/org/dllearner/cli/PADCELFamilyBenchmarkTest.java trunk/interfaces/src/test/java/org/dllearner/cli/PADCELMultiExamplesTest.java Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELAbstract.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELAbstract.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELAbstract.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,142 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.Set; -import java.util.SortedSet; -import java.util.concurrent.ConcurrentSkipListSet; - -import org.dllearner.core.AbstractCELA; -import org.dllearner.core.AbstractReasonerComponent; -import org.dllearner.core.config.ConfigOption; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.NamedClass; - -/** - * Abstract class for all PDL-Learner algorithms family - * - * @author An C. Tran - * - */ -public abstract class PADCELAbstract extends AbstractCELA { - - // ---------------------------------- - // configuration options - // ---------------------------------- - @ConfigOption(name = "numberOfWorkers", defaultValue = "2", description = "This option is used to set the number of workers will be created to serve the leaner. This should be = 2 * total number of cores of CPUs") - protected int numberOfWorkers = 4; // max number of workers will be created - - @ConfigOption(name = "maxExecutionTimeInSeconds", defaultValue = "0", description = "maximum execution of the algorithm in seconds") - protected int maxExecutionTimeInSeconds = 0; - - @ConfigOption(name = "noisePercentage", defaultValue = "0.0", description = "The percentage of noise within the examples") - protected double noisePercentage = 0.0; - - @ConfigOption(name = "maxNoOfSplits", defaultValue = "10", description = "Max number of splits will be applied for data properties with double range") - protected int maxNoOfSplits = 10; - - @ConfigOption(name = "ignoredConcepts", defaultValue = "", description = "set of concepts that will be ignored in learning the target concept") - protected Set<NamedClass> ignoredConcepts = null; - - - /** - * All generated descriptions thread-safe set is used to avoid concurrently - * accessing - */ - protected ConcurrentSkipListSet<Description> allDescriptions = null; - - /** - * Search tree. It hold all evaluated descriptions that are not correct and - * not weak ==> candidate for partial definitions Nodes in the search tree - * must be ordered using heuristic so that it can help the searching more - * efficiently (best search rather than 'blind' breadth first of depth - * first) NOTE: node = (description + accuracy/correctness/completeness/... - * value) - */ - protected ConcurrentSkipListSet<PADCELNode> searchTree = null; // thread safe - // set - - /** - * partial definitions (they should be sorted so that we can get the best - * partial definition at any time - */ - protected SortedSet<PADCELExtraNode> partialDefinitions = null; - - /** - * Default constructor - */ - public PADCELAbstract() { - super(); - } - - /** - * ======================================================================== - * Constructor for the learning algorithm - * - * @param learningProblem - * Must be a PDLLPosNegLP - * @param reasoningService - * A reasoner - */ - public PADCELAbstract(PADCELPosNegLP learningProblem, AbstractReasonerComponent reasoningService) { - super(learningProblem, reasoningService); - } - - public abstract Description getUnionCurrenlyBestDescription(); - - public abstract int getNoOfCompactedPartialDefinition(); - - public abstract Set<PADCELExtraNode> getPartialDefinitions(); - - public abstract double getCurrentlyOveralMaxCompleteness(); - - public long getNumberOfPartialDefinitions() { - return this.partialDefinitions.size(); - } - - - // ------------------------------------------------ - // setters and getters for configuration options - // ------------------------------------------------ - - public void setNumberOfWorkers(int numberOfWorkers) { - this.numberOfWorkers = numberOfWorkers; - } - - public int getNumberOfWorkers() { - return numberOfWorkers; - } - - public void setMaxExecutionTimeInSeconds(int maxExecutionTime) { - this.maxExecutionTimeInSeconds = maxExecutionTime; - } - - public int getMaxExecutionTimeInSeconds() { - return maxExecutionTimeInSeconds; - } - - public void setNoisePercentage(double noise) { - this.noisePercentage = noise; - } - - public double getNoisePercentage() { - return this.noisePercentage; - } - - - public int getMaxNoOfSplits() { - return maxNoOfSplits; - } - - public void setMaxNoOfSplits(int maxNoOfSplits) { - this.maxNoOfSplits = maxNoOfSplits; - } - - public Set<NamedClass> getIgnoredConcepts() { - return ignoredConcepts; - } - - public void setIgnoredConcepts(Set<NamedClass> ignoredConcepts) { - this.ignoredConcepts = ignoredConcepts; - } - - -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELComplenessComparator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELComplenessComparator.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELComplenessComparator.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,37 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.Comparator; - -import org.dllearner.utilities.owl.ConceptComparator; - -/** - * Comparator for PDLLNode based on the completeness of the description If two - * nodes has the same completeness, description length will be taken into the - * consideration and finally the ConceptComparator - * - * @author An C. Tran - * - */ - -public class PADCELComplenessComparator implements Comparator<PADCELNode> { - - @Override - public int compare(PADCELNode node1, PADCELNode node2) { - int v1 = node1.getCoveredPositiveExamples().size(); - int v2 = node2.getCoveredPositiveExamples().size(); - if (v1 > v2) - return -1; - else if (v1 < v2) - return 1; - else { - if (node1.getDescription().getLength() < node2.getDescription().getLength()) - return -1; - else if (node1.getDescription().getLength() > node2.getDescription().getLength()) - return 1; - else - return new ConceptComparator().compare(node1.getDescription(), - node2.getDescription()); - } - } - -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCompletenessComparator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCompletenessComparator.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCompletenessComparator.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,38 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.Comparator; - -import org.dllearner.utilities.owl.ConceptComparator; - -/** - * Use to compare 2 ExtraPLOENode nodes based on their completeness (coverage). The description - * length and ConceptComparator will be used it they have equal coverage - * - * @author An C. Tran - * - */ -public class PADCELCompletenessComparator implements Comparator<PADCELExtraNode> { - - @Override - public int compare(PADCELExtraNode node1, PADCELExtraNode node2) { - - int v1 = node1.getCoveredPositiveExamples().size(); - int v2 = node2.getCoveredPositiveExamples().size(); - - if (v1 > v2) - return -1; - else if (v1 < v2) - return 1; - else { - int len1 = node1.getDescription().getLength(); - int len2 = node2.getDescription().getLength(); - if (len1 < len2) - return -1; - else if (len1 > len2) - return 1; - else - return new ConceptComparator().compare(node1.getDescription(), - node2.getDescription()); - } - } -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCorrectnessComparator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCorrectnessComparator.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCorrectnessComparator.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,38 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.Comparator; - -import org.dllearner.utilities.owl.ConceptComparator; - -/** - * Use to compare 2 ExtraPLOENode nodes based on their correctness. The description length and - * ConceptComparator will be used it they have equal coverage - * - * @author An C. Tran - * - */ -public class PADCELCorrectnessComparator implements Comparator<PADCELExtraNode> { - - @Override - public int compare(PADCELExtraNode node1, PADCELExtraNode node2) { - double correctness1 = node1.getCorrectness(); - double correctness2 = node2.getCorrectness(); - - if (correctness1 > correctness2) - return -1; // smaller will be on the top - else if (correctness1 < correctness2) - return 1; - else { - int len1 = node1.getDescription().getLength(); - int len2 = node2.getDescription().getLength(); - - if (len1 < len2) - return -1; - else if (len1 > len2) - return 1; - else - return new ConceptComparator().compare(node1.getDescription(), - node2.getDescription()); - } - } -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCoverageGreedyReducer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCoverageGreedyReducer.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCoverageGreedyReducer.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,82 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.dllearner.core.owl.Individual; - -/** - * This class implements a simple strategy for compacting the partial definition set In this - * strategy, the partial definition will be chosen based on their accuracy. The partial definition - * with the best accuracy will be chosen first and the rests will not be re-calculated before the - * next reduction - * - * @author An C. Tran - * - */ -public class PADCELCoverageGreedyReducer implements PADCELReducer { - - /** - * Compact partial definitions - * - * @param partialDefinitions - * Set of partial definitions - * @param positiveExamples - * Set of positive examples (used to check whether partial definition is useful - * @param uncoveredPositiveExamples - * Number of uncovered positive examples allowed - * - * @return Subset of partial definitions that cover all positive examples - */ - @Override - public SortedSet<PADCELExtraNode> compact(SortedSet<PADCELExtraNode> partialDefinitions, - Set<Individual> positiveExamples) { - return compact(partialDefinitions, positiveExamples, 0); - } - - /** - * Compact partial definition with noise allowed - * - * @param partialDefinitions - * Set of partial definitions - * @param positiveExamples - * Set of positive examples (used to check whether partial definition is useful - * @param uncoveredPositiveExamples - * Number of uncovered positive examples allowed - * - * @return Subset of partial definitions that cover (positive examples \ uncovered positive - * examples) - */ - @Override - public SortedSet<PADCELExtraNode> compact(SortedSet<PADCELExtraNode> partialDefinitions, - Set<Individual> positiveExamples, int uncoveredPositiveExamples) { - - Set<Individual> positiveExamplesTmp = new HashSet<Individual>(); - positiveExamplesTmp.addAll(positiveExamples); - - TreeSet<PADCELExtraNode> minimisedPartialDefinition = new TreeSet<PADCELExtraNode>( - new PADCELCorrectnessComparator()); - - Iterator<PADCELExtraNode> partialDefinitionIterator = partialDefinitions.iterator(); - while ((positiveExamplesTmp.size() > uncoveredPositiveExamples) - && (partialDefinitionIterator.hasNext())) { - PADCELExtraNode node = partialDefinitionIterator.next(); - - int positiveExamplesRemoved = positiveExamplesTmp.size(); - positiveExamplesTmp.removeAll(node.getCoveredPositiveExamples()); - - positiveExamplesRemoved -= positiveExamplesTmp.size(); - - if (positiveExamplesRemoved > 0) { - node.setCorrectness(positiveExamplesRemoved); - minimisedPartialDefinition.add(node); - } - } - - return minimisedPartialDefinition; - } - -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCoveredNegativeExampleComparator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCoveredNegativeExampleComparator.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELCoveredNegativeExampleComparator.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,38 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.Comparator; - -import org.dllearner.utilities.owl.ConceptComparator; - -/** - * Use to compare 2 ExtraPLOENode nodes based on the number of covered negative examples. The - * description length and ConceptComparator will be used it they have equal coverage - * - * @author An C. Tran - * - */ -public class PADCELCoveredNegativeExampleComparator implements Comparator<PADCELExtraNode> { - - @Override - public int compare(PADCELExtraNode node1, PADCELExtraNode node2) { - int coveredNeg1 = node1.getCoveredNegativeExamples().size(); - int coveredNeg2 = node2.getCoveredPositiveExamples().size(); - - if (coveredNeg1 > coveredNeg2) - return -1; // smaller will be on the top - else if (coveredNeg1 < coveredNeg2) - return 1; - else { - int len1 = node1.getDescription().getLength(); - int len2 = node2.getDescription().getLength(); - - if (len1 < len2) - return -1; - else if (len1 > len2) - return 1; - else - return new ConceptComparator().compare(node1.getDescription(), - node2.getDescription()); - } - } -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefaultHeuristic.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefaultHeuristic.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefaultHeuristic.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,95 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import org.dllearner.utilities.owl.ConceptComparator; - -/** - * Implements the heuristic used to expand the search tree. Dimensions used: <br> - * + correctness: main value<br> - * + horizontal expansion: penalty<br> - * + accuracy gained from the parent node: bonus<br> - * + refinement nodes: penalty<br> - * + concept type + name (org.dllearner.utilities.owl.ConceptComparator) - * - * @author An C. Tran - * - */ -public class PADCELDefaultHeuristic implements PADCELHeuristic { - - // penalty for long descriptions - protected double expansionPenaltyFactor = 0.1; - - // bonus for gained accuracy - protected double gainBonusFactor = 0.2; - - // penalty if a node description has very many refinements since exploring - // such a node is computationally very expensive - protected double nodeRefinementPenalty = 0.0001; - - // award for node with high accuracy - protected double accuracyAwardFactor = 0.01; - - // syntactic comparison as final comparison criterion - protected ConceptComparator conceptComparator = new ConceptComparator(); - - /** - * Compare two node - * - * @param node1 - * Node to compare - * @param node2 - * Node to compare - * - * @return 1 if node1 "greater" than node2 and vice versa - */ - public int compare(PADCELNode node1, PADCELNode node2) { - double diff = getNodeScore(node1) - getNodeScore(node2); - - if (diff > 0) { // node1 has better score than node2 - return 1; - } else if (diff < 0) { - return -1; - } else { - int comp = conceptComparator.compare(node1.getDescription(), node2.getDescription()); - - // this allows duplicate descriptions exists in the set - if (comp != 0) - return comp; - else - return -1; - - } - } - - /** - * Calculate score for a node which is used as the searching heuristic - * - * @param node - * Node to be scored - * - * @return Score of the node - */ - protected double getNodeScore(PADCELNode node) { - - // the scoring mainly bases on correctness - double score = node.getCorrectness(); - - // bonus for the accuracy gained - if (!node.isRoot()) { - double parentAccuracy = ((PADCELNode) (node.getParent())).getAccuracy(); - score += (parentAccuracy - node.getAccuracy()) * gainBonusFactor; - } - - // award node with high accuracy - score += node.getAccuracy() * accuracyAwardFactor; - - // penalty for horizontal expansion - score -= node.getHorizontalExpansion() * expansionPenaltyFactor; - // score -= node.getDescription().getLength() * expansionPenaltyFactor; - - return score; - } - - public double getScore(PADCELNode node) { - return this.getNodeScore(node); - } -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefinitionGenerationTimeComparator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefinitionGenerationTimeComparator.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefinitionGenerationTimeComparator.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,37 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -/** - * Compare two node based on their generation time. - * This will be used in the Generation Time Greedy Compactness strategy - * GOLR - * - * @author An C. Tran - */ - -import java.util.Comparator; - -import org.dllearner.utilities.owl.ConceptComparator; - -public class PADCELDefinitionGenerationTimeComparator implements Comparator<PADCELExtraNode> { - - @Override - public int compare(PADCELExtraNode node1, PADCELExtraNode node2) { - double genTime1 = node1.getGenerationTime(); - double genTime2 = node2.getGenerationTime(); - - if (genTime1 < genTime2) - return -1; - else if (genTime1 > genTime2) - return 1; - else { - if (node1.getDescription().getLength() < node2.getDescription().getLength()) - return -1; - else if (node1.getDescription().getLength() > node2.getDescription().getLength()) - return 1; - else - return new ConceptComparator().compare(node1.getDescription(), - node2.getDescription()); - } - } - -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefinitionLengthComparator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefinitionLengthComparator.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefinitionLengthComparator.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,29 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.Comparator; - -import org.dllearner.utilities.owl.ConceptComparator; - -/** - * Compare two node based on their definition length. This will be used in the Definition Length - * Greedy Compactness strategy - * - * @author An C. Tran - * - */ - -public class PADCELDefinitionLengthComparator implements Comparator<PADCELExtraNode> { - - @Override - public int compare(PADCELExtraNode node1, PADCELExtraNode node2) { - int len1 = node1.getDescription().getLength(); - int len2 = node2.getDescription().getLength(); - if (len1 < len2) - return -1; - else if (len1 > len2) - return 1; - else - return new ConceptComparator().compare(node1.getDescription(), node2.getDescription()); - } - -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefinitionLengthReducer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefinitionLengthReducer.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELDefinitionLengthReducer.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,59 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.dllearner.core.owl.Individual; - -/** - * Compact set of partial definitions using Definition Length Grredy Reduction strategy - * - * @author An C. Tran - * - */ -public class PADCELDefinitionLengthReducer implements PADCELReducer { - - @Override - public SortedSet<PADCELExtraNode> compact(SortedSet<PADCELExtraNode> partialDefinitions, - Set<Individual> positiveExamples) { - return compact(partialDefinitions, positiveExamples, 0); - } - - @Override - public SortedSet<PADCELExtraNode> compact(SortedSet<PADCELExtraNode> partialDefinitions, - Set<Individual> positiveExamples, int uncoveredPositiveExamples) { - Set<Individual> positiveExamplesTmp = new HashSet<Individual>(); - positiveExamplesTmp.addAll(positiveExamples); - - TreeSet<PADCELExtraNode> newSortedPartialDefinitions = new TreeSet<PADCELExtraNode>( - new PADCELDefinitionLengthComparator()); - synchronized (partialDefinitions) { - newSortedPartialDefinitions.addAll(partialDefinitions); - } - - TreeSet<PADCELExtraNode> minimisedPartialDefinition = new TreeSet<PADCELExtraNode>( - new PADCELDefinitionGenerationTimeComparator()); - - Iterator<PADCELExtraNode> partialDefinitionIterator = newSortedPartialDefinitions.iterator(); - while ((positiveExamplesTmp.size() > uncoveredPositiveExamples) - && (partialDefinitionIterator.hasNext())) { - PADCELExtraNode node = partialDefinitionIterator.next(); - - int positiveExamplesRemoved = positiveExamplesTmp.size(); - positiveExamplesTmp.removeAll(node.getCoveredPositiveExamples()); - - positiveExamplesRemoved -= positiveExamplesTmp.size(); - - if (positiveExamplesRemoved > 0) { - node.setCorrectness(positiveExamplesRemoved); - minimisedPartialDefinition.add(node); - } - } - - return minimisedPartialDefinition; - } - -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELEvaluationResult.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELEvaluationResult.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELEvaluationResult.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,132 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.Set; - -import org.dllearner.core.owl.Individual; - -/** - * This class represents the result of an evaluation result return from the PDLL learning problem - * (PDLLPosNegLP) <br> - * Information included in a PDLL evaluation includes: - * <ol> - * <li>- accuracy: double</li> - * <li>- correctness: double</li> - * <li>- completeness: double</li> - * <li>- covered positive examples: Set<Individual></li> - * <li>- covered negative examples: Set<Individual></li> - * </ol> - * - * @author An C. Tran - * - */ -public class PADCELEvaluationResult { - - protected double accuracy = -1; - protected double correctness = -1; - protected double completeness = -1; - protected Set<Individual> coveredPossitiveExamples = null; - protected Set<Individual> coveredNegativeExamples = null; - - /** - * Default constructor, use default value for all properties - */ - public PADCELEvaluationResult() { - - } - - /** - * This use to create an evaluation result that is not for a correct definition. So, we don't - * need to hold the set of covered positive examples - * - * @param accuracy - * @param correctness - */ - public PADCELEvaluationResult(double accuracy, double correctness, double completeness) { - this.accuracy = accuracy; - this.correctness = correctness; - this.completeness = completeness; - } - - /** - * Used to create an evaluation result for a correct definition.<br> - * Covered positive examples have to be kept to be used in the result compactness later on.<br> - * This is usually used in case of partial definition - * - * @param accuracy - * @param correctness - * @param completeness - * @param coveredPossitiveExamples - */ - public PADCELEvaluationResult(double accuracy, double correctness, double completeness, - Set<Individual> coveredPossitiveExamples) { - this.accuracy = accuracy; - this.correctness = correctness; - this.completeness = completeness; - this.coveredPossitiveExamples = coveredPossitiveExamples; - } - - /** - * Used to create an evaluation result for a correct definition.<br> - * Both covered positive examples and covered negative examples will be kept to be used in the - * result compactness later on. - * - * @param accuracy - * @param correctness - * @param completeness - * @param coveredPositiveExamples - * @param coveredNegativeExamples - */ - public PADCELEvaluationResult(double accuracy, double correctness, double completeness, - Set<Individual> coveredPositiveExamples, Set<Individual> coveredNegativeExamples) { - - this.accuracy = accuracy; - this.correctness = correctness; - this.completeness = completeness; - this.coveredPossitiveExamples = coveredPositiveExamples; - this.coveredNegativeExamples = coveredNegativeExamples; - } - - // --------------------------------------- - // Getters and setters - // --------------------------------------- - public double getAccuracy() { - return accuracy; - } - - public void setAccuracy(double accuracy) { - this.accuracy = accuracy; - } - - public double getCorrectness() { - return correctness; - } - - public void setCorrectness(double correctness) { - this.correctness = correctness; - } - - public double getCompleteness() { - return completeness; - } - - public void setCompleteness(double completeness) { - this.completeness = completeness; - } - - public Set<Individual> getCoveredPossitiveExamples() { - return coveredPossitiveExamples; - } - - public void setCoveredPossitiveExamples(Set<Individual> coveredPossitiveExamples) { - this.coveredPossitiveExamples = coveredPossitiveExamples; - } - - public Set<Individual> getCoveredNegativeExamples() { - return coveredNegativeExamples; - } - - public void setCoveredNegativeExamples(Set<Individual> coveredNegativeExamples) { - this.coveredNegativeExamples = coveredNegativeExamples; - } - -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELExtraNode.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELExtraNode.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELExtraNode.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,132 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.HashSet; -import java.util.Set; - -import org.dllearner.algorithms.celoe.OENode; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.Individual; - -/** - * Generation time and node type is added into PADCELNode. This information is necessary for some - * reduction algorithms - * - * @author An C. Tran - * - */ -public class PADCELExtraNode extends PADCELNode { - - private double generationTime = Double.MIN_VALUE; // time in ms that the node was generated - private int type = -1; - - Set<OENode> compositeNodes = new HashSet<OENode>(); - - /** - * ============================================================================================ - * Constructor with correctness of the description - * - * @param parentNode - * Parent node of this node - * @param description - * Description of the node - * @param accuracy - * Accuracy of the node - * @param distance - * Distance between the node and the learning problem - * @param correctness - * Correctness of the node - */ - public PADCELExtraNode(OENode parentNode, Description description, double accuracy, - double correctness) { - super(parentNode, description, accuracy, correctness); - } - - public PADCELExtraNode(OENode parentNode, Description description, double accuracy) { - super(parentNode, description, accuracy); - } - - public PADCELExtraNode(PADCELNode node) { - super(node.getParent(), node.getDescription(), node.getAccuracy(), node.getCorrectness()); - setCoveredPositiveExamples(node.getCoveredPositiveExamples()); - setCoveredNegativeExamples(node.getCoveredNegativeExamples()); - } - - public PADCELExtraNode(PADCELNode node, Set<Individual> cp, double generationTime) { - super(node.getParent(), node.getDescription(), node.getAccuracy(), node.getCorrectness()); - super.coveredPositiveExamples = cp; - this.generationTime = generationTime; - } - - /** - * ============================================================================================ - * Constructor with the correctness and the generation time of the description - * - * @param parentNode - * Parent node of this node - * @param description - * Description of the node - * @param accuracy - * Accuracy of the node - * @param distance - * Distance between the node and the learning problem - * @param correctness - * Correctness of the node - * @param genTime - * Time in ms that the work used to generate this node - */ - public PADCELExtraNode(PADCELNode parentNode, Description description, double accuracy, - double correctness, double genTime) { - super(parentNode, description, accuracy, correctness); - this.coveredPositiveExamples = null; - this.generationTime = genTime; - } - - /** - * ============================================================================================ - * Constructor with the set of positive examples covered by the description of the node - * - * @param parentNode - * @param description - * @param accuracy - * @param distance - * @param correctness - * @param cn - * Covered positive examples - */ - public PADCELExtraNode(PADCELNode parentNode, Description description, double accuracy, - double correctness, Set<Individual> cp) { - super(parentNode, description, accuracy, correctness); - super.setCoveredPositiveExamples(cp); - } - - // ------------------------- - // getters and setters - // ------------------------- - public void setCoveredPositiveExamples(Set<Individual> cpn) { - super.setCoveredPositiveExamples(cpn); - } - - public double getGenerationTime() { - return generationTime; - } - - public void setGenerationTime(double d) { - this.generationTime = d; - } - - public void setType(int t) { - this.type = t; - } - - public int getType() { - return this.type; - } - - public void setCompositeList(Set<PADCELExtraNode> compositeNodes) { - this.compositeNodes.addAll(compositeNodes); - } - - public Set<OENode> getCompositeNodes() { - return this.compositeNodes; - } -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELGenerationTimeReducer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELGenerationTimeReducer.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELGenerationTimeReducer.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,62 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.dllearner.core.owl.Individual; - -/** - * Compact two a partial definitions set using Generation Time Greedy strategy - * - * @author An C. Tran - * - */ - -public class PADCELGenerationTimeReducer implements PADCELReducer { - - @Override - public SortedSet<PADCELExtraNode> compact(SortedSet<PADCELExtraNode> partialDefinitions, - Set<Individual> positiveExamples) { - return compact(partialDefinitions, positiveExamples, 0); - } - - @Override - public SortedSet<PADCELExtraNode> compact(SortedSet<PADCELExtraNode> partialDefinitions, - Set<Individual> positiveExamples, int uncoveredPositiveExamples) { - Set<Individual> positiveExamplesTmp = new HashSet<Individual>(); - positiveExamplesTmp.addAll(positiveExamples); - - TreeSet<PADCELExtraNode> newSortedPartialDefinitions = new TreeSet<PADCELExtraNode>( - new PADCELDefinitionGenerationTimeComparator()); - - synchronized (partialDefinitions) { - newSortedPartialDefinitions.addAll(partialDefinitions); - } - - TreeSet<PADCELExtraNode> minimisedPartialDefinition = new TreeSet<PADCELExtraNode>( - new PADCELDefinitionGenerationTimeComparator()); - - Iterator<PADCELExtraNode> partialDefinitionIterator = newSortedPartialDefinitions.iterator(); - - while ((positiveExamplesTmp.size() > uncoveredPositiveExamples) - && (partialDefinitionIterator.hasNext())) { - PADCELExtraNode node = partialDefinitionIterator.next(); - - int positiveExamplesRemoved = positiveExamplesTmp.size(); - positiveExamplesTmp.removeAll(node.getCoveredPositiveExamples()); - - positiveExamplesRemoved -= positiveExamplesTmp.size(); - - if (positiveExamplesRemoved > 0) { - node.setCorrectness(positiveExamplesRemoved); - minimisedPartialDefinition.add(node); - } - } - - return minimisedPartialDefinition; - } - -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELHeuristic.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELHeuristic.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELHeuristic.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,16 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.Comparator; - -/** - * Interface for heuristics used in PADCEL - * - * @author An C. Tran - * - */ -public interface PADCELHeuristic extends Comparator<PADCELNode> { - - public int compare(PADCELNode node1, PADCELNode node2); - - public double getScore(PADCELNode node); -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELImprovedCovegareGreedyReducer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELImprovedCovegareGreedyReducer.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELImprovedCovegareGreedyReducer.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,115 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.util.HashSet; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.apache.log4j.Logger; -import org.dllearner.core.owl.Individual; - -/** - * This class implements "wise" coverage greedy strategy for compacting the partial definitions In - * this strategy, the partial definitions will be chosen based on their coverage. When a partial - * definition has been chosen, coverage of other partial definition will be recalculated - * - * @author An C. Tran - * - */ - -public class PADCELImprovedCovegareGreedyReducer implements PADCELReducer { - - Logger logger = Logger.getLogger(this.getClass()); - - /** - * Compact partial definition with noise allowed - * - * @param partialDefinitions - * Set of partial definitions - * @param positiveExamples - * Set of positive examples (used to check whether partial definition is useful - * @param uncoveredPositiveExamples - * Number of uncovered positive examples allowed - * - * @return Subset of partial definitions that cover all positive examples - */ - @Override - public SortedSet<PADCELExtraNode> compact(SortedSet<PADCELExtraNode> partialDefinitions, - Set<Individual> positiveExamples) { - return this.compact(partialDefinitions, positiveExamples, 0); - } - - /** - * Compact partial definition with noise allowed - * - * @param partialDefinitions - * Set of partial definitions - * @param positiveExamples - * Set of positive examples (used to check whether partial definition is useful - * @param uncoveredPositiveExamples - * Number of uncovered positive examples allowed - * - * @return Subset of partial definitions that cover (positive examples \ uncovered positive - * examples) - */ - @Override - public SortedSet<PADCELExtraNode> compact(SortedSet<PADCELExtraNode> partialDefinitions, - Set<Individual> positiveExamples, int uncoveredPositiveExamples) { - Set<Individual> positiveExamplesTmp = new HashSet<Individual>(); - positiveExamplesTmp.addAll(positiveExamples); - - TreeSet<PADCELExtraNode> reducedPartialDefinition = new TreeSet<PADCELExtraNode>( - new PADCELCompletenessComparator()); - - if (partialDefinitions.size() == 0) - return reducedPartialDefinition; - - synchronized (partialDefinitions) { - Object[] partialDefs = partialDefinitions.toArray(); - - // the highest accurate partial definition - // reducedPartialDefinition.add((PDLLExtraNode)partialDefs[0]); - // positiveExamplesTmp.removeAll(((PDLLExtraNode)partialDefs[0]).getCoveredPositiveExamples()); - - for (int i = 0; (positiveExamplesTmp.size() > uncoveredPositiveExamples) - && (i < partialDefinitions.size()); i++) { - - // count the number of different positive examples covered - int counti = 0; - for (Individual indi : ((PADCELExtraNode) partialDefs[i]) - .getCoveredPositiveExamples()) { - if (positiveExamplesTmp.contains(indi)) - counti++; - } // count the number of different covered positive examples by - // i - - for (int j = i + 1; j < partialDefinitions.size(); j++) { - int countj = 0; - - for (Individual indj : ((PADCELExtraNode) partialDefs[j]) - .getCoveredPositiveExamples()) - if (positiveExamplesTmp.contains(indj)) - countj++; - - // TODO: revise this code: Swapping should be done only one - // time at the end - // swap the partial definition so that the "best" partial - // definition will be in the top - if (countj > counti) { - PADCELExtraNode tmp = (PADCELExtraNode) partialDefs[j]; - partialDefs[j] = partialDefs[i]; - partialDefs[i] = tmp; - counti = countj; - } - } - - reducedPartialDefinition.add((PADCELExtraNode) partialDefs[i]); - positiveExamplesTmp.removeAll(((PADCELExtraNode) partialDefs[i]) - .getCoveredPositiveExamples()); - } - } - - return reducedPartialDefinition; - } - -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELNode.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELNode.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELNode.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,113 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.text.DecimalFormat; -import java.util.HashSet; -import java.util.Set; - -import org.dllearner.algorithms.celoe.OENode; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.Individual; - -/** - * Represents a node in the search tree used in the PDLLeanring<br> - * A node includes description and its corresponding properties such as: correctness, accuracy, - * distance between the description the leaning problem, parent node of the description. It also - * contains a flag which indicates the node is processed or not. - * - * @author An C. Tran - * - */ -public class PADCELNode extends OENode { - - private double correctness = -1.0; - private double completeness = -1.0; - - protected Set<Individual> coveredPositiveExamples = new HashSet<Individual>(); - protected Set<Individual> coveredNegativeExamples = new HashSet<Individual>(); - - private DecimalFormat dfPercent = new DecimalFormat("0.00%"); - - public PADCELNode(OENode parentNode, Description description, double accuracy) { - super(parentNode, description, accuracy); - } - - public PADCELNode(OENode parentNode, Description description, double accuracy, double correctness) { - super(parentNode, description, accuracy); - this.correctness = correctness; - } - - public PADCELNode(OENode parentNode, Description description, double accuracy, - double correctness, double completeness) { - super(parentNode, description, accuracy); - this.correctness = correctness; - this.completeness = completeness; - } - - public PADCELNode(OENode parentNode, Description description) { - super(parentNode, description, 0); - } - - public PADCELNode(OENode parentNode, Description description, - Set<Individual> coveredPositiveExamples, Set<Individual> coveredNegativeExamples) { - super(parentNode, description, 0); - this.coveredPositiveExamples.addAll(coveredPositiveExamples); - this.coveredNegativeExamples.addAll(coveredNegativeExamples); - } - - public void setCorrectness(double cor) { - this.correctness = cor; - } - - public double getCorrectness() { - return this.correctness; - } - - public void setCompleteness(double comp) { - this.completeness = comp; - } - - public double getCompleteness() { - return this.completeness; - } - - public void setAccuracy(double acc) { - this.accuracy = acc; - } - - public Set<Individual> getCoveredPositiveExamples() { - return this.coveredPositiveExamples; - } - - public Set<Individual> getCoveredNegativeExamples() { - return this.coveredNegativeExamples; - } - - public void setCoveredPositiveExamples(Set<Individual> coveredPositiveExamples) { - if (coveredPositiveExamples != null) - this.coveredPositiveExamples.addAll(coveredPositiveExamples); - else - this.coveredPositiveExamples.clear(); - } - - public void setCoveredNegativeExamples(Set<Individual> coveredNegativeExamples) { - if (coveredNegativeExamples != null) - this.coveredNegativeExamples.addAll(coveredNegativeExamples); - else - this.coveredNegativeExamples.clear(); - } - - @Override - public String toString() { - String ret = this.getDescription().toString(null, null) + " ["; - ret += "acc:" + dfPercent.format(this.getAccuracy()) + ", "; - ret += "cor:" + dfPercent.format(this.getCorrectness()) + ", "; - ret += "comp:" + dfPercent.format(this.completeness) + "]"; - return ret; - - } - - public void setDescription(Description newDescription) { - this.description = newDescription; - } - -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELOntologyUtil.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELOntologyUtil.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELOntologyUtil.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,87 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import org.semanticweb.owlapi.apibinding.OWLManager; -import org.semanticweb.owlapi.model.IRI; -import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.model.OWLOntologyCreationException; -import org.semanticweb.owlapi.model.OWLOntologyManager; -import org.semanticweb.owlapi.model.OWLOntologyStorageException; - -/** - * Some utility functions for ontology manipulation - * - * @author An C. Tran - * - */ - -public class PADCELOntologyUtil { - - /** - * ========================================================================================== - * Get ontology given its file path - * - * @param ontologyFilePath - * - * @return Opened ontology - * @throws OWLOntologyCreationException - */ - public static OWLOntology loadOntology(String ontologyFilePath) - throws OWLOntologyCreationException { - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - OWLOntology ontology; - - String flash = (System.getProperty("os.name").contains("Windows")) ? "/" : ""; - - File f = new File(ontologyFilePath); - - if (!ontologyFilePath.contains("file:")) - ontologyFilePath = "file:" + flash + f.getAbsolutePath(); - - ontologyFilePath = ontologyFilePath.replace('\\', '/'); - - ontology = manager.loadOntology(IRI.create(ontologyFilePath)); - - return ontology; - } - - /** - * ============================================================================================ - * Persist the ontology - * - * @param ontology - * Ontology which need to be persisted - * - * @throws OWLOntologyStorageException - */ - public static void persistOntology(OWLOntology ontology) throws OWLOntologyStorageException { - OWLOntologyManager manager = ontology.getOWLOntologyManager(); - manager.saveOntology(ontology); - } - - /** - * ============================================================================================ - * Persist ontology to another ontology - * - * @param ontology - * Ontology contains changes - * @param newFilePath - * Path to the new ontology file - * - * @throws OWLOntologyStorageException - * @throws IOException - */ - public static void persistOntology(OWLOntology ontology, String newFilePath) - throws OWLOntologyStorageException, IOException { - OWLOntologyManager manager = ontology.getOWLOntologyManager(); - - File f = new File(newFilePath); - FileOutputStream fo = new FileOutputStream(f); - - manager.saveOntology(ontology, fo); - fo.close(); - } - -} Deleted: trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELPosNegLP.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELPosNegLP.java 2012-05-15 07:20:52 UTC (rev 3714) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/PADCEL/PADCELPosNegLP.java 2012-05-17 03:09:57 UTC (rev 3715) @@ -1,493 +0,0 @@ -package org.dllearner.algorithms.PADCEL; - -/** - * PDLL Learning problem: provides correctness, completeness, and accuracy calculation. - * Predictive accuracy calculation is used. - * - * @author An C. Tran - */ - -import java.util.Set; - -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedList; - -import org.apache.log4j.Logger; -import org.dllearner.core.AbstractLearningProblem; -import org.dllearner.core.ComponentAnn; -import org.dllearner.core.ComponentInitException; -import org.dllearner.core.AbstractReasonerComponent; -import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.options.ConfigOption; -import org.dllearner.core.options.StringSetConfigOption; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.Individual; - -@ComponentAnn(name = "PDLLPosNegLP", shortName = "pdllPosNegLP", version = 0.1, description = "PDLL positive negative learning problem") -public class PADCELPosNegLP extends AbstractLearningProblem { - - protected Set<Individual> positiveExamples; - protected Set<Individual> negativeExamples; - - protected Set<Individual> uncoveredPositiveExamples; - - private Logger logger = Logger.getLogger(this.getClass()); - - // reasoner component is declared in AbstractLearningProblem class - - /** - * Constructor, used in case that positive and negative examples are provided when this - * component is initialized - * - * @param reasoningService - * Reasoner, provides reasoning service. Used to checking the instance type - * @param positiveExamples - * Positive examples - * @param negativeExamples - * Negative examples - */ - public PADCELPosNegLP(AbstractReasonerComponent reasoningService, - Set<Individual> positiveExamples, Set<Individual> negativeExamples) { - super(reasoningService); - this.positiveExamples = positiveExamples; - this.negativeExamples = negativeExamples; - this.uncoveredPositiveExamples = this.positiveExamples; - } - - /** - * This constructor is used when the learning configuration file is used - * - * @param reasoningService - */ - public PADCELPosNegLP(AbstractReasonerComponent reasoningService) { - super(reasoningService); - } - - /** - * This constructor can be used by SpringDefinition to create bean object Properties of new bean - * may be initialised later using setters - */ - public PADCELPosNegLP() { - super(); - - if (logger.isDebugEnabled()) - logger.debug("Learning problem created: " + this); - } - - /** - * Get list of positive examples covered by a description - * - * @param description - * Description - * - * @return Set of positive examples covered by the description - */ - protected Set<Individual> coveredPositiveExamples(Description description) { - Set<Individual> coveredPositiveExamples = new HashSet<Individual>(); - - for (Individual example : positiveExamples) - if (reasoner.hasType(description, example)) - coveredPositiveExamples.add(example); - - return coveredPositiveExamples; - } - - /** - * Get number of positive examples covered by a description - * - * @param description - * Description - * @return Number if positive examples covered by the description - */ - protected int getNumberCoveredPositiveExamples(Description description) { - int coveredPos = 0; - - for (Individual example : positiveExamples) - if (reasoner.hasType(description, example)) - coveredPos++; - - return coveredPos; - } - - /** - * Get number of negative examples covered by a description - * - * @param description - * Description to test - * - * @return Number of negative examples covered by the description - */ - protected int getNumberOfCoveredNegativeExamples(Description description) { - int coveredNeg = 0; - for (Individual example : negativeExamples) { - if (reasoner.hasType(description, example)) { - coveredNeg++; - } - } - - return coveredNeg; - } - - /** - * Calculate predictive accuracy of a description pred-accuracy(D) = - * (covered-positive-examples(D) + uncovered-negative-examples(D)) / all-examples - * -... [truncated message content] |