org.dllearner.gui
Class Config

java.lang.Object
  extended by org.dllearner.gui.Config

public class Config
extends Object

Config save all together used variables: ComponentManager, KnowledgeSource, Reasoner, ReasonerComponent, LearningProblem, LearningAlgorithm; also inits of these components.

Author:
Jens Lehmann, Tilo Hielscher

Constructor Summary
Config(ComponentManager cm, KnowledgeSource source, ReasonerComponent reasoner, LearningProblem lp, LearningAlgorithm la)
          This constructor can be used systemwide to save configurations in conf files.
Config(StartGUI gui)
          Create central configuration object.
 
Method Summary
<T> void
applyConfigEntry(Component component, ConfigEntry<T> entry)
          Applies a configuration option and cares for all consequences the GUI needs to take.
 KnowledgeSource changeKnowledgeSource(Class<? extends KnowledgeSource> clazz)
          Changes active knowledge source.
 LearningAlgorithm changeLearningAlgorithm(Class<? extends LearningAlgorithm> clazz)
          Change the learning algorithm.
 LearningProblem changeLearningProblem(Class<? extends LearningProblem> clazz)
          Change the learning problem and notify the depending components (learning algorithm).
 ReasonerComponent changeReasoner(Class<? extends ReasonerComponent> clazz)
          Change the reasoner and notify the depending components (learning problem, learning algorithm).
 void enableComponentsIfPossible()
          Tests whether components can be enabled.
 ComponentManager getComponentManager()
          Get ComponentManager.
<T> T
getConfigOptionValue(Component component, ConfigOption<T> option)
          Delegate method for getting config option values.
 KnowledgeSource getKnowledgeSource()
          Get KnowledgeSource.
 LearningAlgorithm getLearningAlgorithm()
          Get LearningAlgorithm.
 LearningProblem getLearningProblem()
          Get LearningProblem.
 ReasonerComponent getReasoner()
          Get Reasoner.
 void init(List<Integer> tabIndex)
          Initialises the specified components and records which ones where initialised.
 boolean isEnabled(int tabIndex)
          Returns whether the corresponding tab is enabled (e.g.
 void loadFile(File file)
          Loads a file using the commandline interface and asks it for loaded components and config options.
 boolean mandatoryOptionsSpecified(Component component)
          Checks whether all mandatory options have been set for a component.
 boolean needsInitKnowledgeSource()
          KnowledgeSource.init has run?
 boolean needsInitLearningAlgorithm()
          LearningAlgorithm.init() has run?
 boolean needsInitLearningProblem()
          LearningProblem.init has run?
 boolean needsInitReasoner()
          Reasoner.init has run?
 KnowledgeSource newKnowledgeSource(Class<? extends KnowledgeSource> clazz)
          Creates a knowledge source and makes it the active source.
 LearningAlgorithm newLearningAlgorithm(Class<? extends LearningAlgorithm> clazz)
          Creates learning algorithm and makes it active.
 LearningProblem newLearningProblem(Class<? extends LearningProblem> clazz)
          Creates learning problem and makes it active.
 ReasonerComponent newReasoner(Class<? extends ReasonerComponent> clazz)
          Creates reasoner + reasoning service and makes it active.
 boolean tabNeedsInit(int tabIndex)
          Returns whether the corresponding tab needs to be initialised.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Config

public Config(ComponentManager cm,
              KnowledgeSource source,
              ReasonerComponent reasoner,
              LearningProblem lp,
              LearningAlgorithm la)
This constructor can be used systemwide to save configurations in conf files. Of course it should not really belong here, but either in core or utilities. Consider refactoring using a subclass of Config for the GUI. Nevertheless it still works.

Parameters:
cm -
source -
reasoner -
rs -
lp -
la -

Config

public Config(StartGUI gui)
Create central configuration object.

Parameters:
gui - The main gui object. It is passed as parameter, such that the configuration handler can update the GUI appropriately.
Method Detail

loadFile

public void loadFile(File file)
Loads a file using the commandline interface and asks it for loaded components and config options. This way, we ensure that the loading process is always compatible with the command line and we do not need to implement the process again for the GUI. Afte loading, the GUI is updates appropriately.

Parameters:
file - The file to load.

getComponentManager

public ComponentManager getComponentManager()
Get ComponentManager.

Returns:
ComponentManager

getKnowledgeSource

public KnowledgeSource getKnowledgeSource()
Get KnowledgeSource.

Returns:
KnowledgeSource

newKnowledgeSource

public KnowledgeSource newKnowledgeSource(Class<? extends KnowledgeSource> clazz)
Creates a knowledge source and makes it the active source.

Parameters:
clazz - knowledge source class
Returns:
knowledge source instance

changeKnowledgeSource

public KnowledgeSource changeKnowledgeSource(Class<? extends KnowledgeSource> clazz)
Changes active knowledge source. This method does not not only create a knowledge source, but also updates the active reasoner to use the new knowledge source.

Parameters:
clazz - knowledge source class
Returns:
knowledge source instance

getReasoner

public ReasonerComponent getReasoner()
Get Reasoner.

Returns:
reasoner

newReasoner

public ReasonerComponent newReasoner(Class<? extends ReasonerComponent> clazz)
Creates reasoner + reasoning service and makes it active.

Parameters:
clazz - The class of the reasoner.
Returns:
A reasoner instance.

changeReasoner

public ReasonerComponent changeReasoner(Class<? extends ReasonerComponent> clazz)
Change the reasoner and notify the depending components (learning problem, learning algorithm).

Parameters:
clazz - The reasoner class.
Returns:
A reasoner instance.

getLearningProblem

public LearningProblem getLearningProblem()
Get LearningProblem.

Returns:
learningProblem

newLearningProblem

public LearningProblem newLearningProblem(Class<? extends LearningProblem> clazz)
Creates learning problem and makes it active.

Parameters:
clazz - The class of the learning problem.
Returns:
A learning problem instance.

changeLearningProblem

public LearningProblem changeLearningProblem(Class<? extends LearningProblem> clazz)
Change the learning problem and notify the depending components (learning algorithm).

Parameters:
clazz - The learning problem class.
Returns:
A learning problem instance.

getLearningAlgorithm

public LearningAlgorithm getLearningAlgorithm()
Get LearningAlgorithm.

Returns:
LearningAlgorithm

newLearningAlgorithm

public LearningAlgorithm newLearningAlgorithm(Class<? extends LearningAlgorithm> clazz)
                                       throws LearningProblemUnsupportedException
Creates learning algorithm and makes it active.

Parameters:
clazz - The class of the learning algorithm.
Returns:
A learning algorithm instance.
Throws:
LearningProblemUnsupportedException - If the learning algorithm does not support the learning problem (TODO should be handled intelligently by GUI).

changeLearningAlgorithm

public LearningAlgorithm changeLearningAlgorithm(Class<? extends LearningAlgorithm> clazz)
                                          throws LearningProblemUnsupportedException
Change the learning algorithm.

Parameters:
clazz - The learning algorithm class.
Returns:
A learning algorithm instance.
Throws:
LearningProblemUnsupportedException - If the learning algorithm does not support the learning problem (TODO should be handled intelligently by GUI).

tabNeedsInit

public boolean tabNeedsInit(int tabIndex)
Returns whether the corresponding tab needs to be initialised.

Parameters:
tabIndex - Index of the tab (0 to 3).
Returns:
True if the tab needs to be initialised for the learning algorithm to run. False, otherwise.

needsInitKnowledgeSource

public boolean needsInitKnowledgeSource()
KnowledgeSource.init has run?

Returns:
true, if init was made, false if not

needsInitReasoner

public boolean needsInitReasoner()
Reasoner.init has run?

Returns:
true, if init was made, false if not

needsInitLearningProblem

public boolean needsInitLearningProblem()
LearningProblem.init has run?

Returns:
true, if init was made, false if not

needsInitLearningAlgorithm

public boolean needsInitLearningAlgorithm()
LearningAlgorithm.init() has run?

Returns:
true, if init was made, false if not

isEnabled

public boolean isEnabled(int tabIndex)
Returns whether the corresponding tab is enabled (e.g. we can start to configure it, because all mandatory options of underlying components have been specified).

Parameters:
tabIndex - Index of the tab (0 to 3).
Returns:
True if the tab is enabled and false otherwise.

init

public void init(List<Integer> tabIndex)
Initialises the specified components and records which ones where initialised. The init process is done in a different thread, so this method returns immediately.

Parameters:
tabIndex - A list of components (0 = knowledge source, 1 = reasoner, ...).

applyConfigEntry

public <T> void applyConfigEntry(Component component,
                                 ConfigEntry<T> entry)
Applies a configuration option and cares for all consequences the GUI needs to take.

Type Parameters:
T - The type of config entry.
Parameters:
component - The component to apply the entry to.
entry - The config entry to apply.
See Also:
ComponentManager.applyConfigEntry(Component, ConfigEntry)

enableComponentsIfPossible

public void enableComponentsIfPossible()
Tests whether components can be enabled. A component is enabled, if it fulfills the following conditions: - the "previous" component has all mandatory options specified - all components before the previous one are enabled Otherwise, the component is disabled. Note it can also happend that enabled components become disabled if mandatory fields are cleared.


mandatoryOptionsSpecified

public boolean mandatoryOptionsSpecified(Component component)
Checks whether all mandatory options have been set for a component. TODO Use specification of mandatory variables.

Parameters:
component - The component to test.
Returns:
True if all mandatory options are set and false otherwise.

getConfigOptionValue

public <T> T getConfigOptionValue(Component component,
                                  ConfigOption<T> option)
Delegate method for getting config option values.

Type Parameters:
T - Type of option.
Parameters:
component - Component, which has the option.
option - The option for which we want to know the value.
Returns:
The value of the specified option.
See Also:
ComponentManager.getConfigOptionValue(Component, ConfigOption)


SourceForge.net Logo DL-Learner is licenced under the terms of the GNU General Public License.
Copyright © 2007-2008 Jens Lehmann