You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by co...@apache.org on 2008/08/17 17:04:00 UTC
[CONF] Apache Lucene Mahout: Watchmaker.GA.Tutorial (page edited)
Watchmaker.GA.Tutorial (MAHOUT) edited by abdelhakim deneche
Page: http://cwiki.apache.org/confluence/display/MAHOUT/Watchmaker.GA.Tutorial
Changes: http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=93002&originalVersion=1&revisedVersion=2
Content:
---------------------------------------------------------------------
h1. How to distribute the fitness evaluation using Mahout.GA
In any Watchmaker program, you'll have to create an instance of a StandaloneEvolutionEngine. For the TSP example this is done in the EvolutionaryTravellingSalesman class:
{code:java}
private EvolutionEngine<List<String>> getEngine(CandidateFactory<List<String>> candidateFactory, EvolutionaryOperator<List<?>> pipeline, Random rng) {
return new StandaloneEvolutionEngine<List<String>>(candidateFactory, pipeline, new RouteEvaluator(distances), selectionStrategy, rng);
}
{code}
The RouteEvaluator class is where the fitness of each individual is evaluated, if we want to distribute the evaluation over a Hadoop Cluster, all we have to is wrap the evaluator in a MahoutFitnessEvaluator, and instead of a StandaloneEvolutionEngine we'll use a STEvolutionEngine :
{code:java}
private EvolutionEngine<List<String>> getEngine(CandidateFactory<List<String>> candidateFactory, EvolutionaryOperator<List<?>> pipeline, Random rng) {
MahoutFitnessEvaluator<List<String>> evaluator = new MahoutFitnessEvaluator<List<String>>(new RouteEvaluator(distances));
return new STEvolutionEngine<List<String>>(candidateFactory, pipeline, evaluator, selectionStrategy, rng);
}
{code}
And voila! your code is ready to run on Hadoop. The complete running example is available with the examples in the org/apache/mahout/ga/watchmaker/travellingsalesman directory
---------------------------------------------------------------------
CONFLUENCE INFORMATION
This message is automatically generated by Confluence
Unsubscribe or edit your notifications preferences
http://cwiki.apache.org/confluence/users/viewnotifications.action
If you think it was sent incorrectly contact one of the administrators
http://cwiki.apache.org/confluence/administrators.action
If you want more information on Confluence, or have a bug to report see
http://www.atlassian.com/software/confluence