diff --git a/src/routing4SITA b/src/routing4SITA index d80bc30..1ae53e7 100755 Binary files a/src/routing4SITA and b/src/routing4SITA differ diff --git a/src/routing4SITA.c b/src/routing4SITA.c index 41543b7..2685b65 100644 --- a/src/routing4SITA.c +++ b/src/routing4SITA.c @@ -28,10 +28,14 @@ int main() { pthread_join(startThread, NULL); - printf("\nBest Path: "); - for(int i = 0; i < data->bestpath->depth; i++){ - printf("%i --> ", data->bestpath->predecessorsBestPath[i]); + printf("pathdepth: %i\n", data->bestpath->depth); + + + printf("\nBest Path: %i", data->bestpath->predecessorsBestPath[0]); + + for(int i = 1; i <= data->bestpath->depth; i++){ + printf(" --> %i", data->bestpath->predecessorsBestPath[i]); } printf("\nWith cost of: %i\n", data->bestpath->lowestCost); @@ -57,22 +61,24 @@ void *Search(void* arguments) { if(data->bestpath->lowestCost == -1) { //first solution found - printf("first solution found\n"); + printf("first solution found! %i\n", data->depth); data->bestpath->lowestCost = data->cost; data->bestpath->depth = data->depth; for(int j = 0; j < data->depth; j++) { data->bestpath->predecessorsBestPath[j] = data->predecessors[j]; } + data->bestpath->predecessorsBestPath[(data->bestpath->depth)] = data->node->id; } else { if(data->bestpath->lowestCost > data->cost) { //new best solution found - printf("new best solution found\n"); + printf("new best solution found! %i\n", data->depth); data->bestpath->lowestCost = data->cost; data->bestpath->depth = data->depth; for(int j = 0; j < data->depth; j++) { data->bestpath->predecessorsBestPath[j] = data->predecessors[j]; } + data->bestpath->predecessorsBestPath[(data->bestpath->depth)] = data->node->id; } } @@ -95,12 +101,16 @@ void *Search(void* arguments) { nextdata->node = (data->node->nodesnext[i]); nextdata->bestpath = data->bestpath; nextdata->cost = data->node->nodescost[i] + data->cost; - nextdata->depth++; + nextdata->depth = data->depth + 1; for(int j = 0; j < data->depth; j++) { nextdata->predecessors[j] = data->predecessors[j]; + + printf("data->predecessors: %i\n", data->predecessors[j]); + } - nextdata->predecessors[(nextdata->depth)+1] = data->node->id; + + nextdata->predecessors[((nextdata->depth) - 1)] = data->node->id; pthread_create(&threads[i], NULL, Search, nextdata); }