示例#1
0
void encode_domain_in_integers( void )

{

  int i,j;

  collect_all_strings();

  if ( gcmd_line.display_info == 102 ) {
    printf("\nconstant table:");
    for ( i = 0; i < gnum_constants; i++ ) {
      printf("\n%d --> %s", i, gconstants[i]);
    }

    printf("\n\ntypes table:");
    for ( i = 0; i < gnum_types; i++ ) {
      printf("\n%d --> %s: ", i, gtype_names[i]);
      for ( j = 0; j < gtype_size[i]; j++ ) {
	printf("%d ", gtype_consts[i][j]);
      }
    }

    printf("\n\npredicates table:");
    for ( i = 0; i < gnum_predicates; i++ ) {
      printf("\n%3d --> %s: ", i, gpredicates[i]);
      for ( j = 0; j < garity[i]; j++ ) {
	printf("%s ", gtype_names[gpredicates_args_type[i][j]]);
      }
    }
    printf("\n\n");
  }


  create_integer_representation();

  cleanup_domain();

  if ( gcmd_line.display_info == 103 ) {
    printf("\n\ncoded initial state is:");
    for ( i = 0; i < gnum_full_initial; i++ ) {
      printf("\n");
      print_Fact( &(gfull_initial[i]) );
    }

    printf("\n\ncoded goal state is:");
    for ( i = 0; i < gnum_goal; i++ ) {
      printf("\n");
      print_Fact( &(ggoal[i]) );
    }

    printf("\n\ncoded operators are:");
    for ( i = 0; i < gnum_operators; i++ ) {
      print_Operator( goperators[i] );
    }
    printf("\n\n");
  }

}
示例#2
0
void build_hard_action_templates( void )

{

  int i, j, size, adr;
  MixedOperator *o;

  /* if there are no hard ops --> nothing to do!
   */
  if ( gnum_hard_operators == 0 ) {
    return;
  }

  /* remove unused params; empty types are already recognised during
   * domain translation; have to be handled after (or while)
   * unaries encoding (if done), though.
   */
  cleanup_hard_domain();

  if ( gcmd_line.display_info == 115 ) {
    printf("\n\ncleaned up hard domain representation is:\n\n");
    for ( i = 0; i < gnum_hard_operators; i++ ) {
      print_Operator( ghard_operators[i] );
    }
  }


  /* create local table of instantiated facts that occur in the
   * initial state. for fast finding out if fact is in ini or not.
   */
  for ( i = 0; i < gnum_predicates; i++ ) {
    size = 1;
    for ( j = 0; j < garity[i]; j++ ) {
      size *= gnum_constants;
    }
    lini[i] = ( int_pointer ) calloc( size, sizeof( int ) );
    for ( j = 0; j < size; j++ ) {
      lini[i][j] = 0;
    }
    for ( j = 0; j < gnum_initial_predicate[i]; j++ ) {
      adr = instantiated_fact_adress( &ginitial_predicate[i][j] );
      lini[i][adr]++;
    }
  }


  /* create mixed op for each param combination
   */
  multiply_hard_op_parameters();

  if ( gcmd_line.display_info == 116 ) {
    printf("\n\nmixed hard domain representation is:\n\n");
    for ( o = ghard_mixed_operators; o; o = o->next ) {
      print_MixedOperator( o );
    }
  }


  /* create pseudo op for each mixed op
   */
  multiply_hard_effect_parameters();
 
  if ( gcmd_line.display_info == 117 ) {
    printf("\n\npseudo hard domain representation is:\n\n");
    for ( i = 0; i < gnum_hard_templates; i++ ) {
      print_PseudoAction( ghard_templates[i] );
    }
  }
 

}
示例#3
0
void build_action_templates( void )

{

  int i, j, k, l, p;
  ActionTemplate *t;
  Operator *o;

  for ( i = 0; i < gnum_operators; i++ ) {
    lo = goperators[i];
    lo_num = i;

    for ( j = 0; j < gnum_constants; j++ ) {
      lused_constant[j] = FALSE;
    }

    lnum_inertia_preconds = 0;
    for ( j = 0; j < lo->num_preconds; j++ ) {
      if ( !gis_added[lo->preconds[j].predicate] &&
	   !gis_deleted[lo->preconds[j].predicate] ) {
	linertia_preconds[lnum_inertia_preconds++] = j;
      }
    }
      
    lnum_multiply_parameters = 0;
    for ( j = 0; j < lo->num_vars; j++ ) {
      for ( k = 0; k < lnum_inertia_preconds; k++ ) {
	p = lo->preconds[linertia_preconds[k]].predicate;
	for ( l = 0; l < garity[p]; l++ ) {
	  if ( lo->preconds[linertia_preconds[k]].args[l] ==
	       ENCODE_VAR( j ) ) {
	    break;
	  }
	}
	if ( l < garity[p] ) {
	  break;
	}
      }
      if ( k < lnum_inertia_preconds ) {
	continue;
      }
      lmultiply_parameters[lnum_multiply_parameters++] = j;
    }

    unify_inertia_preconds( 0 );
  }

  if ( gcmd_line.display_info == 107 ) {
    printf("\n\naction templates:");

    for ( i = 0; i < gnum_operators; i++ ) {
      printf("\n\noperator %s:", goperators[i]->name);
      for ( t = gtemplates; t; t = t->next ) {
	if ( t->op != i ) {
	  continue;
	}
	printf("\ninst: ");
	for ( j = 0; j < goperators[i]->num_vars; j++ ) {
	  if ( t->inst_table[j] < 0 ) {
	    printf("\nuninstantiated param in template! debug me, please\n\n");
	    exit( 1 );
	  }
	  printf("x%d = %s", j, gconstants[t->inst_table[j]]);
	  if ( j < goperators[i]->num_vars - 1 ) {
	    printf(", ");
	  }
	}
      }
    }
  }

  /* now remove inertia preconditions from operator schemata
   */
  for ( i = 0; i < gnum_operators; i++ ) {
    o = goperators[i];

    j = 0;
    while ( j < o->num_preconds ) {
      if ( !gis_added[o->preconds[j].predicate] &&
	   !gis_deleted[o->preconds[j].predicate] ) {
	for ( k = j; k < o->num_preconds - 1; k++ ) { 
 	  o->preconds[k].predicate = o->preconds[k+1].predicate;
	  for ( l = 0; l < garity[o->preconds[k].predicate]; l++ ) {
	    o->preconds[k].args[l] = o->preconds[k+1].args[l];
	  }
	}
	o->num_preconds--;
      } else {
	j++;
      }
    }
  }   

  if ( gcmd_line.display_info == 108 ) {
    printf("\n\ninertia free operators are:");
    for ( i = 0; i < gnum_operators; i++ ) {
      print_Operator( goperators[i] );
    }
    printf("\n\n");
  }

}
示例#4
0
void do_inertia_preprocessing( void )

{

  int i, j;

  collect_inertia_information();

  if ( gcmd_line.display_info == 104 ) {
    printf("\n\npredicates inertia info:");
    for ( i = 0; i < gnum_predicates; i++ ) {
      printf("\n%3d --> %s: ", i, gpredicates[i]);
      printf(" is %s, %s",
	     gis_added[i] ? "ADDED" : "NOT ADDED",
	     gis_deleted[i] ? "DELETED" : "NOT DELETED");
    }
    printf("\n\n");
  }


  split_initial_state();

  if ( gcmd_line.display_info == 105 ) {
    printf("\n\nfull initial state was:");
    for ( i = 0; i < gnum_full_initial; i++ ) {
      printf("\n");
      print_Fact( &(gfull_initial[i]) );
      if ( garity[gfull_initial[i].predicate] == 1 ) {
	printf(" --> obj. number %d", gfull_initial[i].args[0]);
      }
    }

    printf("\n\nsplitted initial state is:");

    printf("\n\nextended types table:");
    for ( i = 0; i < gnum_types; i++ ) {
      printf("\n%d --> ", i);
      if ( gpredicate_to_type[i] == -1 ) {
	printf("%s ", gtype_names[i]);
      } else {
	printf("UNARY INERTIA TYPE (%s) ", gpredicates[gpredicate_to_type[i]]);
      }
      for ( j = 0; j < gtype_size[i]; j++ ) {
	printf("%d ", gtype_consts[i][j]);
      }
    }

    printf("\n\nnon static initial state:");
    for ( i = 0; i < gnum_initial; i++ ) {
      printf("\n");
      print_Fact( &(ginitial[i]) );
    }

    printf("\n\nstatic initial state:");
    for ( i = 0; i < gnum_inertia; i++ ) {
      printf("\n");
      print_Fact( &(ginertia[i]) );
    }
    printf("\n\n");
  }


  encode_unary_inertia_as_types();
  remove_ops_with_empty_parameter_types();
  remove_unused_parameters();

  if ( gcmd_line.display_info == 106 ) {
    printf("\n\nfull initial state was:");
    for ( i = 0; i < gnum_full_initial; i++ ) {
      printf("\n");
      print_Fact( &(gfull_initial[i]) );
      if ( garity[gfull_initial[i].predicate] == 1 ) {
	printf(" --> obj. number %d", gfull_initial[i].args[0]);
      }
    }

    printf("\n\nintersections extended types table:");
    for ( i = 0; i < gnum_types; i++ ) {
      printf("\n%d --> ", i);
      if ( gpredicate_to_type[i] == -1 ) {
	if ( gnum_intersected_types[i] == -1 ) {
	  printf("%s: ", gtype_names[i]);
	} else {
	  printf("INTERSECTED TYPE (");
	  for ( j = 0; j < gnum_intersected_types[i]; j++ ) {
	    if ( gpredicate_to_type[gintersected_types[i][j]] == -1 ) {
	      printf("%s", gtype_names[gintersected_types[i][j]]);
	    } else {
	      printf("UNARY INERTIA TYPE (%s)", 
		     gpredicates[gpredicate_to_type[gintersected_types[i][j]]]);
	    }
	    if ( j < gnum_intersected_types[i] - 1 ) {
	      printf(" and ");
	    }
	  }
	  printf("): ");
	}
      } else {
	printf("UNARY INERTIA TYPE (%s): ", gpredicates[gpredicate_to_type[i]]);
      }
      for ( j = 0; j < gtype_size[i]; j++ ) {
	printf("%d ", gtype_consts[i][j]);
      }
    }

    printf("\n\nops with unary inertia preconds encoded:");
    for ( i = 0; i < gnum_operators; i++ ) {
      print_Operator( goperators[i] );
    }
    printf("\n\n");
  }

}