Class SimplexTableau
- java.lang.Object
-
- org.apache.commons.math3.optimization.linear.SimplexTableau
-
- All Implemented Interfaces:
java.io.Serializable
@Deprecated class SimplexTableau extends java.lang.Object implements java.io.SerializableDeprecated.As of 3.1 (to be removed in 4.0).A tableau for use in the Simplex method.Example:
W | Z | x1 | x2 | x- | s1 | s2 | a1 | RHS --------------------------------------------------- -1 0 0 0 0 0 0 1 0 <= phase 1 objective 0 1 -15 -10 0 0 0 0 0 <= phase 2 objective 0 0 1 0 0 1 0 0 2 <= constraint 1 0 0 0 1 0 0 1 0 3 <= constraint 2 0 0 1 1 0 0 0 1 4 <= constraint 3
W: Phase 1 objective function Z: Phase 2 objective function x1 & x2: Decision variables x-: Extra decision variable to allow for negative values s1 & s2: Slack/Surplus variables a1: Artificial variable RHS: Right hand side- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.String>columnLabelsDeprecated.The variables each column representsprivate java.util.List<LinearConstraint>constraintsDeprecated.Linear constraints.private static doubleCUTOFF_THRESHOLDDeprecated.The cut-off threshold to zero-out entries.private static intDEFAULT_ULPSDeprecated.Default amount of error to accept in floating point comparisons (as ulps).private doubleepsilonDeprecated.Amount of error to accept when checking for optimality.private LinearObjectiveFunctionfDeprecated.Linear objective function.private intmaxUlpsDeprecated.Amount of error to accept in floating point comparisons.private static java.lang.StringNEGATIVE_VAR_COLUMN_LABELDeprecated.Column label for negative vars.private intnumArtificialVariablesDeprecated.Number of artificial variables.private intnumDecisionVariablesDeprecated.Number of decision variables.private intnumSlackVariablesDeprecated.Number of slack variables.private booleanrestrictToNonNegativeDeprecated.Whether to restrict the variables to non-negative values.private static longserialVersionUIDDeprecated.Serializable version identifier.private RealMatrixtableauDeprecated.Simple tableau.
-
Constructor Summary
Constructors Constructor Description SimplexTableau(LinearObjectiveFunction f, java.util.Collection<LinearConstraint> constraints, GoalType goalType, boolean restrictToNonNegative, double epsilon)Deprecated.Build a tableau for a linear problem.SimplexTableau(LinearObjectiveFunction f, java.util.Collection<LinearConstraint> constraints, GoalType goalType, boolean restrictToNonNegative, double epsilon, int maxUlps)Deprecated.Build a tableau for a linear problem.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private voidcopyArray(double[] src, double[] dest)Deprecated.protected RealMatrixcreateTableau(boolean maximize)Deprecated.Create the tableau by itself.protected voiddivideRow(int dividendRow, double divisor)Deprecated.Subtracts a multiple of one row from another.protected voiddropPhase1Objective()Deprecated.Removes the phase 1 objective function, positive cost non-artificial variables, and the non-basic artificial variables from this tableau.booleanequals(java.lang.Object other)Deprecated.protected intgetArtificialVariableOffset()Deprecated.Get the offset of the first artificial variable.protected java.lang.IntegergetBasicRow(int col)Deprecated.Checks whether the given column is basic.private intgetConstraintTypeCounts(Relationship relationship)Deprecated.Get a count of constraints corresponding to a specified relationship.protected double[][]getData()Deprecated.Get the tableau data.protected doublegetEntry(int row, int column)Deprecated.Get an entry of the tableau.protected intgetHeight()Deprecated.Get the height of the tableau.protected static doublegetInvertedCoefficientSum(RealVector coefficients)Deprecated.Get the -1 times the sum of all coefficients in the given array.protected intgetNumArtificialVariables()Deprecated.Get the number of artificial variables.protected intgetNumDecisionVariables()Deprecated.Get the number of decision variables.protected intgetNumObjectiveFunctions()Deprecated.Get the number of objective functions in this tableau.protected intgetNumSlackVariables()Deprecated.Get the number of slack variables.protected intgetOriginalNumDecisionVariables()Deprecated.Get the original number of decision variables.protected intgetRhsOffset()Deprecated.Get the offset of the right hand side.protected intgetSlackVariableOffset()Deprecated.Get the offset of the first slack variable.protected PointValuePairgetSolution()Deprecated.Get the current solution.protected intgetWidth()Deprecated.Get the width of the tableau.inthashCode()Deprecated.protected voidinitializeColumnLabels()Deprecated.Initialize the labels for the columns.(package private) booleanisOptimal()Deprecated.Returns whether the problem is at an optimal state.private LinearConstraintnormalize(LinearConstraint constraint)Deprecated.Get a new equation equivalent to this one with a positive right hand side.java.util.List<LinearConstraint>normalizeConstraints(java.util.Collection<LinearConstraint> originalConstraints)Deprecated.Get new versions of the constraints which have positive right hand sides.private voidreadObject(java.io.ObjectInputStream ois)Deprecated.Deserialize the instance.protected voidsetEntry(int row, int column, double value)Deprecated.Set an entry of the tableau.protected voidsubtractRow(int minuendRow, int subtrahendRow, double multiple)Deprecated.Subtracts a multiple of one row from another.private voidwriteObject(java.io.ObjectOutputStream oos)Deprecated.Serialize the instance.
-
-
-
Field Detail
-
NEGATIVE_VAR_COLUMN_LABEL
private static final java.lang.String NEGATIVE_VAR_COLUMN_LABEL
Deprecated.Column label for negative vars.- See Also:
- Constant Field Values
-
DEFAULT_ULPS
private static final int DEFAULT_ULPS
Deprecated.Default amount of error to accept in floating point comparisons (as ulps).- See Also:
- Constant Field Values
-
CUTOFF_THRESHOLD
private static final double CUTOFF_THRESHOLD
Deprecated.The cut-off threshold to zero-out entries.- See Also:
- Constant Field Values
-
serialVersionUID
private static final long serialVersionUID
Deprecated.Serializable version identifier.- See Also:
- Constant Field Values
-
f
private final LinearObjectiveFunction f
Deprecated.Linear objective function.
-
constraints
private final java.util.List<LinearConstraint> constraints
Deprecated.Linear constraints.
-
restrictToNonNegative
private final boolean restrictToNonNegative
Deprecated.Whether to restrict the variables to non-negative values.
-
columnLabels
private final java.util.List<java.lang.String> columnLabels
Deprecated.The variables each column represents
-
tableau
private transient RealMatrix tableau
Deprecated.Simple tableau.
-
numDecisionVariables
private final int numDecisionVariables
Deprecated.Number of decision variables.
-
numSlackVariables
private final int numSlackVariables
Deprecated.Number of slack variables.
-
numArtificialVariables
private int numArtificialVariables
Deprecated.Number of artificial variables.
-
epsilon
private final double epsilon
Deprecated.Amount of error to accept when checking for optimality.
-
maxUlps
private final int maxUlps
Deprecated.Amount of error to accept in floating point comparisons.
-
-
Constructor Detail
-
SimplexTableau
SimplexTableau(LinearObjectiveFunction f, java.util.Collection<LinearConstraint> constraints, GoalType goalType, boolean restrictToNonNegative, double epsilon)
Deprecated.Build a tableau for a linear problem.- Parameters:
f- linear objective functionconstraints- linear constraintsgoalType- type of optimization goal: eitherGoalType.MAXIMIZEorGoalType.MINIMIZErestrictToNonNegative- whether to restrict the variables to non-negative valuesepsilon- amount of error to accept when checking for optimality
-
SimplexTableau
SimplexTableau(LinearObjectiveFunction f, java.util.Collection<LinearConstraint> constraints, GoalType goalType, boolean restrictToNonNegative, double epsilon, int maxUlps)
Deprecated.Build a tableau for a linear problem.- Parameters:
f- linear objective functionconstraints- linear constraintsgoalType- type of optimization goal: eitherGoalType.MAXIMIZEorGoalType.MINIMIZErestrictToNonNegative- whether to restrict the variables to non-negative valuesepsilon- amount of error to accept when checking for optimalitymaxUlps- amount of error to accept in floating point comparisons
-
-
Method Detail
-
initializeColumnLabels
protected void initializeColumnLabels()
Deprecated.Initialize the labels for the columns.
-
createTableau
protected RealMatrix createTableau(boolean maximize)
Deprecated.Create the tableau by itself.- Parameters:
maximize- if true, goal is to maximize the objective function- Returns:
- created tableau
-
normalizeConstraints
public java.util.List<LinearConstraint> normalizeConstraints(java.util.Collection<LinearConstraint> originalConstraints)
Deprecated.Get new versions of the constraints which have positive right hand sides.- Parameters:
originalConstraints- original (not normalized) constraints- Returns:
- new versions of the constraints
-
normalize
private LinearConstraint normalize(LinearConstraint constraint)
Deprecated.Get a new equation equivalent to this one with a positive right hand side.- Parameters:
constraint- reference constraint- Returns:
- new equation
-
getNumObjectiveFunctions
protected final int getNumObjectiveFunctions()
Deprecated.Get the number of objective functions in this tableau.- Returns:
- 2 for Phase 1. 1 for Phase 2.
-
getConstraintTypeCounts
private int getConstraintTypeCounts(Relationship relationship)
Deprecated.Get a count of constraints corresponding to a specified relationship.- Parameters:
relationship- relationship to count- Returns:
- number of constraint with the specified relationship
-
getInvertedCoefficientSum
protected static double getInvertedCoefficientSum(RealVector coefficients)
Deprecated.Get the -1 times the sum of all coefficients in the given array.- Parameters:
coefficients- coefficients to sum- Returns:
- the -1 times the sum of all coefficients in the given array.
-
getBasicRow
protected java.lang.Integer getBasicRow(int col)
Deprecated.Checks whether the given column is basic.- Parameters:
col- index of the column to check- Returns:
- the row that the variable is basic in. null if the column is not basic
-
dropPhase1Objective
protected void dropPhase1Objective()
Deprecated.Removes the phase 1 objective function, positive cost non-artificial variables, and the non-basic artificial variables from this tableau.
-
copyArray
private void copyArray(double[] src, double[] dest)Deprecated.- Parameters:
src- the source arraydest- the destination array
-
isOptimal
boolean isOptimal()
Deprecated.Returns whether the problem is at an optimal state.- Returns:
- whether the model has been solved
-
getSolution
protected PointValuePair getSolution()
Deprecated.Get the current solution.- Returns:
- current solution
-
divideRow
protected void divideRow(int dividendRow, double divisor)Deprecated.Subtracts a multiple of one row from another.After application of this operation, the following will hold:
minuendRow = minuendRow - multiple * subtrahendRow
- Parameters:
dividendRow- index of the rowdivisor- value of the divisor
-
subtractRow
protected void subtractRow(int minuendRow, int subtrahendRow, double multiple)Deprecated.Subtracts a multiple of one row from another.After application of this operation, the following will hold:
minuendRow = minuendRow - multiple * subtrahendRow
- Parameters:
minuendRow- row indexsubtrahendRow- row indexmultiple- multiplication factor
-
getWidth
protected final int getWidth()
Deprecated.Get the width of the tableau.- Returns:
- width of the tableau
-
getHeight
protected final int getHeight()
Deprecated.Get the height of the tableau.- Returns:
- height of the tableau
-
getEntry
protected final double getEntry(int row, int column)Deprecated.Get an entry of the tableau.- Parameters:
row- row indexcolumn- column index- Returns:
- entry at (row, column)
-
setEntry
protected final void setEntry(int row, int column, double value)Deprecated.Set an entry of the tableau.- Parameters:
row- row indexcolumn- column indexvalue- for the entry
-
getSlackVariableOffset
protected final int getSlackVariableOffset()
Deprecated.Get the offset of the first slack variable.- Returns:
- offset of the first slack variable
-
getArtificialVariableOffset
protected final int getArtificialVariableOffset()
Deprecated.Get the offset of the first artificial variable.- Returns:
- offset of the first artificial variable
-
getRhsOffset
protected final int getRhsOffset()
Deprecated.Get the offset of the right hand side.- Returns:
- offset of the right hand side
-
getNumDecisionVariables
protected final int getNumDecisionVariables()
Deprecated.Get the number of decision variables.If variables are not restricted to positive values, this will include 1 extra decision variable to represent the absolute value of the most negative variable.
- Returns:
- number of decision variables
- See Also:
getOriginalNumDecisionVariables()
-
getOriginalNumDecisionVariables
protected final int getOriginalNumDecisionVariables()
Deprecated.Get the original number of decision variables.- Returns:
- original number of decision variables
- See Also:
getNumDecisionVariables()
-
getNumSlackVariables
protected final int getNumSlackVariables()
Deprecated.Get the number of slack variables.- Returns:
- number of slack variables
-
getNumArtificialVariables
protected final int getNumArtificialVariables()
Deprecated.Get the number of artificial variables.- Returns:
- number of artificial variables
-
getData
protected final double[][] getData()
Deprecated.Get the tableau data.- Returns:
- tableau data
-
equals
public boolean equals(java.lang.Object other)
Deprecated.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Deprecated.- Overrides:
hashCodein classjava.lang.Object
-
writeObject
private void writeObject(java.io.ObjectOutputStream oos) throws java.io.IOExceptionDeprecated.Serialize the instance.- Parameters:
oos- stream where object should be written- Throws:
java.io.IOException- if object cannot be written to stream
-
readObject
private void readObject(java.io.ObjectInputStream ois) throws java.lang.ClassNotFoundException, java.io.IOExceptionDeprecated.Deserialize the instance.- Parameters:
ois- stream from which the object should be read- Throws:
java.lang.ClassNotFoundException- if a class in the stream cannot be foundjava.io.IOException- if object cannot be read from the stream
-
-