org.apache.commons.math3.optim.linear
Class LinearConstraint

java.lang.Object
  extended by org.apache.commons.math3.optim.linear.LinearConstraint
All Implemented Interfaces:
Serializable

public class LinearConstraint
extends Object
implements Serializable

A linear constraint for a linear optimization problem.

A linear constraint has one of the forms:

The ci, li or ri are the coefficients of the constraints, the xi are the coordinates of the current point and v is the value of the constraint.

Since:
2.0
Version:
$Id: LinearConstraint.java 1435539 2013-01-19 13:27:24Z tn $
See Also:
Serialized Form

Field Summary
private  RealVector coefficients
          Coefficients of the constraint (left hand side).
private  Relationship relationship
          Relationship between left and right hand sides (=, <=, >=).
private static long serialVersionUID
          Serializable version identifier.
private  double value
          Value of the constraint (right hand side).
 
Constructor Summary
LinearConstraint(double[] lhsCoefficients, double lhsConstant, Relationship relationship, double[] rhsCoefficients, double rhsConstant)
          Build a constraint involving two linear equations.
LinearConstraint(double[] coefficients, Relationship relationship, double value)
          Build a constraint involving a single linear equation.
LinearConstraint(RealVector lhsCoefficients, double lhsConstant, Relationship relationship, RealVector rhsCoefficients, double rhsConstant)
          Build a constraint involving two linear equations.
LinearConstraint(RealVector coefficients, Relationship relationship, double value)
          Build a constraint involving a single linear equation.
 
Method Summary
 boolean equals(Object other)
           
 RealVector getCoefficients()
          Gets the coefficients of the constraint (left hand side).
 Relationship getRelationship()
          Gets the relationship between left and right hand sides.
 double getValue()
          Gets the value of the constraint (right hand side).
 int hashCode()
           
private  void readObject(ObjectInputStream ois)
          Deserialize the instance.
private  void writeObject(ObjectOutputStream oos)
          Serialize the instance.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serializable version identifier.

See Also:
Constant Field Values

coefficients

private final transient RealVector coefficients
Coefficients of the constraint (left hand side).


relationship

private final Relationship relationship
Relationship between left and right hand sides (=, <=, >=).


value

private final double value
Value of the constraint (right hand side).

Constructor Detail

LinearConstraint

public LinearConstraint(double[] coefficients,
                        Relationship relationship,
                        double value)
Build a constraint involving a single linear equation.

A linear constraint with a single linear equation has one of the forms:

Parameters:
coefficients - The coefficients of the constraint (left hand side)
relationship - The type of (in)equality used in the constraint
value - The value of the constraint (right hand side)

LinearConstraint

public LinearConstraint(RealVector coefficients,
                        Relationship relationship,
                        double value)
Build a constraint involving a single linear equation.

A linear constraint with a single linear equation has one of the forms:

Parameters:
coefficients - The coefficients of the constraint (left hand side)
relationship - The type of (in)equality used in the constraint
value - The value of the constraint (right hand side)

LinearConstraint

public LinearConstraint(double[] lhsCoefficients,
                        double lhsConstant,
                        Relationship relationship,
                        double[] rhsCoefficients,
                        double rhsConstant)
Build a constraint involving two linear equations.

A linear constraint with two linear equation has one of the forms:

Parameters:
lhsCoefficients - The coefficients of the linear expression on the left hand side of the constraint
lhsConstant - The constant term of the linear expression on the left hand side of the constraint
relationship - The type of (in)equality used in the constraint
rhsCoefficients - The coefficients of the linear expression on the right hand side of the constraint
rhsConstant - The constant term of the linear expression on the right hand side of the constraint

LinearConstraint

public LinearConstraint(RealVector lhsCoefficients,
                        double lhsConstant,
                        Relationship relationship,
                        RealVector rhsCoefficients,
                        double rhsConstant)
Build a constraint involving two linear equations.

A linear constraint with two linear equation has one of the forms:

Parameters:
lhsCoefficients - The coefficients of the linear expression on the left hand side of the constraint
lhsConstant - The constant term of the linear expression on the left hand side of the constraint
relationship - The type of (in)equality used in the constraint
rhsCoefficients - The coefficients of the linear expression on the right hand side of the constraint
rhsConstant - The constant term of the linear expression on the right hand side of the constraint
Method Detail

getCoefficients

public RealVector getCoefficients()
Gets the coefficients of the constraint (left hand side).

Returns:
the coefficients of the constraint (left hand side).

getRelationship

public Relationship getRelationship()
Gets the relationship between left and right hand sides.

Returns:
the relationship between left and right hand sides.

getValue

public double getValue()
Gets the value of the constraint (right hand side).

Returns:
the value of the constraint (right hand side).

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

writeObject

private void writeObject(ObjectOutputStream oos)
                  throws IOException
Serialize the instance.

Parameters:
oos - stream where object should be written
Throws:
IOException - if object cannot be written to stream

readObject

private void readObject(ObjectInputStream ois)
                 throws ClassNotFoundException,
                        IOException
Deserialize the instance.

Parameters:
ois - stream from which the object should be read
Throws:
ClassNotFoundException - if a class in the stream cannot be found
IOException - if object cannot be read from the stream


Copyright (c) 2003-2013 Apache Software Foundation