Class LinearObjectiveFunction
java.lang.Object
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 + dThe ci and d are the coefficients of the equation, the xi are the coordinates of the current point.
- Since:
- 2.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RealVector
Coefficients of the linear equation (ci).private final double
Constant term of the linear equation.private static final long
Serializable version identifier. -
Constructor Summary
ConstructorsConstructorDescriptionLinearObjectiveFunction
(double[] coefficients, double constantTerm) LinearObjectiveFunction
(RealVector coefficients, double constantTerm) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Gets the coefficients of the linear equation being optimized.double
Gets the constant of the linear equation being optimized.int
hashCode()
private void
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
Serialize the instance.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerializable version identifier.- See Also:
-
coefficients
Coefficients of the linear equation (ci). -
constantTerm
private final double constantTermConstant term of the linear equation.
-
-
Constructor Details
-
LinearObjectiveFunction
public LinearObjectiveFunction(double[] coefficients, double constantTerm) - Parameters:
coefficients
- Coefficients for the linear equation being optimized.constantTerm
- Constant term of the linear equation.
-
LinearObjectiveFunction
- Parameters:
coefficients
- Coefficients for the linear equation being optimized.constantTerm
- Constant term of the linear equation.
-
-
Method Details
-
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 interfaceMultivariateFunction
- Parameters:
point
- Point at which linear equation must be evaluated.- Returns:
- the value of the linear equation at the current point.
-
value
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
-
hashCode
public int hashCode() -
writeObject
Serialize the instance.- Parameters:
oos
- stream where object should be written- Throws:
IOException
- if object cannot be written to stream
-
readObject
Deserialize the instance.- Parameters:
ois
- stream from which the object should be read- Throws:
ClassNotFoundException
- if a class in the stream cannot be foundIOException
- if object cannot be read from the stream
-