Package org.ojalgo.optimisation.linear
Class SimplexSolver
- java.lang.Object
-
- org.ojalgo.optimisation.GenericSolver
-
- org.ojalgo.optimisation.linear.LinearSolver
-
- org.ojalgo.optimisation.linear.SimplexSolver
-
- All Implemented Interfaces:
Optimisation
,Optimisation.Solver
,UpdatableSolver
- Direct Known Subclasses:
DualSimplexSolver
,PhasedSimplexSolver
,PrimalSimplexSolver
abstract class SimplexSolver extends LinearSolver
Meant to replaceSimplexTableauSolver
. It is already better in many aspects, but still can't do everything required to fully replace the old solver.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
SimplexSolver.Direction
(package private) static class
SimplexSolver.EnterInfo
(package private) static class
SimplexSolver.ExitInfo
Exit fromSimplexStore.ColumnState.BASIS
to eitherSimplexStore.ColumnState.LOWER
orSimplexStore.ColumnState.UPPER
.(package private) static class
SimplexSolver.IterDescr
-
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 SimplexStore
mySimplex
private double[]
mySolutionShift
private double
myValueShift
private static NumberContext
PIVOT
private static NumberContext
RATIO
-
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 SimplexSolver(Optimisation.Options solverOptions, SimplexStore simplexStore)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) SimplexSolver
basis(int[] basis)
(package private) static <S extends SimplexStore>
Sbuild(ExpressionsBasedModel model, java.util.function.Function<LinearStructure,S> factory)
(package private) void
doDualIterations(SimplexSolver.IterDescr iteration)
(package private) void
doPrimalIterations(SimplexSolver.IterDescr iteration)
private Access1D<?>
extractMultipliers()
(package private) Optimisation.Result
extractResult()
private double[]
extractSolution()
private double
extractValue()
boolean
fixVariable(int index, double value)
java.util.Collection<Equation>
generateCutCandidates(double fractionality, boolean... integer)
private boolean
getDualExitCandidate(SimplexSolver.IterDescr iteration)
LinearStructure
getEntityMap()
private double
getLowerBound(int index)
private double[]
getLowerBounds()
private boolean
getPrimalEnterCandidate(SimplexSolver.IterDescr iteration)
private double
getUpperBound(int index)
private double[]
getUpperBounds()
(package private) void
initiatePhase1()
(package private) boolean
isDualFeasible()
(package private) boolean
isPrimalFeasible()
private void
logCurrentState()
(package private) SimplexSolver.IterDescr
prepareToIterate()
(package private) abstract void
setup(SimplexStore simplex)
Determine if non-basic variables are at their lower or upper bound (or if they are unbounded) Shift ranges/bounds so that (one of) the bound(s) is at zero Assumes that the ranges/bounds of basic variables are already defined this way.(package private) void
shift(int index, double shift, double weight)
private void
shift(int column, SimplexStore.ColumnState state)
private Optimisation.Result
solveUnconstrained()
(package private) void
switchToPhase2()
private boolean
testDualEnterRatio(SimplexSolver.IterDescr iteration)
private boolean
testPrimalExitRatio(SimplexSolver.IterDescr iteration)
private void
update(SimplexSolver.IterDescr iteration)
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.-
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, solve
-
Methods inherited from interface org.ojalgo.optimisation.UpdatableSolver
integers, isMapped
-
-
-
-
Field Detail
-
PIVOT
private static final NumberContext PIVOT
-
RATIO
private static final NumberContext RATIO
-
mySimplex
private final SimplexStore mySimplex
-
mySolutionShift
private final double[] mySolutionShift
-
myValueShift
private double myValueShift
-
-
Constructor Detail
-
SimplexSolver
SimplexSolver(Optimisation.Options solverOptions, SimplexStore simplexStore)
-
-
Method Detail
-
build
static <S extends SimplexStore> S build(ExpressionsBasedModel model, java.util.function.Function<LinearStructure,S> factory)
-
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()
-
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
-
extractMultipliers
private Access1D<?> extractMultipliers()
-
extractSolution
private double[] extractSolution()
-
extractValue
private double extractValue()
-
getDualExitCandidate
private boolean getDualExitCandidate(SimplexSolver.IterDescr iteration)
-
getLowerBound
private double getLowerBound(int index)
-
getLowerBounds
private double[] getLowerBounds()
-
getPrimalEnterCandidate
private boolean getPrimalEnterCandidate(SimplexSolver.IterDescr iteration)
-
getUpperBound
private double getUpperBound(int index)
-
getUpperBounds
private double[] getUpperBounds()
-
logCurrentState
private void logCurrentState()
-
shift
private void shift(int column, SimplexStore.ColumnState state)
-
solveUnconstrained
private Optimisation.Result solveUnconstrained()
-
testDualEnterRatio
private boolean testDualEnterRatio(SimplexSolver.IterDescr iteration)
-
testPrimalExitRatio
private boolean testPrimalExitRatio(SimplexSolver.IterDescr iteration)
-
update
private void update(SimplexSolver.IterDescr iteration)
-
basis
final SimplexSolver basis(int[] basis)
-
doDualIterations
final void doDualIterations(SimplexSolver.IterDescr iteration)
-
doPrimalIterations
final void doPrimalIterations(SimplexSolver.IterDescr iteration)
-
extractResult
final Optimisation.Result extractResult()
-
initiatePhase1
final void initiatePhase1()
-
isDualFeasible
final boolean isDualFeasible()
-
isPrimalFeasible
final boolean isPrimalFeasible()
-
prepareToIterate
final SimplexSolver.IterDescr prepareToIterate()
-
setup
abstract void setup(SimplexStore simplex)
- Determine if non-basic variables are at their lower or upper bound (or if they are unbounded)
- Shift ranges/bounds so that (one of) the bound(s) is at zero
- Assumes that the ranges/bounds of basic variables are already defined this way.
-
shift
final void shift(int index, double shift, double weight)
-
switchToPhase2
void switchToPhase2()
-
-