package agents.anac.y2014.KGAgent; import java.util.ArrayList; import java.util.List; import java.util.Random; import agents.anac.y2014.kGA_gent.library_genetic.Gene; import agents.anac.y2014.kGA_gent.library_genetic.GenerationChange; public class BidGenerationChange implements GenerationChange{ /** * @param args */ public static void main(String[] args) { // TODO 自動���れ�メソッド・スタブ } int size = 50; int end = 40; double line = 2.0; static Random rnd=null; int gen = 0; public BidGenerationChange() { //System.out.println("Call BidGenerationChange Instance"); if(rnd==null){ rnd = new Random(); } } public BidGenerationChange(int size) { this.size =size; //System.out.println("Call BidGenerationChange Instance"); if(rnd==null){ rnd = new Random(); } } public BidGenerationChange(int size,int gen) { end=gen; this.size =size; //System.out.println("Call BidGenerationChange Instance"); if(rnd==null){ rnd = new Random(); } } /* * トーナメント戦略 ランダム�個体�択肢��1番�2番�交�を行� */ static int tornament = 8; @Override public List Generation(List list) { // TODO 自動���れ�メソッド・スタブ //System.out.println("call Generation"); ArrayList ret = new ArrayList(size); int f=size-2,s=size-1,buf; gen ++; MyBidGene bufBidGene = (MyBidGene)list.get(0); ret.add(new MyBidGene(bufBidGene)); while (ret.size() < size) { f=size-2; s=size-1; for (int i = 0; i < tornament; i++) { buf = rnd.nextInt(size); s = Math.min(buf, s); f = Math.min(s, f); } Gene b = list.get(s).Cros(list.get(f)); b.Mutate(); ret.add(b); } //System.out.println("end Generation"); return ret; } @Override public List StartGeneration(Gene gene) { // TODO 自動���れ�メソッド・スタブ List ret = new ArrayList(size); while (ret.size() StartGeneration() { // TODO 自動���れ�メソッド・スタブ // System.out.println("Calll StartGeneration"); List ret = new ArrayList(size); while (ret.size() list) { // TODO 自動���れ�メソッド・スタブ if(gen > end){ return true; } return false; } }