|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--mil.af.afit.uvr.HEngine
The HEngine
is the main source of interaction between code
that uses the Universal Vehicle Router (UVR) and the UVR itself. It accepts
information about the vehicles and orders and tries to find a solution
based on the parameters you specify. The default solver is the
SolomonConstructionSolver
. The default evaluator is the
EvaluatorWithPriorities
.
HEngineEvent
,
HEngineListener
,
HEvaluator
,
HOrder
,
HVehicle
,
HSolution
,
EvaluatorWithPriorities
,
SolomonConstructionSolver
Field Summary | |
protected java.util.Properties |
properties
|
static java.lang.String |
PROPERTIES_HEADER
|
static java.lang.String |
SOLVER_KEY_PREFIX
|
static java.lang.String |
UVR_PROPERTIES_DIR_KEY
|
static java.lang.String |
UVR_PROPERTIES_FILE_NAME
|
Constructor Summary | |
HEngine()
Constructs an HEngine that is not yet aware of any
orders or vehicles. |
|
HEngine(HVehicle[] vehicles,
HOrder[] orders)
Constructs an HEngine based on the passed orders and vehicles. |
|
HEngine(HVehicle[] vehicles,
HOrder[] orders,
int numberOfThreads)
Constructs an HEngine based on the passed orders and vehicles
and specifies the number of threads subsequent solvers should use. |
|
HEngine(java.util.Properties prop)
Constructs an HEngine that is not yet aware of any
orders or vehicles. |
Method Summary | |
void |
addHEngineListener(HEngineListener listener)
Add a listener to the engine. |
protected static void |
err(java.lang.Exception e)
|
java.util.Enumeration |
getAvailableSolvers()
Returns an enumeration of HSolver s already known to the HEngine . |
HSolution |
getBestHSolution()
Returns the best solution so far. |
static java.util.Properties |
getDefaultProperties()
Return the default properties for the HEngine . |
double |
getEffort()
Returns the amount of effort that the HEngine will expend. |
HEvaluator |
getHEvaluator()
Returns the evaluator being used. |
int |
getNumberOfThreads()
Returns the number of threads that was requested for the solver to use. |
float |
getPercentDone()
Returns the progress of the HEngine as a value
between zero and one, inclusively. |
java.util.Properties |
getProperties()
Returns the properties being used. |
double |
getRequestedSolutionEffort()
Deprecated. Use getEffort() . |
HSolver |
getSolver()
Returns the solver that will be used or is being used by the HEngine . |
void |
HSolverEventPerformed(mil.af.afit.uvr.HSolverEvent e)
Called when an HSolverEvent is fired. |
boolean |
isCanceled()
Returns true if the user has tried to cancel the HEngine. |
protected static void |
out(java.lang.Object obj)
|
void |
removeHEngineListener(HEngineListener listener)
Remove a listener from the engine. |
protected void |
setBestHSolution(HSolution soln)
Used internally to set the best known solution |
double |
setEffort(double effort)
Sets the requested effort. |
void |
setHEvaluator(HEvaluator evaluator)
Sets the evaluator to use. |
void |
setHOrders(HOrder[] orders)
Sets the orders to be served by the vehicles |
void |
setHVehicles(HVehicle[] vehicles)
Sets the vehicles used to service the orders. |
void |
setNumberOfThreads(int numberOfThreads)
Sets the suggested number of threads to use. |
protected void |
setPercentAlottedToSolomon(float percentAlotted)
This determines how much of the progress is represented as coming from the HSolomon work. |
double |
setRequestedSolutionEffort(double effort)
Deprecated. Use setEffort() . |
void |
setSolver(HSolver solver)
Sets the solver to be used by the HEngine . |
HSolver |
setSolver(java.lang.String solverName)
Deprecated. Set the solver by using an actual HSolver
object. If you must keep a String record
of a solver, use the class name and then instantiate a
new solver with Class.forName(
strSolverClassName ).newInstance() . |
protected void |
solomonReportingProgress(float progress)
Used internally by HSolomon to report progress. |
void |
startSolving()
Starts the HEngine solving in another thread. |
void |
stopSolving()
Stops the HEngine . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String UVR_PROPERTIES_DIR_KEY
public static final java.lang.String UVR_PROPERTIES_FILE_NAME
public static final java.lang.String SOLVER_KEY_PREFIX
public static final java.lang.String PROPERTIES_HEADER
protected java.util.Properties properties
Constructor Detail |
public HEngine()
HEngine
that is not yet aware of any
orders or vehicles. Since one of the things the HEngine
does on construction is begin to load available solvers in another thread, it can
be beneficial to use this constructor right before waiting for some
user input.public HEngine(java.util.Properties prop)
HEngine
that is not yet aware of any
orders or vehicles. The HEngine
will start with the
properties specified. Currently this is only used to specify which
solvers to make available. The properties are stored in the following manner:
uvr.solver.1=package.subpackage.solverclassname
uvr.solver.2=otherpackage.subpack.subpacktoo.othersolverclassname
The HEngine
will stop loading solvers when the sequence is broken.
HSolver
,
Properties
public HEngine(HVehicle[] vehicles, HOrder[] orders)
HEngine
based on the passed orders and vehicles.vehicles
- the vehicles to useorders
- the orders to useHVehicle
,
HOrder
public HEngine(HVehicle[] vehicles, HOrder[] orders, int numberOfThreads)
HEngine
based on the passed orders and vehicles
and specifies the number of threads subsequent solvers should use. This can
be helpful on multiprocessor computers.vehicles
- the vehicles to useorders
- the orders to usenumberOfThreads
- suggested number of threads to useHVehicle
,
HOrder
Method Detail |
public static final java.util.Properties getDefaultProperties()
HEngine
. Use this
to force the default solvers to load in case your uvr.properties
file got messed up.Properties
protected final void setPercentAlottedToSolomon(float percentAlotted)
percentAlotted
- how much of the overall progress is attributed to HSolomonpublic final double setRequestedSolutionEffort(double effort)
setEffort()
.
HEngine
and thus reduces solve time.effort
- amount of effort to expendreturn
- the new effort settingpublic final double setEffort(double effort)
HEngine
and thus reduces solve time.effort
- amount of effort to expendreturn
- the new effort settingpublic final double getRequestedSolutionEffort()
getEffort()
.
HEngine
will expend.public final double getEffort()
HEngine
will expend.public final boolean isCanceled()
HEngine
public final void stopSolving()
HEngine
. If in the middle of the tour-building heuristic,
there may be a delay before the HEngine
actually stops working.
An event signaling that the engine has stopped will be fired.public final void startSolving()
HEngine
solving in another thread. Control returns
to the calling method immediately.public final java.util.Enumeration getAvailableSolvers()
HSolver
s already known to the HEngine
.
You should never use the actual solver objects returned. Always create a new
instance with something like the following:
HEngine engine = new HEngine();
Enumeration enum = engine.getAvailableSolvers();
HSolver solverToUse = null;
try
{ solverToUse = (HSolver) enum.nextElement().getClass().newInstance();
} // end try
catch( IllegalAccessException e ){}
catch( InstantiationExceptione e ){}
HSolver
s known to the HEngine
HSolver
,
Enumeration
public final HSolver getSolver()
HEngine
.HSolver
public final void setSolver(HSolver solver)
HEngine
. If the solver
is different than any already in use, it is added to the engine's list.solver
- solver to useHSolver
public final HSolver setSolver(java.lang.String solverName)
HSolver
object. If you must keep a String
record
of a solver, use the class name and then instantiate a
new solver with Class.forName(
strSolverClassName ).newInstance()
.
getAvailableSolvers()
.solverName
- name of solver to useHSolver
public final void setHEvaluator(HEvaluator evaluator)
evaluator
- evaluator to useHEvaluator
public final void setNumberOfThreads(int numberOfThreads)
numberOfThreads
- number of suggested threads to usepublic final int getNumberOfThreads()
protected final void setBestHSolution(HSolution soln)
soln
- best solutionHSolution
public final HSolution getBestHSolution()
HSolution
public final HEvaluator getHEvaluator()
HEvaluator
public final java.util.Properties getProperties()
HSolver
,
Properties
public final float getPercentDone()
HEngine
as a value
between zero and one, inclusively.public final void setHVehicles(HVehicle[] vehicles)
vehicles
- the vehicles to use to server the ordersHVehicle
,
HOrder
public final void setHOrders(HOrder[] orders)
orders
- the orders to be served by the vehiclesHOrder
,
HVehicle
protected final void solomonReportingProgress(float progress)
HSolomon
to report progress.progress
- progress between zero and onepublic void HSolverEventPerformed(mil.af.afit.uvr.HSolverEvent e)
HSolverEvent
is fired.HSolverEventPerformed
in interface mil.af.afit.uvr.HSolverListener
e
- event firedHSolverEvent
,
HSolverListener
public final void addHEngineListener(HEngineListener listener)
listener
- the listener to notify of engine eventsHEngineListener
,
HEngineEvent
public final void removeHEngineListener(HEngineListener listener)
listener
- the listener which will no longer
receive engine eventsHEngineListener
,
HEngineEvent
protected static final void out(java.lang.Object obj)
protected static final void err(java.lang.Exception e)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |