429 432 6JVTBQ77XGHOMUMDZL3MQM4FWCU5CWRDZYQ6X7Q




C++ Neural Networks and Fuzzy Logic:Application to Nonlinear Optimization
Click Here! function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { var end = document.cookie.indexOf (";", j); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(j, end)); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } var m1=''; var gifstr=GetCookie("UsrType"); if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; } document.write(m1+m2+m3);           Keyword Title Author ISBN Publisher Imprint Brief Full  Advanced      Search  Search Tips Please Select ----------- Components Content Mgt Certification Databases Enterprise Mgt Fun/Games Groupware Hardware Intranet Dev Middleware Multimedia Networks OS Prod Apps Programming Security UI Web Services Webmaster Y2K ----------- New Titles ----------- Free Archive




To access the contents, click the chapter and section titles.


C++ Neural Networks and Fuzzy Logic


(Publisher: IDG Books Worldwide, Inc.)

Author(s): Valluru B. Rao

ISBN: 1558515526

Publication Date: 06/01/95










Search this book:
 





















Previous
Table of Contents
Next




Performance of the Hopfield Network
Let us now look at Hopfield and Tank’s approach at solving the TSP.

Hopfield and Tank Example
The Hopfield network’s use in solving the traveling salesperson problem is a pioneering effort in the use of the neural network approach for this problem. Hopfield and Tank’s example is for a problem with 10 cities. The parameters used were, A1= 500, A2 = 500, A3 = 200, A4 = 500, τ = 1, λ = 50, and m = 15. A good solution corresponding to a local minimum for E is the expected, if not the best, solution (global minimum). An annealing process could be considered to move out of any local minimum. As was mentioned before, the traveling salesperson problem is one of those problems for which a single approach cannot be found that will be successful in all cases. There isn’t very much guidance as to how to choose the parameters in general for the use of the Hopfield network to solve the traveling salesperson problem.
C++ Implementation of the Hopfield Network for the Traveling Salesperson Problem
We present a C++ program for the Hopfield network operation for the traveling salesperson problem. The header file is in the Listing 15.1, and the source file is in the Listing 15.2. A tsneuron class is declared for a neuron and a network class for the network. The network class is declared a friend in the tsneuron class. The program follows the procedure described for setting inputs, connection weights, and updating.
Program Details
The following is a listing of the characteristics of the C++ program along with definitions and/or functions.


•  The number of cities, the number of iterations, and the distances between the cities are solicited from the user.
•  The distances are taken as integer values. If you want to use real numbers as distances, the type for distance matrix needs to be changed to float, and corresponding changes are needed for calcdist ( ) function, etc.
•  tourcity and tourorder arrays keep track of the cities that have to be covered and the order in which it is to be done.
•  A neuron corresponds to each combination of a city and its order in the tour. The ith city visited in the order j , is the neuron corresponding to the element j + i*n, in the array for neurons. Here n is the number of cities. The i and the j vary from 0 to n – 1. There are n2 neurons.
•  mtrx is the matrix giving the weights on the connections between the neurons. It is a square matrix of order n2.
•  An input vector is generated at random in the function main ( ), and is later referred to as ip
•  asgninpt ( ) function presents the input vector ip to the network and determines the initial activations of the neurons.
•  getacts ( ) function updates the activations of the neurons after each iteration.
•  getouts ( ) function computes the outputs after each iteration. la is used as abbreviation for lambda in its argument.
•  iterate ( ) function carries out the number of iterations desired.
•  findtour ( ) function determines the tour orders of cities to be visited using the outputs of the neurons. When used at the end of the iterations, it gives the solution obtained for the traveling salesperson problem.
•  calcdist ( ) function calculates the distance of the tour in the solution.

Listing 15.1 Header file for the C++ program for the Hopfield network for the traveling salesperson problem


//trvslsmn.h V. Rao, H. Rao
#include <iostream.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>

#define MXSIZ 11

class tsneuron
{
protected:
int cit,ord;
float output;
float activation;
friend class network;

public:
tsneuron() { };
void getnrn(int,int);
};

class network
{
public:
int citnbr;
float pra,prb,prc,prd,totout,distnce;

tsneuron (tnrn)[MXSIZ][MXSIZ];
int dist[MXSIZ][MXSIZ];
int tourcity[MXSIZ];
int tourorder[MXSIZ];
float outs[MXSIZ][MXSIZ];
float acts[MXSIZ][MXSIZ];
float mtrx[MXSIZ][MXSIZ];
float citouts[MXSIZ];
float ordouts[MXSIZ];

network() { };
void getnwk(int,float,float,float,float);
void getdist(int);
void findtour();
void asgninpt(float *);
void calcdist();
void iterate(int,int,float,float,float);
void getacts(int,float,float);
void getouts(float);

//print functions

void prdist();
void prmtrx(int);
void prtour();
void practs();
void prouts();
};






Previous
Table of Contents
Next






Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.



Wyszukiwarka

Podobne podstrony:
429 16
429 431
INDEX (429)
429 02
427 429
429 07
index (429)
Maho HCNC 432 [MS] M491 89

więcej podobnych podstron