# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.qp.lp.problem

## Class LPProblemImpl1

• java.lang.Object
• com.numericalmethod.suanshu.optimization.multivariate.constrained.convex.sdp.socp.qp.lp.problem.LPProblemImpl1
• All Implemented Interfaces:
LPProblem, ConstrainedOptimProblem, OptimProblem
Direct Known Subclasses:
LPCanonicalProblem1, LPCanonicalProblem2, LPStandardProblem

public class LPProblemImpl1
extends Object
implements LPProblem
This is an implementation of a linear programming problem, LPProblem. For convenient construction, this implementation allows all forms of linear constraints:
• greater-than-or-equal-to constraints: Agr * x ≥ bgr
• less-than-or-equal-to constraints: Ale * x ≤ ble
• equality constraints: Aeq * x = beq
• box constraints (bounds): l ≤ x ≤ u
By convention, if no bound is mentioned for a variable, x ≥ 0.
• ### Constructor Summary

Constructors
Constructor and Description
LPProblemImpl1(Vector cost, LinearGreaterThanConstraints greater, LinearEqualityConstraints equal)
Construct a general linear programming problem with only greater-than-or-equal-to and equality constraints.
LPProblemImpl1(Vector cost, LinearGreaterThanConstraints greater, LinearLessThanConstraints less, LinearEqualityConstraints equal, BoxConstraints bounds)
Construct a general linear programming problem.
• ### Method Summary

All Methods
Modifier and Type Method and Description
ImmutableMatrix A()
Get the coefficients, A, of the greater-than-or-equal-to constraints A * x ≥ b.
ImmutableMatrix Aeq()
Get the coefficients, Aeq, of the equality constraints Aeq * x ≥ beq.
ImmutableVector b()
Get the values, b, of the greater-than-or-equal-to constraints A * x ≥ b.
ImmutableVector beq()
Get the values, beq, of the equality constraints Aeq * x ≥ beq.
ImmutableVector c()
Get the objective function.
int dimension()
Get the number of variables.
RealScalarFunction f()
Get the objective function.
LinearEqualityConstraints getEqualityConstraints()
Gets the equality constraints, hi(x) = 0
LinearLessThanConstraints getLessThanConstraints()
Gets the less-than-or-equal-to constraints, gi(x) ≤ 0
boolean isFree(int i)
Check whether xi is a free variable after handling the box constraints.
int nEqualities()
Get the number of equality constraints.
int nGreaterThanInequalities()
Get the number of greater-than-or-equal-to constraints.
String toString()
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
• ### Constructor Detail

• #### LPProblemImpl1

public LPProblemImpl1(Vector cost,
LinearGreaterThanConstraints greater,
LinearLessThanConstraints less,
LinearEqualityConstraints equal,
BoxConstraints bounds)
Construct a general linear programming problem.
Parameters:
cost - the objective function
greater - the greater-than-or-equal-to inequality constraints
less - the less-than-or-equal-to inequality constraints
equal - the equality constraints
bounds - the bounds for variables
• #### LPProblemImpl1

public LPProblemImpl1(Vector cost,
LinearGreaterThanConstraints greater,
LinearEqualityConstraints equal)
Construct a general linear programming problem with only greater-than-or-equal-to and equality constraints.
Parameters:
cost - the objective function
greater - the greater-than-or-equal-to inequality constraints
equal - the equality constraints
• ### Method Detail

• #### nGreaterThanInequalities

public int nGreaterThanInequalities()
Get the number of greater-than-or-equal-to constraints.
Returns:
the number of greater-than-or-equal-to inequalities
• #### nEqualities

public int nEqualities()
Get the number of equality constraints.
Returns:
the number of equality constraints
• #### dimension

public int dimension()
Description copied from interface: OptimProblem
Get the number of variables.
Specified by:
dimension in interface OptimProblem
Returns:
the number of variables.
• #### f

public RealScalarFunction f()
Description copied from interface: OptimProblem
Get the objective function.
Specified by:
f in interface OptimProblem
Returns:
the objective function
• #### getLessThanConstraints

public LinearLessThanConstraints getLessThanConstraints()
Description copied from interface: ConstrainedOptimProblem
Gets the less-than-or-equal-to constraints, gi(x) ≤ 0
Specified by:
getLessThanConstraints in interface ConstrainedOptimProblem
Returns:
the less-than-or-equal-to constraints
• #### getEqualityConstraints

public LinearEqualityConstraints getEqualityConstraints()
Description copied from interface: ConstrainedOptimProblem
Gets the equality constraints, hi(x) = 0
Specified by:
getEqualityConstraints in interface ConstrainedOptimProblem
Returns:
the equality constraints
• #### c

public ImmutableVector c()
Description copied from interface: LPProblem
Get the objective function.
Specified by:
c in interface LPProblem
Returns:
the objective function
• #### A

public ImmutableMatrix A()
Description copied from interface: LPProblem
Get the coefficients, A, of the greater-than-or-equal-to constraints A * x ≥ b.
Specified by:
A in interface LPProblem
Returns:
the coefficients of the greater-than-or-equal-to constraints
• #### b

public ImmutableVector b()
Description copied from interface: LPProblem
Get the values, b, of the greater-than-or-equal-to constraints A * x ≥ b.
Specified by:
b in interface LPProblem
Returns:
the values of the greater-than-or-equal-to constraints
• #### Aeq

public ImmutableMatrix Aeq()
Description copied from interface: LPProblem
Get the coefficients, Aeq, of the equality constraints Aeq * x ≥ beq.
Specified by:
Aeq in interface LPProblem
Returns:
the coefficients of the equality constraints
• #### beq

public ImmutableVector beq()
Description copied from interface: LPProblem
Get the values, beq, of the equality constraints Aeq * x ≥ beq.
Specified by:
beq in interface LPProblem
Returns:
the values of the equality constraints
• #### isFree

public boolean isFree(int i)
Description copied from interface: LPProblem
Check whether xi is a free variable after handling the box constraints.
Specified by:
isFree in interface LPProblem
Parameters:
i - the index of a variable, counting from 1
Returns:
true if xi is free
• #### toString

public String toString()
Overrides:
toString in class Object