Hi, I'm yen.
Recently, I am doing my thesis project on the topic of Genetic Algorithm with Integer representation. Anyone can help me to write a simple program to solve the Travelling Salesman Problem by using Genetic Algorithm which is in integer representation?
The task is to find the shortest path of the TSP by GA program. Just a simple program.
Maybe it can start with the least 10 cities.
Thanks for help.

Hope anyone of you can see me here...thanks...
I need a program now..

commented: You're not going to get one -1

Recently, I am doing my thesis project

I'm sure your supervising professor said, just throw it up on the web and turn in whatever comes back...

For someone to begin to help you with this, you need to bring your existing code to the table. No one is going to write this for you.

commented: yes +35

Try here.

I have plenty of projects of my own to do, thanks very much.

commented: :) +35

I'm sure your supervising professor said, just throw it up on the web and turn in whatever comes back...

For someone to begin to help you with this, you need to bring your existing code to the table. No one is going to write this for you.

Sorry..I just to try an error..I am surprisingly shocked when I saw your reply..
I am not trying to ask someone to write the whole program for me, maybe I can retrieve a guidance as my reference from here..rather than blank in front of the pc..sorry if I had offended..

This is my own work..got errors..and thinking to continue more functions..

#include<stdio.h>		//to use printf function
#include<stdlib.h>		//to use rand function

#define RANDOM ((float)rand())	//random number
#define L 25			//length of chromosome
#define N 100			//size of population

void scan();		//user input
void cal();			//calculate the value based on the selection operator
void initial_population();	//generate an initial population
void fitness_evaluation(struct pop);	//evaluate the fitness of chromosome
void print();		//print the chromosomes in population
void selection();	//switch the selection operator

short parent[N+1], point[L+1];
short G,z,c;
float p;

struct pop           //create chromosome structure
{
	unsigned short gene[L+1];
	short fitness;
}chrom[N+1],off_chrom[N+1];

FILE *fout;

main()		//main function
{
	short F;
	float r;

	fout=fopen("result","w");		//open a file for output data

	scan();		//user input the datas and genetic operators

	initial_population();		//generate an initial population at random
	fitness_evaluation(&chrom);	//evaluate fitness of each chromosomes in initial population

	print();					//fprintf the initial population

	for(G=2;G<=z;G++)			//loop the generation
	{
		cal();					//calculate the value of chosen selection operator

		for(c=1;c<=N/2;c++)		//loop to produce N offspring
		{
			selection();		//switch to generate the selected selection operator

			r=RANDOM;			//generate a random number
			if(r<=p)
				crossover();	//switch to generate the selected crossover
			else
				reproduction();	//both parents produce two offsprings by reproduction
		}

		mutation();				//switch to generate the selected mutation operator

		fitness_evaluation(&off_chrom);	//evaluate the fitness of offspring

		replacement();			//replace the least fit chromosome by the fittest offspring

		printf();				//fprintf the new population

		F=sum_fitness();		//sum the fitness of new generation
		if(F==(N*L))			//stop the GA when the population converge
		{
			fprintf(fout,"The population is converges in generation %d.\n",G);
			break;
		}
	}

	fclose(fout);		//close the file
}						//end of main

I need a program now..

This came across as if you were demanding someone to do your coding.

Sorry..I just to try an error..I am surprisingly shocked when I saw your reply..
I am not trying to ask someone to write the whole program for me, maybe I can retrieve a guidance as my reference from here..rather than blank in front of the pc..sorry if I had offended..

I appreciate your apology and your candor.

Edit:
However, looking at your program there are a handful of syntactical errors, but the greatest deficit is in the "key" functions to the program. In other words, I appreciate that you posted your code, but you still have many blanks to fill in. Unless someone knows GAs or can read about them quickly, you'll still need to bear the burden of these functions. See if you can come up with anything, even a pseudocode representation first.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.