Introduction to Genetic Algorithms

C is a general-purpose structured programming language that is powerful, efficient, and compact. C combines the features of a high level language with the elements of the assembler and thus is, close to man and machine. Programs written in C are very efficient and fast. C++ is an object-oriented language that a C programmer can appreciate, especially who is an early age assembly language programmer. C++ orients towards execution performance and then towards flexibility. The name C++ signifies the evolutionary nature of the changes from C. Thus genetic algorithm being an approach based on natural evolution can be implemented using the structured programming and object programming languages. This chapter discusses few problems solved using genetic algorithm in C/C++.
In traveling salesman problem, salesman travels n cities and returns to the starting city with the minimal cost, he is not allowed to cross the city more than once. In this problem we are taking the assumption that all the n cities are inter connected. The cost indicates the distance between two cities. To solve this problem we make use of genetic algorithm because the cities are randomly. Initial population for this problem is randomly selected cities. Fitness function is nothing but the minimum cost. Initially the fitness function is set to the maximum value and for each travel, the cost is calculated and compared with the fitness function. The new fitness value is assigned to the minimum cost. Initial population is randomly chosen and...