Package org.ojalgo.optimisation.linear
Class SimplexTableauSolver
- java.lang.Object
-
- org.ojalgo.optimisation.GenericSolver
-
- org.ojalgo.optimisation.linear.LinearSolver
-
- org.ojalgo.optimisation.linear.SimplexTableauSolver
-
- All Implemented Interfaces:
Optimisation
,Optimisation.Solver
,UpdatableSolver
final class SimplexTableauSolver extends LinearSolver
Classic simplex tableau solver:- Primal algorithm
- 2-phase
- All variables assumed >=0, and RHS required to be >=0
- Variable bounds other than >=0 handled like constraints
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
SimplexTableauSolver.IterationPoint
-
Nested classes/interfaces inherited from class org.ojalgo.optimisation.linear.LinearSolver
LinearSolver.Builder, LinearSolver.Configuration, LinearSolver.ModelIntegration, LinearSolver.NewIntegration, LinearSolver.OldIntegration
-
Nested classes/interfaces inherited from interface org.ojalgo.optimisation.Optimisation
Optimisation.Constraint, Optimisation.ConstraintType, Optimisation.Integration<M extends Optimisation.Model,S extends Optimisation.Solver>, Optimisation.Model, Optimisation.Objective, Optimisation.Options, Optimisation.ProblemStructure, Optimisation.Result, Optimisation.Sense, Optimisation.Solver, Optimisation.State
-
-
Field Summary
Fields Modifier and Type Field Description private static NumberContext
ACC
private static NumberContext
DEGENERATE
private LongToNumberMap<java.lang.Double>
myFixedVariables
private SimplexTableauSolver.IterationPoint
myPoint
private SimplexTableau
myTableau
private static NumberContext
PHASE1
private static NumberContext
PIVOT
private static NumberContext
RATIO
private static NumberContext
WEIGHT
-
Fields inherited from class org.ojalgo.optimisation.linear.LinearSolver
INTEGRATION, NEW_INTEGRATION, OLD_INTEGRATION
-
Fields inherited from class org.ojalgo.optimisation.GenericSolver
options
-
-
Constructor Summary
Constructors Constructor Description SimplexTableauSolver(SimplexTableau tableau, Optimisation.Options solverOptions)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static <T extends SimplexTableau>
Tbuild(ExpressionsBasedModel model, java.util.function.Function<LinearStructure,T> factory)
(package private) static SimplexTableau
buildDual(ConvexData<java.lang.Double> convex, Optimisation.Options options, boolean checkFeasibility)
(package private) static SimplexTableau
buildPrimal(ConvexData<java.lang.Double> convex, Optimisation.Options options, boolean checkFeasibility)
protected Optimisation.Result
buildResult()
private void
cleanUpPhase1Artificials()
https://math.stackexchange.com/questions/3254444/artificial-variables-in-two-phase-simplex-method(package private) static Optimisation.Result
doSolveDual(ConvexData<java.lang.Double> convex, Optimisation.Options options, boolean zeroC)
(package private) static Optimisation.Result
doSolvePrimal(ConvexData<java.lang.Double> convex, Optimisation.Options options, boolean zeroC)
protected double
evaluateFunction(Access1D<?> solution)
protected Access1D<?>
extractMultipliers()
protected Access1D<?>
extractSolution()
Extract solution MatrixStore from the tableau.(package private) int
findNextPivotCol()
(package private) int
findNextPivotRow()
boolean
fixVariable(int index, double value)
java.util.Collection<Equation>
generateCutCandidates(double fractionality, boolean... integer)
LinearStructure
getEntityMap()
private int
getRowObjective()
private double
infeasibility()
protected boolean
initialise(Optimisation.Result kickStarter)
private boolean
isTableauPrintable()
private void
logDebugTableau(java.lang.String message)
protected boolean
needsAnotherIteration()
(package private) void
performIteration(SimplexTableauSolver.IterationPoint pivot)
private int
phase()
(package private) static void
set(ExpressionsBasedModel model, Primitive2D constraintsBdy, int indCnstr, int basePosVars, int baseNegVars, Variable variable, double factor)
(package private) static void
set(ExpressionsBasedModel model, Primitive2D constraintsBdy, int indCnstr, int basePosVars, int baseNegVars, Structure1D.IntIndex key, double factor)
(package private) static int
sizeOfDual(ConvexData<?> convex)
(package private) static int
sizeOfPrimal(ConvexData<?> convex)
Optimisation.Result
solve(Optimisation.Result kickStarter)
private static Optimisation.Result
toConvexStateFromDual(Optimisation.Result result, ConvexData<java.lang.Double> convex)
private static Optimisation.Result
toConvexStateFromPrimal(Optimisation.Result result, ConvexData<java.lang.Double> convex)
boolean
updateRange(int index, double lower, double upper)
A generalisation ofUpdatableSolver.fixVariable(int, double)
where the new/updated lower and upper bounds do not need to be equal.protected boolean
validate()
private double
value()
-
Methods inherited from class org.ojalgo.optimisation.linear.LinearSolver
newBuilder, newBuilder, newGeneralBuilder, newGeneralBuilder, newSolver, newStandardBuilder, newStandardBuilder, solve, toObjectiveFunction
-
Methods inherited from class org.ojalgo.optimisation.GenericSolver
countIterations, countTime, error, getClassSimpleName, getDuration, getState, incrementIterationsCount, isIterationAllowed, isLogDebug, isLogOff, isLogProgress, log, log, log, log, logProgress, resetIterationsCount, setState, setValidator, validate, validate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ojalgo.optimisation.Optimisation.Solver
dispose, solve
-
Methods inherited from interface org.ojalgo.optimisation.UpdatableSolver
integers, isMapped
-
-
-
-
Field Detail
-
ACC
private static final NumberContext ACC
-
DEGENERATE
private static final NumberContext DEGENERATE
-
PHASE1
private static final NumberContext PHASE1
-
PIVOT
private static final NumberContext PIVOT
-
RATIO
private static final NumberContext RATIO
-
WEIGHT
private static final NumberContext WEIGHT
-
myFixedVariables
private LongToNumberMap<java.lang.Double> myFixedVariables
-
myPoint
private final SimplexTableauSolver.IterationPoint myPoint
-
myTableau
private final SimplexTableau myTableau
-
-
Constructor Detail
-
SimplexTableauSolver
SimplexTableauSolver(SimplexTableau tableau, Optimisation.Options solverOptions)
-
-
Method Detail
-
toConvexStateFromDual
private static Optimisation.Result toConvexStateFromDual(Optimisation.Result result, ConvexData<java.lang.Double> convex)
-
toConvexStateFromPrimal
private static Optimisation.Result toConvexStateFromPrimal(Optimisation.Result result, ConvexData<java.lang.Double> convex)
-
build
static <T extends SimplexTableau> T build(ExpressionsBasedModel model, java.util.function.Function<LinearStructure,T> factory)
-
buildDual
static SimplexTableau buildDual(ConvexData<java.lang.Double> convex, Optimisation.Options options, boolean checkFeasibility)
-
buildPrimal
static SimplexTableau buildPrimal(ConvexData<java.lang.Double> convex, Optimisation.Options options, boolean checkFeasibility)
-
doSolveDual
static Optimisation.Result doSolveDual(ConvexData<java.lang.Double> convex, Optimisation.Options options, boolean zeroC)
-
doSolvePrimal
static Optimisation.Result doSolvePrimal(ConvexData<java.lang.Double> convex, Optimisation.Options options, boolean zeroC)
-
set
static void set(ExpressionsBasedModel model, Primitive2D constraintsBdy, int indCnstr, int basePosVars, int baseNegVars, Structure1D.IntIndex key, double factor)
-
set
static void set(ExpressionsBasedModel model, Primitive2D constraintsBdy, int indCnstr, int basePosVars, int baseNegVars, Variable variable, double factor)
-
sizeOfDual
static int sizeOfDual(ConvexData<?> convex)
-
sizeOfPrimal
static int sizeOfPrimal(ConvexData<?> convex)
-
fixVariable
public boolean fixVariable(int index, double value)
- Parameters:
index
- The, solver specific, variable indexvalue
- The value to fix that variable to- Returns:
- true if fixing is supported and was successful, otherwise false
-
generateCutCandidates
public final java.util.Collection<Equation> generateCutCandidates(double fractionality, boolean... integer)
-
getEntityMap
public LinearStructure getEntityMap()
-
solve
public Optimisation.Result solve(Optimisation.Result kickStarter)
-
updateRange
public boolean updateRange(int index, double lower, double upper)
Description copied from interface:UpdatableSolver
A generalisation ofUpdatableSolver.fixVariable(int, double)
where the new/updated lower and upper bounds do not need to be equal.- Parameters:
index
- The, solver specific, variable indexlower
- New lower boundupper
- New upper bound- Returns:
- true if updating the range is supported and was successful, otherwise false
-
cleanUpPhase1Artificials
private void cleanUpPhase1Artificials()
https://math.stackexchange.com/questions/3254444/artificial-variables-in-two-phase-simplex-method
-
getRowObjective
private int getRowObjective()
-
infeasibility
private double infeasibility()
-
isTableauPrintable
private boolean isTableauPrintable()
-
logDebugTableau
private void logDebugTableau(java.lang.String message)
-
phase
private int phase()
-
value
private double value()
-
buildResult
protected Optimisation.Result buildResult()
-
evaluateFunction
protected double evaluateFunction(Access1D<?> solution)
-
extractMultipliers
protected Access1D<?> extractMultipliers()
-
extractSolution
protected Access1D<?> extractSolution()
Extract solution MatrixStore from the tableau. Should be able to feed this toevaluateFunction(Access1D)
.
-
initialise
protected boolean initialise(Optimisation.Result kickStarter)
-
needsAnotherIteration
protected boolean needsAnotherIteration()
-
validate
protected boolean validate()
-
findNextPivotCol
int findNextPivotCol()
-
findNextPivotRow
int findNextPivotRow()
-
performIteration
void performIteration(SimplexTableauSolver.IterationPoint pivot)
-
-