com.opttek.optquest
Class COptNeuralNet

java.lang.Object
  extended bycom.opttek.optquest.COptNeuralNet

public class COptNeuralNet
extends java.lang.Object

The COptNeuralNet is used to create, train, and predict an OptQuest Neural Network. Nodes are defined using COptNeuralNetNode. Arcs are defined using COptNeuralNetArc. These nodes and arcs are added to the COptNeuralNet to create the OptQuest Neural Network. The network can then be trained using OptQuest Engine techniques. Once the network is trained, the network can be used to predict outputs from inputs. The structure can be saved and read back in.


Field Summary
static int SECTION_ACTIVATION
           
static int SECTION_ARCNODENODEWEIGHT
           
static int SECTION_EPOWER
           
static int SECTION_NODELEVEL
           
static int SECTION_NUMLEVELS
           
static int SECTION_NUMNODESATLEVEL
           
static int SECTION_VERSION
           
 
Constructor Summary
COptNeuralNet()
          Default Constructor.
COptNeuralNet(int license)
           
 
Method Summary
 void AddArc(COptNeuralNetArc arc)
          AddArc() adds an arc to the OptQuest Neural Network.
 void AddBiasNode(COptNeuralNetNode node)
          AddBiasNode() adds a Bias node to the OptQuest Neural Network.
 void AddHiddenNode(COptNeuralNetNode node)
          AddHiddenNode() adds a Hidden node to the OptQuest Neural Network.
 void AddInputNode(COptNeuralNetNode node)
          AddInputNode() adds an Input node to the OptQuest Neural Network.
 void AddOutputNode(COptNeuralNetNode node)
          AddOutputNode() adds an Output node to the OptQuest Neural Network.
 void AddRandomWeights()
          AddRandomWeights() sets the random values to all of the weights in the network.
 void CreateAndAddBiasNodes()
          CreateAndAddBiasNodes() allows the user to add a bias node without creating the object separately.
 void CreateAndAddHiddenNodes(int numNodes, int level)
          CreateAndAddHiddenNodes() allows the user to add hidden nodes without creating the objects separately.
 void CreateAndAddInputNodes(int numNodes)
          CreateAndAddInputNodes() allows the user to add input nodes without creating the objects separately.
 void CreateAndAddOutputNodes(int numNodes, int level)
          CreateAndAddOutputNodes() allows the user to add output nodes without creating the objects separately.
 void DeleteArc(COptNeuralNetArc arc)
          DeleteArc() deletes an arc from the OptQuest Neural Network.
 void DeleteNode(COptNeuralNetNode node)
          DeleteNode() deletes a node from the OptQuest Neural Network.
 void FullyConnectNetwork()
          FullyConnectNetwork() allows the user to add fully connect the network without creating any arc objects.
 double GetBestObjectiveValue()
          GetBestObjectiveValue() gets the best objective so far.
 double GetEPower()
          GetEPower() returns the coefficient of the power for the sigmoid.
 int GetIteration()
          GetIteration() gets the current iteration.
 int GetNumberOfHidden()
          GetNumberOfHidden() returns the number of total hidden nodes in the network.
 int GetNumberOfInputs()
          GetNumberOfInputs() returns the number of input nodes in the network.
 int GetNumberOfIterations()
          GetNumberOfIterations() returns the number of iterations set.
 int GetNumberOfOutputs()
          GetNumberOfOutputs() returns the number of output nodes in the network.
 int GetRepeat()
          GetRepeat() gets the current repeat.
 void MonitorStatus()
          Monitor Status is used to monitor the progress of the training.
 void Predict(double[] input, double[] predict)
          Predict() predicts the outputs from the supplied inputs.
 void Predict(int numObs, double[][] input, double[][] predict)
          Predict() predicts the outputs from the supplied inputs.
 void ReadNetworkDefinition(java.lang.String filename)
          ReadNetworkDefinition() reads the network definition from a file and creates the network from the information provided in the file.
 void SetDefaultActivation(int useActivationFunction)
          SetDefaultActivation() sets the default activation function for the OptQuest Neural Network.
 void SetEPower(double power)
          SetEPower() sets the coefficient of the power for the sigmoid.
 void SetInputScale()
          SetInputScale() sets the scaling of the input to a [0,1] value based on the minimum/maximum values in the training set.
 void SetLicense(int license)
           
 void SetLowerBound(double lowerBound)
          SetLowerBound() sets the lower bound of the weights.
 void SetMeanErrorPower(double val)
          SetMeanErrorPower() sets the power to which the absolute difference is raised when calculating the objective for the training.
 void SetOptimizePower(double lowerbound, double upperbound)
          SetOptimizePower() indicates to optimize the power coefficient during training.
 void SetOutputScale()
          SetOutputScale() sets the scaling of the output to a [0,1] value based on the minimum/maximum values in the training set.
 void SetRegressionForLastLevel(boolean bUseRgr)
          SetRegressionForLastLevel() sets whether or not to use linear regression for the arc weights coming into the output nodes.
 void SetRepeat(int repeat)
          SetRepeat() repeats the training for the given number of times (default = 1).
 void SetStoppingRuleError(double val)
          SetStoppingRuleError() sets the error for which the training stops before the number of iterations is complete().
 void SetStoppingRuleIterations(int iterations)
          SetStoppingRuleIterations() sets the number of iterations to run during training.
 void SetTrainingSetMemory(int numObs, double[][] inputMatrix, double[][] expectedMatrix, double[][] predictedMatrix)
          SetInputTypeMemory() sets the training set input.
 void SetTrainingTypeAll()
          SetTrainingTypeAll() trains all non-fixed weights.
 void SetTrainingTypeLevel()
          SetTrainingTypeLevel() trains each all non-fixed weights at each level, starting at the outputs.
 void SetTrainingTypeNode()
          SetTrainingTypeNode() trains each all non-fixed weights coming in to each node, node by node.
 void SetTrainingTypeNodeRandom()
          SetTrainingTypeNodeRandom() trains each all non-fixed weights coming in to each node, node by node in a random order.
 void SetTrainingTypeRandom(int numWeights)
          SetTrainingTypeRandom() randomly selects "numWeights" number of non-fixed weights to train.
 void SetUpperBound(double upperBound)
          SetUpperBound() sets the upper bound of the weights.
 void Stop()
          Stop() stops the training.
 void Train()
          Train() trains the network based on the training parameters set.
 void WriteNetworkDefinition(java.lang.String filename)
          WriteNetworkDefinition() writes the network definition into a file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SECTION_VERSION

public static final int SECTION_VERSION
See Also:
Constant Field Values

SECTION_NUMLEVELS

public static final int SECTION_NUMLEVELS
See Also:
Constant Field Values

SECTION_NUMNODESATLEVEL

public static final int SECTION_NUMNODESATLEVEL
See Also:
Constant Field Values

SECTION_NODELEVEL

public static final int SECTION_NODELEVEL
See Also:
Constant Field Values

SECTION_ARCNODENODEWEIGHT

public static final int SECTION_ARCNODENODEWEIGHT
See Also:
Constant Field Values

SECTION_ACTIVATION

public static final int SECTION_ACTIVATION
See Also:
Constant Field Values

SECTION_EPOWER

public static final int SECTION_EPOWER
See Also:
Constant Field Values
Constructor Detail

COptNeuralNet

public COptNeuralNet()
Default Constructor.


COptNeuralNet

public COptNeuralNet(int license)
Method Detail

SetLicense

public void SetLicense(int license)

CreateAndAddInputNodes

public void CreateAndAddInputNodes(int numNodes)
                            throws COptNeuralNetException
CreateAndAddInputNodes() allows the user to add input nodes without creating the objects separately. The nodes use the default activation function and are at level 1.

Parameters:
numNodes - - the number of input nodes.
Throws:
COptNeuralNetException

CreateAndAddBiasNodes

public void CreateAndAddBiasNodes()
                           throws COptNeuralNetException
CreateAndAddBiasNodes() allows the user to add a bias node without creating the object separately. The node is at level 1.

Throws:
COptNeuralNetException

CreateAndAddHiddenNodes

public void CreateAndAddHiddenNodes(int numNodes,
                                    int level)
                             throws COptNeuralNetException
CreateAndAddHiddenNodes() allows the user to add hidden nodes without creating the objects separately. The nodes use the default activation function.

Parameters:
numNodes - - the number of hidden nodes.
level - - the level of hidden nodes.
Throws:
COptNeuralNetException

CreateAndAddOutputNodes

public void CreateAndAddOutputNodes(int numNodes,
                                    int level)
                             throws COptNeuralNetException
CreateAndAddOutputNodes() allows the user to add output nodes without creating the objects separately. The nodes use the default activation function.

Parameters:
numNodes - - the number of hidden nodes.
level - - the level of hidden nodes.
Throws:
COptNeuralNetException

FullyConnectNetwork

public void FullyConnectNetwork()
FullyConnectNetwork() allows the user to add fully connect the network without creating any arc objects.


AddInputNode

public void AddInputNode(COptNeuralNetNode node)
                  throws COptNeuralNetException
AddInputNode() adds an Input node to the OptQuest Neural Network. The node contains the information about the level, type, etc.

Parameters:
node - - the node to add to the network.
Throws:
COptNeuralNetException

AddHiddenNode

public void AddHiddenNode(COptNeuralNetNode node)
                   throws COptNeuralNetException
AddHiddenNode() adds a Hidden node to the OptQuest Neural Network. The node contains the information about the level, type, etc.

Parameters:
node - - the node to add to the network.
Throws:
COptNeuralNetException

AddOutputNode

public void AddOutputNode(COptNeuralNetNode node)
                   throws COptNeuralNetException
AddOutputNode() adds an Output node to the OptQuest Neural Network. The node contains the information about the level, type, etc.

Parameters:
node - - the node to add to the network.
Throws:
COptNeuralNetException

AddBiasNode

public void AddBiasNode(COptNeuralNetNode node)
                 throws COptNeuralNetException
AddBiasNode() adds a Bias node to the OptQuest Neural Network. The node contains the information about the level, type, etc.

Parameters:
node - - the node to add to the network.
Throws:
COptNeuralNetException

DeleteNode

public void DeleteNode(COptNeuralNetNode node)
DeleteNode() deletes a node from the OptQuest Neural Network.

Parameters:
node - - the node to remove from the network.

GetNumberOfInputs

public int GetNumberOfInputs()
GetNumberOfInputs() returns the number of input nodes in the network.


GetNumberOfOutputs

public int GetNumberOfOutputs()
GetNumberOfOutputs() returns the number of output nodes in the network.


GetNumberOfHidden

public int GetNumberOfHidden()
GetNumberOfHidden() returns the number of total hidden nodes in the network.


AddArc

public void AddArc(COptNeuralNetArc arc)
            throws COptNeuralNetException
AddArc() adds an arc to the OptQuest Neural Network. The arc contains the information about the from/to nodes and the weight.

Parameters:
arc - - the arc to add to the network.
Throws:
COptNeuralNetException

DeleteArc

public void DeleteArc(COptNeuralNetArc arc)
DeleteArc() deletes an arc from the OptQuest Neural Network.

Parameters:
arc - - the arc to delete from the network.

Predict

public void Predict(int numObs,
                    double[][] input,
                    double[][] predict)
             throws COptNeuralNetException
Predict() predicts the outputs from the supplied inputs.

Parameters:
numObs - - number of observations in the input matrix
input - - input matrix of input values. The first index is the observation (0 to numObs-1). The second index is the input node (1 to Number of Input Nodes). The order is the same as they were added to the network.
predict - - output matrix of predicted values. The first index is the observation (0 to numObs-1). The second index is the output node (1 to Number of Output Nodes). The order is the same as they were added to the network.
Throws:
COptNeuralNetException

Predict

public void Predict(double[] input,
                    double[] predict)
             throws COptNeuralNetException
Predict() predicts the outputs from the supplied inputs.

Parameters:
input - - input array of input values. The index is the input node (1 to Number of Input Nodes). The order is the same as they were added to the network.
predict - - output matrix of predicted values. The index is the output node (1 to Number of Output Nodes). The order is the same as they were added to the network.
Throws:
COptNeuralNetException

SetDefaultActivation

public void SetDefaultActivation(int useActivationFunction)
SetDefaultActivation() sets the default activation function for the OptQuest Neural Network.

Parameters:
useActivationFunction -
  • COptNeuralNetNode.SIGMOID01ACTIVATION. The network uses the [0,1] sigmoid function as the activation function.
  • COptNeuralNetNode.SIGMOIDNEG11ACTIVATION. The network uses the [-1,1] sigmoid function as the activation function.
  • COptNeuralNetNode.IDENTITYACTIVATION. The network uses the identity function as the activation function. No function is applied to the value.

SetEPower

public void SetEPower(double power)
SetEPower() sets the coefficient of the power for the sigmoid. Changing the power coefficient changes the slope of the sigmoid. Default value is 1.

Parameters:
power - - new power coefficient

GetEPower

public double GetEPower()
GetEPower() returns the coefficient of the power for the sigmoid.


SetOptimizePower

public void SetOptimizePower(double lowerbound,
                             double upperbound)
SetOptimizePower() indicates to optimize the power coefficient during training.

Parameters:
lowerbound - - lower bound of the power coefficient.
upperbound - - upper bound of the power coefficient.

ReadNetworkDefinition

public void ReadNetworkDefinition(java.lang.String filename)
                           throws COptNeuralNetException
ReadNetworkDefinition() reads the network definition from a file and creates the network from the information provided in the file.

Parameters:
filename - - filename containing the network definition.
Throws:
COptNeuralNetException

WriteNetworkDefinition

public void WriteNetworkDefinition(java.lang.String filename)
                            throws COptNeuralNetException
WriteNetworkDefinition() writes the network definition into a file. This file can later be read in via ReadNetworkDefinition() for predicting or for further training.

Parameters:
filename - - filename containing the network definition.
Throws:
COptNeuralNetException

Stop

public void Stop()
Stop() stops the training.


AddRandomWeights

public void AddRandomWeights()
                      throws COptQuestException
AddRandomWeights() sets the random values to all of the weights in the network.

Throws:
COptQuestException

Train

public void Train()
           throws COptNeuralNetException,
                  COptQuestException
Train() trains the network based on the training parameters set.

Throws:
COptNeuralNetException
COptQuestException

SetTrainingTypeRandom

public void SetTrainingTypeRandom(int numWeights)
SetTrainingTypeRandom() randomly selects "numWeights" number of non-fixed weights to train. Weights can be fixed by the user or by the use of regression.

Parameters:
numWeights -

SetTrainingTypeAll

public void SetTrainingTypeAll()
SetTrainingTypeAll() trains all non-fixed weights. Weights can be fixed by the user or by the use of regression.


SetTrainingTypeNode

public void SetTrainingTypeNode()
SetTrainingTypeNode() trains each all non-fixed weights coming in to each node, node by node. Weights can be fixed by the user or by the use of regression. If all weights coming into a node is fixed, that node is skipped.


SetTrainingTypeNodeRandom

public void SetTrainingTypeNodeRandom()
SetTrainingTypeNodeRandom() trains each all non-fixed weights coming in to each node, node by node in a random order. Weights can be fixed by the user or by the use of regression. If all weights coming into a node is fixed, that node is skipped.


SetTrainingTypeLevel

public void SetTrainingTypeLevel()
SetTrainingTypeLevel() trains each all non-fixed weights at each level, starting at the outputs. Weights can be fixed by the user or by the use of regression. If all weights at a level is fixed, that level is skipped.


SetStoppingRuleIterations

public void SetStoppingRuleIterations(int iterations)
SetStoppingRuleIterations() sets the number of iterations to run during training. If the training is by node or by level, this is the number of iterations at each node/level.

Parameters:
iterations - - number of iterations to run

SetRepeat

public void SetRepeat(int repeat)
SetRepeat() repeats the training for the given number of times (default = 1).

Parameters:
repeat -

GetNumberOfIterations

public int GetNumberOfIterations()
GetNumberOfIterations() returns the number of iterations set.

Returns:
number of iterations set.

SetTrainingSetMemory

public void SetTrainingSetMemory(int numObs,
                                 double[][] inputMatrix,
                                 double[][] expectedMatrix,
                                 double[][] predictedMatrix)
SetInputTypeMemory() sets the training set input.

Parameters:
numObs - - number of Observations in the input/outputs
inputMatrix - - matrix containing input values. First index is the observation (0 to numObs-1). Second index is the input values (1 to number of input nodes).
expectedMatrix - - matrix containing expected values. First index is the observation (0 to numObs-1). Second index is the output values (1 to number of output nodes).
predictedMatrix - - temporary matrix to place predicted values. First index is the observation (0 to numObs-1). Second index is the output values (1 to number of output nodes).

SetInputScale

public void SetInputScale()
SetInputScale() sets the scaling of the input to a [0,1] value based on the minimum/maximum values in the training set.


SetOutputScale

public void SetOutputScale()
SetOutputScale() sets the scaling of the output to a [0,1] value based on the minimum/maximum values in the training set.


SetRegressionForLastLevel

public void SetRegressionForLastLevel(boolean bUseRgr)
SetRegressionForLastLevel() sets whether or not to use linear regression for the arc weights coming into the output nodes.

Parameters:
bUseRgr - -true/false

MonitorStatus

public void MonitorStatus()
Monitor Status is used to monitor the progress of the training. GetIteration() can be called to get the current iteration. GetRepeat() can be called to get the current repeat. GetBestObjectiveValue() can be called to get the best objective so far.


GetRepeat

public int GetRepeat()
GetRepeat() gets the current repeat.

Returns:
repeat number from 1 to number of repeats.

GetIteration

public int GetIteration()
GetIteration() gets the current iteration.

Returns:
iteration number from 1 to number of iteration.

GetBestObjectiveValue

public double GetBestObjectiveValue()
GetBestObjectiveValue() gets the best objective so far.

Returns:
best objective so far.

SetUpperBound

public void SetUpperBound(double upperBound)
SetUpperBound() sets the upper bound of the weights.

Parameters:
upperBound - - upper bound of the weights.

SetLowerBound

public void SetLowerBound(double lowerBound)
SetLowerBound() sets the lower bound of the weights.

Parameters:
lowerBound - - lower bound of the weights.

SetMeanErrorPower

public void SetMeanErrorPower(double val)
SetMeanErrorPower() sets the power to which the absolute difference is raised when calculating the objective for the training.

Parameters:
val - - power

SetStoppingRuleError

public void SetStoppingRuleError(double val)
SetStoppingRuleError() sets the error for which the training stops before the number of iterations is complete().

Parameters:
val - - error to stop upon reaching