Class Criterion

java.lang.Object
edu.kit.mcda.core.Criterion
All Implemented Interfaces:
Changed, Description, Dye, Identifier, Label, Domain, MetaInformation
Direct Known Subclasses:
LinkedCriterion

public class Criterion extends Object implements MetaInformation, Domain
Class to manage all the data and meta data of a criterion.
Author:
Tim Mueller
  • Constructor Details

    • Criterion

      public Criterion()
      Constructor of Criterion. No parameters required. Calls preInit(), init(), and postInit().
  • Method Details

    • getValue

      public double getValue(String _identifier)
      Get the value of an alternative for this criterion.
      Parameters:
      _identifier - the identifier of the alternative
      Returns:
      the value of the alternative
    • setValue

      public void setValue(String _identifier, double _value)
      Link a value to an alternative for this criterion.
      Parameters:
      _identifier - the identifier of the alternative
      _value - the actual value
    • getQualitativeValue

      public String getQualitativeValue(String _identifier)
    • setQualitativeValue

      public void setQualitativeValue(String _alternativeIdentifier, String _qualitativeIdentifier)
      Link a nominal value to an alternative for this criterion.
      Parameters:
      _alternativeIdentifier - the identifier of the alternative
      _qualitativeIdentifier - the key of the nominal value
    • getFunctionValue

      public double getFunctionValue(String _identifier)
      Get the value of the value function of an alternative for this criterion.
      Parameters:
      _identifier - the identifier of the alternative
      Returns:
      the value of the alternative
    • getValueFunction

      public ValueFunction getValueFunction(String _identifier)
      Get the value function of an alternative for this criterion.
      Parameters:
      _identifier - the identifier of the alternative
      Returns:
      the value function of the alternative
    • hasValueFunction

      public boolean hasValueFunction(String _identifier)
      Test if the value function of an alternative for this criterion exists.
      Parameters:
      _identifier - the identifier of the alternative
      Returns:
      true if a function is defined for this alternative
    • setValueFunction

      public void setValueFunction(String _identifier, ValueFunction _valueFunction)
      Link a value function to an alternative for this criterion.
      Parameters:
      _identifier - the identifier of the alternative
      _valueFunction - the actual value function
    • removeValueFunction

      public void removeValueFunction(String _identifier)
      Remove a value function linked to the identifier.
      Parameters:
      _identifier - the identifier of the alternative linked to the value function to remove
    • getValues

      public LinkedHashMap<String,Double> getValues()
      Get a map of the values. The map is a copy of the original.
      Returns:
      a map of the values
    • getNormalizedValue

      public Double getNormalizedValue(String _identifier)
      Get a normalised value for an alternative.
      Parameters:
      _identifier - the alternative identifier
      Returns:
      the normalised value for the alternative
    • getNormalizedValues

      public LinkedHashMap<String,Double> getNormalizedValues()
      Get a map of the normalised values. The map is a copy of the original.
      Returns:
      a map of the normalised values
    • getNormalizedMinimum

      public double getNormalizedMinimum()
      Get the minimum of the normalised values. It is the upper bound of the range.
      Returns:
      the minimum of the normalised values
    • getNormalizedMaximum

      public double getNormalizedMaximum()
      Get the maximum of the normalised values. It is the upper bound of the range.
      Returns:
      the maximum of the normalised values
    • hasGroup

      public boolean hasGroup()
      Check if criterion belongs to a group. This is the case if the actual group of this criterion is not Defaults.GROUP.
      Returns:
      true if this criterion is member of a group
    • hasWeightFunction

      public boolean hasWeightFunction()
      Check if a weight function is linked to this criterion. Access the group and retrieve information from it if possible.
      Returns:
      true if a weight is referenced to this criterion
    • getWeightFunction

      public ValueFunction getWeightFunction()
      Get the weight function linked to this criterion. Access the group and retrieve information from it if possible. Return null if no group or no value function is associated.
      Returns:
      the weight function of this criterion in its group
    • addAlternative

      public void addAlternative(String _identifier)
      Add an alternative to the values list. As value for the alternative the Defaults.CRITERION_VALUE is set.
      Parameters:
      _identifier - the identifier of the new alternative
    • removeAlternative

      public void removeAlternative(String _identifier)
      Remove an alternative by its identifier.
      Parameters:
      _identifier - the identifier of the alternative to remove
    • containsAlternative

      public boolean containsAlternative(String _identifier)
      Check if an alternative is registered in this criterion.
      Parameters:
      _identifier - the identifier of the alternative to check for
      Returns:
      true if the alternative is registered
    • getAlternatives

      public ArrayList<String> getAlternatives()
      Get a list of all registered alternatives. The list is a copy of its original.
      Returns:
      a list of the alternatives
    • getWorst

      public double getWorst()
      Get the worst value of this criterion
      Returns:
      the worst value
    • getBest

      public double getBest()
      Get the best value of this criterion.
      Returns:
      the best value
    • getMinimum

      public double getMinimum()
      Get the minimum (not necessarily best) value of this criterion.
      Specified by:
      getMinimum in interface Domain
      Returns:
      the minimum value for this criterion
    • getMaximum

      public double getMaximum()
      Get the maximum (not necessarily best) value of this criterion.
      Specified by:
      getMaximum in interface Domain
      Returns:
      the maximum value for this criterion
    • setBounds

      public boolean setBounds(double _minimum, double _maximum)
      Specified by:
      setBounds in interface Domain
      Parameters:
      _minimum - the minimum to set
      _maximum - the maximum to set
      Returns:
      true if maximum was valid and set, false if it was rejected
    • isQualitative

      public boolean isQualitative()
      Description copied from interface: Domain
      Whether the domain is discrete or continuous.
      Specified by:
      isQualitative in interface Domain
      Returns:
      true if the domain is discrete, false otherwise
    • getQualitativeSet

      public QualitativeSet getQualitativeSet()
      Description copied from interface: Domain
      Whether the domain is discrete or continuous.
      Specified by:
      getQualitativeSet in interface Domain
      Returns:
      true if the domain is discrete, false otherwise
    • setQualitativeSet

      public void setQualitativeSet(QualitativeSet _nominalSet)
    • isUsingValueAHP

      public boolean isUsingValueAHP()
      Returns usingValueAHP
      Returns:
      if AHP is used for alternatives
    • setUsingValueAHP

      public void setUsingValueAHP(boolean _usingValueAHP)
      Sets usingValueAHP, if false, copy previous values to parameter "values"
      Parameters:
      _usingValueAHP -
    • getValueAHP

      public AHP getValueAHP()
      Returns AHP of alternatives
      Returns:
    • setValueAHP

      public void setValueAHP(AHP _valueAhp) throws Exception
      Parameters:
      _valueAhp -
      Throws:
      Exception
    • createValuesFromAHP

      public void createValuesFromAHP()
      Create weights from AHP and set them internally. Adjusts the weights in a way that they optimally fit in the sliders display (between 0.0 and 10.0).
    • getParents

      public LinkedHashMap<String,CriterionGroup> getParents()
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getGoal

      public Goal getGoal()
    • getGroup

      public CriterionGroup getGroup()
      Returns:
    • setGroup

      public void setGroup(CriterionGroup _group)
      Parameters:
      _group -
    • getNormalizationMethod

      public AbstractNormalization getNormalizationMethod()
      Returns:
    • setNormalizationMethod

      public void setNormalizationMethod(AbstractNormalization _normalizationMethod)
      Parameters:
      _normalizationMethod -
    • getIdentifier

      public String getIdentifier()
      Description copied from interface: Identifier
      Get a unique identifier. Most likely a UUID.
      Specified by:
      getIdentifier in interface Identifier
      Returns:
      the id
    • setIdentifier

      public void setIdentifier(String _identifier)
      Description copied from interface: Identifier
      Set a unique identifier. Most likely a UUID.
      Specified by:
      setIdentifier in interface Identifier
      Parameters:
      _identifier - the id to set
    • getLabel

      public String getLabel()
      Description copied from interface: Label
      Get the default label without reference to a language.
      Specified by:
      getLabel in interface Label
      Returns:
      the default label
    • getLabel

      public String getLabel(String _language)
      Description copied from interface: Label
      Get the label in reference to the given language.
      Specified by:
      getLabel in interface Label
      Parameters:
      _language - the language in which the label is requested
      Returns:
      the localised label
    • getLabels

      public LinkedHashMap<String,String> getLabels()
      Get all labels with reference to a language.
      Specified by:
      getLabels in interface Label
      Returns:
      all labels
    • setLabel

      public void setLabel(String _label)
      Set the default label. Delegates to setLabel(java.lang.String,java.lang.String) using Keys.DEFAULT.
      Specified by:
      setLabel in interface Label
      Parameters:
      _label - the label to set
    • setLabel

      public void setLabel(String _language, String _label)
      Set a label for this criterion.
      Specified by:
      setLabel in interface Label
      Parameters:
      _language - the language to set the label for
      _label - the label to set
    • clearLabels

      protected void clearLabels()
      Allow clear of labels for inheriting classes.
    • hasDescription

      public boolean hasDescription()
      Check if a non default description is set for the default language. Delegates to hasDescription(java.lang.String) using Keys.DEFAULT.
      Returns:
      true if a non default description is set
    • hasDescription

      public boolean hasDescription(String _language)
      Check if a non default description is set for the language in question.
      Parameters:
      _language - the language to check for
      Returns:
      true if a non default description is set for the language in question
    • getDescription

      public String getDescription()
      Get the default description without reference to a language. Delegates to getDescription(java.lang.String) using Keys.DEFAULT.
      Specified by:
      getDescription in interface Description
      Returns:
      the default description
    • getDescription

      public String getDescription(String _language)
      Get the description in reference to the given language.
      Specified by:
      getDescription in interface Description
      Parameters:
      _language - the language identifier
      Returns:
      the localised description
    • getDescriptions

      public LinkedHashMap<String,String> getDescriptions()
      Get all descriptions with reference to a language.
      Specified by:
      getDescriptions in interface Description
      Returns:
      all descriptions
    • setDescription

      public void setDescription(String _description)
      Set the default description. Delegates to setDescription(java.lang.String,java.lang.String) using Keys.DEFAULT.
      Specified by:
      setDescription in interface Description
      Parameters:
      _description - the description to set
    • setDescription

      public void setDescription(String _language, String _description)
      Set a description for the given language.
      Specified by:
      setDescription in interface Description
      Parameters:
      _language - the language identifier
      _description - the description for the given language
    • clearDescriptions

      protected void clearDescriptions()
      Allow clear of descriptions for inheriting classes.
    • getDye

      public Color getDye()
      Get the dedicated color to use within the context.
      Specified by:
      getDye in interface Dye
      Returns:
      the dedicated color
    • setDye

      public void setDye(Color _dye)
      Set the dedicated color to use within the context.
      Specified by:
      setDye in interface Dye
      Parameters:
      _dye - the dedicated color to set
    • getUnit

      public String getUnit()
    • setUnit

      public void setUnit(String _unit)
    • isInverse

      public boolean isInverse()
    • setInverse

      public void setInverse(boolean _inverse)
    • hasChanged

      public boolean hasChanged()
      Get the status of the changed flag.
      Specified by:
      hasChanged in interface Changed
      Returns:
      the changed status
    • setChanged

      public void setChanged(boolean _changed)
      Set the status of the changed flag.
      Specified by:
      setChanged in interface Changed
      Parameters:
      _changed - the changed status to be set
    • importFromXML

      public void importFromXML(org.jdom2.Element _masterNode)
      Imports the data from a specified node. Criterion group and normalized values are not imported. Normalized values are computed on demand.
      Parameters:
      _masterNode - the node containing the criterion data
    • exportToXML

      public org.jdom2.Element exportToXML()
      Exports the criterion to the specified node. The criterion group and the normalized values are not exported.
      Returns:
      a master element containing the export
    • getValueForXML

      public double getValueForXML(String _identifier)
      Parameters:
      _identifier -
      Returns: