double Solver::getSolution(){ const bool debug = debug1; vrpd = new VRPD(*this); vrp = new VRP(*this); vrp->initHelper(); double startingTemp = startingTemperatur, coolingRatio = coolRatio; int numLoops = numOfLoops, itersPerLoop = numOfItersPerLoop, nListSize = numOfListSize; int heuristics = theHeuristics; bool verbose = false; vrp->SA_solve(heuristics, startingTemp, coolingRatio, itersPerLoop, numLoops, nListSize, verbose); if (debug) { displayDebugInfo(); } trackBestSolution(); double result = vrp->getCurrentObject(); delete vrpd; delete vrp; return result; }
int main(int argc, char **argv) { int i; int n; int count; unsigned int seed=0; NodePtr node; JobPtr job; ListPtr list; if (argc < 2) { fprintf(stderr, "Usage: %s <list size> [<test size=list size>] [<seed>] \n",argv[0]); exit(1); } n = atoi(argv[1]); count = n; if (argc >= 3) { count = atoi(argv[2]); } if (argc == 4) { seed = atoi(argv[3]); } list = createList(); runEdgeCases(); printf("%s\n%s\n", sep, "Running addAtFrontTest"); addAtFrontTest(list, count); if (DEBUG > 0) displayDebugInfo(list); printf("\n%s\n%s\n", sep, "Running removeFromFrontAll Test"); removeFrontAll(list, count); if (DEBUG > 0) displayDebugInfo(list); printf("\n%s\n%s\n", sep, "Running addAtRear Test"); addAtRearTest(list, count); if (DEBUG > 0) displayDebugInfo(list); printf("\n%s\n%s\n", sep, "Running removingFromRear Test"); removeRearAll(list, count); if (DEBUG > 0) displayDebugInfo(list); //for(i = count; i > 0; i--) //removeFrontOne(list); printf("\n%s\n%s\n", sep, "Running removeNode Test"); addAtRearTest(list, count); removeNodeAllTest(list, count); if (DEBUG > 0) displayDebugInfo(list); printf("\n%s\n%s\n", sep, "Running reverseList Test"); addAtRearTest(list, count); reverseList(list); verifyAddAtFrontList(list, count); if (DEBUG > 0) displayDebugInfo(list); printf("\n%s\n%s\n", sep, "Running random tests"); for (i=0; i<n; i++) { job = createJob(i, "args", i); node = createNode(job); /*printf("job ptr = %p node ptr = %p\n", job, node);*/ addAtFront(list, node); } runRandomTests(count, seed, n, list); freeList(list); exit(0); }