From: <jen...@us...> - 2008-09-12 12:35:13
|
Revision: 1200 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1200&view=rev Author: jenslehmann Date: 2008-09-12 12:35:09 +0000 (Fri, 12 Sep 2008) Log Message: ----------- added change methods to components such that underlying components can be replaced Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java trunk/src/dl-learner/org/dllearner/core/LearningProblem.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/InitWorker.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -83,6 +83,7 @@ private Map<Integer,List<Description>> generatedDefinitions = new HashMap<Integer,List<Description>>(); public BruteForceLearner(LearningProblem learningProblem, ReasoningService rs) { + super(learningProblem, rs); this.learningProblem = learningProblem; this.rs = rs; this.configurator = new BruteForceLearnerConfigurator(this); Modified: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -67,6 +67,7 @@ private static String defaultSearchTreeFile = "log/searchTree.txt"; public DBpediaNavigationSuggestor(LearningProblem learningProblem, ReasoningService rs) { + super(learningProblem, rs); // this.rs=rs; this.configurator = new DBpediaNavigationSuggestorConfigurator(this); try{ @@ -96,10 +97,12 @@ } public DBpediaNavigationSuggestor(PosOnlyDefinitionLP learningProblem, ReasoningService rs) { + super(learningProblem, rs); System.out.println("test1"); } public DBpediaNavigationSuggestor(PosNegDefinitionLP learningProblem, ReasoningService rs) { + super(learningProblem, rs); System.out.println("test2"); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -56,6 +56,7 @@ private static Logger logger = Logger.getLogger(RandomGuesser.class); public RandomGuesser(LearningProblem learningProblem, ReasoningService rs) { + super(learningProblem, rs); this.learningProblem = learningProblem; this.rs = rs; this.configurator = new RandomGuesserConfigurator(this); Modified: trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -56,7 +56,7 @@ private Set<Description> simpleSuggestions; public SimpleSuggestionLearningAlgorithm() { - // this.learningProblem = learningProblem; + super(null, null); this.configurator = new SimpleSuggestionLearningAlgorithmConfigurator(this); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -131,12 +131,9 @@ private Score bestScore; private Description bestConcept; - private PosNegLP learningProblem; - // private GeneticRefinementOperator psi; private Psi psi; - private ReasoningService rs; /** * Creates an algorithm object. By default a steady state algorithm with @@ -146,8 +143,7 @@ * */ public GP(PosNegLP learningProblem, ReasoningService rs) { - this.learningProblem = learningProblem; - this.rs = rs; + super(learningProblem, rs); this.configurator = new GPConfigurator(this); } @@ -276,14 +272,14 @@ */ @Override public void init() { - rs.prepareSubsumptionHierarchy(); - rs.prepareRoleHierarchy(); + reasoningService.prepareSubsumptionHierarchy(); + reasoningService.prepareRoleHierarchy(); } @Override public void start() { // falls refinement-Wahrscheinlichkeit größer 0, dann erzeuge psi - psi = new Psi(learningProblem, rs); + psi = new Psi((PosNegLP)learningProblem, reasoningService); System.out.println(); System.out.println("Starting Genetic Programming Learner"); @@ -446,11 +442,11 @@ i++; // mutation } else if(rand >= crossoverBoundary && rand < mutationBoundary) { - newIndividuals[i] = GPUtilities.mutation(learningProblem, rs, individuals[selectedIndividuals[i]]); + newIndividuals[i] = GPUtilities.mutation(learningProblem, reasoningService, individuals[selectedIndividuals[i]]); // hill climbing } else if(rand >= mutationBoundary && rand < hillClimbingBoundary) { // System.out.println("hill climbing"); - newIndividuals[i] = GPUtilities.hillClimbing(learningProblem, rs, individuals[selectedIndividuals[i]]); + newIndividuals[i] = GPUtilities.hillClimbing(learningProblem, reasoningService, individuals[selectedIndividuals[i]]); // refinement operator } else if(rand >= hillClimbingBoundary && rand < refinementBoundary) { newIndividuals[i] = psi.applyOperator(individuals[selectedIndividuals[i]]); @@ -624,9 +620,9 @@ // int depth = rand.nextInt(initMaxDepth-initMinDepth)+initMinDepth; if(grow) - individuals[i] = GPUtilities.createGrowRandomProgram(learningProblem, rs, depth, adc); + individuals[i] = GPUtilities.createGrowRandomProgram(learningProblem, reasoningService, depth, adc); else - individuals[i] = GPUtilities.createFullRandomProgram(learningProblem, rs, depth, adc); + individuals[i] = GPUtilities.createFullRandomProgram(learningProblem, reasoningService, depth, adc); } /* Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -92,11 +92,7 @@ private ExampleBasedROLearner algorithm; private static Logger logger = Logger .getLogger(ExampleBasedROLearner.class); - private String logLevel = CommonConfigOptions.logLevelDefault; - - // learning problem to solve and background knowledge - private ReasoningService rs; - private LearningProblem learningProblem; + private String logLevel = CommonConfigOptions.logLevelDefault; // configuration options private boolean writeSearchTree; @@ -150,15 +146,13 @@ // soll später einen Operator und eine Heuristik entgegennehmen // public ROLearner(LearningProblem learningProblem, LearningProblem learningProblem2) { - public ExampleBasedROLComponent(PosNegLP learningProblem, ReasoningService rs) { - this.learningProblem = learningProblem; - this.rs = rs; + public ExampleBasedROLComponent(PosNegLP learningProblem, ReasoningService reasoningService) { + super(learningProblem, reasoningService); this.configurator = new ExampleBasedROLComponentConfigurator(this); } - public ExampleBasedROLComponent(PosOnlyDefinitionLP learningProblem, ReasoningService rs) { - this.learningProblem = learningProblem; - this.rs = rs; + public ExampleBasedROLComponent(PosOnlyDefinitionLP learningProblem, ReasoningService reasoningService) { + super(learningProblem, reasoningService); this.configurator = new ExampleBasedROLComponentConfigurator(this); } @@ -290,7 +284,7 @@ public void init() throws ComponentInitException { // exit with a ComponentInitException if the reasoner is unsupported for this learning algorithm - if(rs.getReasonerType() == ReasonerType.DIG) { + if(reasoningService.getReasonerType() == ReasonerType.DIG) { throw new ComponentInitException("DIG does not support the inferences needed in the selected learning algorithm component: " + getName()); } @@ -327,38 +321,38 @@ // concepts/roles if(allowedConcepts != null) { // sanity check to control if no non-existing concepts are in the list - Helper.checkConcepts(rs, allowedConcepts); + Helper.checkConcepts(reasoningService, allowedConcepts); usedConcepts = allowedConcepts; } else if(ignoredConcepts != null) { - usedConcepts = Helper.computeConceptsUsingIgnoreList(rs, ignoredConcepts); + usedConcepts = Helper.computeConceptsUsingIgnoreList(reasoningService, ignoredConcepts); } else { - usedConcepts = Helper.computeConcepts(rs); + usedConcepts = Helper.computeConcepts(reasoningService); } if(allowedRoles != null) { - Helper.checkRoles(rs, allowedRoles); + Helper.checkRoles(reasoningService, allowedRoles); usedRoles = allowedRoles; } else if(ignoredRoles != null) { - Helper.checkRoles(rs, ignoredRoles); - usedRoles = Helper.difference(rs.getObjectProperties(), ignoredRoles); + Helper.checkRoles(reasoningService, ignoredRoles); + usedRoles = Helper.difference(reasoningService.getObjectProperties(), ignoredRoles); } else { - usedRoles = rs.getObjectProperties(); + usedRoles = reasoningService.getObjectProperties(); } // prepare subsumption and role hierarchies, because they are needed // during the run of the algorithm - rs.prepareSubsumptionHierarchy(usedConcepts); + reasoningService.prepareSubsumptionHierarchy(usedConcepts); if(improveSubsumptionHierarchy) - rs.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - rs.prepareRoleHierarchy(usedRoles); + reasoningService.getSubsumptionHierarchy().improveSubsumptionHierarchy(); + reasoningService.prepareRoleHierarchy(usedRoles); // prepare datatype hierarchy only if necessary - if(rs.hasDatatypeSupport()) - rs.prepareDatatypePropertyHierarchy(); + if(reasoningService.hasDatatypeSupport()) + reasoningService.prepareDatatypePropertyHierarchy(); // create a refinement operator and pass all configuration // variables to it RhoDRDown operator = new RhoDRDown( - rs, + reasoningService, applyAllFilter, applyExistsFilter, useAllConstructor, @@ -374,7 +368,7 @@ // options to it algorithm = new ExampleBasedROLearner( learningProblem, - rs, + reasoningService, operator, algHeuristic, startClass, Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -103,8 +103,6 @@ private boolean stop = false; private boolean isRunning = false; - private ReasoningService rs; - private Comparator<Node> nodeComparator; private NodeComparatorStable nodeComparatorStable = new NodeComparatorStable(); private ConceptComparator conceptComparator = new ConceptComparator(); @@ -198,21 +196,21 @@ // soll später einen Operator und eine Heuristik entgegennehmen // public ROLearner(LearningProblem learningProblem, LearningProblem learningProblem2) { - public ROLearner(PosNegLP learningProblem, ReasoningService rs) { + public ROLearner(PosNegLP learningProblem, ReasoningService reasoningService) { + super(learningProblem, reasoningService); this.learningProblem = learningProblem; - this.rs = rs; this.configurator = new ROLearnerConfigurator(this); posOnly=false; - baseURI = rs.getBaseURI(); + baseURI = reasoningService.getBaseURI(); } - public ROLearner(PosOnlyDefinitionLP learningProblem, ReasoningService rs) { + public ROLearner(PosOnlyDefinitionLP learningProblem, ReasoningService reasoningService) { + super(learningProblem, reasoningService); this.posOnlyLearningProblem = learningProblem; - this.rs = rs; this.configurator = new ROLearnerConfigurator(this); posOnly=true; - baseURI = rs.getBaseURI(); + baseURI = reasoningService.getBaseURI(); } public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { @@ -348,7 +346,7 @@ } // this.learningProblem2 = learningProblem2; - operator = new RhoDown(rs, applyAllFilter, applyExistsFilter, useAllConstructor, useExistsConstructor, useNegation, useBooleanDatatypes); + operator = new RhoDown(reasoningService, applyAllFilter, applyExistsFilter, useAllConstructor, useExistsConstructor, useNegation, useBooleanDatatypes); // candidate sets entsprechend der gewählten Heuristik initialisieren candidates = new TreeSet<Node>(nodeComparator); @@ -356,30 +354,30 @@ if(allowedConcepts != null) { // sanity check to control if no non-existing concepts are in the list - Helper.checkConcepts(rs, allowedConcepts); + Helper.checkConcepts(reasoningService, allowedConcepts); usedConcepts = allowedConcepts; } else if(ignoredConcepts != null) { - usedConcepts = Helper.computeConceptsUsingIgnoreList(rs, ignoredConcepts); + usedConcepts = Helper.computeConceptsUsingIgnoreList(reasoningService, ignoredConcepts); } else { - usedConcepts = Helper.computeConcepts(rs); + usedConcepts = Helper.computeConcepts(reasoningService); } if(allowedRoles != null) { - Helper.checkRoles(rs, allowedRoles); + Helper.checkRoles(reasoningService, allowedRoles); usedRoles = allowedRoles; } else if(ignoredRoles != null) { - Helper.checkRoles(rs, ignoredRoles); - usedRoles = Helper.difference(rs.getObjectProperties(), ignoredRoles); + Helper.checkRoles(reasoningService, ignoredRoles); + usedRoles = Helper.difference(reasoningService.getObjectProperties(), ignoredRoles); } else { - usedRoles = rs.getObjectProperties(); + usedRoles = reasoningService.getObjectProperties(); } // prepare subsumption and role hierarchies, because they are needed // during the run of the algorithm - rs.prepareSubsumptionHierarchy(usedConcepts); + reasoningService.prepareSubsumptionHierarchy(usedConcepts); if(improveSubsumptionHierarchy) - rs.getSubsumptionHierarchy().improveSubsumptionHierarchy(); - rs.prepareRoleHierarchy(usedRoles); + reasoningService.getSubsumptionHierarchy().improveSubsumptionHierarchy(); + reasoningService.prepareRoleHierarchy(usedRoles); } public static String getName() { @@ -763,7 +761,7 @@ if(toEvaluateConcepts.size()>0) { // Test aller Konzepte auf properness (mit DIG in nur einer Anfrage) long propCalcReasoningStart = System.nanoTime(); - improperConcepts = rs.subsumes(toEvaluateConcepts, concept); + improperConcepts = reasoningService.subsumes(toEvaluateConcepts, concept); propernessTestsReasoner+=toEvaluateConcepts.size(); // boolean isProper = !learningProblem.getReasoningService().subsumes(refinement, concept); propernessCalcReasoningTimeNs += System.nanoTime() - propCalcReasoningStart; @@ -988,19 +986,19 @@ // System.out.println("properness max recursion depth: " + maxRecDepth); // System.out.println("max. number of one-step refinements: " + maxNrOfRefinements); // System.out.println("max. number of children of a node: " + maxNrOfChildren); - logger.debug("subsumption time: " + Helper.prettyPrintNanoSeconds(rs.getSubsumptionReasoningTimeNs())); - logger.debug("instance check time: " + Helper.prettyPrintNanoSeconds(rs.getInstanceCheckReasoningTimeNs())); + logger.debug("subsumption time: " + Helper.prettyPrintNanoSeconds(reasoningService.getSubsumptionReasoningTimeNs())); + logger.debug("instance check time: " + Helper.prettyPrintNanoSeconds(reasoningService.getInstanceCheckReasoningTimeNs())); } if(showBenchmarkInformation) { - long reasoningTime = rs.getOverallReasoningTimeNs(); + long reasoningTime = reasoningService.getOverallReasoningTimeNs(); double reasoningPercentage = 100 * reasoningTime/(double)algorithmRuntime; long propWithoutReasoning = propernessCalcTimeNs-propernessCalcReasoningTimeNs; double propPercentage = 100 * propWithoutReasoning/(double)algorithmRuntime; double deletionPercentage = 100 * childConceptsDeletionTimeNs/(double)algorithmRuntime; - long subTime = rs.getSubsumptionReasoningTimeNs(); + long subTime = reasoningService.getSubsumptionReasoningTimeNs(); double subPercentage = 100 * subTime/(double)algorithmRuntime; double refinementPercentage = 100 * refinementCalcTimeNs/(double)algorithmRuntime; double redundancyCheckPercentage = 100 * redundancyCheckTimeNs/(double)algorithmRuntime; Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -45,6 +45,56 @@ public abstract class LearningAlgorithm extends Component { /** + * The learning problem variable, which must be used by + * all learning algorithm implementations. + */ + protected LearningProblem learningProblem; + + /** + * The reasoning service variable, which must be used by + * all learning algorithm implementations. + */ + protected ReasoningService reasoningService; + + /** + * Each learning algorithm gets a learning problem and + * a reasoner as input. + * @param learningProblem The learning problem to solve. + * @param reasoningService The reasoner connecting to the + * underlying knowledge base. + */ + public LearningAlgorithm(LearningProblem learningProblem, ReasoningService reasoningService) { + this.learningProblem = learningProblem; + this.reasoningService = reasoningService; + } + + /** + * Call this when you want to change the learning problem, but + * leave everything else as is. Method can be used to apply + * a configured algorithm to different learning problems. + * Implementations, which do not only use the provided learning + * algorithm variable, must make sure that a call to this method + * indeed changes the learning problem. + * @param learningProblem The new learning problem. + */ + public void changeLearningProblem(LearningProblem learningProblem) { + this.learningProblem = learningProblem; + } + + /** + * Call this when you want to change the reasoning service, but + * leave everything else as is. Method can be used to use + * a configured algorithm with different reasoners. + * Implementations, which do not only use the provided reasoning + * service class variable, must make sure that a call to this method + * indeed changes the reasoning service. + * @param reasoningService The new reasoning service. + */ + public void changeReasoningService(ReasoningService reasoningService) { + this.reasoningService = reasoningService; + } + + /** * This is the maximum number of results, which the learning * algorithms need to keep. (Often algorithms do not need * to store any results except the best one, so this limit Modified: trunk/src/dl-learner/org/dllearner/core/LearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -60,6 +60,18 @@ } /** + * Method to exchange the reasoner underlying the learning + * problem. + * Implementations, which do not only use the provided reasoning + * service class variable, must make sure that a call to this method + * indeed changes the reasoning service. + * @param reasoningService New reasoning service. + */ + public void changeReasoningService(ReasoningService reasoningService) { + this.reasoningService = reasoningService; + } + + /** * Computes the <code>Score</code> of a given class description * with respect to this learning problem. * This can (but does not need to) be used by learning algorithms Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -40,11 +40,38 @@ import org.dllearner.utilities.datastructures.SortedSetTuple; /** + * Component representing a reasoner. + * * @author Jens Lehmann * */ public abstract class ReasonerComponent extends Component implements Reasoner { + protected Set<KnowledgeSource> sources; + + public ReasonerComponent(Set<KnowledgeSource> sources) { + this.sources = sources; + } + + /** + * @return the sources + */ + public Set<KnowledgeSource> getSources() { + return sources; + } + + /** + * Method to exchange the reasoner underlying the learning + * problem. + * Implementations, which do not only use the provided sources + * class variable, must make sure that a call to this method + * indeed changes them. + * @param The new knowledge sources. + */ + public void changeSources(Set<KnowledgeSource> sources) { + this.sources = sources; + } + public abstract boolean hasDatatypeSupport(); public boolean subsumes(Description superConcept, Description subConcept) @@ -258,4 +285,5 @@ public Set<NamedClass> getInconsistentClasses() throws ReasoningMethodUnsupportedException{ throw new ReasoningMethodUnsupportedException(); } + } Modified: trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/gui/ComponentPanel.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -1,7 +1,6 @@ package org.dllearner.gui; import java.awt.BorderLayout; -import java.awt.LayoutManager; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.LinkedList; @@ -39,10 +38,6 @@ private JButton clearButton; private JComboBox comboBox = new JComboBox(); - public ComponentPanel(LayoutManager layout) { - super(layout); - } - ComponentPanel(final Config config, StartGUI startGUI, Class<? extends Component> panelClass, Class<? extends Component> defaultComponent) { this(config, startGUI, panelClass, defaultComponent,null); } Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -20,8 +20,10 @@ package org.dllearner.gui; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.Set; import org.apache.log4j.Logger; import org.dllearner.core.Component; @@ -145,17 +147,20 @@ */ public KnowledgeSource changeKnowledgeSource(Class<? extends KnowledgeSource> clazz) { source = cm.knowledgeSource(clazz); + Set<KnowledgeSource> sources = new HashSet<KnowledgeSource>(); + sources.add(source); + reasoner.changeSources(sources); // logger.debug("knowledge source " + clazz + " changed"); // create a new reasoner object using the current class and the selected source - reasoner = cm.reasoner(reasoner.getClass(), source); - rs = cm.reasoningService(reasoner); - lp = cm.learningProblem(lp.getClass(), rs); - try { - la = cm.learningAlgorithm(la.getClass(), lp, rs); - } catch (LearningProblemUnsupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } +// reasoner = cm.reasoner(reasoner.getClass(), source); +// rs = cm.reasoningService(reasoner); +// lp = cm.learningProblem(lp.getClass(), rs); +// try { +// la = cm.learningAlgorithm(la.getClass(), lp, rs); +// } catch (LearningProblemUnsupportedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } return source; } @@ -187,13 +192,15 @@ public ReasonerComponent changeReasoner(Class<? extends ReasonerComponent> clazz) { reasoner = cm.reasoner(clazz, source); rs = cm.reasoningService(reasoner); - lp = cm.learningProblem(lp.getClass(), rs); - try { - la = cm.learningAlgorithm(la.getClass(), lp, rs); - } catch (LearningProblemUnsupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + lp.changeReasoningService(rs); + la.changeReasoningService(rs); +// lp = cm.learningProblem(lp.getClass(), rs); +// try { +// la = cm.learningAlgorithm(la.getClass(), lp, rs); +// } catch (LearningProblemUnsupportedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } return reasoner; } @@ -240,12 +247,13 @@ public LearningProblem changeLearningProblem(Class<? extends LearningProblem> clazz) { lp = cm.learningProblem(clazz, rs); - try { - la = cm.learningAlgorithm(la.getClass(), lp, rs); - } catch (LearningProblemUnsupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + la.changeLearningProblem(lp); +// try { +// la = cm.learningAlgorithm(la.getClass(), lp, rs); +// } catch (LearningProblemUnsupportedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } return lp; } Modified: trunk/src/dl-learner/org/dllearner/gui/InitWorker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/InitWorker.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/gui/InitWorker.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -98,6 +98,14 @@ try { for(Component component : components) { component.init(); + + // when the reasoner has been initialised, we need to update + // the option panel (such that the user can see the existing + // examples, classes etc.) + if(component instanceof ReasonerComponent) { + gui.panels[2].updateOptionPanel(); + gui.panels[3].updateOptionPanel(); + } } } catch (ComponentInitException e) { gui.getStatusPanel().setExceptionMessage(e.getMessage()); @@ -111,14 +119,6 @@ waitFrame.dispose(); } - // when the reasoner has been initialised, we need to update - // the option panel (such that the user can see the existing - // examples, classes etc.) - if(components instanceof ReasonerComponent) { - gui.panels[2].updateOptionPanel(); - gui.panels[3].updateOptionPanel(); - } - return true; } } Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -85,7 +85,6 @@ URL reasonerURL; - Set<KnowledgeSource> sources; // Variablen für Reasoner DIGHTTPConnector connector; @@ -116,8 +115,8 @@ public DIGReasoner(Set<KnowledgeSource> sources) { + super(sources); this.configurator = new DIGReasonerConfigurator(this); - this.sources = sources; try { reasonerURL = new URL("http://localhost:8081"); } catch (MalformedURLException e) { Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -107,7 +107,6 @@ // private ReasoningService rs; private OWLAPIReasoner rc; - private Set<KnowledgeSource> sources; // we use sorted sets (map indices) here, because they have only log(n) // complexity for checking whether an element is contained in them @@ -127,7 +126,7 @@ private Map<DatatypeProperty, Map<Individual, SortedSet<Integer>>> id = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Integer>>>(); public FastInstanceChecker(Set<KnowledgeSource> sources) { - this.sources = sources; + super(sources); this.configurator = new FastInstanceCheckerConfigurator(this); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -45,6 +45,7 @@ public FastRetrievalReasoner(Set<KnowledgeSource> sources) { + super(sources); this.configurator = new FastRetrievalReasonerConfigurator(this); rc = ComponentFactory.getDIGReasoner(sources); @@ -68,10 +69,11 @@ } public FastRetrievalReasoner(FlatABox abox) { + super(null); this.configurator = new FastRetrievalReasonerConfigurator(this); this.abox = abox; fastRetrieval = new FastRetrieval(abox); - + // atomare Konzepte und Rollen initialisieren atomicConcepts = new HashSet<NamedClass>(); for(String concept : abox.concepts) { Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-12 10:52:14 UTC (rev 1199) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-09-12 12:35:09 UTC (rev 1200) @@ -110,7 +110,6 @@ return configurator; } - private Set<KnowledgeSource> sources; private OWLReasoner reasoner; // the data factory is used to generate OWL API objects private OWLDataFactory factory; @@ -141,9 +140,8 @@ private List<OWLOntology> owlAPIOntologies = new LinkedList<OWLOntology>(); public OWLAPIReasoner(Set<KnowledgeSource> sources) { - this.sources = sources; + super(sources); this.configurator = new OWLAPIReasonerConfigurator(this); - } public static String getName() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |