net.sourceforge.cilib.functions.discrete
Class KnapSack

java.lang.Object
  extended by net.sourceforge.cilib.functions.Function
      extended by net.sourceforge.cilib.functions.DiscreteFunction
          extended by net.sourceforge.cilib.functions.discrete.KnapSack
All Implemented Interfaces:
Serializable, Cloneable

public class KnapSack
extends DiscreteFunction

Perform the knapsack problem optimisation.

Author:
Gary Pampara
See Also:
Serialized Form

Constructor Summary
KnapSack()
           
 
Method Summary
 double evaluate(Vector x)
          Evaluate the function output, given the function input, x.
 int getCapacity()
           
 KnapSack getClone()
          Create a cloned copy of the current object and return it.
 Object getMaximum()
          Accessor for the function maximum.
 Object getMinimum()
          Accessor for the function minimum.
 int getNumberOfObjects()
           
 ArrayList<Double> getValue()
           
 ArrayList<Double> getWeight()
           
 void setCapacity(int capacity)
           
 void setNumberOfObjects(int numberOfObjects)
           
 void setValue(ArrayList<Double> value)
           
 void setValue(String valueString)
          Helper method.
 void setWeight(ArrayList<Double> weight)
           
 void setWeight(String weightString)
          Helper method.
 
Methods inherited from class net.sourceforge.cilib.functions.DiscreteFunction
evaluate
 
Methods inherited from class net.sourceforge.cilib.functions.Function
getBehavioralDomainRegistry, getDimension, getDomain, getDomainRegistry, setBehavioralDomain, setBehaviouralDomainRegistry, setDomain
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KnapSack

public KnapSack()
Method Detail

getClone

public KnapSack getClone()
Description copied from interface: Cloneable
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

getMinimum

public Object getMinimum()
Description copied from class: DiscreteFunction
Accessor for the function minimum. This is the minimum value of the function in the given domain.

Overrides:
getMinimum in class DiscreteFunction
Returns:
The minimum function value.

getMaximum

public Object getMaximum()
Description copied from class: DiscreteFunction
Accessor for the function maximum. This is the maximum value of the function in the given domain.

Overrides:
getMaximum in class DiscreteFunction
Returns:
The maximum of the function.

evaluate

public double evaluate(Vector x)
Description copied from class: DiscreteFunction
Evaluate the function output, given the function input, x.

Specified by:
evaluate in class DiscreteFunction
Parameters:
x - The Vector representing the function input.
Returns:
The result of the evaluation.

getCapacity

public int getCapacity()
Returns:
Returns the capacity.

setCapacity

public void setCapacity(int capacity)
Parameters:
capacity - The capacity to set.

getNumberOfObjects

public int getNumberOfObjects()
Returns:
Returns the numberOfObjects.

setNumberOfObjects

public void setNumberOfObjects(int numberOfObjects)
Parameters:
numberOfObjects - The numberOfObjects to set.

getValue

public ArrayList<Double> getValue()
Returns:
Returns the value.

setValue

public void setValue(ArrayList<Double> value)
Parameters:
value - The value to set.

setValue

public void setValue(String valueString)
Helper method. This method enables in input of a comma-separated string, containing the values for the different object types.

Parameters:
valueString - A comma separated string defining the values for each selection bucket.

getWeight

public ArrayList<Double> getWeight()
Returns:
Returns the weight.

setWeight

public void setWeight(ArrayList<Double> weight)
Parameters:
weight - The weight to set.

setWeight

public void setWeight(String weightString)
Helper method. This method enables in input of a comma-separated string, containing the weight values for the different object types.

Parameters:
weightString - A comma separated string defining the weight value for each selection bucket.


Copyright © 2009 CIRG. All Rights Reserved.