?? greedycrossoverenginetests.java.svn-base
字號:
/*
* $Source: f:/cvs/prgm/tsp/src/org/saiko/ai/genetics/tsp/engines/crossover/GreedyCrossoverEngineTests.java,v $
* $Id: GreedyCrossoverEngineTests.java,v 1.2 2005/08/23 23:18:05 dsaiko Exp $
* $Date: 2005/08/23 23:18:05 $
* $Revision: 1.2 $
* $Author: dsaiko $
*
* Traveling Salesman Problem genetic algorithm.
* This source is released under GNU public licence agreement.
* dusan@saiko.cz
* http://www.saiko.cz/ai/tsp/
*
* Change log:
* $Log: GreedyCrossoverEngineTests.java,v $
* Revision 1.2 2005/08/23 23:18:05 dsaiko
* Finished.
*
* Revision 1.1 2005/08/22 22:08:50 dsaiko
* Created engines with heuristics
*
* Revision 1.3 2005/08/13 15:02:09 dsaiko
* build task
*
* Revision 1.2 2005/08/13 10:32:34 dsaiko
* JUnit tests modified - checking the result of algorithm (not for JGap - it does not work there ...)
*
* Revision 1.1 2005/08/12 23:52:17 dsaiko
* Initial revision created
*
*/
package org.saiko.ai.genetics.tsp.engines.crossover;
import junit.framework.TestCase;
import org.saiko.ai.genetics.tsp.City;
import org.saiko.ai.genetics.tsp.TSP;
/**
* @author Dusan Saiko (dusan@saiko.cz)
* Last change $Date: 2005/08/23 23:18:05 $
*
* Object TestCase
* @see org.saiko.ai.genetics.tsp.engines.crossover.GreedyCrossoverEngine
*/
public class GreedyCrossoverEngineTests extends TestCase {
/** String containing the CVS revision. **/
public final static String CVS_REVISION = "$Revision: 1.2 $";
/**
* Test routine
*/
public void testEngine() {
TSP tsp=new TSP();
City c1=new City(0,tsp.configuration,"a",1,1);
City c2=new City(1,tsp.configuration,"b",2,1);
City c3=new City(2,tsp.configuration,"c",2,2);
City c4=new City(3,tsp.configuration,"d",1,2);
//clone() array operation
City[] gene=new City[]{
c1, c2, c3, c4
};
City.initDistanceCache(gene.length);
GreedyCrossoverEngine e=new GreedyCrossoverEngine();
tsp.configuration.setInitialPopulationSize(10000);
e.initialize(tsp.configuration,gene);
for(int i=0; i<50; i++) {
e.nextGeneration();
}
assertTrue(e.getBestChromosome().getTotalDistance()==4.0);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -