org.coinor.opents
Class SolutionAdapter

java.lang.Object
  extended byorg.coinor.opents.SolutionAdapter
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, Solution

public class SolutionAdapter
extends java.lang.Object
implements Solution

This is the class to extend when creating your own solution definitions.

It is essential that you still implement your own clone() method and clone whatever custom properties you have in your solution definition.

For an excellent discussion of cloning techniques, see the Java Developer Connection Tech Tip http://developer.java.sun.com/developer/JDCTechTips/2001/tt0306.html.

Here is an example of how to clone your solution. Notice that it properly calls the super.clone() method so that the SolutionAdapter's clone() method is also called. Then an int array is cloned and a HashMap is cloned.


     ...
     public Object clone()
     {
         MySolution sol = (MySolution) super.clone();
         sol.myIntArray = (int[])      this.myIntArray.clone();
         sol.myMap      = (HashMap)    this.myMap.clone();
     }   // end clone
     ...
 

This code is licensed for public use under the Common Public License version 0.5.
The Common Public License, developed by IBM and modeled after their industry-friendly IBM Public License, differs from other common open source licenses in several important ways:

Copyright © 2001 Robert Harder

Since:
1.0b
See Also:
Serialized Form

Constructor Summary
SolutionAdapter()
           
 
Method Summary
 java.lang.Object clone()
          An essential Java method that returns of copy of the object.
 double[] getObjectiveValue()
          If the value has been set for this solution, then the value will be returned.
 void setObjectiveValue(double[] objValue)
          Generally used by the TabuSearch to set the value of the objective function and set objectiveValid to true.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SolutionAdapter

public SolutionAdapter()
Method Detail

getObjectiveValue

public final double[] getObjectiveValue()
If the value has been set for this solution, then the value will be returned. Be careful if this returns null since this may indicate that the TabuSearch has not yet set the solution's value.

Specified by:
getObjectiveValue in interface Solution
Returns:
The value of the solution
Since:
1.0

setObjectiveValue

public final void setObjectiveValue(double[] objValue)
Generally used by the TabuSearch to set the value of the objective function and set objectiveValid to true.

Specified by:
setObjectiveValue in interface Solution
Parameters:
objValue - The objective function value
Since:
1.0

clone

public java.lang.Object clone()
An essential Java method that returns of copy of the object. Specifically the double array that holds the objective value is properly cloned.

Specified by:
clone in interface Solution
Returns:
A copy of this.
Since:
1.0
See Also:
Cloneable