001    /**
002     * Copyright (C) 2007-2011, Jens Lehmann
003     *
004     * This file is part of DL-Learner.
005     *
006     * DL-Learner is free software; you can redistribute it and/or modify
007     * it under the terms of the GNU General Public License as published by
008     * the Free Software Foundation; either version 3 of the License, or
009     * (at your option) any later version.
010     *
011     * DL-Learner is distributed in the hope that it will be useful,
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014     * GNU General Public License for more details.
015     *
016     * You should have received a copy of the GNU General Public License
017     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
018     */
019    
020    package org.dllearner.core.options;
021    
022    import org.dllearner.core.AbstractCELA;
023    
024    
025    
026    /**
027     * Contains methods for creating common configuration options, i.e. options
028     * which are or may be of use for several components. 
029     * 
030     * @author Jens Lehmann
031     *
032     */
033    public final class CommonConfigOptions {
034            
035            // some default values
036            
037            //public static boolean applyAllFilterDefault = true;
038            //public static boolean applyExistsFilterDefault = true;        
039            //public static boolean useTooWeakListDefault = true;
040            //public static boolean useOverlyGeneralListDefault = true;
041            //public static boolean useShortConceptConstructionDefault = true;
042            //public static boolean improveSubsumptionHierarchyDefault = true;
043            public static boolean useAllConstructorDefault = true;
044            public static boolean useExistsConstructorDefault = true;
045            public static boolean useHasValueConstructorDefault = false;
046            public static boolean useDataHasValueConstructorDefault = false;
047            public static int valueFrequencyThresholdDefault = 3;
048            public static boolean useCardinalityRestrictionsDefault = true;
049            public static int cardinalityLimitDefault = 5;
050            public static boolean useNegationDefault = true;
051            public static boolean useBooleanDatatypesDefault = true;
052            public static boolean useDoubleDatatypesDefault = true;
053            public static boolean useStringDatatypesDefault = false;
054            public static int maxExecutionTimeInSecondsDefault = 0;
055            public static int minExecutionTimeInSecondsDefault = 0;
056            public static int guaranteeXgoodDescriptionsDefault = 1;
057            public static int maxClassDescriptionTestsDefault = 0;
058            public static String logLevelDefault = "DEBUG";
059            public static double noisePercentageDefault = 0.0;
060            public static boolean terminateOnNoiseReachedDefault = true;
061            public static boolean instanceBasedDisjointsDefault = true;
062            
063            public static StringConfigOption getVerbosityOption() {
064                    StringConfigOption verbosityOption = new StringConfigOption("verbosity", "control verbosity of output for this component", "warning");
065                    String[] allowedValues = new String[] {"quiet", "error", "warning", "notice", "info", "debug"};
066                    verbosityOption.setAllowedValues(allowedValues);
067                    return verbosityOption;
068            }
069            
070            public static DoubleConfigOption getNoisePercentage() {
071                    DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples",noisePercentageDefault);
072                    noisePercentage.setLowerLimit(0);
073                    noisePercentage.setUpperLimit(100);
074                    return noisePercentage;
075            }
076            
077            public static BooleanConfigOption getTerminateOnNoiseReached() {
078                    return new BooleanConfigOption("terminateOnNoiseReached", "specifies whether to terminate when noise criterion is met", terminateOnNoiseReachedDefault);
079            }
080            
081            public static BooleanConfigOption getTerminateOnNoiseReached(boolean defaultValue) {
082                    return new BooleanConfigOption("terminateOnNoiseReached", "specifies whether to terminate when noise criterion is met", defaultValue);
083            }       
084            
085            public static IntegerConfigOption getMaxDepth(int defaultValue) {
086                    return new IntegerConfigOption("maxDepth", "maximum depth of description", defaultValue);
087            }
088            
089            public static DoubleConfigOption getPercentPerLenghtUnitOption(double defaultValue) {
090                    DoubleConfigOption option = new DoubleConfigOption("percentPerLenghtUnit", "describes the reduction in classification accuracy in percent one is willing to accept for reducing the length of the concept by one", defaultValue);
091                    option.setLowerLimit(0.0);
092                    option.setUpperLimit(1.0);
093                    return option;
094            }
095            
096            public static DoubleConfigOption getExpansionPenaltyFactor(double defaultValue) {
097                    DoubleConfigOption option = new DoubleConfigOption("expansionPenaltyFactor", "describes the reduction in heuristic score one is willing to accept for reducing the length of the concept by one", defaultValue);
098                    return option;
099            }
100            
101            public static StringConfigOption getReturnType() {
102                    return new StringConfigOption("returnType", "Specifies the type which the solution has to belong to (if already) known. This means we inform the learning algorithm that the solution is a subclass of this type.");
103            }
104            
105            public static BooleanConfigOption getUNA() {
106                    return new BooleanConfigOption("una", "unique names assumption", false);
107            }
108            
109            public static BooleanConfigOption getOWA() {
110                    return new BooleanConfigOption("owa", "open world assumption (if set to false, we try to close the world", true);
111            }
112            
113            public static StringSetConfigOption allowedConcepts() {
114                    return new StringSetConfigOption("allowedConcepts", "concepts the algorithm is allowed to use");
115            }
116            
117            public static StringSetConfigOption allowedRoles() {
118                    return new StringSetConfigOption("allowedRoles", "roles the algorithm is allowed to use");
119            }
120            
121            public static StringSetConfigOption ignoredConcepts() {
122                    return new StringSetConfigOption("ignoredConcepts", "concepts the algorithm must ignore");
123            }
124            
125            public static StringSetConfigOption ignoredRoles() {
126                    return new StringSetConfigOption("ignoredRoles", "roles the algorithm must ignore");
127            }       
128            
129            public static BooleanConfigOption useAllConstructor() {
130                    return new BooleanConfigOption("useAllConstructor", "specifies whether the universal concept constructor is used in the learning algorithm",useAllConstructorDefault);
131            }
132            
133            public static BooleanConfigOption useExistsConstructor() {
134                    return new BooleanConfigOption("useExistsConstructor", "specifies whether the existential concept constructor is used in the learning algorithm",useExistsConstructorDefault);
135            }
136            
137            public static BooleanConfigOption useHasValueConstructor() {
138                    return new BooleanConfigOption("useHasValueConstructor", "specifies whether the hasValue constructor is used in the learning algorithm",useHasValueConstructorDefault);
139            }       
140            
141            public static BooleanConfigOption useDataHasValueConstructor() {
142                    return new BooleanConfigOption("useDataHasValueConstructor", "specifies whether the hasValue constructor is used in the learning algorithm in combination with data properties",useDataHasValueConstructorDefault);
143            }       
144            
145            public static IntegerConfigOption valueFreqencyThreshold() {
146                    return new IntegerConfigOption("valueFrequencyThreshold", "specifies how often an object must occur as value in order to be considered for hasValue restrictions",valueFrequencyThresholdDefault);
147            }
148            
149            public static BooleanConfigOption useCardinalityRestrictions() {
150                    return new BooleanConfigOption("useCardinalityRestrictions", "specifies whether CardinalityRestrictions is used in the learning algorithm",useCardinalityRestrictionsDefault);
151            }
152            
153            public static IntegerConfigOption cardinalityLimit() {
154                    return new IntegerConfigOption("cardinalityLimit", "Gives the maximum number used in cardinality restrictions.",cardinalityLimitDefault);
155            }       
156            
157            public static BooleanConfigOption useNegation() {
158                    return new BooleanConfigOption("useNegation", "specifies whether negation is used in the learning algorothm",useNegationDefault);
159            }
160            
161            public static BooleanConfigOption useNegation(boolean defaultValue) {
162                    return new BooleanConfigOption("useNegation", "specifies whether negation is used in the learning algorothm",defaultValue);
163            }       
164            
165            public static BooleanConfigOption useBooleanDatatypes() {
166                    return new BooleanConfigOption("useBooleanDatatypes", "specifies whether boolean datatypes are used in the learning algorothm",useBooleanDatatypesDefault);
167            }       
168            
169            public static BooleanConfigOption useDoubleDatatypes() {
170                    return new BooleanConfigOption("useDoubleDatatypes", "specifies whether double datatypes are used in the learning algorothm",useDoubleDatatypesDefault);
171            }       
172            
173            public static BooleanConfigOption useStringDatatypes() {
174                    return new BooleanConfigOption("useStringDatatypes", "specifies whether string datatypes are used in the learning algorothm",useStringDatatypesDefault);
175            }       
176            
177            public static IntegerConfigOption maxExecutionTimeInSeconds() {
178                    return new IntegerConfigOption("maxExecutionTimeInSeconds", "algorithm will stop after specified seconds",maxExecutionTimeInSecondsDefault);
179            }       
180            
181            public static IntegerConfigOption maxExecutionTimeInSeconds(int defaultValue) {
182                    return new IntegerConfigOption("maxExecutionTimeInSeconds", "algorithm will stop after specified seconds",defaultValue);
183            }               
184            
185            public static IntegerConfigOption minExecutionTimeInSeconds() {
186                    return new IntegerConfigOption("minExecutionTimeInSeconds", "algorithm will run at least specified seconds",minExecutionTimeInSecondsDefault);
187            }       
188            
189            public static IntegerConfigOption guaranteeXgoodDescriptions() {
190                    return new IntegerConfigOption("guaranteeXgoodDescriptions", "algorithm will run until X good (100%) concept descritpions are found",guaranteeXgoodDescriptionsDefault);
191            }
192            
193            public static IntegerConfigOption maxNrOfResults(int defaultValue) {
194                    IntegerConfigOption opt = new IntegerConfigOption("maxNrOfResults", "Sets the maximum number of results one is interested in. (Setting this to a lower value may increase performance as the learning algorithm has to store/evaluate/beautify less descriptions).", defaultValue);
195                    opt.setLowerLimit(1);
196                    opt.setUpperLimit(AbstractCELA.MAX_NR_OF_RESULTS);
197                    return opt;
198            }
199            
200            public static IntegerConfigOption maxClassDescriptionTests() {
201                    return new IntegerConfigOption("maxClassDescriptionTests", "The maximum number of candidate hypothesis the algorithm is allowed to test (0 = no limit). The algorithm will stop afterwards. " +
202                                    "(The real number of tests can be slightly higher, because this criterion usually won't be checked after each single test.)",maxClassDescriptionTestsDefault);
203            }       
204            
205            public static StringConfigOption getLogLevel() {
206                    return new StringConfigOption("logLevel", "determines the logLevel for this component, can be {TRACE, DEBUG, INFO}",logLevelDefault);
207            }
208            
209            public static BooleanConfigOption getInstanceBasedDisjoints() {
210                    return new BooleanConfigOption("instanceBasedDisjoints", "Specifies whether to use real disjointness checks or instance based ones (no common instances) in the refinement operator.", instanceBasedDisjointsDefault);
211            }       
212    }