Package org.ojalgo.optimisation
Class GenericSolver
- java.lang.Object
-
- org.ojalgo.optimisation.GenericSolver
-
- All Implemented Interfaces:
Optimisation
,Optimisation.Solver
- Direct Known Subclasses:
ConvexSolver
,GomorySolver
,IntegerSolver
,LinearSolver
public abstract class GenericSolver extends java.lang.Object implements Optimisation.Solver
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GenericSolver.Builder<B extends GenericSolver.Builder<B,S>,S extends GenericSolver>
-
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 java.lang.String
myClassSimpleName
private java.util.concurrent.atomic.AtomicInteger
myIterationsCount
private Optimisation.State
myState
private Stopwatch
myStopwatch
private ExpressionsBasedModel.Validator
myValidator
Optimisation.Options
options
-
Constructor Summary
Constructors Modifier Constructor Description private
GenericSolver()
protected
GenericSolver(Optimisation.Options optimisationOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
countIterations()
protected long
countTime()
The number of ms since solver instantiated or iterations count reset.protected void
error(java.lang.String messagePattern, java.lang.Object... arguments)
protected java.lang.String
getClassSimpleName()
protected CalendarDateDuration
getDuration()
The number of s since solver instantiated or iterations count reset.protected Optimisation.State
getState()
protected int
incrementIterationsCount()
Should be called after a completed iteration.protected boolean
isIterationAllowed()
Should be called at the start of an iteration (before it actually starts) to check if you should abort instead.protected boolean
isLogDebug()
Detailed debug loggingprotected boolean
isLogOff()
No loggingprotected boolean
isLogProgress()
Cursory progress logging (at least)protected void
log()
protected void
log(int tabs, java.lang.String messagePattern, java.lang.Object... arguments)
protected void
log(java.lang.String messagePattern, java.lang.Object... arguments)
protected void
log(java.lang.String descripttion, Access2D<?> matrix)
protected void
logProgress(int iterationsDone, java.lang.String classSimpleName, CalendarDateDuration duration)
protected void
resetIterationsCount()
protected void
setState(Optimisation.State state)
As the solver algorithm reaches various states it should be recorded here.protected void
setValidator(ExpressionsBasedModel.Validator validator)
Optionally set a validator.protected boolean
validate(ExpressionsBasedModel modifiedModel)
protected boolean
validate(Access1D<?> solverSolution)
-
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
-
-
-
-
Field Detail
-
options
public final Optimisation.Options options
-
myClassSimpleName
private transient java.lang.String myClassSimpleName
-
myIterationsCount
private final java.util.concurrent.atomic.AtomicInteger myIterationsCount
-
myState
private Optimisation.State myState
-
myStopwatch
private final Stopwatch myStopwatch
-
myValidator
private ExpressionsBasedModel.Validator myValidator
-
-
Constructor Detail
-
GenericSolver
private GenericSolver()
-
GenericSolver
protected GenericSolver(Optimisation.Options optimisationOptions)
-
-
Method Detail
-
countIterations
protected final int countIterations()
-
countTime
protected final long countTime()
The number of ms since solver instantiated or iterations count reset.
-
error
protected final void error(java.lang.String messagePattern, java.lang.Object... arguments)
-
getClassSimpleName
protected final java.lang.String getClassSimpleName()
-
getDuration
protected final CalendarDateDuration getDuration()
The number of s since solver instantiated or iterations count reset.
-
getState
protected Optimisation.State getState()
-
incrementIterationsCount
protected final int incrementIterationsCount()
Should be called after a completed iteration. The iterations count is not "1" untill the first iteration is completed.
-
isIterationAllowed
protected final boolean isIterationAllowed()
Should be called at the start of an iteration (before it actually starts) to check if you should abort instead. Will return false if either the iterations count or the execution time has reached their respective limits.
-
isLogDebug
protected final boolean isLogDebug()
Detailed debug logging
-
isLogOff
protected final boolean isLogOff()
No logging
-
isLogProgress
protected final boolean isLogProgress()
Cursory progress logging (at least)
-
log
protected final void log()
-
log
protected final void log(int tabs, java.lang.String messagePattern, java.lang.Object... arguments)
-
log
protected final void log(java.lang.String descripttion, Access2D<?> matrix)
-
log
protected final void log(java.lang.String messagePattern, java.lang.Object... arguments)
-
logProgress
protected void logProgress(int iterationsDone, java.lang.String classSimpleName, CalendarDateDuration duration)
-
resetIterationsCount
protected final void resetIterationsCount()
-
setState
protected final void setState(Optimisation.State state)
As the solver algorithm reaches various states it should be recorded here. It's particularly important to record when a feasible solution has been reached.
-
setValidator
protected final void setValidator(ExpressionsBasedModel.Validator validator)
Optionally set a validator. If set, solvers may callvalidate(Access1D)
orvalidate(ExpressionsBasedModel)
at suitable points in the code to validate its actions. This is a solver debugging tool - not to be used in production code.
-
validate
protected final boolean validate(Access1D<?> solverSolution)
-
validate
protected final boolean validate(ExpressionsBasedModel modifiedModel)
-
-