|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
org.jgap.distr.grid.gp.JGAPClientGP
public class JGAPClientGP
A client defines work for the grid and sends it to the JGAPServer. Use this class as base class for your grid client implementations.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
static java.lang.String |
APP_VERSION
|
static java.lang.String |
CLIENT_DATABASE
|
static java.lang.String |
CONTEXT_ANY
|
static java.lang.String |
CONTEXT_ID_ANY
|
static java.lang.String |
CONTEXT_ID_EMPTY
|
static java.lang.String |
CONTEXT_WORK_REQUEST
|
static java.lang.String |
CONTEXT_WORK_RESULT
|
static java.lang.Object[][] |
FIELDSTOSKIP
|
protected GridNodeClientConfig |
m_gridconfig
|
protected JGAPRequestGP |
m_workReq
|
static java.lang.String |
MODULE_ANY
|
static java.lang.String |
MODULE_CS
|
static java.lang.String |
MODULE_SC
|
static java.lang.String |
MODULE_SW
|
static java.lang.String |
MODULE_WS
|
static java.lang.String |
RESULTS_DATABASE
|
static int |
TIMEOUT_SECONDS
|
static int |
WAITTIME_SECONDS
|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
JGAPClientGP(GridNodeClientConfig a_gridconfig,
java.lang.String a_clientClassName,
boolean a_WANMode,
boolean a_receiveOnly,
boolean a_list,
boolean a_no_comm,
boolean a_no_evolution,
boolean a_endless,
int a_max_fetch_results)
|
|
JGAPClientGP(IGridClientMediator a_gcmed,
GridNodeClientConfig a_gridconfig,
java.lang.String a_clientClassName,
boolean a_WANMode,
boolean a_receiveOnly,
boolean a_list,
boolean a_no_comm,
boolean a_no_evolution,
boolean a_endless,
int a_max_fetch_results)
|
|
| Method Summary | |
|---|---|
protected void |
afterEvolve(IGridClientMediator a_gcmed)
Called in run() after one evolution step is executed. |
protected boolean |
afterSendWorkRequests(JGAPRequestGP[] a_workRequests)
Called in run() after sending work requests successfully. |
protected void |
afterStopped(java.lang.Throwable a_t)
Called after stopping the client in run(). |
protected void |
beforeEvolve(IGridClientMediator a_gcmed)
Called in run() before one evolution step is executed. |
protected boolean |
beforeGenerateWorkRequests()
Called in run() before generating work requests for sending. |
protected boolean |
beforeSendWorkRequests(JGAPRequestGP[] a_workRequests)
Called in run() before sending work requests. |
protected void |
checkForUpdates(java.lang.String a_URL,
java.lang.String a_libDir,
java.lang.String a_workDir)
|
protected void |
errorOnSendWorkRequests(java.lang.Throwable uex,
JGAPRequestGP[] a_workRequests)
|
protected void |
evolve(IGridClientMediator a_gcmed,
boolean a_receiveOnly)
If necessary: override to implement your evolution cycle individually. |
GPConfiguration |
getConfiguration()
|
java.lang.String[] |
getFilenames(java.lang.String a_dir)
|
IGridClientMediator |
getGridClientMediator()
|
protected IGridConfigurationGP |
getGridConfigurationGP()
|
protected java.lang.String |
getKeyFromObject(java.lang.Object a_obj)
Override in sub classes. |
int |
getMaxFetchResults()
|
protected java.lang.String |
getResultFilename(JGAPResultGP a_result)
|
protected java.lang.String |
getRunID()
|
java.lang.String |
getWorkDirectory()
|
boolean |
isNoCommunication()
|
protected void |
listRequests()
Override in sub classes: list available requests |
protected void |
listResults()
Override in sub classes: list available results |
static void |
main(java.lang.String[] args)
Starts a client (first parameter: name of specific setup class). |
protected static Options |
makeOptions()
|
protected void |
onBeginOfRunning()
Called at start of run(). |
protected void |
onDeleteError(java.lang.Exception a_ex)
Called in case of any unhandled error when trying to delete a request or result. |
protected void |
onError(java.lang.Exception a_ex)
Called in run() in case of any unhandled error. |
protected void |
onErrorReceiveWorkResults(JGAPRequestGP[] a_workRequests,
java.lang.Exception a_ex)
Called in run() on error when receiving work results. |
protected void |
presetPopulation(JGAPRequestGP a_workRequest)
Presets initial population to be included for input to workers. |
protected void |
receiveWorkResults(JGAPRequestGP[] workList)
|
protected void |
removeEntries(java.util.Map a_cachedKeys,
java.util.Map a_foundKeys)
|
protected boolean |
resultReceived(GPPopulation a_pop)
New results has been received. |
protected boolean |
resultReceived(IGPProgram a_fittest)
A new result has been received. |
void |
run()
Threaded: Splits work, sends it to workers and receives computed solutions. |
protected void |
saveResult(java.lang.String a_dir,
java.lang.String a_filename,
IGPProgram a_obj)
Saves a result to disk. |
protected JGAPRequestGP[] |
sendWorkRequests(int a_evolutionIndex,
IClientEvolveStrategyGP evolver,
IRequestSplitStrategyGP splitter,
IClientFeedbackGP feedback)
|
protected void |
sendWorkRequests(JGAPRequestGP[] a_workList)
|
void |
setWorkDirectory(java.lang.String a_workDir)
|
void |
setWorkRequest(JGAPRequestGP a_request)
|
protected void |
showCurrentResults()
|
void |
start()
|
void |
writeToFile(java.lang.Object a_obj,
java.lang.String a_dir,
java.lang.String a_filename)
Writes an object to a local file. |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String APP_VERSION
public static final java.lang.String MODULE_CS
public static final java.lang.String CLIENT_DATABASE
public static final java.lang.String RESULTS_DATABASE
public static final java.lang.String MODULE_SC
public static final java.lang.String MODULE_SW
public static final java.lang.String MODULE_WS
public static final java.lang.String MODULE_ANY
public static final java.lang.String CONTEXT_WORK_REQUEST
public static final java.lang.String CONTEXT_WORK_RESULT
public static final java.lang.String CONTEXT_ANY
public static final java.lang.String CONTEXT_ID_EMPTY
public static final java.lang.String CONTEXT_ID_ANY
public static final int TIMEOUT_SECONDS
public static final int WAITTIME_SECONDS
public static final java.lang.Object[][] FIELDSTOSKIP
protected GridNodeClientConfig m_gridconfig
protected JGAPRequestGP m_workReq
| Constructor Detail |
|---|
public JGAPClientGP(GridNodeClientConfig a_gridconfig,
java.lang.String a_clientClassName,
boolean a_WANMode,
boolean a_receiveOnly,
boolean a_list,
boolean a_no_comm,
boolean a_no_evolution,
boolean a_endless,
int a_max_fetch_results)
throws java.lang.Exception
java.lang.Exception
public JGAPClientGP(IGridClientMediator a_gcmed,
GridNodeClientConfig a_gridconfig,
java.lang.String a_clientClassName,
boolean a_WANMode,
boolean a_receiveOnly,
boolean a_list,
boolean a_no_comm,
boolean a_no_evolution,
boolean a_endless,
int a_max_fetch_results)
throws java.lang.Exception
java.lang.Exception| Method Detail |
|---|
protected java.lang.String getRunID()
public void setWorkRequest(JGAPRequestGP a_request)
protected void onBeginOfRunning()
throws java.lang.Exception
java.lang.Exception
protected boolean beforeSendWorkRequests(JGAPRequestGP[] a_workRequests)
throws java.lang.Exception
a_workRequests - work requests pending to be sent
java.lang.Exception
protected boolean beforeGenerateWorkRequests()
throws java.lang.Exception
java.lang.Exception
protected boolean afterSendWorkRequests(JGAPRequestGP[] a_workRequests)
throws java.lang.Exception
a_workRequests - the sent requests
java.lang.Exception
protected void errorOnSendWorkRequests(java.lang.Throwable uex,
JGAPRequestGP[] a_workRequests)
throws java.lang.Exception
java.lang.Exception
protected void beforeEvolve(IGridClientMediator a_gcmed)
throws java.lang.Exception
a_gcmed - the GridClient mediator
java.lang.Exception
protected void afterEvolve(IGridClientMediator a_gcmed)
throws java.lang.Exception
a_gcmed - the GridClient mediator
java.lang.Exception
protected void afterStopped(java.lang.Throwable a_t)
throws java.lang.Exception
a_t - null if no error occured on stopping, otherwise exception object
java.lang.Exception
protected void onError(java.lang.Exception a_ex)
throws java.lang.Exception
a_ex - exception object expressing the error
java.lang.Exception
protected void onDeleteError(java.lang.Exception a_ex)
throws java.lang.Exception
a_ex - exception object expressing the error
java.lang.Exception
protected void onErrorReceiveWorkResults(JGAPRequestGP[] a_workRequests,
java.lang.Exception a_ex)
throws java.lang.Exception
a_workRequests - for which to receive resultsa_ex - Exception occured
java.lang.Exception - rethrow an unhandled exception!public void run()
run in interface java.lang.Runnablerun in class java.lang.Thread
protected JGAPRequestGP[] sendWorkRequests(int a_evolutionIndex,
IClientEvolveStrategyGP evolver,
IRequestSplitStrategyGP splitter,
IClientFeedbackGP feedback)
throws java.lang.Exception
java.lang.Exception
protected void sendWorkRequests(JGAPRequestGP[] a_workList)
throws java.lang.Exception
java.lang.Exception
protected void receiveWorkResults(JGAPRequestGP[] workList)
throws java.lang.Exception
java.lang.Exceptionprotected java.lang.String getResultFilename(JGAPResultGP a_result)
protected void evolve(IGridClientMediator a_gcmed,
boolean a_receiveOnly)
throws java.lang.Exception
a_gcmed - the GridClient mediatora_receiveOnly - false: Don't send any work requests, just receive
results from former evolutions
java.lang.Exceptionpublic void start()
start in class java.lang.Threadpublic GPConfiguration getConfiguration()
public IGridClientMediator getGridClientMediator()
protected IGridConfigurationGP getGridConfigurationGP()
public void writeToFile(java.lang.Object a_obj,
java.lang.String a_dir,
java.lang.String a_filename)
throws java.lang.Exception
a_obj - the object to persista_dir - directory to write the file toa_filename - name of the file to create
java.lang.Exception
public void setWorkDirectory(java.lang.String a_workDir)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getWorkDirectory()
protected void checkForUpdates(java.lang.String a_URL,
java.lang.String a_libDir,
java.lang.String a_workDir)
throws java.lang.Exception
java.lang.Exceptionprotected void listRequests()
protected void listResults()
public boolean isNoCommunication()
public static void main(java.lang.String[] args)
args - String[]protected static Options makeOptions()
protected void removeEntries(java.util.Map a_cachedKeys,
java.util.Map a_foundKeys)
protected java.lang.String getKeyFromObject(java.lang.Object a_obj)
throws java.lang.Exception
a_obj - the object to get the key from
java.lang.Exception
protected boolean resultReceived(GPPopulation a_pop)
throws java.lang.Exception
a_pop - the fittest results received for a work request
java.lang.Exception
protected boolean resultReceived(IGPProgram a_fittest)
throws java.lang.Exception
a_fittest - the fittest result received for a work request
java.lang.Exception
protected void saveResult(java.lang.String a_dir,
java.lang.String a_filename,
IGPProgram a_obj)
throws java.lang.Exception
a_dir - the directory to put the result intoa_filename - name of the file to writea_obj - the result object to write
java.lang.Exception
public java.lang.String[] getFilenames(java.lang.String a_dir)
throws java.lang.Exception
java.lang.Exception
protected void presetPopulation(JGAPRequestGP a_workRequest)
throws java.lang.Exception
a_workRequest - the work request that is about to be sent.
java.lang.Exception
protected void showCurrentResults()
throws java.lang.Exception
java.lang.Exceptionpublic int getMaxFetchResults()
|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||