亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? acopanel.java

?? ACO JAVA 應(yīng)用JAVA編寫(xiě)的解決TSP問(wèn)題的源代碼。多多交流
?? JAVA
字號(hào):
/*----------------------------------------------------------------------  File    : ACOPanel.java  Contents: ant colony optimization viewer panel  Author  : Christian Borgelt  History : 19.11.2005 file created---------------------------------------------------------------------*/package acopt;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.awt.image.*;import java.util.Arrays;import java.util.Random;/*--------------------------------------------------------------------*/class Edge implements Comparable {/*--------------------------------------------------------------------*/  /* --- instance variables --- */  protected int i, j;           /* indices of connected vertices */  protected int c;              /* color index */  /*------------------------------------------------------------------*/  public Edge () {}  public Edge (int i, int j, int c)  { this.i = i; this.j = j; this.c = c; }  /*------------------------------------------------------------------*/  public int compareTo (Object obj)  {                             /* --- compare two edges */    if (this.c < ((Edge)obj).c) return -1;    if (this.c > ((Edge)obj).c) return +1;    return 0;                   /* return sign of color difference */  }  /* compareTo() */}  /* class Edge() *//*--------------------------------------------------------------------*/public class ACOPanel extends JPanel {/*--------------------------------------------------------------------*/  /* --- instance variables --- */  private TSP       tsp;        /* traveling salesman problem */  private AntColony antc;       /* ant colony for TSP */  private double    xoff, yoff; /* translation parameters */  private double    scale;      /* scaling factor */  private int[]     xs, ys;     /* screen coordinates */  private Edge[]    edges;      /* (sorted) list of edges */  private Color[]   cols;       /* colors for trail */  private Stroke    thick;      /* stroke for trail drawing */  private Stroke    thin;       /* stroke for tour drawing */  /*------------------------------------------------------------------*/  public ACOPanel ()  {                             /* --- create an ACO panel */    this.tsp   = null;          /* there is no TSP */    this.antc  = null;          /* and no ant colony yet */    this.xoff  = this.yoff = 0; /* initialize offset */    this.scale = 64.0;          /* and scale */    this.cols  = new Color[256];/* initialize the colors */    for (int i = 256; --i >= 0; )      this.cols[255-i] = new Color(i/255.0F, i/255.0F, i/255.0F);    this.thick = new BasicStroke(7.0F);    this.thin  = new BasicStroke(2.0F);  }  /* ACOPanel() */  /*------------------------------------------------------------------*/  public ACOPanel (TSP tsp)  { this(); this.setTSP(tsp); }  /*------------------------------------------------------------------*/  public TSP       getTSP  () { return this.tsp;  }  public AntColony getAnts () { return this.antc; }  /*------------------------------------------------------------------*/  public void setTSP (TSP tsp)  {                             /* --- set new traveling salesman p. */    this.antc  = null;          /* delete the ant colony */    this.edges = null;          /* and the edge vector */    this.tsp   = tsp;           /* and store the new TSP */    if (this.tsp == null)       /* if no tsp, set default size */      this.setPreferredSize(new Dimension(656, 656));    else {                      /* if a new TSP was set */      this.xoff = tsp.getX();      this.yoff = tsp.getY();   /* set default offset */      this.setScale(64.0);      /* and default scale */      int n = this.tsp.size();  /* create the edge vector */      this.edges = new Edge[n = (n *(n-1)) >> 1];      while (--n >= 0) this.edges[n] = new Edge();    }                           /* create the edges */    this.revalidate();          /* adapt the enclosing scroll pane */    this.repaint();             /* and redraw the TSP */  }  /* setTSP() */  /*------------------------------------------------------------------*/  public double getScale () { return this.scale; }  /*------------------------------------------------------------------*/  public void setScale (double scale)  {                             /* --- rescale the display */    int       i, n;             /* loop variables, number of vertices */    Dimension d;                /* preferred size of panel */    int       w, h;             /* size of background rectangle */    this.scale = scale;         /* set new scaling factor */    d = new Dimension();        /* compute new preferred size */    d.width  = (int)(this.tsp.getWidth()  *scale +16.5);    d.height = (int)(this.tsp.getHeight() *scale +16.5);    this.setPreferredSize(d);   /* set new preferred size */    w = 8; h = d.height -8;     /* get the coordinates of the origin */    n = this.tsp.size();        /* get the number of points */    this.xs = new int[n];       /* and create buffer vectors */    this.ys = new int[n];       /* for the transformed points */    for (i = n; --i >= 0; ) {   /* traverse the points */      this.xs[i] = (int)(w +scale *(this.tsp.getX(i) -this.xoff) +0.5);      this.ys[i] = (int)(h -scale *(this.tsp.getY(i) -this.yoff) +0.5);    }                           /* compute screen coordinates */  }  /* setScale() */  /*------------------------------------------------------------------*/  public void initAnts (int antcnt, double phero, Random rand)  {                             /* --- initialize an ant colony */    if (this.tsp == null) return;    this.antc = new AntColony(this.tsp, antcnt, rand);    this.antc.init(phero);      /* create and init. an ant colony */    this.repaint();             /* and redraw the TSP */  }  /* initAnts() */  /*------------------------------------------------------------------*/  public void setParams (double exploit, double alpha, double beta,                         double trail, double elite, double evap)  {                             /* --- set parameters */    if (this.antc == null) return;    this.antc.setExploit(exploit);    this.antc.setAlpha(alpha);    this.antc.setBeta(beta);    this.antc.setTrail(trail);    this.antc.setElite(elite);    this.antc.setEvap(evap);  }  /* setParams() */  /*------------------------------------------------------------------*/  public void runAnts ()  {                             /* --- run the ants */    if (this.antc == null) return;    this.antc.runAllAnts();     /* run all ants once */    this.repaint();             /* and redraw the TSP */  }  /* runAnts() */  /*------------------------------------------------------------------*/  public void paint (Graphics g)  {                             /* --- (re)paint the whole panel */    int       i, j, k, n;       /* loop variables, number of vertices */    Dimension d;                /* (preferred) size of panel */    int       w, h;             /* size of background rectangle */    int       x, y, ox, oy;     /* coordinates of points */    double    trl, avg, max;    /* (average/maximal) trail on edge */    double    scl;              /* scaling factor */    int[]     tour;             /* best tour found so far */    Edge      e;                /* to traverse the edges */    d = this.getSize();         /* get the (preferred) panel size */    w = d.width; h = d.height;  /* (whichever is larger) */    d = this.getPreferredSize();    if (d.width  > w) w = d.width;    if (d.height > h) h = d.height;    g.setColor(Color.white);    /* set the background color */    g.fillRect(0, 0, w, h);     /* draw the background */    if (this.tsp == null)       /* if there is no TSP, */      return;                   /* abort the function */    n = this.tsp.size();        /* get the number of vertices and */    w = 8; h = d.height -8;     /* the coordinates of the origin */    /* --- draw the trail --- */    if (this.antc != null) {    /* if there is an ant colony */      avg = this.antc.getTrailAvg();      max = this.antc.getTrailMax();      if (max < 2*avg) max = 2*avg;      max = 255.0/max;          /* compute color scaling factor */      for (k = 0, i = n; --i >= 0; ) {        for (j = i; --j >= 0; ) {          e   = this.edges[k++];/* traverse the edges */          trl = this.antc.getTrail(e.i = i, e.j = j);          e.c = (int)(max*trl); /* compute the color index */          if (e.c > 255) e.c = 255;        }                       /* bound the color index */      }                         /* (for programming safety) */      Arrays.sort(this.edges, 0, k);      ((Graphics2D)g).setStroke(this.thick);      for (i = 0; i < k; i++) { /* traverse the edges */        e = this.edges[i];      /* get edge and set color */        g.setColor(this.cols[e.c]);        g.drawLine(this.xs[e.i],this.ys[e.i],this.xs[e.j],this.ys[e.j]);      }                         /* draw a line between the vertices */      ((Graphics2D)g).setStroke(this.thin);      g.setColor(Color.red);    /* draw the best tour in red */      tour = this.antc.getBestTour();      i    = tour[0];           /* get the tour and its start */      for (k = n; --k >= 0; ) { /* traverse the edges of the tour */         j = i; i = tour[k];     /* get the next vertex index */        g.drawLine(this.xs[i], this.ys[i], this.xs[j], this.ys[j]);      }                         /* draw the next edge of the tour */    }                           /* (first edge closes tour) */    /* --- draw the vertices --- */    for (i = n; --i >= 0; ) {   /* traverse the vertices */      x = this.xs[i]; y = this.ys[i];      g.setColor(Color.black);  /* black outline */      g.fillOval(x-4, y-4, 9, 9);      g.setColor(Color.red);    /* red interior */      g.fillOval(x-3, y-3, 7, 7);    }                           /* draw a circle */  }  /* paint() */  /*------------------------------------------------------------------*/  public BufferedImage makeImage ()  {                             /* --- create an image of contents */    BufferedImage img;          /* created image */    Dimension     d;            /* size of panel */        d   = this.getPreferredSize();    img = new BufferedImage(d.width, d.height,            BufferedImage.TYPE_3BYTE_BGR);    this.paint(img.getGraphics());    return img;                 /* draw window contents to image */  }  /* BufferedImage() */      /* and return the image */}  /* class ACOPanel */

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩色视频在线观看| 成人欧美一区二区三区视频网页| 国产精品卡一卡二| 欧美亚洲一区二区在线观看| 久久99在线观看| 日韩三区在线观看| 91亚洲精品久久久蜜桃| 亚洲色图欧洲色图婷婷| 日韩一区二区免费视频| 美国毛片一区二区三区| 亚洲色图20p| 色综合久久九月婷婷色综合| 精品一区二区三区蜜桃| 久久综合色8888| 91极品视觉盛宴| 成人av在线电影| 国模一区二区三区白浆| 偷拍一区二区三区四区| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 不卡一区二区在线| 亚洲激情第一区| 欧美精品在线观看播放| 91丨porny丨中文| 亚洲www啪成人一区二区麻豆| 国产精品久久一卡二卡| 精品国产免费人成电影在线观看四季| 欧美日韩一二区| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 亚洲视频在线观看三级| 91麻豆国产在线观看| 国产丶欧美丶日本不卡视频| 中文字幕一区二区三区四区不卡| 欧美xxxxx牲另类人与| 成人在线一区二区三区| 一区二区三区美女视频| 国产精品美女久久久久aⅴ国产馆| 亚洲精品一线二线三线| 精品国产免费一区二区三区四区 | 欧美精品一区男女天堂| 欧美激情中文不卡| 精品久久久久久久久久久久久久久久久| 欧美日韩中文字幕精品| 免费久久精品视频| 日本不卡不码高清免费观看| 久久久精品一品道一区| 久久这里只有精品首页| 欧美精品一区二区蜜臀亚洲| 精品国产伦一区二区三区观看体验| 日韩亚洲欧美成人一区| 成人高清免费观看| 婷婷国产v国产偷v亚洲高清| 亚洲成av人影院在线观看网| 偷窥国产亚洲免费视频| 中文字幕欧美区| 欧美激情一区二区三区蜜桃视频| 国产欧美一区二区精品性| 亚洲国产精品ⅴa在线观看| 国产区在线观看成人精品| 国产蜜臀av在线一区二区三区| 国产欧美一区二区精品性色超碰| 亚洲欧美影音先锋| 日韩欧美的一区| 91国产福利在线| 欧美日韩精品三区| 成人视屏免费看| 九色porny丨国产精品| 久久66热re国产| 一区二区三区**美女毛片| 亚洲自拍欧美精品| 国产欧美一区二区精品婷婷| 国产精品久久午夜| 精品对白一区国产伦| 欧美亚洲国产一卡| 欧美日韩精品一区二区三区| 欧美成人猛片aaaaaaa| 欧美极品aⅴ影院| 亚洲最快最全在线视频| 91精品国产一区二区| 久久亚洲精品小早川怜子| 国产精品日韩成人| 欧美精品一区二| 亚洲欧美一区二区视频| 亚洲h在线观看| 亚洲男同1069视频| 日韩精品免费视频人成| 一区二区成人在线观看| 久久成人综合网| 91一区二区在线| 91免费视频网址| 国产精品一区二区果冻传媒| 91网址在线看| 日韩欧美二区三区| 激情六月婷婷综合| 天堂av在线一区| 国产成人aaa| 88在线观看91蜜桃国自产| 国产欧美一区二区精品性色| 精品卡一卡二卡三卡四在线| 一区二区三区在线播| 一区二区三区四区在线播放| 极品美女销魂一区二区三区免费| 日韩福利电影在线观看| 成人av资源下载| 日韩午夜在线观看视频| 色乱码一区二区三区88| 久久综合给合久久狠狠狠97色69| 久久久久久久久久久久久夜| 亚洲国产aⅴ天堂久久| 成+人+亚洲+综合天堂| 精品久久久久av影院 | 日本一区二区免费在线| 午夜伦理一区二区| av电影一区二区| 久久精品视频在线免费观看 | 国产精品小仙女| 日韩一区二区三区免费观看| 日韩码欧中文字| 粉嫩av一区二区三区粉嫩| 日韩视频在线你懂得| 一区二区三区在线观看国产| 99re在线视频这里只有精品| 久久天天做天天爱综合色| 久久精品视频免费| 亚洲免费观看高清完整版在线观看| 韩国av一区二区三区在线观看 | 国产精品色婷婷久久58| 亚洲色图欧美偷拍| 不卡的av中国片| 欧美色倩网站大全免费| 亚洲欧美aⅴ...| 99精品在线免费| 亚洲欧洲色图综合| 亚洲高清免费观看 | 99久久99久久免费精品蜜臀| 欧美日韩免费视频| 久久久精品国产免费观看同学| 成人免费小视频| 蜜乳av一区二区| 在线成人av网站| 国产精品传媒视频| 日本一不卡视频| 91精品午夜视频| 香蕉影视欧美成人| 777久久久精品| 日韩av电影免费观看高清完整版 | 久热成人在线视频| 91精品国产综合久久香蕉麻豆| 亚洲福利国产精品| 国产精品一二三四| 99久久精品免费| 一区二区三区四区蜜桃| 欧美性videosxxxxx| 亚洲福利一二三区| 欧美电影一区二区| 狠狠网亚洲精品| 欧美色老头old∨ideo| 国产精品久久久久影院老司| jiyouzz国产精品久久| 日韩欧美在线网站| 亚洲一级二级三级| 欧美一卡二卡在线观看| 亚洲影院在线观看| 538在线一区二区精品国产| 青青国产91久久久久久| 欧美日韩精品一区二区三区蜜桃 | 天天免费综合色| www.综合网.com| 久久综合精品国产一区二区三区 | 国产欧美一区二区精品性| 91麻豆产精品久久久久久| 国产亚洲成年网址在线观看| 不卡视频在线观看| 亚洲国产视频一区二区| 91捆绑美女网站| 国产精品欧美经典| 欧美视频一区二区三区| 一区二区三区免费看视频| 欧美一区二区视频网站| 成人午夜视频网站| 久久精品网站免费观看| 欧美色图激情小说| 亚洲精品视频自拍| 日韩欧美一区二区视频| 91网站黄www| 日韩一区欧美一区| 欧美一区二区三区小说| eeuss国产一区二区三区| 日本一区二区久久| 欧美日韩高清在线播放| 粉嫩一区二区三区在线看| 国产欧美1区2区3区| 国产精品123| 午夜久久久久久久久久一区二区| 国产三区在线成人av| 风流少妇一区二区| 视频一区免费在线观看| 日韩伦理av电影| 久久综合久久99| 日韩一级片在线观看| 久久99久久99|