scpsolver.constraints
Class LinearEqualsConstraint

java.lang.Object
  extended by scpsolver.constraints.LinearEqualsConstraint
All Implemented Interfaces:
Constraint, Convertable, LinearConstraint

public class LinearEqualsConstraint
extends java.lang.Object
implements LinearConstraint, Convertable


Constructor Summary
LinearEqualsConstraint(double[] pc, double t, java.lang.String name)
           
LinearEqualsConstraint(SparseVector c, double t, java.lang.String name)
           
 
Method Summary
 void addToLinearProgramSolver(LinearProgramSolver solver)
          Adds one line representing this constraint to the constraint matrix of a given solver.
 java.lang.StringBuffer convertToCPLEX()
          Creates a CPLEX description of the given instance.
 java.lang.StringBuffer convertToGMPL()
          Creates a GMPL description of the given instance.
 double[] getC()
          Returns the weight vector of this constraint.
 SparseVector getCSparse()
          Returns a sparse representation of the weight vector.
 java.lang.String getName()
          Returns the name of a specific constraint.
 double getRHS()
          Returns the right hand side.
 double getT()
          Returns the target value of this constraint.
 boolean isSatisfiedBy(double[] x)
          Evaluates the constraint at input value x and checks if the constraint holds.
 void setC(double[] pc)
           
 void setT(double t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearEqualsConstraint

public LinearEqualsConstraint(SparseVector c,
                              double t,
                              java.lang.String name)

LinearEqualsConstraint

public LinearEqualsConstraint(double[] pc,
                              double t,
                              java.lang.String name)
Method Detail

setC

public void setC(double[] pc)

getC

public double[] getC()
Description copied from interface: LinearConstraint
Returns the weight vector of this constraint.

For easier constraint manipulation, SCPSolver saves not one big constraint matrix as the formal description of a linear problem suggests, but creates a line for line representation of this matrix. Therefore, a formal description of this vector is the i-th line of A, if this constraint is the i-th constraint.

Specified by:
getC in interface LinearConstraint
Returns:
the weight vector of this constraint

getT

public double getT()
Description copied from interface: LinearConstraint
Returns the target value of this constraint.

Specified by:
getT in interface LinearConstraint
Returns:
the t

setT

public void setT(double t)
Parameters:
t - the t to set

getName

public java.lang.String getName()
Description copied from interface: Constraint
Returns the name of a specific constraint.

When creating a new constraint for a problem, a name can be given to this constraint to identify it later and see, which specific constrains hold and maybe which contradict each other.

Please note: unlike Problem, where the name describes the type of problem instead of the actual instance, here the name the describes the actual instance and not the generic type.

Specified by:
getName in interface Constraint
Returns:

isSatisfiedBy

public boolean isSatisfiedBy(double[] x)
Description copied from interface: Constraint
Evaluates the constraint at input value x and checks if the constraint holds. Returns true if input x satisfies the constraint, false otherwise. The input dimension (i.e. the array.length), must be the same as the target function.

Specified by:
isSatisfiedBy in interface Constraint
Parameters:
x - the position, where the constraint is to be evaluated
Returns:
true if input value x satisfies this constraint, false otherwise

addToLinearProgramSolver

public void addToLinearProgramSolver(LinearProgramSolver solver)
Description copied from interface: LinearConstraint
Adds one line representing this constraint to the constraint matrix of a given solver.

Specified by:
addToLinearProgramSolver in interface LinearConstraint
Parameters:
solver - an instance of a linear program solver

convertToCPLEX

public java.lang.StringBuffer convertToCPLEX()
Description copied from interface: Convertable
Creates a CPLEX description of the given instance.

Specified by:
convertToCPLEX in interface Convertable
Returns:
a CPLEX description of the given instance

convertToGMPL

public java.lang.StringBuffer convertToGMPL()
Description copied from interface: Convertable
Creates a GMPL description of the given instance.

Specified by:
convertToGMPL in interface Convertable
Returns:
a GMPL description of the given instance

getCSparse

public SparseVector getCSparse()
Description copied from interface: LinearConstraint
Returns a sparse representation of the weight vector.

Specified by:
getCSparse in interface LinearConstraint
Returns:
a sparse representation of the weight vector
See Also:
getC

getRHS

public double getRHS()
Description copied from interface: Constraint
Returns the right hand side.

Specified by:
getRHS in interface Constraint
Returns:
right hand side