genopt.util
Class Assigner

java.lang.Object
  extended by genopt.util.Assigner

public class Assigner
extends java.lang.Object

Object to substitute references to variables by its numerical values.

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
private static java.lang.String LS
          System dependent line separator
 
Constructor Summary
Assigner()
           
 
Method Summary
static java.lang.String[] assign(java.lang.String[] keyWords, java.lang.String[] values)
          assigns to all keyWords its value by eliminating all references to a keyword with its value
private static void checkValidInput(int[][] p)
          checks for valid input syntax (cycles and references to itself are not allowed)
private static boolean[] getAssigned(int[][] p)
          gets an array which contains true at the i-th element if the 0-th element of the i-th row of p is equal to -1
private static int[][] getReferences(java.lang.String[] keyWords, java.lang.String[] values)
          gets all references to a keyWords
private static boolean isAllTrue(boolean[] b)
          checks whether all values of b are true
private static void updateValues(java.lang.String[] keyWords, java.lang.String[] values, int[][] p)
          updates the values by eliminating the keyWord references
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LS

private static final java.lang.String LS
System dependent line separator

Constructor Detail

Assigner

public Assigner()
Method Detail

assign

public static java.lang.String[] assign(java.lang.String[] keyWords,
                                        java.lang.String[] values)
                                 throws java.lang.IllegalArgumentException,
                                        java.lang.RuntimeException
assigns to all keyWords its value by eliminating all references to a keyword with its value

Parameters:
keyWords - the keyWords
values - the values of the keywords
Returns:
the values where no value has any reference to a keyWord
Throws:
java.lang.IllegalArgumentException
java.lang.RuntimeException

checkValidInput

private static void checkValidInput(int[][] p)
                             throws java.lang.IllegalArgumentException
checks for valid input syntax (cycles and references to itself are not allowed)

Throws:
java.lang.IllegalArgumentException - if variables cannot be assigned or if a reference to itself occurs

updateValues

private static void updateValues(java.lang.String[] keyWords,
                                 java.lang.String[] values,
                                 int[][] p)
updates the values by eliminating the keyWord references

Parameters:
keyWords - the keyWords
values - the values of the keywords
p - NxN array which has a number in each element that points to the keyWord which is referenced. If there is no reference, then the element is equal to -1

getAssigned

private static boolean[] getAssigned(int[][] p)
gets an array which contains true at the i-th element if the 0-th element of the i-th row of p is equal to -1

Parameters:
p - NxN array which has a -1 as the first element of the i-th column if there is no further assignement to the i-th variable
Returns:
array which contain true at the i-th element if the i-th element is not refered anywhere, falseotherwise

isAllTrue

private static boolean isAllTrue(boolean[] b)
checks whether all values of b are true

Parameters:
b - the array to be checked
Returns:
true if all elements are true, false otherwise

getReferences

private static int[][] getReferences(java.lang.String[] keyWords,
                                     java.lang.String[] values)
gets all references to a keyWords

Parameters:
keyWords - the keyWords
values - the values of the keywords
Returns:
a NxN matrix that contains in its i-th column all references to the i-th keyWords in values