edu.indiana.iucbrf.solution
Class Solution

java.lang.Object
  extended by edu.indiana.iucbrf.solution.Solution
All Implemented Interfaces:
Featured, SwingRepresentableWithDomain, SwingRepresentable, XMLRepresentable, java.io.Serializable, java.lang.Comparable

public class Solution
extends java.lang.Object
implements java.io.Serializable, Featured, java.lang.Comparable, XMLRepresentable

Classes in the Solution component package are used both as part of a Case object and as stand-alone descriptors of the system's solution to a new problem.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface edu.indiana.util.swing.SwingRepresentable
TITLE_FONT
 
Constructor Summary
protected Solution()
          Creates new Solution.
  Solution(FeatureCollection features, Domain domain)
           
 
Method Summary
 void adjust(double adjustAmount)
          This implementation throws an UnsupportedOperationException.
 int compareTo(java.lang.Object obj)
           
 boolean equals(java.lang.Object other)
          Two solutions are equal if each individual feature is equal.
 void fromXML(java.lang.String XMLString)
           
 Feature getFeature(FeatureKey featureKey)
          Get the value of a particular feature.
 FeatureCollection getFeatures()
           
 boolean getIsReferenceSolution()
           
 double getValueAsDouble()
          Obtain a double representation of this solution.
 void setIsReferenceSolution(boolean isReferenceSolution)
           
 java.lang.String toString()
          Get a String representation of this Solution.
 java.lang.String toString(Domain domain)
           
 javax.swing.JComponent toSwing(Domain domain)
           
 javax.swing.JComponent toSwing(int detailLevel)
          Detail level may be ignored by implementations.
 java.lang.String toXML(Domain domain)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Solution

protected Solution()
Creates new Solution.


Solution

public Solution(FeatureCollection features,
                Domain domain)
Method Detail

getIsReferenceSolution

public boolean getIsReferenceSolution()

setIsReferenceSolution

public void setIsReferenceSolution(boolean isReferenceSolution)

equals

public boolean equals(java.lang.Object other)
Two solutions are equal if each individual feature is equal.

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object obj)
Specified by:
compareTo in interface java.lang.Comparable

toString

public java.lang.String toString()
Get a String representation of this Solution. This method should be overridden if a more elaborate toString() method is desired.

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(Domain domain)
Specified by:
toString in interface Featured

toSwing

public javax.swing.JComponent toSwing(int detailLevel)
Description copied from interface: SwingRepresentable
Detail level may be ignored by implementations. If used, the standard is for detailLevel 0 to be least detail, with higher values growing more detailed. 0 is least detail, higher numbers are more

Specified by:
toSwing in interface SwingRepresentable

toSwing

public javax.swing.JComponent toSwing(Domain domain)
Specified by:
toSwing in interface SwingRepresentableWithDomain

toXML

public java.lang.String toXML(Domain domain)
Specified by:
toXML in interface XMLRepresentable

fromXML

public void fromXML(java.lang.String XMLString)
Specified by:
fromXML in interface XMLRepresentable

getFeature

public Feature getFeature(FeatureKey featureKey)
Get the value of a particular feature.

Specified by:
getFeature in interface Featured
Parameters:
featureID - The index of the desired feature.
Returns:
An Object that is the desired feature value.

getFeatures

public FeatureCollection getFeatures()
Specified by:
getFeatures in interface Featured

getValueAsDouble

public double getValueAsDouble()
                        throws java.lang.UnsupportedOperationException
Obtain a double representation of this solution. This implementation takes the first solution feature (the one keyed on the first key returned by domain.orderedKeyIterator()), and casts it to a DoubleRepresentable. If this feature is not DoubleRepresentable, an UnsupportedOperationException is thrown.

Returns:
A double representation of this solution.
Throws:
java.lang.UnsupportedOperationException

adjust

public void adjust(double adjustAmount)
            throws java.lang.UnsupportedOperationException
This implementation throws an UnsupportedOperationException. The system designer should override this method if adjusting of a Solution according to a double is desired. For example, this is necessary in applying noise to a solution of a randomly-generated problem.

Throws:
java.lang.UnsupportedOperationException