/* parseResult * Parses a message containing the graph adjacency matrix * Message format "[graphsize]:[graph adjacency matrix]" */ static void parseResult(char *pch) { /* Get gsize */ pch = strtok(NULL, ":"); int gsize = atoi(pch); /* Get Clique Count */ pch = strtok(NULL, ":"); int clCount = atoi(pch); /* Get matrix */ pch = strtok(NULL, ":"); int *g = ChartoGraph(pch, gsize); /* Verify integrity of g */ int realCount = CliqueCount(g, gsize); /* Message is invalid */ if (realCount != clCount) { fprintf(stderr, "Message could not be validated!\n"); fprintf(stderr, "Clique count from message: %d, actual clique count: %d!\n", clCount, realCount); return; } /* Update scheduler */ if(clCount == 0) { fprintf(stderr, "Counterexample successfully received!\n"); if(gsize > _Scheduler->currCEsize) { /* Found a counterexample */ /* Update Scheduler */ _Scheduler->currCEsize = gsize; /* clear list and add new counterexample */ free_dllist(_Scheduler->counterExamples); _Scheduler->counterExamples = new_dllist(); _Scheduler->listSize = 0; addCounterExample(g); /* Update current pointer */ _Scheduler->currPtr = dll_first(_Scheduler->counterExamples); /*print only when save a counterexample*/ fprintf(stderr, "get a counterexample with bigger size, size: %d\n, currCEsize: %d\n", gsize, _Scheduler->currCEsize); /* Save counterexample into a file */ SaveGraph(g,gsize, "../../../counterexamples"); } /* Just add new counterexample */ else if(gsize == _Scheduler->currCEsize) { fprintf(stderr, "Saving a counterexample with same size\n"); addCounterExample(g); SaveGraph(g,gsize, "../../../counterexamples"); } } }
void DemoKeeper::notifyMenuCtrlAccept(wraps::ContextMenu* _sender, const std::string& _id) { if (_id == "SaveGraph") { SaveGraph(); return; } else if (_id == "LoadGraph") { LoadGraph(); return; } else if (_id == "ClearGraph") { ClearGraph(); return; } std::string name = _id; size_t index = name.find("Controller"); if (index != MyGUI::ITEM_NONE) name.erase(index); else { index = name.find("State"); if (index != MyGUI::ITEM_NONE) name.erase(index); } static size_t name_index = 0; name_index++; name = MyGUI::utility::toString(name, "_", name_index); createNode(_id, name); }
//---------------------------------------------------------------------------- bool GpuLocalSolver2::OnPreIteration (uint64_t iteration) { #ifdef PRE_GAUSSSEIDEL_SAVE int j0 = mDimension[0]*(mDimension[1]/2); for (int i0 = 0; i0 < mDimension[0]; ++i0, ++j0) { mSlice[i0] = mReadBack[j0]; } int frame = (int)iteration; SaveGraph(mFolder, frame, 100.0f, mDimension[0], mSlice); float umax = mSlice[mDimension[0]/2]; std::cout << "frame = " << frame << " : umax = " << umax << std::endl; #else WM5_UNUSED(iteration); #endif return true; }
//---------------------------------------------------------------------------- bool GpuLocalSolver3::OnPreIteration (uint64_t iteration) { #ifdef PRE_GAUSSSEIDEL_SAVE int u, v; for (int i0 = 0; i0 < mDimension[0]; ++i0) { Map3Dto2D(i0, mDimension[1]/2, mDimension[2]/2, u, v); mSlice[i0] = mReadBack[u + mBound[0]*v]; } int frame = (int)iteration; SaveGraph(mFolder, frame, 100.0f, mDimension[0], mSlice); float umax = mSlice[mDimension[0]/2]; std::cout << "frame = " << frame << " : umax = " << umax << std::endl; #else WM5_UNUSED(iteration); #endif return true; }