/** *
Parameter handling and option descriptions.
* ** (This example is from {@link de.lmu.ifi.dbs.elki.algorithm.AbstractDistanceBasedAlgorithm AbstractDistanceBasedAlgorithm}.) *{@code // Defining option IDs * public static final OptionID DISTANCE_FUNCTION_ID = * OptionID.getOrCreateOptionID( * "algorithm.distancefunction", * "Distance function to determine the distance between database objects." * ); * }
* (This example is from {@link de.lmu.ifi.dbs.elki.algorithm.AbstractDistanceBasedAlgorithm DistanceBasedAlgorithm}.) *{@code // Defining Parameters * final ObjectParameter> DISTANCE_FUNCTION_PARAM = * new ObjectParameter >( * DISTANCE_FUNCTION_ID, * DistanceFunction.class, * EuclideanDistanceFunction.class * ); * }
* (This example is from {@link de.lmu.ifi.dbs.elki.algorithm.AbstractDistanceBasedAlgorithm DistanceBasedAlgorithm}.) * * *{@code // Getting parameters * protected DistanceBasedAlgorithm(Parameterization config) { * super(config); * if (config.grab(DISTANCE_FUNCTION_PARAM)) { * distanceFunction = DISTANCE_FUNCTION_PARAM.instantiateClass(config); * } * } * }
* (This example is from {@link de.lmu.ifi.dbs.elki.application.AbstractApplication AbstractApplication}.) * * * The {@code if config.grab} statement ensures that the parameter was set. Note that the configuration * manager is passed on to the child instance. *{@code // Using flags * protected AbstractApplication(Parameterization config) { * super(config); * if(config.grab(VERBOSE_FLAG)) { * verbose = VERBOSE_FLAG.getValue(); * } * } * }
*{@code // Compound parameter dependency * config.grab(FIRST_OPTION); * config.grab(SECOND_OPTION); * if (FIRST_OPTION.isDefined() && SECOND_OPTION.isDefined()) { * // Now we have validated values for both available. * } * }
* (This example is from {@link de.lmu.ifi.dbs.elki.KDDTask KDDTask}.) * * * TODO: Much of the constraint functionality can be solved much easier by direct Java code and * {@code reportError}. Unless the constraints can be used by a GUI for input assistance, we should * consider replacing them with direct code. *{@code // Global constraints * config.grab(NORMALIZATION_PARAM); * config.grab(NORMALIZATION_UNDO_FLAG); * GlobalParameterConstraint gpc = * new ParameterFlagGlobalConstraint, Class extends Normalization >>( * NORMALIZATION_PARAM, null, * NORMALIZATION_UNDO_FLAG, true); * if (config.checkConstraint(gpc)) { * // Code that depends on the constraints being satisfied. * } * }
*{@code // Proper dealing with errors * try { * // code that might fail with an IO exception * } except(IOException e) { * config.reportError(new WrongParameterValueException(...)); * } * // process remaining parameters, to report additional errors. * }
* (This example is from {@link de.lmu.ifi.dbs.elki.application.AbstractApplication AbstractApplication}.) *{@code // Use command line parameters * SerializedParameterization params = new SerializedParameterization(args); * }
* (This example is from {@link de.lmu.ifi.dbs.elki.algorithm.clustering.correlation.ERiC ERiC}.) *{@code // Internal parameterization * ListParameterization parameters = new ListParameterization(); * * parameters.addParameter(PCAFilteredRunner.PCA_EIGENPAIR_FILTER, FirstNEigenPairFilter.class); * parameters.addParameter(FirstNEigenPairFilter.EIGENPAIR_FILTER_N, correlationDimension); * }
* (This example code is from {@link de.lmu.ifi.dbs.elki.algorithm.clustering.subspace.DiSH DiSH}.) * * Note how error handling is performed by explicity specification of an error target and by * calling failOnErrors() at the end of parameterization. * * * (Note: the current implementation of this approach may be inadequate for XML or Tree based * parameterization, due to tree inconsistencies. This is an open TODO issue) *{@code // predefine some parameters * ListParameterization opticsParameters = new ListParameterization(); * opticsParameters.addParameter(OPTICS.DISTANCE_FUNCTION_ID, DiSHDistanceFunction.class); * // ... more parameters ... * ChainedParameterization chain = new ChainedParameterization(opticsParameters, config); * chain.errorsTo(opticsParameters); * optics = new OPTICS(chain); * opticsParameters.failOnErrors(); * }
* (This is an example from {@link de.lmu.ifi.dbs.elki.algorithm.clustering.correlation.COPAC COPAC}.) *{@code // config is an existing parameterization * TrackParameters trackpar = new TrackParameters(config); * DatabasetmpDB = PARTITION_DB_PARAM.instantiateClass(trackpar); * Collection > dbpars = trackpar.getGivenParameters(); * }
*{@code // config is an existing parameterization * ListParameterization myconfig = new ListParameterization(); * // dummy values for input and output * myconfig.addParameter(INPUT_ID, "/dev/null"); * myconfig.addParameter(OUTPUT_ID, "/dev/null"); * TrackParameters track = new TrackParameters(config); * ChainedParameterization chain = new ChainedParameterization(myconfig, track); * wrapper = WRAPPER_PARAM.instantiateClass(chain); * }
For documentation, the classes should also be annotated with * {@link de.lmu.ifi.dbs.elki.utilities.documentation.Title} * {@link de.lmu.ifi.dbs.elki.utilities.documentation.Description} and * {@link de.lmu.ifi.dbs.elki.utilities.documentation.Reference} (where possible).
* * @apiviz.excludeSubtypes de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable */ /* This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see