genopt.db
Class DiscreteParameter

java.lang.Object
  extended by genopt.db.IndependentParameter
      extended by genopt.db.DiscreteParameter
All Implemented Interfaces:
java.lang.Cloneable

public class DiscreteParameter
extends IndependentParameter

Object that represents a discrete parameter of the optimization process.

Meaning of field discreteType:

 0: string
 1: integer
 2: double

This project was carried out at:

and supported by

GenOpt Copyright (c) 1998-2011, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.

Version:
GenOpt(R) 3.1.0 (December 8, 2011)

Author:
Michael Wetter

Field Summary
protected  int dimension
          number of admissible elements
protected  int discreteType
          flag for native type of elements in values
0: string,
1: integer,
2: double
protected  int index
          current value of the parameter
protected  java.lang.String[] values
          set of admissible values
protected  double[] valuesNum
          set of admissible values.
 
Fields inherited from class genopt.db.IndependentParameter
name
 
Constructor Summary
DiscreteParameter()
          constructor.
DiscreteParameter(java.lang.String VariableName, int InitialValue, java.lang.String[] Values)
          Constructor for a discrete variable.
 
Method Summary
protected  java.lang.Object clone()
          Clone
 int getDiscreteType()
          Gets the discrete discreteType, as specified in DiscreteParameter.
 int getIndex()
          Gets the index that points to the currently selected value.
 double getValueDouble()
          Gets the double representation of the currently selected value.
 double getValueDouble(int ind)
          Gets the double representation of the element with index ind.
 java.lang.String getValueString()
          Gets the string representation of the currently selected value.
 java.lang.String getValueString(int ind)
          Gets the string representation of the element with index ind.
 int length()
          Gets the number of elements
 
Methods inherited from class genopt.db.IndependentParameter
getName
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

values

protected java.lang.String[] values
set of admissible values


valuesNum

protected double[] valuesNum
set of admissible values.
valuesNum is the double representation of values


dimension

protected int dimension
number of admissible elements


discreteType

protected int discreteType
flag for native type of elements in values
0: string,
1: integer,
2: double


index

protected int index
current value of the parameter

Constructor Detail

DiscreteParameter

public DiscreteParameter()
constructor. Does nothing


DiscreteParameter

public DiscreteParameter(java.lang.String VariableName,
                         int InitialValue,
                         java.lang.String[] Values)
Constructor for a discrete variable.

Parameters:
VariableName - Name of the free parameter as specified in the command file
InitialValue - Index of initial value of free parameter
Values - Set of admissible values
Method Detail

clone

protected java.lang.Object clone()
Clone

Overrides:
clone in class java.lang.Object

getIndex

public final int getIndex()
Gets the index that points to the currently selected value.

Returns:
index that points to the currently selected value.

length

public final int length()
Gets the number of elements

Returns:
the number of elements

getValueString

public final java.lang.String getValueString()
Gets the string representation of the currently selected value.

Returns:
the string representation of the currently selected value.

getValueString

public final java.lang.String getValueString(int ind)
Gets the string representation of the element with index ind.

Parameters:
ind - index of the element
Returns:
the string representation of the element with index ind

getValueDouble

public final double getValueDouble()
Gets the double representation of the currently selected value.
If the variable represents discrete numerical values, then the double value of the currently selected value is returned.
If the variable represents different string values, then the currently selected index is returned.

Returns:
the double representation of the currently selected value.

getValueDouble

public final double getValueDouble(int ind)
Gets the double representation of the element with index ind.
If the variable represents discrete numerical values, then the double value of the currently selected value is returned.
If the variable represents different string values, then the argument ind is returned.

Parameters:
ind - index of the element
Returns:
the double representation of the element with index ind

getDiscreteType

public int getDiscreteType()
Gets the discrete discreteType, as specified in DiscreteParameter.

Returns:
discreteType
0: string
1: integer
2: double