From: <jen...@us...> - 2008-09-22 08:04:53
|
Revision: 1235 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1235&view=rev Author: jenslehmann Date: 2008-09-22 08:04:33 +0000 (Mon, 22 Sep 2008) Log Message: ----------- - GUI fixes - added maxClassDescriptionTests as option to ExampleBasedROLComponent Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/StatisticsThread.java trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-21 12:50:24 UTC (rev 1234) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-09-22 08:04:33 UTC (rev 1235) @@ -134,6 +134,7 @@ private int maxExecutionTimeInSeconds = CommonConfigOptions.maxExecutionTimeInSecondsDefault; private int minExecutionTimeInSeconds = CommonConfigOptions.minExecutionTimeInSecondsDefault; private int guaranteeXgoodDescriptions = CommonConfigOptions.guaranteeXgoodDescriptionsDefault; + private int maxClassDescriptionTests = CommonConfigOptions.maxClassDescriptionTestsDefault; // Variablen zur Einstellung der Protokollierung // boolean quiet = false; @@ -196,6 +197,7 @@ options.add(CommonConfigOptions.maxExecutionTimeInSeconds()); options.add(CommonConfigOptions.minExecutionTimeInSeconds()); options.add(CommonConfigOptions.guaranteeXgoodDescriptions()); + options.add(CommonConfigOptions.maxClassDescriptionTests()); options.add(CommonConfigOptions.getLogLevel()); options.add(new BooleanConfigOption("usePropernessChecks", "specifies whether to check for equivalence (i.e. discard equivalent refinements)",usePropernessChecksDefault)); options.add(new IntegerConfigOption("maxPosOnlyExpansion", "specifies how often a node in the search tree of a posonly learning problem needs to be expanded before it is" + @@ -274,6 +276,8 @@ minExecutionTimeInSeconds = (Integer) entry.getValue(); }else if(name.equals("guaranteeXgoodDescriptions")) { guaranteeXgoodDescriptions = (Integer) entry.getValue(); + } else if(name.equals("maxClassDescriptionTests")) { + maxClassDescriptionTests = (Integer) entry.getValue(); } else if(name.equals("logLevel")) { logLevel = ((String)entry.getValue()).toUpperCase(); } else if(name.equals("forceRefinementLengthIncrease")) { @@ -390,6 +394,7 @@ maxExecutionTimeInSeconds, minExecutionTimeInSeconds, guaranteeXgoodDescriptions, + maxClassDescriptionTests, forceRefinementLengthIncrease ); // note: used concepts and roles do not need to be passed Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-09-21 12:50:24 UTC (rev 1234) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-09-22 08:04:33 UTC (rev 1235) @@ -119,6 +119,7 @@ private boolean minExecutionTimeShown = false; private int guaranteeXgoodDescriptions = 1; private boolean guaranteeXgoodShown = false; + private int maxClassDescriptionTests; // if set to false we do not test properness; this may seem wrong // but the disadvantage of properness testing are additional reasoner @@ -242,7 +243,7 @@ boolean useTooWeakList, boolean useOverlyGeneralList, boolean useShortConceptConstruction, boolean usePropernessChecks, int maxPosOnlyExpansion, int maxExecutionTimeInSeconds, int minExecutionTimeInSeconds, - int guaranteeXgoodDescriptions, boolean forceRefinementLengthIncrease) { + int guaranteeXgoodDescriptions, int maxClassDescriptionTests, boolean forceRefinementLengthIncrease) { if (learningProblem instanceof PosNegLP) { PosNegLP lp = (PosNegLP) learningProblem; @@ -287,6 +288,7 @@ this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds; this.minExecutionTimeInSeconds = minExecutionTimeInSeconds; this.guaranteeXgoodDescriptions = guaranteeXgoodDescriptions; + this.maxClassDescriptionTests = maxClassDescriptionTests; this.forceRefinementLengthIncrease = forceRefinementLengthIncrease; // logger.setLevel(Level.DEBUG); @@ -296,6 +298,29 @@ stop = false; isRunning = true; runtime = System.currentTimeMillis(); + + // reset values (algorithms may be started several times) + candidates.clear(); + candidatesStable.clear(); + newCandidates.clear(); + solutionFound = false; + solutions.clear(); + maxExecutionTimeShown = false; + minExecutionTimeShown = false; + guaranteeXgoodShown = false; + propernessTestsReasoner = 0; + propernessTestsAvoidedByShortConceptConstruction = 0; + propernessTestsAvoidedByTooWeakList = 0; + conceptTestsTooWeakList = 0; + conceptTestsOverlyGeneralList = 0; + propernessCalcTimeNs = 0; + propernessCalcReasoningTimeNs = 0; + childConceptsDeletionTimeNs = 0; + refinementCalcTimeNs = 0; + redundancyCheckTimeNs = 0; + evaluateSetCreationTimeNs = 0; + improperConceptsRemovalTimeNs = 0; + Monitor totalLearningTime = JamonMonitorLogger.getTimeMonitor(ExampleBasedROLComponent.class, "totalLearningTime") .start(); // TODO: write a JUnit test for this problem (long-lasting or infinite @@ -1327,6 +1352,10 @@ if (solutions.size() > 0) solutionFound = true; } + if(!solutionFound && maxClassDescriptionTests != 0) { + int conceptTests = conceptTestsReasoner + conceptTestsTooWeakList + conceptTestsOverlyGeneralList; + solutionFound = (conceptTests >= maxClassDescriptionTests); + } } private boolean guaranteeXgoodDescriptions() { Modified: trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-09-21 12:50:24 UTC (rev 1234) +++ trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-09-22 08:04:33 UTC (rev 1235) @@ -83,6 +83,15 @@ } /** + * Used for rewriting (simplification, beautification) of + * evaluated descriptions returned by the learning algorithm. + * @param description The description to set. + */ + public void setDescription(Description description) { + this.description = description; + } + + /** * @see org.dllearner.core.owl.Description#getLength() * @return Length of the description. */ @@ -202,4 +211,5 @@ } return j; } + } Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-09-21 12:50:24 UTC (rev 1234) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-09-22 08:04:33 UTC (rev 1235) @@ -249,7 +249,13 @@ if(!filterNonMinimalDescriptions || ConceptTransformation.isDescriptionMinimal(ed.getDescription())) { // before we add the description we replace EXISTS r.TOP with // EXISTS r.range(r) if range(r) is atomic - ConceptTransformation.replaceRange(ed.getDescription(), reasoningService); + // (we need to clone, otherwise we change descriptions which could + // be in the search of the learning algorith, which leads to + // unpredictable behaviour) + Description d = ed.getDescription().clone(); + ConceptTransformation.replaceRange(d, reasoningService); + ed.setDescription(d); + returnList.add(ed); } Modified: trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-09-21 12:50:24 UTC (rev 1234) +++ trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-09-22 08:04:33 UTC (rev 1235) @@ -47,6 +47,7 @@ public static int maxExecutionTimeInSecondsDefault = 0; public static int minExecutionTimeInSecondsDefault = 0; public static int guaranteeXgoodDescriptionsDefault = 1; + public static int maxClassDescriptionTestsDefault = 0; public static String logLevelDefault = "DEBUG"; //public static double noisePercentageDefault = 0.0; @@ -128,6 +129,11 @@ return new IntegerConfigOption("guaranteeXgoodDescriptions", "algorithm will run until X good (100%) concept descritpions are found",guaranteeXgoodDescriptionsDefault); } + public static IntegerConfigOption maxClassDescriptionTests() { + return new IntegerConfigOption("maxClassDescriptionTests", "The maximum number of candidate hypothesis the algorithm is allowed to test (0 = no limit). The algorithm will stop afterwards. " + + "(The real number of tests can be slightly higher, because this criterion usually won't be checked after each single test.)",maxClassDescriptionTestsDefault); + } + public static StringConfigOption getLogLevel() { return new StringConfigOption("logLevel", "determines the logLevel for this component, can be {TRACE, DEBUG, INFO}",logLevelDefault); } Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-21 12:50:24 UTC (rev 1234) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-09-22 08:04:33 UTC (rev 1235) @@ -194,6 +194,10 @@ // // TODO Auto-generated catch block // e.printStackTrace(); // } + needsInit[0] = true; + needsInit[1] = true; + needsInit[2] = true; + needsInit[3] = true; return source; } @@ -236,6 +240,9 @@ rs = cm.reasoningService(reasoner); lp.changeReasoningService(rs); la.changeReasoningService(rs); + needsInit[1] = true; + needsInit[2] = true; + needsInit[3] = true; return reasoner; } @@ -276,6 +283,8 @@ public LearningProblem changeLearningProblem(Class<? extends LearningProblem> clazz) { lp = cm.learningProblem(clazz, rs); la.changeLearningProblem(lp); + needsInit[2] = true; + needsInit[3] = true; return lp; } @@ -313,6 +322,7 @@ public LearningAlgorithm changeLearningAlgorithm(Class<? extends LearningAlgorithm> clazz) throws LearningProblemUnsupportedException { la = cm.learningAlgorithm(clazz, lp, rs); + needsInit[3] = true; return la; } Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-09-21 12:50:24 UTC (rev 1234) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-09-22 08:04:33 UTC (rev 1235) @@ -66,7 +66,7 @@ private Config config; private StartGUI startGUI; - private long algorithmStartTime = 0; +// private long algorithmStartTime = 0; private GridBagLayout gridbag = new GridBagLayout(); private GridBagConstraints constraints = new GridBagConstraints(); @@ -86,8 +86,53 @@ private JLabel[] time = new JLabel[5]; private JLabel[] percent = new JLabel[5]; - + private class AlgorithmThread extends Thread { + private long startTime; + private long endTime; + + @Override + public void run() { + startTime = System.nanoTime(); +// setPriority(Thread.MIN_PRIORITY); + config.getLearningAlgorithm().start(); + endTime = System.nanoTime(); + } + + public long getRuntimeNanos() { + if(isAlive()) { + System.out.println("ALIVE"); + return System.nanoTime() - startTime; + } else { + System.out.println("NOT ALIVE"); + return endTime - startTime; + } + } + } + AlgorithmThread algorithmThread; + // separate thread for learning algorithm +// Thread algorithmThread = new Thread() { +// +// private long startTime; +// private long endTime; +// +// @Override +// public void run() { +// startTime = System.nanoTime(); +//// setPriority(Thread.MIN_PRIORITY); +// config.getLearningAlgorithm().start(); +// endTime = System.nanoTime(); +// } +// +// public long getRuntimeNanos() { +// if(isAlive()) { +// return System.nanoTime() - startTime; +// } else { +// return endTime - startTime; +// } +// } +// }; + RunPanel(Config config, StartGUI startGUI) { super(new BorderLayout()); @@ -172,19 +217,11 @@ public void actionPerformed(ActionEvent e) { // start if (e.getSource() == runButton) { - - // separate thread for learning algorithm - Thread algorithmThread = new Thread() { - @Override - public void run() { - setPriority(Thread.MIN_PRIORITY); - config.getLearningAlgorithm().start(); - } - }; - + algorithmThread = new AlgorithmThread(); config.getReasoningService().resetStatistics(); algorithmThread.start(); - algorithmStartTime = System.nanoTime(); +// algorithmStartTime = System.nanoTime(); +// algorithmThread. StatisticsThread threadStatistics = new StatisticsThread(config, this); threadStatistics.start(); runButton.setEnabled(false); @@ -230,8 +267,9 @@ // + config.getLearningAlgorithm().getSolutionScore().toString() // + "\n\n"); - // update algorith runtime - long algorithmRunTime = System.nanoTime() - algorithmStartTime; + // update algorithm runtime +// long algorithmRunTime = System.nanoTime() - algorithmStartTime; + long algorithmRunTime = algorithmThread.getRuntimeNanos(); bar[0].update(1.0); time[0].setText(makeTime(algorithmRunTime)); percent[0].setText("100%"); Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-21 12:50:24 UTC (rev 1234) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-09-22 08:04:33 UTC (rev 1235) @@ -253,7 +253,7 @@ Logger rootLogger = Logger.getRootLogger(); rootLogger.removeAllAppenders(); rootLogger.addAppender(consoleAppender); - rootLogger.setLevel(Level.DEBUG); + rootLogger.setLevel(Level.TRACE); File file = null; if (args.length > 0) @@ -308,10 +308,17 @@ } }); if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { - logger.info("Saving current configuration to " + fc.getSelectedFile() + "."); + File file = fc.getSelectedFile(); + // returns name without path to it + String name= file.getName(); + // if there is no extension, we append .conf + if(!name.contains(".")) { + file = new File(file.getAbsolutePath() + ".conf"); + } + logger.info("Saving current configuration to " + file + "."); ConfigSave save = new ConfigSave(config); try { - save.saveFile(fc.getSelectedFile()); + save.saveFile(file); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); Modified: trunk/src/dl-learner/org/dllearner/gui/StatisticsThread.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StatisticsThread.java 2008-09-21 12:50:24 UTC (rev 1234) +++ trunk/src/dl-learner/org/dllearner/gui/StatisticsThread.java 2008-09-22 08:04:33 UTC (rev 1235) @@ -49,7 +49,7 @@ while (config.getLearningAlgorithm().isRunning()) { // update statistics every 3 seconds runPanel.showStats(); - sleep(3000); + sleep(2000); } // show final stats runPanel.showStats(); Modified: trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java 2008-09-21 12:50:24 UTC (rev 1234) +++ trunk/src/dl-learner/org/dllearner/gui/widgets/WidgetPanelBoolean.java 2008-09-22 08:04:33 UTC (rev 1235) @@ -71,7 +71,7 @@ // set cb-index String[] kbBoxItems = { "true", "false" }; cb = new JComboBox(kbBoxItems); - if (!value) { + if (value) { cb.setSelectedIndex(0); } else { cb.setSelectedIndex(1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |