public class Point extends java.lang.Object implements java.lang.Comparable<Point>
The discrete parameters are stored as zero-based indices.
This class has methods to get for each discrete parameter its value
as a Gray coded binary int[]
arrays.
This project was carried out at:
and supported byGenOpt Copyright (c) 1998-2021, 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.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
com
the point's comment
|
protected double[] |
cooCon
the point's continuous coordinates
|
protected int[] |
cooDis
the point's discrete coordinates
|
protected int[] |
cooDisBitLength
the length of the binary string representation
|
protected int[] |
cooDisMax
the maximum allowed value for the point's discrete coordinates.
|
protected int |
dimCon
the number of continuous independent variables
|
protected int |
dimDis
the number of discrete independent variables
|
protected int |
dimF
the dimension of the function value vector
|
static double |
EPSILON
Accuracy for testing of rounding errors
|
protected double[] |
fun
the point's function values
|
static double |
ONEMINUSEPSILON |
static double |
ONEPLUSEPSILON |
protected int |
simNum
the number of the simulation corresponding to this point
|
protected int |
steNum
the point's step number
|
Constructor and Description |
---|
Point(double[] xCon,
double[] f,
int stepNumber,
java.lang.String comment)
Constructor for a point with only continuous independent variables
|
Point(double[] xCon,
int[] xDis,
double[] f,
int stepNumber,
java.lang.String comment)
Constructor for a point with continuous and discrete
independent variables
|
Point(double[] xCon,
int[] xDis,
int[] xDisMax,
double[] f,
int stepNumber,
java.lang.String comment,
int simulationNumber)
Constructor for a point with continuous and discrete
independent variables
|
Point(int[] xDis,
double[] f,
int stepNumber,
java.lang.String comment)
Constructor for a point with only discrete independent variables
|
Point(int nCon,
int nDis,
int nF)
Constructor
|
Modifier and Type | Method and Description |
---|---|
private void |
_initialize(int nCon,
int nDis,
int nF)
Allocates all arrays.
|
protected static boolean |
areEqual(double x1,
double x2)
Compares two numbers for equality.
|
java.lang.Object |
clone()
Clones the object.
|
int |
compare(Point o1,
Point o2)
Compares two objects for equality,
whereas only the x-coordinates in (
float precision),
the index of the discrete variables,
and the step number are compared. |
int |
compareTo(Point pt)
Compares this object with the specified object for equality,
whereas only the x-coordinates in (
float precision),
the index of the discrete variables,
and the step number are compared. |
boolean |
equals(Point o)
Compares this object with the specified object for equality,
whereas only the x-coordinates in (
float precision),
the index of the discrete variables,
and the step number are compared. |
java.lang.String |
getComment()
Gets the point's comment
|
int |
getDimensionContinuous()
Gets the number of continuous coordinates
|
int |
getDimensionDiscrete()
Gets the number of discrete coordinates
|
int |
getDimensionF()
Gets the dimension of the points function value vector
|
double[] |
getF()
Gets the point's function values
|
double |
getF(int i)
Gets the point's function values
|
int[] |
getGrayBinaryString(int index)
Gets the value of a discrete variable encoded as a binary string
using Gray encoding.
|
int |
getGrayBinaryStringLength(int index)
Gets the string length used to represent the maximum value of the parameter
as a Gray coded binary string.
|
int[] |
getIndex()
Gets the indices of the discrete point's
|
int |
getIndex(int i)
Gets the i-th point's index
|
int[] |
getMaximumIndex()
Gets the maximum allowed value of the indices of the discrete point's
|
int |
getSimulationNumber()
Gets the simulation number
|
int |
getStepNumber()
Gets the point's step number
|
double[] |
getX()
Gets the point's continuous independent variables
|
double |
getX(int i)
Gets the point's i-th continuous coordinate
|
static void |
main(java.lang.String[] args) |
void |
set(double[] x,
double[] f,
int stepNumber,
java.lang.String comment)
Sets a point with only continuous independent variables
|
void |
set(double[] xCon,
int[] xDis,
double[] f,
int stepNumber,
java.lang.String comment)
Sets a point with continuous and discrete independent variables
|
void |
set(double[] xCon,
int[] xDis,
int[] xDisMax,
double[] f,
int stepNumber,
java.lang.String comment)
Sets a point with continuous and discrete independent variables
|
void |
set(double[] x,
int stepNumber,
java.lang.String comment)
Sets a point with only continuous independent variables
|
void |
set(int[] x,
double[] f,
int stepNumber,
java.lang.String comment)
Sets a point with only discrete independent variables
|
void |
set(int[] x,
int stepNumber,
java.lang.String comment)
Sets a point with only discrete independent variables
|
void |
setComment(java.lang.String comment)
Sets a comment
|
void |
setF(double[] f)
Sets a point's function value
|
void |
setF(int i,
double f)
Sets a point's function value
|
void |
setGrayBinaryString(int index,
int[] graBinStr)
Sets the value of a discrete variable as a Gray encoded binary string.
|
void |
setIndex(int[] x)
Sets the indices of the point's discrete variables
|
void |
setIndex(int[] xDis,
int[] xDisMax)
Sets the indices of the point's discrete variables and its maximum allowed values
|
void |
setIndex(int i,
int ind)
Sets the index of the point's i-th discrete variables
|
void |
setMaximumIndex(int i,
int max)
Sets the maximum value for the index of the
point's i-th discrete variables.
|
void |
setSimulationNumber(int simulationNumber)
Sets a the simulation number
|
void |
setStepNumber(int stepNumber)
Sets a the step number
|
void |
setX(double[] x)
Sets the point's continuous coordinates
|
void |
setX(int i,
double x)
Sets the i-th continuous independent variable
|
void |
setX(int variableNumber,
int index)
Deprecated.
replaced by
setIndex(int, int) |
void |
setXIndex(double[] xCon,
int[] xDis)
Sets the point's discrete and continuous coordinates
|
java.lang.String |
toString()
Returns a string representation of the object.
|
public static double EPSILON
public static double ONEMINUSEPSILON
public static double ONEPLUSEPSILON
protected double[] cooCon
protected int[] cooDis
protected int[] cooDisMax
protected int[] cooDisBitLength
protected double[] fun
protected java.lang.String com
protected int steNum
protected int dimCon
protected int dimDis
protected int dimF
protected int simNum
public Point(int nCon, int nDis, int nF)
nCon
- number of continuous variablesnDis
- number of discrete variablesnF
- number of function valuespublic Point(int[] xDis, double[] f, int stepNumber, java.lang.String comment)
xDis
- the point's discrete coordinatesf
- its function valuesstepNumber
- the step numbercomment
- a commentpublic Point(double[] xCon, double[] f, int stepNumber, java.lang.String comment)
xCon
- the point's continuous coordinatesf
- its function valuesstepNumber
- the step numbercomment
- a commentpublic Point(double[] xCon, int[] xDis, double[] f, int stepNumber, java.lang.String comment)
xCon
- the point's continuous coordinatesxDis
- the point's discrete coordinatesf
- its function valuesstepNumber
- the step numbercomment
- a commentpublic Point(double[] xCon, int[] xDis, int[] xDisMax, double[] f, int stepNumber, java.lang.String comment, int simulationNumber)
xCon
- the point's continuous coordinatesxDis
- the point's discrete coordinatesxDisMax
- the point's maximum value of the discrete coordinatesf
- its function valuesstepNumber
- the step numbercomment
- a commentsimulationNumber
- the number of the simulationjava.lang.IllegalArgumentException
- if xDis
and xDisMax
are not null
but of different lengthprivate void _initialize(int nCon, int nDis, int nF)
nCon
- number of continuous variablesnDis
- number of discrete variablesnF
- number of function valuespublic java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public double[] getF()
public double getF(int i)
i
- the index of the function valuepublic double[] getX()
public int[] getIndex()
public int[] getMaximumIndex()
public double getX(int i)
i
- the index of the continuous coordinatepublic int getIndex(int i)
i
- the number of the discrete variablepublic int getDimensionContinuous()
public int getDimensionDiscrete()
public int getDimensionF()
public int getStepNumber()
public java.lang.String getComment()
public void setX(double[] x)
x
- the point's continuous coordinatespublic void setIndex(int[] x) throws java.lang.IllegalArgumentException
x
- the indices of the point's discrete variablesjava.lang.IllegalArgumentException
- if an element is negative, or
an element is larger than the maximum allowed value, or
the length of the argument is different from the one allocated
by this objectpublic void setIndex(int[] xDis, int[] xDisMax)
xDis
- the indices of the point's discrete variablesxDisMax
- the maximum allowed value for the indices of the point's discrete variablesjava.lang.IllegalArgumentException
- if an element is negative, or
an element is larger than the maximum allowed value, or
the array lengths are differentpublic void setIndex(int i, int ind) throws java.lang.IllegalArgumentException
i
- number of discrete variableind
- index of the point's i-th discrete variablesjava.lang.IllegalArgumentException
- if the argument is negative or
larger than the maximum allowed valuepublic void setXIndex(double[] xCon, int[] xDis) throws java.lang.IllegalArgumentException
xCon
- the point's continuous coordinatesxDis
- the point's discrete coordinatesjava.lang.IllegalArgumentException
- if an element is negative, or
an element is larger than the maximum allowed value, or
the length of the argument is different from the one allocated
by this objectpublic void setX(int i, double x)
i
- the zero-based index of the continuous independent variablex
- value to be setpublic void setX(int variableNumber, int index)
setIndex(int, int)
variableNumber
- the zero-based index of the discrete independent
variableindex
- the index of the variablejava.lang.IllegalArgumentException
- if the argument is negative or
larger than the maximum allowed valuepublic void setF(int i, double f)
i
- the index of the function valuef
- points function valuepublic void setF(double[] f)
f
- a points function valuepublic void setStepNumber(int stepNumber)
stepNumber
- the step numberpublic void setSimulationNumber(int simulationNumber)
simulationNumber
- the number of the simulationpublic int getSimulationNumber()
public void setComment(java.lang.String comment)
comment
- the commentpublic void set(double[] x, double[] f, int stepNumber, java.lang.String comment) throws java.lang.IllegalArgumentException
x
- the point's continuous coordinatesf
- its function valuesstepNumber
- its step numbercomment
- its commentjava.lang.IllegalArgumentException
- if an element of x
is negative, or is larger than the maximum allowed value, or
the length of the argument is different from the one allocated
by this objectpublic void set(int[] x, double[] f, int stepNumber, java.lang.String comment) throws java.lang.IllegalArgumentException
x
- the point's discrete coordinatesf
- its function valuesstepNumber
- its step numbercomment
- its commentjava.lang.IllegalArgumentException
- if an element of x
is negative, or is larger than the maximum allowed value, or
the length of the argument is different from the one allocated
by this objectpublic void set(double[] xCon, int[] xDis, double[] f, int stepNumber, java.lang.String comment) throws java.lang.IllegalArgumentException
xCon
- the point's continuous coordinatesxDis
- the point's discrete coordinatesf
- its function valuesstepNumber
- its step numbercomment
- its commentjava.lang.IllegalArgumentException
- if an element of xDis
is negative, or is larger than the maximum allowed value, or
the length of the argument is different from the one allocated
by this objectpublic void set(double[] xCon, int[] xDis, int[] xDisMax, double[] f, int stepNumber, java.lang.String comment) throws java.lang.IllegalArgumentException
xCon
- the point's continuous coordinatesxDis
- the point's discrete coordinatesxDisMax
- the point's maximum value for the discrete coordinatesf
- its function valuesstepNumber
- its step numbercomment
- its commentjava.lang.IllegalArgumentException
- if an element of xDis
is negative, or is larger than the maximum allowed value, or
the length of the argument is different from the one allocated
by this objectpublic void set(double[] x, int stepNumber, java.lang.String comment)
x
- the point's continuous coordinatesstepNumber
- its step numbercomment
- its commentpublic void set(int[] x, int stepNumber, java.lang.String comment) throws java.lang.IllegalArgumentException
x
- the point's discrete coordinatesstepNumber
- its step numbercomment
- its commentjava.lang.IllegalArgumentException
- if an element of x
is negative, or is larger than the maximum allowed value, or
the length of the argument is different from the one allocated
by this objectpublic int compareTo(Point pt)
float
precision),
the index of the discrete variables,
and the step number are compared.compareTo
in interface java.lang.Comparable<Point>
0
if the objects are equal,
-1
if the received object is the smaller one
+1
if the received object is the larger oneprotected static boolean areEqual(double x1, double x2)
x1
- first numberx2
- second numbertrue
if the numbers are equal except
for rounding errorspublic boolean equals(Point o)
float
precision),
the index of the discrete variables,
and the step number are compared.o
- Object to be comparedtrue
if the objects are equal
in the sense of the compareTo(Object)
method,
false
otherwisepublic int compare(Point o1, Point o2)
float
precision),
the index of the discrete variables,
and the step number are compared.o1
- Object to be comparedo2
- Object to be compared0
if the objects are equal,
-1
if o1 < o2,
+1
if o1 < o2,
in the sense of the compareTo(Object)
methodpublic void setMaximumIndex(int i, int max) throws java.lang.IllegalArgumentException
i
- index of discrete variablemax
- maximum value of the point's i-th discrete variablesjava.lang.IllegalArgumentException
- if max < 0
public int getGrayBinaryStringLength(int index) throws java.lang.IllegalArgumentException
index
- index of the discrete variablejava.lang.IllegalArgumentException
- if the maximum value has not been set for
this variablepublic int[] getGrayBinaryString(int index)
index
- index of the discrete variablepublic void setGrayBinaryString(int index, int[] graBinStr)
graBinStr
represent a larger value than the maximum
allowed value for this variable, then the variable value will be set
to its maximum value.index
- index of the discrete variablegraBinStr
- the value of the discrete variable as a Gray encoded binary stringjava.lang.IllegalArgumentException
- if no maximum is set for this variablepublic static void main(java.lang.String[] args)