int mda_dump_header( XDR *xdrs) { short int rank; long int extrapvs; int i; f_print( xdrs, "Version = %g\n" ); li_print( xdrs, "Scan number = %li\n"); rank = si_print( xdrs, "Data rank = %i\n"); if( rank <= 0) { fflush(stdout); exit(1); } print("Largest scan bounds = "); for( i = 0; i < rank; i++) { if( i) print(" x "); li_print( xdrs, "%li"); } print("\n"); li_print( xdrs, "Regularity = %li\n"); extrapvs = li_print( xdrs, "File offset to extra PV's = %li bytes\n"); if( extrapvs < 0) { fflush(stdout); exit(1); } print("\n\n"); if( extrapvs) return 1; else return 0; }
typename graph_traits<Graph>::size_type subiso_triangles(Graph& g, vertex_property_map<Graph, VertexProperty>& vPropmap, edge_property_map<Graph, EdgeProperty>& ePropmap, Visitor& user_vis) { typedef typename graph_traits<Graph>::size_type size_type; typedef typename graph_traits<Graph>::vertex_descriptor vertex_descriptor; typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor; typedef vertex_property_map<Graph, VertexProperty> vertex_property_map_t; typedef edge_property_map<Graph, EdgeProperty> edge_property_map_t; typedef pair<size_type, size_type> pair_t; typedef Graph TargetGraph; typedef size_type size_type_trg; typedef array_property_map<size_type, vertex_id_map<TargetGraph> > vertex_property_map_trg; typedef array_property_map<size_type, edge_id_map<TargetGraph> > edge_property_map_trg; // ************************************************************ // ** finding bipartite structure ***************************** // ************************************************************ TargetGraph target; const size_type_trg numVertsTarget = 3; const size_type_trg numEdgesTarget = 3; size_type_trg sourcesTarget[numEdgesTarget] = { 0, 1, 2 }; size_type_trg targetsTarget[numEdgesTarget] = { 1, 2, 0 }; size_type vTypesTarget[numVertsTarget] = { 0, 1, 2 }; size_type eTypesTarget[numEdgesTarget] = { 0, 0, 0 }; init(numVertsTarget, numEdgesTarget, sourcesTarget, targetsTarget, target); #ifdef DEBUG printf("TARGET:\n"); print(target); #endif // ************************************************************ vertex_id_map<TargetGraph> trg_vid_map = get(_vertex_id_map, target); edge_id_map<TargetGraph> trg_eid_map = get(_edge_id_map, target); vertex_property_map_trg vTypemapTarget(vTypesTarget, trg_vid_map); edge_property_map_trg eTypemapTarget(eTypesTarget, trg_eid_map); // ************************************************************* // SET UP THE TARGET WALK // ************************************************************* dynamic_array<vertex_descriptor> walk_verts; walk_verts.push_back(vertices(target)[0]); walk_verts.push_back(vertices(target)[1]); walk_verts.push_back(vertices(target)[2]); walk_verts.push_back(vertices(target)[0]); dynamic_array<edge_descriptor> walk_edges; walk_edges.push_back(edges(target)[0]); walk_edges.push_back(edges(target)[1]); walk_edges.push_back(edges(target)[2]); // ************************************************************* typedef default_path_printer<Graph> path_printer; typedef tri_match_visitor<Graph, Visitor, vertex_property_map_t> path_evaluator; // ********************************************************************** // WILD CARDS: for an example of allowing "wild cards" (don't care // conditions), comment in the dontcare_comparator to // replace si_default_comparator. // ********************************************************************** // typedef subtri_dontcare_comparator<Graph, vertex_property_map_t, // edge_property_map_t, TargetGraph, // vertex_property_map_trg, // edge_property_map_trg> // si_comparator; typedef si_default_comparator<Graph, vertex_property_map_t, edge_property_map_t, TargetGraph, vertex_property_map_trg, edge_property_map_trg> si_comparator; si_comparator si_comp(vPropmap, ePropmap, vTypemapTarget, eTypemapTarget); path_printer si_print(g); path_evaluator si_visit(g, user_vis, vPropmap); /* dynamic_array<pair_t> level_pairs; level_pairs.push_back(pair_t(0, 3)); size_type num_candidates = subgraph_isomorphism(g, target, walk_verts, walk_edges, si_comp, si_visit, level_pairs); */ // The last argument forces vertex 0 in the walk to be the same as vertex 3 // in the walk. (Constraining the candidate matches to be closed walks in // this case.) size_type num_candidates = subgraph_isomorphism(g, target, si_comp, si_visit); return num_candidates; }
static void search_basic(search_configuration *conf) { thread *workers; rating_t rating; unsigned int i; time_t start, stop; /* check parameters */ ASSERT(conf != (search_configuration *)0); /* get start time */ start = time(NULL); /* determine search depths */ conf->precalcdepth = MIN(3, conf->problem->depth); printf("(%i/%i) ", conf->precalcdepth, conf->problem->depth); /* initialize search configuration */ conf->numleafnodes = 0; conf->numleafnodesdone = 0; conf->numleafnodesleft = 0; conf->nextleaf = (search_node *)0; /* initalize search result */ conf->result->rating = RATING_INIT_INF; ML_CLEAR(conf->result->solution); ML_CLEAR(conf->result->bestmoves); conf->result->numnodes = 0; conf->result->time = 0; /* create search tree */ conf->rootnode = (search_node *)w_malloc(sizeof(search_node)); search_create_tree(conf, &(conf->problem->pos), conf->rootnode, 0); /* check if basic search tree contains the solution */ rating = search_update_ratings(conf->rootnode, conf->problem->pos.player, 0); if (rating != RATING_INIT_INF) { conf->result->rating = rating; search_collect_result(conf); printf("result already found in precalculated tree"); } /* check if no further search necessary */ else if (conf->problem->depth <= conf->precalcdepth) { printf("no result found in precalculated tree, no main search necessary"); } /* if not, start the main search */ else { /* all leaf nodes are searched again in main search: no not count them twice */ conf->result->numnodes -= conf->numleafnodes; /* prepare stats bar */ search_init_statsbar(stdout); /* prepare threads */ conf->numleafnodesleft = conf->numleafnodes; workers = (thread *)w_malloc(conf->numthreads * sizeof(thread)); mutex_create(&(conf->workerlock)); /* create and start all working threads */ for (i = 0; i < conf->numthreads; i++) { thread_create(&(workers[i]), search_mainsearch_thread, (void *)conf); } /* supend main thread until all jobs have been finished */ for (i = 0; i < conf->numthreads; i++) { thread_join(&(workers[i])); } /* workers should have finished all jobs */ ASSERT(conf->numleafnodesleft == 0); ASSERT(conf->numleafnodes == conf->numleafnodesdone); ASSERT(conf->nextleaf == (search_node *)0); /* clean up */ mutex_destroy(&(conf->workerlock)); w_free(workers); /* extract result from search tree */ rating = search_update_ratings(conf->rootnode, conf->problem->pos.player, 0); if (rating != RATING_INIT_INF) { conf->result->rating = rating; search_collect_result(conf); } } printf(" ("); si_print(stdout, conf->result->numnodes); printf("N)\n"); /* clean up */ search_destroy_tree(conf->rootnode); w_free(conf->rootnode); /* get total time */ stop = time(NULL); conf->result->time = stop - start; }
void mda_dump_extra( XDR *xdrs) { enum PV_TYPES { DBR_STRING=0, DBR_CTRL_CHAR=32, DBR_CTRL_SHORT=29, DBR_CTRL_LONG=33, DBR_CTRL_FLOAT=30, DBR_CTRL_DOUBLE=34 }; int i, j; short int pvs, type, count; count = 0; print( "\n\nExtra PV Offset = %li", xdr_getpos( xdrs) ); pvs = si_print( xdrs, "\n\nNumber of Extra PV's = %i.\n"); if( pvs < 0) { fflush(stdout); exit(1); } for( i = 0 ; i < pvs; i++) { print( "\nExtra PV #%i:\n", i+1); cs_print( xdrs, " Name = %s\n"); cs_print( xdrs, " Description = %s\n"); if( !xdr_short(xdrs, &type) ) return; if( (type != DBR_STRING) && (type != DBR_CTRL_CHAR) && (type != DBR_CTRL_SHORT) && (type != DBR_CTRL_LONG) && (type != DBR_CTRL_FLOAT) && (type != DBR_CTRL_DOUBLE)) { print( " Type = %i (UNKNOWN)\n", type); print( "\nExiting......\n"); exit(2); } if( type != DBR_STRING) { count = si_print( xdrs, " Count = %i\n"); cs_print( xdrs, " Unit = %s\n"); } switch(type) { case DBR_STRING: print( " Type = %i (DBR_STRING)\n", type); cs_print( xdrs, " Value = \"%s\"\n"); break; case DBR_CTRL_CHAR: { unsigned int size, maxsize; char *bytes; print( " Type = %i (DBR_CTRL_CHAR)\n", type); print( " Value%s = ", (count == 1) ? "" : "s"); maxsize = count; if( !xdr_bytes( xdrs, &(bytes), &size, maxsize ) ) return; count = size; for( j = 0; j < count; j++) { if( j) print( ", "); print( "%i", bytes[j]); } print( "\n"); } break; case DBR_CTRL_SHORT: { short int *shorts; print( " Type = %i (DBR_CTRL_SHORT\n", type); print( " Value%s = ", (count == 1) ? "" : "s"); shorts = (short int *) malloc( count * sizeof(short)); if( !xdr_vector( xdrs, (char *) shorts, count, sizeof( short), (xdrproc_t) xdr_short)) return; for( j = 0; j < count; j++) { if( j) print( ", "); print( "%i", shorts[j]); } print( "\n"); free (shorts); } break; case DBR_CTRL_LONG: { long int *longs; print( " Type = %i (DBR_CTRL_LONG)\n", type); print( " Value%s = ", (count == 1) ? "" : "s"); longs = (long int *) malloc( count * sizeof(long)); if( !xdr_vector( xdrs, (char *) longs, count, sizeof( long), (xdrproc_t) xdr_long)) return ; for( j = 0; j < count; j++) { if( j) print( ", "); print( "%li", longs[j]); } print( "\n"); free( longs); } break; case DBR_CTRL_FLOAT: { float *floats; print( " Type = %i (DBR_CTRL_FLOAT)\n", type); print( " Value%s = ", (count == 1) ? "" : "s"); floats = (float *) malloc( count * sizeof(float)); if( !xdr_vector( xdrs, (char *) floats, count, sizeof( float), (xdrproc_t) xdr_float)) return ; for( j = 0; j < count; j++) { if( j) print( ", "); print( "%.9g", floats[j]); } print( "\n"); free( floats); } break; case DBR_CTRL_DOUBLE: { double *doubles; print( " Type = %i (DBR_CTRL_DOUBLE)\n", type); print( " Value%s = ", (count == 1) ? "" : "s"); doubles = (double *) malloc( count * sizeof(double)); if( !xdr_vector( xdrs, (char *) doubles, count, sizeof( double), (xdrproc_t) xdr_double)) return; for( j = 0; j < count; j++) { if( j) print( ", "); print( "%.9lg", doubles[j]); } print( "\n"); free( doubles); } break; } } }
void mda_dump_scan( XDR *xdrs) { int i, j; short int rank, num_pos, num_det, num_trg; long int req_pts, cmp_pts; long int *offsets; offsets = NULL; rank = si_print( xdrs, "This scan's rank = %i\n"); req_pts = li_print( xdrs, "Number of requested points = %li\n"); cmp_pts = li_print( xdrs, "Last completed point = %li\n"); if( (rank <= 0) || (req_pts <= 0) || (cmp_pts < 0) ) { fflush(stdout); exit(1); } if( rank > 1) { offsets = (long int *) malloc( sizeof( long int) * req_pts); print("Offsets to lower scans = "); for( i = 0; i < req_pts; i++) { if( i) print(", "); offsets[i] = li_print( xdrs, "%li"); } print("\n"); } cs_print( xdrs, "Scan name = \"%s\"\n"); cs_print( xdrs, "Scan time = \"%s\"\n"); num_pos = si_print( xdrs, "Number of positioners = %i\n"); num_det = si_print( xdrs, "Number of detectors = %i\n"); num_trg = si_print( xdrs, "Number of triggers = %i\n"); if( num_pos < 0) { fflush(stdout); exit(1); } for( i = 0; i < num_pos; i++) { print( "\nPositioner Data Set #%i\n", i+1); si_print( xdrs, " Positioner: %i\n"); cs_print( xdrs, " Name: %s\n"); cs_print( xdrs, " Description: %s\n"); cs_print( xdrs, " Step Mode: %s\n"); cs_print( xdrs, " Unit: %s\n"); cs_print( xdrs, " Readback Name: %s\n"); cs_print( xdrs, " Readback Description: %s\n"); cs_print( xdrs, " Readback Unit: %s\n"); } if( num_det < 0) { fflush(stdout); exit(1); } for( i = 0; i < num_det; i++) { print( "\nDetector Data Set #%i\n", i+1); si_print( xdrs, " Detector: %2i\n"); cs_print( xdrs, " Name: %s\n"); cs_print( xdrs, " Description: %s\n"); cs_print( xdrs, " Unit: %s\n"); } if( num_trg < 0) { fflush(stdout); exit(1); } for( i = 0; i < num_trg; i++) { print( "\nTrigger #%i\n", i+1); si_print( xdrs, " Trigger: %i\n"); cs_print( xdrs, " Name: %s\n"); f_print( xdrs, " Command: %g\n"); } for( i = 0; i < num_pos; i++) { print( "\nPositioner #%i data:\n", i+1); for( j = 0; j < req_pts; j++) d_print( xdrs, "%.9lg "); print( "\n"); } for( i = 0; i < num_det; i++) { print( "\nDetector #%i data:\n", i+1); for( j = 0; j < req_pts; j++) f_print( xdrs, "%.9g "); print( "\n"); } if( rank > 1) for( i = 0; i < req_pts; i++) { if( offsets[i] == 0) break; print( "\n\n%i-D Subscan #%i\n", rank - 1, i+1); print( "Offset = %li\n\n", xdr_getpos( xdrs) ); mda_dump_scan( xdrs); } }