org.akutan.optimization
Class Constraint

java.lang.Object
  extended by org.akutan.optimization.Constraint

public class Constraint
extends java.lang.Object

Base class for linear optimization constraints

Since:

Nested Class Summary
static class Constraint.Type
           
 
Constructor Summary
Constraint(cern.colt.matrix.DoubleMatrix1D coefficients, double rhs, Constraint.Type type)
          Constructs a generalized constraint
 
Method Summary
 double get(int i)
          Return the coefficient from the constraint for asset (i)
 cern.colt.matrix.DoubleMatrix1D getCoefficients()
          Return the vector of coefficients from the constraint
 double getRhs()
          Returns the constant
 Constraint.Type getType()
          Returns the type of constraint
static Constraint.Type getTypeFromString(java.lang.String s)
          Converts a String into a constraint type
static java.lang.String getTypeString(Constraint.Type type)
          Returns the type of constraint as a String
 java.lang.String getVarId(int i)
          Builds up a string of characters to identify the variable
static cern.colt.matrix.DoubleMatrix1D makeCoefficients(int n)
          Builds a coefficient matrix with increasing values equal to the cell index in each cell
 java.lang.String toString()
          Return the Constraint formatted as a String for debugging
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Constraint

public Constraint(cern.colt.matrix.DoubleMatrix1D coefficients,
                  double rhs,
                  Constraint.Type type)
Constructs a generalized constraint

Parameters:
coefficients -
rhs -
type -
Method Detail

makeCoefficients

public static cern.colt.matrix.DoubleMatrix1D makeCoefficients(int n)
Builds a coefficient matrix with increasing values equal to the cell index in each cell

Parameters:
n -
Returns:
Matrix of coefficients for the constraint

getRhs

public double getRhs()
Returns the constant

Returns:

getType

public Constraint.Type getType()
Returns the type of constraint

Returns:

getTypeString

public static java.lang.String getTypeString(Constraint.Type type)
Returns the type of constraint as a String

Parameters:
type - Type of constraint as an enum
Returns:
Sring name for type of constraint

getTypeFromString

public static Constraint.Type getTypeFromString(java.lang.String s)
Converts a String into a constraint type

Parameters:
s - Input String which is turned into a conatraint type
Returns:
Returns the constraint type enum

getCoefficients

public cern.colt.matrix.DoubleMatrix1D getCoefficients()
Return the vector of coefficients from the constraint

Returns:
Vector of coefficientd

get

public double get(int i)
Return the coefficient from the constraint for asset (i)

Parameters:
i - Index which identifies which asset is selected.
Returns:
The specific constraint for asset (i)

getVarId

public java.lang.String getVarId(int i)
Builds up a string of characters to identify the variable

Parameters:
i - Index of variable
Returns:
Name of variable

toString

public java.lang.String toString()
Return the Constraint formatted as a String for debugging

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()