org.optimizationservices.oscommon.util
Class CommonUtil

java.lang.Object
  extended by org.optimizationservices.oscommon.util.CommonUtil

public class CommonUtil
extends java.lang.Object

The CommonUtil class contains methods for performing common basic operations used by many classes in the Optimization Services (OS) framework.

Since:
OS1.0
Version:
1.0, 03/14/2004
Author:
Robert Fourer, Jun Ma, Kipp Martin

Constructor Summary
CommonUtil()
          Constructor.
 
Method Summary
static boolean checkOSRepository()
          check the OSRepository from the information given in OSRepository.xml and print out relevant information.
static java.util.GregorianCalendar createNativeDateTime(long timeMillis)
          create the native dateTime from a the timeMillis, which is the millisecond since 1/1/1970.
static boolean createOSRepository()
          Create the OSRepository from the information given in OSRepository.xml.
static java.lang.String getJobID(java.lang.String option)
           
static boolean isNegativeInfinity(java.lang.String numberString)
          Check whether a number string is negative infinity or not, including the following (case insensitive): -infinity, -inf,
static boolean isPostiveInfinity(java.lang.String numberString)
          Check whether a number string is positive infinity or not, including the following (case insensitive): infinity, inf,
static void main(java.lang.String[] argv)
          main for test purposes.
static boolean mpsToOSiL(java.lang.String mpsFileName, java.lang.String osilFileName, java.lang.String instanceName, java.lang.String instanceSource, java.lang.String instanceDescription)
          Write the sparse coefficient matrix related elements in an OSiL xml file.
static java.util.Vector<java.lang.String> stringToVector(java.lang.String string, java.lang.String delimiters)
          Converts a delimited string to a vector.
static boolean[] vectorToBolArray(java.util.Vector v)
          Converts a vector of boolean to a boolean array.
static char[] vectorToChaArray(java.util.Vector v)
          Converts a vector of characters to a character array.
static double[] vectorToDblArray(java.util.Vector v)
          Converts a vector of doubles to a double array.
static int[] vectorToIntArray(java.util.Vector v)
          Converts a vector of integers to an integer array.
static java.lang.String[] vectorToStrArray(java.util.Vector v)
          Converts a vector of strings to a string array.
static java.lang.String vectorToString(java.util.Vector vector, char delimiter)
          Converts a vector to a string, delimited by a specified delimiter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonUtil

public CommonUtil()
Constructor.

Method Detail

getJobID

public static java.lang.String getJobID(java.lang.String option)

vectorToIntArray

public static int[] vectorToIntArray(java.util.Vector v)
Converts a vector of integers to an integer array.

Parameters:
v - The vector to be converted.
Returns:
an integer array.

vectorToDblArray

public static double[] vectorToDblArray(java.util.Vector v)
Converts a vector of doubles to a double array.

Parameters:
v - the vector to be converted.
Returns:
a double array.

vectorToStrArray

public static java.lang.String[] vectorToStrArray(java.util.Vector v)
Converts a vector of strings to a string array.

Parameters:
v - the vector to be converted.
Returns:
a string array.

vectorToBolArray

public static boolean[] vectorToBolArray(java.util.Vector v)
Converts a vector of boolean to a boolean array.

Parameters:
v - the vector to be converted.
Returns:
a boolean array.

vectorToChaArray

public static char[] vectorToChaArray(java.util.Vector v)
Converts a vector of characters to a character array.

Parameters:
v - the vector to be converted.
Returns:
a character array.

stringToVector

public static java.util.Vector<java.lang.String> stringToVector(java.lang.String string,
                                                                java.lang.String delimiters)
Converts a delimited string to a vector.

Parameters:
string - holds the string to be converted to a vector.
delimiter - holds the delimiters of the string.
Returns:
the vector converted from the string

vectorToString

public static java.lang.String vectorToString(java.util.Vector vector,
                                              char delimiter)
Converts a vector to a string, delimited by a specified delimiter.

Parameters:
vector - holds the vector to be converted to a string.
delimiter - holds the delimiter character to put in the converted string.
Returns:

isPostiveInfinity

public static boolean isPostiveInfinity(java.lang.String numberString)
Check whether a number string is positive infinity or not, including the following (case insensitive): infinity, inf,

Parameters:
numberString - holds the number string to be checked.
Returns:
whether a number string is postive infinity or not.

isNegativeInfinity

public static boolean isNegativeInfinity(java.lang.String numberString)
Check whether a number string is negative infinity or not, including the following (case insensitive): -infinity, -inf,

Parameters:
numberString - holds the number string to be checked.
Returns:
whether a number string is negative infinity or not.

checkOSRepository

public static boolean checkOSRepository()
check the OSRepository from the information given in OSRepository.xml and print out relevant information.

Returns:
whether the OSRepository is checked successfully or not.

createOSRepository

public static boolean createOSRepository()
Create the OSRepository from the information given in OSRepository.xml.

Returns:
whether the OSRepository is created successfully or not.

mpsToOSiL

public static boolean mpsToOSiL(java.lang.String mpsFileName,
                                java.lang.String osilFileName,
                                java.lang.String instanceName,
                                java.lang.String instanceSource,
                                java.lang.String instanceDescription)
Write the sparse coefficient matrix related elements in an OSiL xml file.

The coefMatrix (AMatrix) stores all the information in the A part of Ax ~ b, i.e. the linear part of all constraints

Parameters:
isColumnMajor - holds the value of whether the coefMatrix (AMatrix) holding linear constraint data is stored by column. If false, the matrix is stored by row.
nonzeroValues - holds the values of the vector element value in coefMatrix (AMatrix), which contains nonzero elements.
nonzeroIndexes - holds the values of the vector element rowIdx or colIdx in coefMatrix (AMatrix). If the matrix is stored by column (row), rowIdx (colIdx) is the vector of row (column) indexes.
startIndexes - holds the values of the vector element start in coefMatrix (AMatrix), which points to the start of a column (row) of nonzero elements in coefMatrix (AMatrix).
mpsFileName - holds the name of the file to be written to. The path is fixed at the xml folder of the impact project.
name -
source -
description -
Returns:
whether user wants to clear the arrays passed in to save memory if the arrays will still be referenced, a false value is to be returned.

createNativeDateTime

public static java.util.GregorianCalendar createNativeDateTime(long timeMillis)
create the native dateTime from a the timeMillis, which is the millisecond since 1/1/1970.

Parameters:
timeMillis - holds the time represented in milliseconds since 1/1/1970.
Returns:
the converted native dateTime (Gregorian Calendar).

main

public static void main(java.lang.String[] argv)
main for test purposes.

Parameters:
argv - command line arguments.