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

java.lang.Object
  extended by org.apache.commons.math3.optim.linear.LinearObjectiveFunction
All Implemented Interfaces:
Serializable, MultivariateFunction, OptimizationData

public class LinearObjectiveFunction
extends Object
implements MultivariateFunction, OptimizationData, Serializable

An objective function for a linear optimization problem.

A linear objective function has one the form:

 c1x1 + ... cnxn + d
 
The ci and d are the coefficients of the equation, the xi are the coordinates of the current point.

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

Field Summary
private  RealVector coefficients
          Coefficients of the linear equation (ci).
private  double constantTerm
          Constant term of the linear equation.
private static long serialVersionUID
          Serializable version identifier.
 
Constructor Summary
LinearObjectiveFunction(double[] coefficients, double constantTerm)
           
LinearObjectiveFunction(RealVector coefficients, double constantTerm)
           
 
Method Summary
 boolean equals(Object other)
           
 RealVector getCoefficients()
          Gets the coefficients of the linear equation being optimized.
 double getConstantTerm()
          Gets the constant of the linear equation being optimized.
 int hashCode()
           
private  void readObject(ObjectInputStream ois)
          Deserialize the instance.
 double value(double[] point)
          Computes the value of the linear equation at the current point.
 double value(RealVector point)
          Computes the value of the linear equation at the current point.
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 linear equation (ci).


constantTerm

private final double constantTerm
Constant term of the linear equation.

Constructor Detail

LinearObjectiveFunction

public LinearObjectiveFunction(double[] coefficients,
                               double constantTerm)
Parameters:
coefficients - Coefficients for the linear equation being optimized.
constantTerm - Constant term of the linear equation.

LinearObjectiveFunction

public LinearObjectiveFunction(RealVector coefficients,
                               double constantTerm)
Parameters:
coefficients - Coefficients for the linear equation being optimized.
constantTerm - Constant term of the linear equation.
Method Detail

getCoefficients

public RealVector getCoefficients()
Gets the coefficients of the linear equation being optimized.

Returns:
coefficients of the linear equation being optimized.

getConstantTerm

public double getConstantTerm()
Gets the constant of the linear equation being optimized.

Returns:
constant of the linear equation being optimized.

value

public double value(double[] point)
Computes the value of the linear equation at the current point.

Specified by:
value in interface MultivariateFunction
Parameters:
point - Point at which linear equation must be evaluated.
Returns:
the value of the linear equation at the current point.

value

public double value(RealVector point)
Computes the value of the linear equation at the current point.

Parameters:
point - Point at which linear equation must be evaluated.
Returns:
the value of the linear equation at the current point.

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