蚂蚁算法的java实现,主要在选择路径的迭代上做了改进

源代码在线查看: patch.java

软件大小: 17 K
上传用户: leeixndong
关键词: java 蚂蚁算法 路径 迭代
下载地址: 免注册下载 普通下载 VIP

相关代码

				package SimFrameWork;
				import java.util.List;
				import java.util.ArrayList;
				
				public abstract class Patch{
				  public Patch(){
				    neighbours=new Patch[8];
				    turtles=new ArrayList();
				  }
				  public abstract void update();
				  public final void addTurtle(Turtle t){
				    turtles.add(t);
				  }
				  public final int turtleCount(){
				    return turtles.size();
				  }
				  public final void removeTurtle(Turtle t){
				    turtles.remove(t);
				  }
				  public final List getTurtles(){
				    return turtles;
				  }
				  public final Patch getNeighbour(int i){
				    return neighbours[i];
				  }
				  public int value(){
				    return patchValue;
				  }
				  public void incrValue(){
				    patchValue+=1;
				  }
				  public void decrValue(){
				    patchValue-=1;
				  }
				  protected final void setNeighbour(int nbour,Patch p){
				    neighbours[nbour]=p;
				  }
				  public final static int N=0;
				  public final static int NE=1;
				  public final static int E=2;
				  public final static int SE=3;
				  public final static int S=4;
				  public final static int SW=5;
				  public final static int W=6;
				  public final static int NW=7;
				  protected int patchValue;
				  private Patch[] neighbours;
				  private List turtles;
				}			

相关资源