⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 intel ipp4.1性能库的一些例子。
💻 C
📖 第 1 页 / 共 2 页
字号:
  /* build type hierarchy   */  /* This is needed to get all types.   */  new_build_orig_constant_list();   /* preprocess PlNodes so as to be able to translate them   * into CodeNodes   */  /* assign unique names to variables and normalize effects   */  pddl_outer();  /* collect all strings in the domain representation, store   * them into global string arrays, and   * collect inertia information on the way.   * also create types and predicate args types   */  /* compute values of global arrays   *   * gconstants_table   * gtypes_table   * gpredicates_table   * garity   * gpredicates_args_type   */  collect_all_strings();  /* translate Input formula into coded format;   *   * also do syntax checking    * (legal effects, conditions, quantification etc.)   * and structure normalization   */  transform_PlNodes_to_CodeNodes();  /* perform advanced domain definition check:   * simplify input, i.e., search for formula that can be   * trivially simplified and issue warnings, if one is found.   *   * then, find logical tautologies, like A and not A, and issue    * warnings for any such occurence.   *   * afterwards, continue planning on the again simplified    * (due to tautologies) domain description   *   * NOTE: the arguments to that functions only say that "yes, issue   *       a warning wenever you find something"    */  simplify_all_CodeNodes( TRUE );  detect_all_tautologies( TRUE );  simplify_all_CodeNodes( TRUE );  /* prepare for instantiation process:   * build implicit tuple tables for fast access to   * initial state information ( see Technical Report 122 )   *   * also used in unary to types encoding, that's why it   * needs to be done here already   */  build_predicate_tables();  /* encode unary inertia used in op and goal state description   * as types (see TR 122), to make instantiation   * process a good deal faster   *   * afterwards, find new (maybe resulting from that) tautologies,   * simplify description and go on.   */  encode_unary_inertia_in_types();  detect_all_tautologies( FALSE );  simplify_all_CodeNodes( FALSE );  if ( gcmd_line.display_info == 5 ) {    printf("\nfinal pre-instantiation initial state is:\n");    print_CodeNode( gcode_initial_state, 0 );    printf("\nfinal pre-instantiation goal state is:\n");    print_CodeNode( gcode_goal_state, 0 );    printf("\nfinal pre-instantiation operators are:");    for ( o = gcode_operators; o; o = o->next ) {      print_CodeOperator( o );    }  }  /* the actual instantiation part, first step that actually may need   * significant computation time: create all instances of operator   * schemata, and transform all quantifiers (ALL/EX) into con/dis junction   *   * representation is simultaneously cleand up where easily possible (in   * particular, initial + goal state are fully simplified and checked),   * as that might well save a lot of time.    *   * for better overview, the final clean up of operators, tautologies and (e.g.)    * empty effects removal, is done separately in spite of this, after also setting   * relevants.   *   * anyone crazy enough to try can maybe gain some efficiency by   * messing the two (three) parts of code together. GOOD LUCK !   *   * something more striking: I don't really know if at all, or how many,   *                          tautologies can result from instantiating.   *                          maybe one can spare the tautologie search   *                          in all instances and then, also the simplification   *                          of condition CodeNodes in final clean up   */  multiply_params_and_quantifiers();  if ( gcmd_line.display_info == 6 ) {    printf("\n1. step instantiated initial state is:\n");    print_CodeNode( gcode_initial_state, 0 );    printf("\n1. step instantiated goal state is:\n");    print_CodeNode( gcode_goal_state, 0 );    printf("\n1. step instantiated operators are:");    for ( o = ginst_code_operators; o; o = o->next ) {      print_CodeOperator( o );    }  }  /* now we don't need the global tuple tables anymore;   * so free their memory   */  free_predicate_tables();  /* detect all facts that can, in principle, change their truth value during   * planning. these are the facts that are relevant to the problem.   *   * set all other atoms to TRUE/FALSE and perform a final clean up of the    * actions. (initial + goal are also simplified a last time)   */  collect_relevant_facts();  detect_inst_CodeOperator_tautologies();  simplify_all_inst_CodeOperators();  if ( gcmd_line.display_info == 8 ) {    printf("\nfinal initial state is:\n");    print_CodeNode( gcode_initial_state, 0 );    printf("\nfinal goal state is:\n");    print_CodeNode( gcode_goal_state, 0 );    printf("\nfinal operators are:");    for ( o = ginst_code_operators; o; o = o->next ) {      print_CodeOperator( o );    }  }  /* transform the cleaned up and simplified CodeNode ops, initial and goal   * into bitmaps, i.e., represent each fact by its index in grelevant_facts   * and a set of facts by the membership vector. if goal is disjunctive,   * add a new GOAL_REACHED fact as well as one obvious op for each disjunct.   * On the way, melt identical effects, which means that effects that have the same   * set of preconditions are put together. The identification of an op's    * unconditional effects is a special case of this   */  generate_bitmap_representation();  /* now we're actually finished with instantiating and can worry about   * planning for a change   */  times( &end );  TIME( inst_time );  if ( gcmd_line.display_info ) {    printf("\ninstantiated %d actions\n\n\n", gnum_bit_operators);  }  /* RIFO: remove irrelevant facts and operators */  /* rifo called with -R (and not -M) option, applying fixed heuristic given in command line */  if (gcmd_line.rifo_on && !gcmd_line.rifo_meta_on)    {      if ( gcmd_line.display_info )	{	  fprintf( OUT, "\nremoving irrelevant facts and operators\n");	}      times(&start);      find_relevant_initial_facts();      times(&end);      TIME( rifo_time );      rifo_total_time = rifo_time;    }  /* rifo called with -M option, use metastrategy */  else if (gcmd_line.rifo_meta_on)    {       if ( gnum_bit_operators > action_threshold 	   && gconstants_table_size > objects_threshold )	rifo_meta = 2;      else if ( gconstants_table_size > objects_threshold )	rifo_meta = 1;            /* save original states and operators for the case that rifo fails*/      save_original_ipp_information();    }  while ( rifo_meta >= 0 )    { /* repeat planning with decresing strength of filtering until goals 	 are reached or no plan can be found at all */      if (rifo_meta > 0)	{	  if (gcmd_line.display_info >=1 )	    {	      fprintf( OUT, "\nrifo metastrategy: %s filtering\n"		       , rifo_meta==2 ? "strong" : "weak");	    }	  times(&start);	  find_relevant_initial_facts();	  times(&end);	  TIME( rifo_time );	  rifo_total_time += rifo_time;	}      else 	if ( gcmd_line.rifo_meta_on )	  {	    if (gcmd_line.display_info )	      {		fprintf( OUT, "\nrifo metastrategy: no filtering\n\n" );	      }	  }      /* now we get back to general, non-RIFO code */            /* build the graph until goals or fixpoint are reached */      min_time = gcmd_line.min_time;      times(&start);      reached_goals = build_graph( &min_time );      times(&end);      TIME( build_time );            if ( !reached_goals ) {	if ( min_time < MAX_PLAN ) {/* fixpoint without goals */	  if ( gcmd_line.display_info ) {	    fprintf( OUT, "\nproblem unsolvable: can't reach non exclusive goals\n\n");	    output_planner_info( inst_time, rifo_total_time, build_time - gexcl_time,				 gexcl_time, search_time, min_time );	  }	} else {	  if ( gcmd_line.display_info ) {/* graph oversized */	    fprintf( OUT, "\nMAX_PLAN too small( preset value: %d )\n\n", MAX_PLAN );	    output_planner_info( inst_time, rifo_total_time, build_time - gexcl_time,				 gexcl_time, search_time, min_time );	  }	}	if ( rifo_meta == 0 )	  exit( 0 );      }      else	{	  if ( gsame_as_prev_flag ) {/* we're in the fixpoint already */	    if ( gcmd_line.display_info ) {	      fprintf( OUT, "\ngraph has leveled off! wave front mechanism is taking over\n");	    }	    times(&start);	    /* after graph has leveled off, search is overtaken by the so-called wave front,	     * as introduced by Long and Fox in 	     * "The efficient Implementation of the Planning Graph in STAN", JAIR 10,1999	     */	    min_time = search_wave_front();	    if ( gwf_found_plan || !rifo_meta )	      {		times(&end);		TIME( search_time );		if ( gcmd_line.display_info ) {		  output_planner_info( inst_time, rifo_total_time, 				       build_time - gexcl_time,				       gexcl_time, search_time, min_time );		}		exit( 0 );	      }	    else	      break;	  }	  	  for ( ; min_time < MAX_PLAN; min_time++ ) {	    /* search and build one extra layer in alternating steps	     */	    	    times(&start);	    found_plan = search_plan( min_time );	    times(&end);	    TIME( search_time );	    	    if ( found_plan ) 	      {		break;	      }	    	    times(&start);	    build_graph_evolution_step();	    times(&end);	    TIME( build_time );	    	    if ( gsame_as_prev_flag ) {	      if ( gcmd_line.display_info ) {		fprintf( OUT, "\ngraph has leveled off! wave front mechanism is taking over\n");	      }	      times(&start);	      min_time = search_wave_front();	      if ( !rifo_meta || gwf_found_plan )		{		  times(&end);		  TIME( search_time );		  if ( gcmd_line.display_info ) {		    output_planner_info( inst_time, rifo_total_time, 					 build_time - gexcl_time,					 gexcl_time, search_time, min_time );		  }		  exit( 0 );		}	      else		break;	    }	  }	  	  if ( found_plan )	    break;	  	}             /* if no solution was found even without rifo filtering, exit IPP,	 else try weaker filter strategy */      if ( rifo_meta == 0 )	{ exit( 0 ); }      else	{ 	  rifo_meta--;	  free_graph_and_search_info(); 	  /* restore old states and operators */	  reset_original_ipp_information();	  /* this flag is needed to reset build_graph_evolution_step() */	  new_plan = TRUE;	}      } /* end of RIFO meta-strategy */  get_plan( min_time );  if ( gofficial_output_style )     print_official_result();  if ( gcmd_line.display_info ) {    if ( !gofficial_output_style ) {      print_plan( min_time );      fprintf( OUT, "\n" );    }    output_planner_info( inst_time, rifo_total_time, build_time - gexcl_time,			 gexcl_time, search_time, min_time );  }    exit( 0 );}void print_official_result(){  int i;  times( &lend );  printf("%s", gproblem_name);  printf(",%.2f", ( float ) ( ( lend.tms_utime - lstart.tms_utime + \                              lend.tms_stime - lstart.tms_stime  ) / 100.0) );  printf(",%d", gnum_plan_ops ); /* gnum_plan_ops is set by get_plan_ops */  for ( i = 0; i < gnum_plan_ops; i++ ) {    printf( ",(" );    print_op_name( gplan_ops[i] );    printf( ")" );  }  printf("\n"); }/* *  ----------------------------- HELPING FUNCTIONS ---------------------------- */void output_planner_info( float inst_time, float rifo_time,			  float build_time, float excl_time, 			  float search_time, int min_time ){  if ( gnum_of_actions_tried > 0 ) {    fprintf( OUT, "\n\nnumber of actions tried: %10d", 	     gnum_of_actions_tried-gnum_of_noops_tried);    fprintf( OUT, "\nnumber of noops tried  : %10d", gnum_of_noops_tried);    fprintf( OUT, "\n\nhad %7d simple memoizing hits", gsimple_hits );    fprintf( OUT, "\nhad %7d partial memoizing hits", gpartial_hits );    fprintf( OUT, "\nhad %7d subset memoizing hits", gsubset_hits );    fprintf( OUT, "\n" );  }  fprintf( OUT, "\ntime spent: %7.2f seconds instantiating %d operators", 	   inst_time, gnum_bit_operators );  if ( gcmd_line.rifo_on || gcmd_line.rifo_meta_on ){    fprintf( OUT, "\n            %7.2f seconds for rifo", rifo_time );  }  fprintf( OUT, "\n            %7.2f seconds building graph", build_time );  fprintf( OUT, "\n            %7.2f seconds calculating exclusions", excl_time );  if ( gnum_of_actions_tried > 0 ) {    fprintf( OUT, "\n            %7.2f seconds searching graph", search_time );    fprintf( OUT, "\n            %7.2f seconds total time", 	     inst_time + rifo_time + build_time + excl_time + search_time );  }   fprintf( OUT, "\n\nMemory used: %6.2f MBytes for domain representation", (float) gmemory/1000000);  if ( gcmd_line.rifo_on || gcmd_line.rifo_meta_on ) {    fprintf( OUT, "\n             %6.2f MBytes for rifo", (float) rifo_memory/1000000);}  fprintf( OUT, "\n             %6.2f MBytes for graph", (float) ggraph_memory/1000000);  fprintf( OUT, "\n             %6.2f MBytes for exclusions", (float) gexcl_memory/1000000);  fprintf( OUT, "\n             %6.2f MBytes for memoization", (float) gmemo_memory/1000000);  fprintf( OUT, "\n             %6.2f MBytes for wave front\n\n", (float) gwave_memory/1000000);  printf("\n\n");  if ( gcmd_line.write_graph ) {    if ( gcmd_line.display_info ) {      printf("\nwriting graph...\n\n");    }    SaveGraph( gcmd_line.save_name, min_time );  }}void ipp_usage( void ){  printf("\nusage of ipp:\n\n");  printf("OPTIONS   DESCRIPTIONS\n\n");  printf("-p <str>    path for operator and fact file\n");  printf("-o <str>    operator file name\n");  printf("-f <str>    fact file name\n\n");  printf("-i <num>    run-time information level( preset: 1 )\n");  printf("     0      nothing\n");  printf("     1      info on action number, graph, search and plan\n");  printf("     2      1 + info on problem constants, types and predicates\n");    printf("     3      1 + 2 + loaded operators, initial and goal state\n");  printf("     4      1 + predicates and their inertia status\n");  printf("     5      1 + 4 + goal state and operators with unary inertia encoded\n");  printf("     6      1 + actions, initial and goal state after expansion of variables\n");   printf("     7      1 + facts selected as relevant to the problem\n");  printf("     8      1 + final domain representation\n");  printf(" > 100      1 + various debugging information\n\n");  printf("-W          write complete graph to text files after planning\n");  printf("-w <str>    specify name for graph output files( preset: graph )\n\n");  printf("-m <num>    build graph up to level <num> without search\n");  printf("-S          don't do complete subset test in memoization\n");  printf("-C          print plan in AIPS 2000 Competition format\n\n");  printf("-M          rifo: remove irrelevant facts and operators using metastrategy\n");   printf("-R          rifo: remove irrelevant facts and operators using custom settings\n");   printf("-r <num>    rifo: filtering strength [1,2] (preset: 1 )\n");  printf("-u <num>    rifo: unionstrategy [1-4] (preset: 3 )\n\n");}Bool process_command_line( int argc, char *argv[] ){  char option;  memset(gcmd_line.path, 0, MAX_LENGTH);  memset(gcmd_line.ops_file_name, 0, MAX_LENGTH);  memset(gcmd_line.fct_file_name, 0, MAX_LENGTH);  gcmd_line.display_info = 1;  gcmd_line.write_graph = FALSE;  gcmd_line.save_name = gdef_save_name;  gcmd_line.do_subset = TRUE;  gcmd_line.min_time = 0;  gcmd_line.rifo_on = FALSE;  gcmd_line.rifo_union = 3;  gcmd_line.rifo_filter = 1;  gcmd_line.debug = 0;  while ( --argc && ++argv ) {    if ( *argv[0] != '-' || strlen(*argv) != 2 ) {      return FALSE;    }    option = *++argv[0];    switch ( option ) {    case 'W':      gcmd_line.write_graph = TRUE;      break;    case 'S':      gcmd_line.do_subset = FALSE;      break;    case 'R':      gcmd_line.rifo_on = TRUE;      break;    case 'M':      gcmd_line.rifo_meta_on = TRUE;      break;    case 'C':      gofficial_output_style = TRUE;      gcmd_line.display_info = 0;      break;    default:      if ( --argc && ++argv ) {	switch ( option ) {	case 'p':	  strncpy( gcmd_line.path, *argv, MAX_LENGTH );	  break;	case 'o':	  strncpy( gcmd_line.ops_file_name, *argv, MAX_LENGTH );	  break;	case 'f':	  strncpy( gcmd_line.fct_file_name, *argv, MAX_LENGTH );	  break;	case 'i':	  sscanf( *argv, "%d", &gcmd_line.display_info );	  break;	case 'w':	  strncpy( gcmd_line.save_name, *argv, MAX_LENGTH );	  break;	case 'm':	  sscanf( *argv, "%d", &gcmd_line.min_time );	  break;	case 'r':	  sscanf( *argv, "%d", &gcmd_line.rifo_filter );	  break;	case 'u':	  sscanf( *argv, "%d", &gcmd_line.rifo_union );	  break;	case 'd':	  sscanf( *argv, "%d", &gcmd_line.debug );	  break;	default:	  printf( "\nipp: unknown option: %c entered\n\n", option );	  return FALSE;	}      } else {	return FALSE;      }    }  }  return TRUE;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -