public class HybridSolvePolicy
extends java.lang.Object
Solves are grouped into cycles, each beginning with a direct solve. If
t_d is the time of the direct solve and t_1, ... t_n are the
times of the following iterative solves, the policy tries to minimize the
average solve time
tavg = (t_d + t_1 + ... + t_n) / (n+1)by requesting a refactor as soon as
tavg stops decreasing, i.e.,
when t_n >= tavg_(n-1). An iterative solve failure also causes a
refactor.
If hybrid solves give no benefit in a cycle, because the first iterative
solve takes at least as long as the direct solve, or because it fails, the
policy backs off by skipping iterative solves for a number of solves. The
backoff starts at getInitialBackoff() and doubles for each
consecutive unsuccessful cycle, up to getMaxBackoff(). It is cleared
when a first iterative solve succeeds.
Times can be given in any units, provided they are consistent.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_INITIAL_BACKOFF |
static int |
DEFAULT_MAX_BACKOFF |
| Constructor and Description |
|---|
HybridSolvePolicy() |
| Modifier and Type | Method and Description |
|---|---|
int |
getBackoff()
Returns the length of the most recent backoff, or 0 if the backoff has
been cleared.
|
double |
getCycleAverage()
Returns the average solve time for the completed solves in the current
cycle, or 0 if there are none.
|
int |
getCycleSolves()
Returns the number of completed solves in the current cycle, including
the direct solve.
|
int |
getInitialBackoff() |
int |
getMaxBackoff() |
int |
getSkipCount()
Returns the number of solves remaining in the current backoff.
|
void |
invalidateFactor()
Indicates that the current factorization is no longer valid (e.g.,
because the matrix structure has been reanalyzed), so that the next
solve must be direct.
|
boolean |
isRefactorPending()
Queries whether a refactor has been requested.
|
int |
numBackoffs() |
int |
numDirectSolves() |
int |
numFailedSolves() |
int |
numIterativeSolves() |
void |
recordDirect(double time)
Records a direct (factor and) solve, which starts a new cycle.
|
void |
recordIterative(double time)
Records a successful iterative solve.
|
void |
recordIterativeFailure()
Records a failed iterative solve.
|
void |
reset()
Resets the policy to its initial state, clearing all timing, cycle and
backoff information.
|
void |
setInitialBackoff(int n) |
void |
setMaxBackoff(int n) |
boolean |
useIterative()
Queries whether the next solve should be iterative.
|
public static final int DEFAULT_INITIAL_BACKOFF
public static final int DEFAULT_MAX_BACKOFF
public void reset()
public void invalidateFactor()
public boolean useIterative()
true if the next solve should be iterativepublic void recordDirect(double time)
time - time required for the solvepublic void recordIterative(double time)
time - time required for the solvepublic void recordIterativeFailure()
public boolean isRefactorPending()
true if a refactor is pendingpublic int getCycleSolves()
public double getCycleAverage()
public int getBackoff()
public int getSkipCount()
public int getInitialBackoff()
public void setInitialBackoff(int n)
public int getMaxBackoff()
public void setMaxBackoff(int n)
public int numDirectSolves()
public int numIterativeSolves()
public int numFailedSolves()
public int numBackoffs()