- 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 classSimplexSolver.Direction(package private) static classSimplexSolver.EnterInfo(package private) static classSimplexSolver.ExitInfoExit fromSimplexStore.ColumnState.BASISto eitherSimplexStore.ColumnState.LOWERorSimplexStore.ColumnState.UPPER.(package private) static classSimplexSolver.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 SimplexStoremySimplexprivate double[]mySolutionShiftprivate doublemyValueShiftprivate static NumberContextPIVOTprivate static NumberContextRATIO-
Fields inherited from class org.ojalgo.optimisation.linear.LinearSolver
INTEGRATION, NEWER_DUAL_SOLVER, OLDER_PRIMAL_SOLVER
-
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) SimplexSolverbasis(int[] basis)(package private) static <S extends SimplexStore>
Sbuild(ExpressionsBasedModel model, java.util.function.Function<LinearStructure,S> factory)(package private) voiddoDualIterations(SimplexSolver.IterDescr iteration)(package private) voiddoPrimalIterations(SimplexSolver.IterDescr iteration)(package private) static Optimisation.ResultdoSolveConvexAsDual(ConvexData<java.lang.Double> convex, Optimisation.Options options, boolean zeroC)(package private) static Optimisation.ResultdoSolveConvexAsPrimal(ConvexData<java.lang.Double> convex, Optimisation.Options options, boolean zeroC)private Access1D<?>extractMultipliers()(package private) Optimisation.ResultextractResult()private double[]extractSolution()private doubleextractValue()booleanfixVariable(int index, double value)java.util.Collection<Equation>generateCutCandidates(double fractionality, boolean... integer)private booleangetDualExitCandidate(SimplexSolver.IterDescr iteration)LinearStructuregetEntityMap()private doublegetLowerBound(int index)private double[]getLowerBounds()private booleangetPrimalEnterCandidate(SimplexSolver.IterDescr iteration)private doublegetUpperBound(int index)private double[]getUpperBounds()(package private) booleanisDualFeasible()(package private) booleanisPrimalFeasible()private voidlogCurrentState()(package private) SimplexSolver.IterDescrprepareToIterate()(package private) abstract voidsetup(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) voidshift(int index, double shift, double weight)private doubleshift(int column, SimplexStore.ColumnState state)(package private) static intsizeOfDual(ConvexData<?> convex)(package private) static intsizeOfPrimal(ConvexData<?> convex)private Optimisation.ResultsolveUnconstrained()(package private) voidswitchToPhase2()private booleantestDualEnterRatio(SimplexSolver.IterDescr iteration)private booleantestPrimalExitRatio(SimplexSolver.IterDescr iteration)private voidupdate(SimplexSolver.IterDescr iteration)booleanupdateRange(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.private booleanverifyDualFeasibility()private booleanverifyPrimalFeasibility()-
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)
-
doSolveConvexAsDual
static Optimisation.Result doSolveConvexAsDual(ConvexData<java.lang.Double> convex, Optimisation.Options options, boolean zeroC)
-
doSolveConvexAsPrimal
static Optimisation.Result doSolveConvexAsPrimal(ConvexData<java.lang.Double> convex, Optimisation.Options options, boolean zeroC)
-
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()
-
updateRange
public boolean updateRange(int index, double lower, double upper)Description copied from interface:UpdatableSolverA 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 double 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)
-
verifyDualFeasibility
private boolean verifyDualFeasibility()
-
verifyPrimalFeasibility
private boolean verifyPrimalFeasibility()
-
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()
-
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()
-
-