void solve(int nitems, int *n1ind, int *n2ind) { // TODO: free graph on failure int ncolours = 2; bool success = false; while (!success) { // Is it a good idea to reconstruct the graph just to update // the number of possible colors? Maybe you can do a DFS to update // to update the value Graph graph = construct_graph(ncolours, nitems, n1ind, n2ind); success = start_solver(&graph); ncolours++; } }
int main(int argc, const char * argv[]) { int i; int Nx = 128; int Ny = 256; int center_x = 64; int center_y = 128; int frames = 8; float dt = 0.1f; float visc = 0.001f; float *u, *v; // allocate data int size = (Nx+2)*(Ny+2); u = calloc(size, sizeof(float)); v = calloc(size, sizeof(float)); if (!u || !v) printf("Cannot allocate data\n"); file = fopen("output.txt","w"); fprintf(file, "%d %d %d %d %d\n", frames, Nx, Ny, center_x, center_y); start_solver((Nx+2)*(Ny+2)); v[IX(center_x, center_y)] = 100.0; vel_step(Nx, Ny, u, v, visc, dt); vel_step(Nx, Ny, u, v, visc, dt); vel_step(Nx, Ny, u, v, visc, dt); vel_step(Nx, Ny, u, v, visc, dt); for (i=0;i<frames;i++) { vel_step(Nx, Ny, u, v, visc, dt); vel_step(Nx, Ny, u, v, visc, dt); vel_step(Nx, Ny, u, v, visc, dt); vel_step(Nx, Ny, u, v, visc, dt); print_vel(u, v, Nx, Ny); } end_solver(); fclose(file); return 0; }
int main (int argc, char *argv[]) { int from_z3[2]; int from_yices[2]; int status; if (argc < 2) { fprintf(stderr, "usage: %s file\n", argv[0]); exit(1); } FILE *z3file = fopen(argv[1], "r"); FILE *yicesfile = fopen(argv[1], "r"); assert(z3file != NULL); assert(yicesfile != NULL); //Set up the pipes to talk to the solvers status = pipe(from_z3); assert(status == 0); status = pipe(from_yices); assert(status == 0); start_solver(Z3, fileno(z3file), from_z3[1]); start_solver(YICES, fileno(yicesfile), from_yices[1]); assert(z3file != NULL); assert(yicesfile != NULL); fclose(z3file); fclose(yicesfile); //Set up our in process sockets context = zmq_ctx_new (); //Setup the controller as the sink void *responder = zmq_socket (context, ZMQ_PULL); int rc = zmq_bind (responder, "inproc://controller"); assert (rc == 0); //Set to receive all messages //int sk = zmq_setsockopt (responder, ZMQ_SUBSCRIBE, NULL, 0); //assert (sk == 0); //Set up our workers (Solvers) void *skz3 = zmq_socket(context, ZMQ_PUSH); rc = zmq_connect(skz3, "inproc://controller"); assert (rc == 0); void *skyices = zmq_socket(context, ZMQ_PUSH); rc = zmq_connect(skyices, "inproc://controller"); assert (rc == 0); //Start the controller / worker threads pthread_t control; status = pthread_create(&control, NULL, control_worker, (void*)responder); assert(status == 0); start_worker(Z3, skz3, from_z3[0]); start_worker(YICES, skyices, from_yices[0]); while(1) sched_yield(); return 0; }