#include <iostream>
usingnamespace std;
void greedyfunc(void);
double TSP(void);
void checkingvalid(void);
int size = 5;
int dummyroad[size];
bool myarray[5];
int main(void)
{
;
}
void greedyfunc(void)
{
int index;
for(int i=1;i<index;i++)
if (vals[i] < loVal)
loVal = vals[i];
}
}
double TSP(first.parent, second parent)
{
int index;
for(int i = 0;i<index;i++)
if(first.parent.i == second.parent.i)
return (first.parent.i);
elseif (first.parent.i > second.parent.i)
{
greedyfunc(second.parent.i);
}
else
{
greedyfunc(first.parent.i);
}
}
void checkingvalid(void)
{
int num;
int index;
for(int i = 0; i < index; i++)
{
;//connnecting routes adding 1 each time, add 2 the first time.
}
while (num != size)
delete route; //remember to declare it.
}
As you see i am NO WHERE near to complete. Now here's my approach.
1)assuming the array[5] is initialized with numbers, the numbers represent the length it takes it travel from each of the 5 cities, so right away you can imagine a 5 by 5 symmetric matrix.
2) my problem is i don't know how to start with cities, i recognize the city by length, as you see in line 29 i am trying to compare each parents route segment, and if the segment is the same(meaning if both routes have point A to point C) the new child route will also have that segment. Within that tsp function, i will also call greedyfunc, where greedyfunc is just a function that connect the closest city which i have no idea how to code it )=.
This method is call genetic algorithm, i know there are some code out there but i don't understand and i would like to stay in my approach. anyone can help me with it i will be greatly appreciated.