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.
Because solve times are measured by a wall clock, the resulting sequence
of iterative and direct solves is not repeatable. For debugging, a fixed
cycle length can be specified (see setFixedCycleLength(int)), in which
case times are ignored and a refactor is requested after a fixed number of
iterative solves. Iterative solve failures still cause a refactor and
backoff, which, given repeatable inputs, are also repeatable.
| 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.
|
static int |
getDefaultFixedCycleLength()
Returns the default fixed cycle length for newly created policies.
|
int |
getFixedCycleLength()
Returns the fixed cycle length.
|
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.
|
static void |
setDefaultFixedCycleLength(int n)
Sets the default fixed cycle length for newly created policies.
|
void |
setFixedCycleLength(int n)
Sets a fixed cycle length
n. |
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 getFixedCycleLength()
setFixedCycleLength(int).public void setFixedCycleLength(int n)
n. If n > 0, solve times are
ignored and a refactor is requested after n successful
iterative solves, making the solve sequence repeatable. If n <=
0, cycles are determined by solve times (the default).n - fixed cycle length, or 0 to use solve timespublic static int getDefaultFixedCycleLength()
public static void setDefaultFixedCycleLength(int n)
setFixedCycleLength(int).n - default fixed cycle length, or 0 to use solve timespublic 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()