⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 computegng.java

📁 关于自组织神经网络的一种新结构程序,并包含了其它几种神经网络的程序比较
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   * The current number of calculations done in one step.    *  This variable can be set by the user. After <TT> stepSize </TT>   *  calculations the result is displayed.   */  protected int stepSize = 50;  /**   * This vaiable determines how long the compute thread sleeps. In this time   *  the user can interact with the program. Slow machines and/or slow   *  WWW-browsers need more time than fast machines and/or browsers.   *  This variable can be set by the user.   */  protected int speed = 400;  /**   * The actual x size of the grid array.   */  protected int grid_x = 0;  /**   * The actual y size of the grid array.   */  protected int grid_y = 0;  /**   * The direction factor for the x axis (-1 or 1) used for the   * 'Moving Rectangle' distribution   */  protected int bounceX = -1;  /**   * The direction factor for the y axis (-1 or 1) used for the   * 'Moving Rectangle' distribution   */  protected int bounceY = -1;  /**   * The x coordinate for the 'Jumping Rectangle' and 'R.Mouse' distribution   */  protected int jumpX = 250;  /**   * The y coordinate for the 'Jumping Rectangle' and 'R.Mouse' distribution   */  protected int jumpY = 250;  /**   * Stores the old x value of the remainder in order to detect the bounce   * (used for the 'Moving Rectangle' distribution)   */  protected double bounceX_old = 1;  /**   * Stores the old y value of the remainder in order to detect the bounce   * (used for the 'Moving Rectangle' distribution)   */  protected double bounceY_old = 1;  /**   * The value epsilon for the HCL algorithm.   *  This variable can be set by the user.   */  protected float epsilon = 0.1f;  /**   * The value epsilon for the GNG algorithm (winner).   *  This variable can be set by the user.   */  protected float epsilonGNG = 0.1f;  /**   * The value epsilon for the GNG algorithm (second).   *  This variable can be set by the user.   */  protected float epsilonGNG2 = 0.001f;  /**   * The value alpha for the GNG algorithm.   *  This variable can be set by the user.   */  protected float alphaGNG = 0.5f;  /**   * The value beta for the GNG algorithm.   *  This variable can be set by the user.   */  protected float betaGNG = 0.0005f;  /**   * The utility factor for the GNG-U algorithm.   *  This variable can be set by the user.   */  protected float utilityGNG = 3.0f;  /**   * The decay factor for utility   */  protected float forgetFactorUtility = 1.0f - betaGNG;  /**   * The factor to forget old values.   */  protected float forgetFactor = 1.0f - betaGNG;  /**   * The value lambda initial for the NG,NGwCHL,GG algorithms.   *  This variable can be set by the user.   */  protected float l_i = 30.0f;  /**   * The value lambda final for the NG,NGwCHL,GG algorithms.   *  This variable can be set by the user.   */  protected float l_f = 0.01f;  /**   * The value epsiolon(t) for the NG,NGwCHL algorithms.   */  protected float e_t = 0.0f;  /**   * The value epsiolon initial for the NG,NGwCHL,GG algorithms.   *  This variable can be set by the user.   */  protected float e_i = 0.3f;  /**   * The value epsiolon final for the NG,NGwCHL,GG algorithms.   *  This variable can be set by the user.   */  protected float e_f = 0.05f;  /**   * The value t_max for the NG,NGwCHL,SOM algorithms.   *  This variable can be set by the user.   */  protected float t_max = 40000.0f;  /**   * The value delete edge initial for the NGwCHL algorithm.   *  This variable can be set by the user.   */  protected float delEdge_i = 20.0f;  /**   * The value delete edge final for the NGwCHL algorithm.   *  This variable can be set by the user.   */  protected float delEdge_f = 200.0f;  /**   * The value sigma for the GG algorithm.   *  This variable can be set by the user.   */  protected float sigma = 0.9f;  /**   * The value sigma_i for the SOM algorithm.   *  This variable can be set by the user.   */  protected float sigma_i = 5.0f;  /**   * The value sigma_f for the SOM algorithm.   *  This variable can be set by the user.   */  protected float sigma_f = 5.0f;  /**   * This value is displayed in the error graph.   */  protected float valueGraph = 0.0f;  /**   * This value contains the best error value for LBG-U up to now.   */  protected float errorBestLBG_U = Float.MAX_VALUE;  /**   * The string shown in the fine-tuning phase of the method GG.   */  protected String fineTuningS = "";  /**   * The constructor.   *    * @param graph	The drawing area   */  ComputeGNG(DemoGNG graph) {    this.graph = graph;  }  /**   * Add a node. The new node will be randomly placed within the    *  given dimension.   *    * @param d          The dimension of the initial drawing area   * @return           The index of the new node   */  protected int addNode(Dimension d) {    if ( (nnodes == MAX_NODES) || (nnodes >= maxNodes) )      return -1;    NodeGNG n = new NodeGNG();	if (rndInitB) {	  n.x = (float) (10 + (d.width-20) * Math.random());	  n.y = (float) (10 + (d.height-20) * Math.random());	} else {	  getSignal(distribution);	  n.x = SignalX;	  n.y = SignalY;	}    n.nNeighbor = 0;	if (algo == 5)	  n.moved = true;    nodes[nnodes] = n;    nNodesChangedB = true;    return nnodes++;  }  /**   * Add a node. The new node will be placed at the   *  given coordinates.   *    * @param x          The x-coordinate of the new node   * @param y          The y-coordinate of the new node   * @return           The index of the new node   */  protected int addNode(int x, int y) {    if ( (nnodes == MAX_NODES) || (nnodes >= maxNodes) )      return -1;    NodeGNG n = new NodeGNG();    n.x = x;    n.y = y;	if (algo == 5)	  n.moved = true;    nodes[nnodes] = n;    nNodesChangedB = true;    return nnodes++;  }  /**   * Add a node. The new node will be placed between the   *  given nodes which must be connected. The existing edge is splitted.   *  The new node gets the average of the interesting values of   *  the two given nodes.   *    * @param n1         The index of a node   * @param n2         The index of a node   * @return           The index of the new node   */  protected int insertNode(int n1, int n2) {    if ( (nnodes == MAX_NODES) || (nnodes >= maxNodes) )      return -1;    if ( (n1 < 0) || (n2 < 0) )      return -1;    NodeGNG n = new NodeGNG();    float dx = (nodes[n1].x - nodes[n2].x) / 2.0f;    float dy = (nodes[n1].y - nodes[n2].y) / 2.0f;    nodes[n1].error *= (1.0f - alphaGNG);    nodes[n2].error *= (1.0f - alphaGNG);    n.error = (nodes[n1].error + nodes[n2].error)/2.0f;    n.utility = (nodes[n1].utility + nodes[n2].utility)/2.0f;    n.x = nodes[n1].x - dx;    n.y = nodes[n1].y - dy;    n.inserted = true;    nodes[nnodes] = n;    deleteEdge(n1, n2);    addEdge(n1, nnodes);    addEdge(n2, nnodes);    nNodesChangedB = true;    return nnodes++;  }  /**   * Add a node into the grid. The new node will be randomly placed within the    *  given dimension.   *    * @param x          The x coordinate of the grid array   * @param y          The y coordinate of the grid array   * @param d          The dimension of the initial drawing area   * @return           The index of the new node   */  protected int addGridNode(int x, int y, Dimension d) {    if ( (x > MAX_GRID_X) || (y > MAX_GRID_Y) )      return -1;	int n = addNode(d);	nodes[n].x_grid = x;	nodes[n].y_grid = y;	grid[x][y] = new GridNodeGNG(n, nodes[n]);    return n;  }  /**   * Initialize the grid. The new nodes will be randomly placed within the    *  given dimension.   *    * @param x          The x size of the grid array   * @param y          The y size of the grid array   * @param d          The dimension of the initial drawing area   */  protected void initGrid(int x, int y, Dimension d) {    if ( (x > MAX_GRID_X) || (y > MAX_GRID_Y) )      return;	int i, j;	if (algo == 7)	  maxNodes = x * y;	for (i = 0; i < x; i++)	  for (j = 0; j < y; j++)		addGridNode(i, j, d);	grid_x = x;	grid_y = y;	for (i = 0; i < grid_x; i++) {	  for (j = 0; j < grid_y; j++) {		if ( i < (grid_x - 1) )		  addEdge(grid[i][j].index, grid[i+1][j].index);		if ( j < (grid_y - 1) )		  addEdge(grid[i][j].index, grid[i][j+1].index);	  }	}  }  /**   * Prepare to insert a row or column into the grid.   *    * @return		The index of the last inserted node or -1   */  protected int insertGrid() {	int tau = 0;	int x = 0;	int y = 0;	int n = -1;	float d1 = 0, d2 = 0, d3 = 0, d4 = 0, max = 0;	for (int i = 0; i < grid_x; i++) {	  for (int j = 0; j < grid_y; j++) {		// Find maximum resource value tau		if ( grid[i][j].tau > tau ) {		  tau = grid[i][j].tau;		  x = i;		  y = j;		}		grid[i][j].tau = 0;		grid[i][j].node.inserted = false;	  }	}	// Identify the neighbor with the most different reference vector

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -