Opus5
Class ScalesBalancingProblem.Node

java.lang.Object
  |
  +--Opus5.AbstractObject
        |
        +--Opus5.ScalesBalancingProblem.Node
All Implemented Interfaces:
java.lang.Cloneable, Comparable, Solution
Enclosing class:
ScalesBalancingProblem

protected final class ScalesBalancingProblem.Node
extends AbstractObject
implements Solution

A node in the solution space of a scales balancing problem.

Version:
$Id: ScalesBalancingProblem.java,v 3.2 1998/07/28 20:03:35 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.

Field Summary
protected  int diff
          The current weight difference between the pans.
protected  int numberPlaced
          The number of weights placed into pans.
protected  int[] pan
          The pans in which the weights have been placed.
protected  int unplacedTotal
          The current total weight of all unplaced weights.
 
Fields inherited from interface Opus5.Solution
copyright
 
Constructor Summary
ScalesBalancingProblem.Node()
          Constructs the root node in the solution space of a this scales balancing problem.
ScalesBalancingProblem.Node(ScalesBalancingProblem.Node node)
          Copy constructor.
 
Method Summary
 java.lang.Object clone()
          Clones this object.
protected  int compareTo(Comparable arg)
          Compares this node in the solution space with the specified comparable object.
 int getBound()
          Returns a lower bound on the objective function for this node and all possible descendants of this node in the solution space.
 int getObjective()
          Returns the value of the objective function for this node.
 Enumeration getSuccessors()
          Returns a enumeration that enumerates all the successors of this node in the solution space.
 boolean isComplete()
          Tests if this node is a complete solution.
 boolean isFeasible()
          Tests if this node is a feasible solution.
 void placeNext(int p)
          Places the next unplaced weight in the specified pan.
 java.lang.String toString()
          Returns a string representation of this node.
 
Methods inherited from class Opus5.AbstractObject
compare, equals, isEQ, isGE, isGT, isLE, isLT, isNE
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Opus5.Comparable
compare, isEQ, isGE, isGT, isLE, isLT, isNE
 

Field Detail

diff

protected int diff
The current weight difference between the pans.

unplacedTotal

protected int unplacedTotal
The current total weight of all unplaced weights.

numberPlaced

protected int numberPlaced
The number of weights placed into pans.

pan

protected int[] pan
The pans in which the weights have been placed.
Constructor Detail

ScalesBalancingProblem.Node

public ScalesBalancingProblem.Node()
Constructs the root node in the solution space of a this scales balancing problem.

ScalesBalancingProblem.Node

public ScalesBalancingProblem.Node(ScalesBalancingProblem.Node node)
Copy constructor. Constructs a node in the solution space of a this scales balancing problem by copying the values of a given node.
Parameters:
node - The given node.
Method Detail

clone

public java.lang.Object clone()
Clones this object.
Overrides:
clone in class java.lang.Object
Returns:
A clone of this object.

getObjective

public int getObjective()
Returns the value of the objective function for this node. The result is the absolute value of the difference between the total weights in the left and right pans.
Specified by:
getObjective in interface Solution
Returns:
The value of the objective function.

getBound

public int getBound()
Returns a lower bound on the objective function for this node and all possible descendants of this node in the solution space.
Specified by:
getBound in interface Solution
Returns:
A lower bound on the object function.

isFeasible

public boolean isFeasible()
Tests if this node is a feasible solution.
Specified by:
isFeasible in interface Solution
Returns:
True always.

isComplete

public boolean isComplete()
Tests if this node is a complete solution.
Specified by:
isComplete in interface Solution
Returns:
True if all the weights have been placed in a pan; false otherwise.

placeNext

public void placeNext(int p)
Places the next unplaced weight in the specified pan.
Parameters:
p - The pan into which the next weight is placed.

toString

public java.lang.String toString()
Returns a string representation of this node.
Overrides:
toString in class java.lang.Object
Returns:
A string representation of this node.

getSuccessors

public Enumeration getSuccessors()
Returns a enumeration that enumerates all the successors of this node in the solution space.
Specified by:
getSuccessors in interface Solution
Returns:
An enumeration that enumerates the successors of this node.
See Also:
Enumeration

compareTo

protected int compareTo(Comparable arg)
Compares this node in the solution space with the specified comparable object. This method is not implemented.
Overrides:
compareTo in class AbstractObject
Throws:
MethodNotImplemented - Always.