コード例 #1
0
ファイル: output.c プロジェクト: dtolpin/probabilistic-ff
void print_Operator( Operator *o )

{

  Effect *e;
  Literal *l;
  int i, m = 0;

  printf("\n\n----------------Operator %s, translated form, step 1--------------\n", o->name);

  for ( i = 0; i < o->num_vars; i++ ) {
    printf("\nx%d (%s) of type %s, removed ? %s",
	   i, o->var_names[i], gtype_names[o->var_types[i]],
	   o->removed[i] ? "YES" : "NO");
  }
  printf("\ntotal params %d, real params %d\n", 
	 o->num_vars, o->number_of_real_params);

  printf("\nPreconds:\n");
  print_Wff( o->preconds, 0 );

  printf("\n\nEffects:");
  for ( e = o->effects; e; e = e->next ) {
    printf("\n\neffect %d, parameters %d", m++, e->num_vars);

    for ( i = 0; i < e->num_vars; i++ ) {
      printf("\nx%d (%s) of type %s",
	     o->num_vars + i, e->var_names[i], gtype_names[e->var_types[i]]);
    }
    printf("\nConditions, P %lf:\n", e->eff_p);/* july06 */
    print_Wff( e->conditions, 0 );
    printf("\nEffect Literals");
    for ( l = e->effects; l; l = l->next ) {
      if ( l->negated ) {
	printf("\nNOT ");
      } else {
	printf("\n");
      }
      print_Fact( &(l->fact) );
    }
  }

}
コード例 #2
0
ファイル: output.c プロジェクト: dtolpin/probabilistic-ff
void print_MixedOperator( MixedOperator *o )

{

  int i, m;
  Effect *e;
  Literal *l;

  printf("\n\n----------------Operator %s, mixed form--------------\n", 
	 o->op->name);
 
  for ( i = 0; i < o->op->num_vars; i++ ) {
    printf("\nx%d = %s of type ", i, gconstants[o->inst_table[i]]);
    print_type( o->op->var_types[i] );
  }

  printf("\nPreconds:\n");
  for ( i = 0; i < o->num_preconds; i++ ) {
    print_Fact( &(o->preconds[i]) );
    printf("\n");
  }

  m = 0;
  printf("\n\nEffects:");
  for ( e = o->effects; e; e = e->next ) {
    printf("\n\neffect %d, parameters %d", m++, e->num_vars);

    for ( i = 0; i < e->num_vars; i++ ) {
      printf("\nx%d of type %s",
	     o->op->num_vars + i, gtype_names[e->var_types[i]]);
    }
    printf("\nConditions, P %lf:\n", e->eff_p);/* july 06 */
    print_Wff( e->conditions, 0 );
    printf("\nEffect Literals");
    for ( l = e->effects; l; l = l->next ) {
      if ( l->negated ) {
	printf("\nNOT ");
      } else {
	printf("\n");
      }
      print_Fact( &(l->fact) );
    }
  }

}
コード例 #3
0
void print_MixedOperator( MixedOperator *o )

{

  int i, m;
  Effect *e;
  NumericEffect *ne;
  Literal *l;

  printf("\n\n----------------Operator %s, mixed form--------------\n", 
	 o->operator->name);
 
  for ( i = 0; i < o->operator->num_vars; i++ ) {
    printf("\nx%d = %s of type ", i, gconstants[o->inst_table[i]]);
    print_type( o->operator->var_types[i] );
  }

  printf("\nPreconds:\n");
  for ( i = 0; i < o->num_preconds; i++ ) {
    print_Fact( &(o->preconds[i]) );
    printf("\n");
  }
  for ( i = 0; i < o->num_numeric_preconds; i++ ) {
    switch ( o->numeric_preconds_comp[i] ) {
    case LE:
      printf("(< ");
      break;
    case LEQ:
      printf("(<= ");
      break;
    case EQ:
      printf("(= ");
      break;
    case GEQ:
      printf("(>= ");
      break;
    case GE:
      printf("(> ");
      break;
    default:
      printf("\nwrong comparator of Expnodes in mixedpre %d\n\n", 
	     o->numeric_preconds_comp[i]);
      exit( 1 );
    }
    print_ExpNode( o->numeric_preconds_lh[i] );
    print_ExpNode( o->numeric_preconds_rh[i] );
    printf(")\n");
  }

  m = 0;
  printf("\n\nEffects:");
  for ( e = o->effects; e; e = e->next ) {
    printf("\n\neffect %d, parameters %d", m++, e->num_vars);

    for ( i = 0; i < e->num_vars; i++ ) {
      printf("\nx%d of type %s",
	     o->operator->num_vars + i, gtype_names[e->var_types[i]]);
    }
    printf("\nConditions\n");
    print_Wff( e->conditions, 0 );
    printf("\nEffect Literals");
    for ( l = e->effects; l; l = l->next ) {
      if ( l->negated ) {
	printf("\nNOT ");
      } else {
	printf("\n");
      }
      print_Fact( &(l->fact) );
    }
    printf("\nNumeric Effects");
    for ( ne = e->numeric_effects; ne; ne = ne->next ) {
      switch ( ne->neft ) {
      case ASSIGN:
	printf("\nassign ");
	break;
      case SCALE_UP:
	printf("\nscale-up ");
	break;
      case SCALE_DOWN:
	printf("\nscale-down ");
	break;
      case INCREASE:
	printf("\nincrease ");
	break;
      case DECREASE:
	printf("\ndecrease ");
	break;
      default:
	printf("\n\nprint effect: illegal neft %d\n\n", ne->neft);
	exit( 1 );
      }
      print_Fluent( &(ne->fluent) );
      print_ExpNode( ne->rh );
    }
  }

}
コード例 #4
0
void print_Operator( Operator *o )

{

  Effect *e;
  Literal *l;
  NumericEffect *ne;
  int i, m = 0;

  printf("\n\n----------------Operator %s, translated form, step 1--------------\n", o->name);

  for ( i = 0; i < o->num_vars; i++ ) {
    printf("\nx%d (%s) of type %s, removed ? %s",
	   i, o->var_names[i], gtype_names[o->var_types[i]],
	   o->removed[i] ? "YES" : "NO");
  }
  printf("\ntotal params %d, real params %d\n", 
	 o->num_vars, o->number_of_real_params);

  printf("\nPreconds:\n");
  print_Wff( o->preconds, 0 );

  printf("\n\nEffects:");
  for ( e = o->effects; e; e = e->next ) {
    printf("\n\neffect %d, parameters %d", m++, e->num_vars);

    for ( i = 0; i < e->num_vars; i++ ) {
      printf("\nx%d (%s) of type %s",
	     o->num_vars + i, e->var_names[i], gtype_names[e->var_types[i]]);
    }
    printf("\nConditions\n");
    print_Wff( e->conditions, 0 );
    printf("\nEffect Literals");
    for ( l = e->effects; l; l = l->next ) {
      if ( l->negated ) {
	printf("\nNOT ");
      } else {
	printf("\n");
      }
      print_Fact( &(l->fact) );
    }
    printf("\nNumeric Effects");
    for ( ne = e->numeric_effects; ne; ne = ne->next ) {
      switch ( ne->neft ) {
      case ASSIGN:
	printf("\nassign ");
	break;
      case SCALE_UP:
	printf("\nscale-up ");
	break;
      case SCALE_DOWN:
	printf("\nscale-down ");
	break;
      case INCREASE:
	printf("\nincrease ");
	break;
      case DECREASE:
	printf("\ndecrease ");
	break;
      default:
	printf("\n\nprint effect: illegal neft %d\n\n", ne->neft);
	exit( 1 );
      }
      print_Fluent( &(ne->fluent) );
      print_ExpNode( ne->rh );
    }
  }

}
コード例 #5
0
void print_Wff( WffNode *n, int indent )

{

  WffNode *i;

  if ( !n ) {
    printf("none\n");
    return;
  }
  
  switch (n->connective) {
  case ALL: 
    printf("ALL x%d (%s): %s\n", n->var, n->var_name,
	    gtype_names[n->var_type]);
    print_indent(indent);
    printf("(   ");
    print_Wff(n->son,indent+4);
    print_indent(indent);
    printf(")\n");
    break;
  case EX:
    printf("EX  x%d (%s) : %s\n",  n->var, n->var_name,
	    gtype_names[n->var_type]);
    print_indent(indent);
    printf("(   ");
    print_Wff(n->son,indent+4);
    print_indent(indent);
    printf(")\n");
    break;
  case AND: 
    printf("A(  ");
    print_Wff(n->sons, indent+4);
    if ( n->sons ) {
      for ( i = n->sons->next; i!=NULL; i = i->next ) {
	if ( !i->prev ) {
	  printf("\nprev in AND not correctly set!\n\n");
	  exit( 1 );
	}
	print_indent(indent);
	printf("AND ");
	print_Wff(i,indent+4);
      }
    }
    print_indent(indent);      
    printf(")\n");
    break;
  case OR:  
    printf("O(  ");
    print_Wff(n->sons, indent+4);
    for ( i = n->sons->next; i!=NULL; i = i->next ) {
      print_indent(indent);
      printf("OR ");
      print_Wff(i,indent+4);
    }
    print_indent(indent);      
    printf(")\n");
    break;
  case NOT:
    if (ATOM==n->son->connective) {
      printf("NOT ");
      print_Wff(n->son,indent+4);
    } else {
      printf("NOT(");
      print_Wff(n->son,indent+4);
      print_indent(indent+3);
      printf(")\n");
    }
    break;
  case ATOM:
    print_Fact(n->fact);
    if ( n->NOT_p != -1 ) printf(" - translation NOT");
    printf("\n");
    break;
  case TRU:
     printf("(TRUE)\n");
     break;
  case FAL:
     printf("(FALSE)\n");
     break;   
  case COMP:
    switch (n->comp) {
    case LE:
      printf("(< ");
      break;
    case LEQ:
      printf("(<= ");
      break;
    case EQ:
      printf("(= ");
      break;
    case GEQ:
      printf("(>= ");
      break;
    case GE:
      printf("(> ");
      break;
    default:
      printf("\nwrong comparator of Expnodes in WFF %d\n\n", n->comp);
      exit( 1 );
    }
    print_ExpNode( n->lh );
    print_ExpNode( n->rh );
    printf(")\n");
    break;
  default:
    printf("\n***** ERROR ****");
    printf("\nprint_Wff: %d > Wrong Node specifier\n", n->connective);
    exit(1);
  }     

} 
コード例 #6
0
ファイル: inst_hard.c プロジェクト: JackDanny/cours-M2-IARF
void create_hard_pseudo_effects( PseudoAction *a, Effect *e, int curr_var )

{

  int par, t, i, m;
  WffNode *tmp1, *w, *ww;
  PseudoActionEffect *tmp2;

  if ( curr_var < e->num_vars ) {
    par = a->operator->num_vars + curr_var;

    t = e->var_types[curr_var];
    for ( i = 0; i < gtype_size[t]; i++ ) {
      linst_table[par] = gtype_consts[t][i];

      create_hard_pseudo_effects( a, e, curr_var + 1 );

      linst_table[par] = -1;
    }
    return;
  }

  tmp1 = instantiate_wff( e->conditions );

  if ( tmp1->connective == FAL ) {
    free_WffNode( tmp1 );
    return;
  }

  dnf( &tmp1 );
  cleanup_wff( &tmp1 );

  /* only debugging, REMOVE LATER
   */
  if ( is_dnf( tmp1 ) == -1 ) {
    printf("\n\nILLEGAL DNF %s AFTER INSTANTIATION\n\n", a->operator->name);
    print_Wff( tmp1, 0 );
    exit( 1 );
  }

  switch ( tmp1->connective ) {
  case OR:
    for ( w = tmp1->sons; w; w = w->next ) {
      tmp2 = new_PseudoActionEffect();
      if ( w->connective == AND ) {
	m = 0;
	for ( ww = w->sons; ww; ww = ww->next ) m++;
	tmp2->conditions = ( Fact * ) calloc( m, sizeof( Fact ) );
	tmp2->num_conditions = m;
	m = 0;
	for ( ww = w->sons; ww; ww = ww->next ) {
	  tmp2->conditions[m].predicate = ww->fact->predicate;
	  for ( i = 0; i < garity[ww->fact->predicate]; i++ ) {
	    tmp2->conditions[m].args[i] = ww->fact->args[i];
	  }
	  m++;
	}
      } else {
	tmp2->conditions = ( Fact * ) calloc( 1, sizeof( Fact ) );
	tmp2->num_conditions = 1;
	tmp2->conditions[0].predicate = w->fact->predicate;
	for ( i = 0; i < garity[w->fact->predicate]; i++ ) {
	  tmp2->conditions[0].args[i] = w->fact->args[i];
	}
      }
      make_instantiate_literals( tmp2, e->effects );
      tmp2->next = a->effects;
      a->effects = tmp2;
      a->num_effects++;
    }
    break;
  case AND:
    tmp2 = new_PseudoActionEffect();
    m = 0;
    for ( w = tmp1->sons; w; w = w->next ) m++;
    tmp2->conditions = ( Fact * ) calloc( m, sizeof( Fact ) );
    tmp2->num_conditions = m;
    m = 0;
    for ( w = tmp1->sons; w; w = w->next ) {
      tmp2->conditions[m].predicate = w->fact->predicate;
      for ( i = 0; i < garity[w->fact->predicate]; i++ ) {
	tmp2->conditions[m].args[i] = w->fact->args[i];
      }
      m++;
    }
    make_instantiate_literals( tmp2, e->effects );
    tmp2->next = a->effects;
    a->effects = tmp2;
    a->num_effects++;
    break;
  case ATOM:
    tmp2 = new_PseudoActionEffect();
    tmp2->conditions = ( Fact * ) calloc( 1, sizeof( Fact ) );
    tmp2->num_conditions = 1;
    tmp2->conditions[0].predicate = tmp1->fact->predicate;
    for ( i = 0; i < garity[tmp1->fact->predicate]; i++ ) {
      tmp2->conditions[0].args[i] = tmp1->fact->args[i];
    }
    make_instantiate_literals( tmp2, e->effects );
    tmp2->next = a->effects;
    a->effects = tmp2;
    a->num_effects++;
    break;
  case TRU:
    tmp2 = new_PseudoActionEffect();
    make_instantiate_literals( tmp2, e->effects );
    tmp2->next = a->effects;
    a->effects = tmp2;
    a->num_effects++;
    break;
  default:
    printf("\n\nillegal connective %d in parsing DNF precond.\n\n",
	   tmp1->connective);
    exit( 1 );
  }

  free_WffNode( tmp1 );

}
コード例 #7
0
ファイル: inst_hard.c プロジェクト: JackDanny/cours-M2-IARF
void create_hard_mixed_operators( Operator *o, int curr_var )

{

  int t, i, m;
  WffNode *tmp1, *w, *ww;
  MixedOperator *tmp2;

  if ( curr_var < o->num_vars ) {
    if ( o->removed[curr_var] ) {
      /* param doesn't matter -- select any appropriate type constant
       * at least one there; otherwise, op would not have been translated.
       */
      linst_table[curr_var] = gtype_consts[o->var_types[curr_var]][0];
      create_hard_mixed_operators( o, curr_var + 1 );
      linst_table[curr_var] = -1;
      return;
    }

    t = o->var_types[curr_var];
    for ( i = 0; i < gtype_size[t]; i++ ) {
      linst_table[curr_var] = gtype_consts[t][i];

      create_hard_mixed_operators( o, curr_var + 1 );

      linst_table[curr_var] = -1;
    }
    return;
  }

  tmp1 = instantiate_wff( o->preconds );

  if ( tmp1->connective == FAL ) {
    free_WffNode( tmp1 );
    return;
  }

  dnf( &tmp1 );
  cleanup_wff( &tmp1 );

  if ( tmp1->connective == FAL ) {
    free_WffNode( tmp1 );
    return;
  }

  /* only debugging, REMOVE LATER
   */
  if ( is_dnf( tmp1 ) == -1 ) {
    printf("\n\nILLEGAL DNF %s AFTER INSTANTIATION\n\n", o->name);
    print_Wff( tmp1, 0 );
    exit( 1 );
  }

  switch ( tmp1->connective ) {
  case OR:
    for ( w = tmp1->sons; w; w = w->next ) {
      tmp2 = new_MixedOperator( o );
      for ( i = 0; i < o->num_vars; i++ ) {
	tmp2->inst_table[i] = linst_table[i];
      }
      if ( w->connective == AND ) {
	m = 0;
	for ( ww = w->sons; ww; ww = ww->next ) m++;
	tmp2->preconds = ( Fact * ) calloc( m, sizeof( Fact ) );
	tmp2->num_preconds = m;
	m = 0;
	for ( ww = w->sons; ww; ww = ww->next ) {
	  tmp2->preconds[m].predicate = ww->fact->predicate;
	  for ( i = 0; i < garity[ww->fact->predicate]; i++ ) {
	    tmp2->preconds[m].args[i] = ww->fact->args[i];
	  }
	  m++;
	}
      } else {
	tmp2->preconds = ( Fact * ) calloc( 1, sizeof( Fact ) );
	tmp2->num_preconds = 1;
	tmp2->preconds[0].predicate = w->fact->predicate;
	for ( i = 0; i < garity[w->fact->predicate]; i++ ) {
	  tmp2->preconds[0].args[i] = w->fact->args[i];
	}
      }
      tmp2->effects = instantiate_Effect( o->effects );
      tmp2->next = ghard_mixed_operators;
      ghard_mixed_operators = tmp2;
      gnum_hard_mixed_operators++;
    }
    break;
  case AND:
    tmp2 = new_MixedOperator( o );
    for ( i = 0; i < o->num_vars; i++ ) {
      tmp2->inst_table[i] = linst_table[i];
    }
    m = 0;
    for ( w = tmp1->sons; w; w = w->next ) m++;
    tmp2->preconds = ( Fact * ) calloc( m, sizeof( Fact ) );
    tmp2->num_preconds = m;
    m = 0;
    for ( w = tmp1->sons; w; w = w->next ) {
      tmp2->preconds[m].predicate = w->fact->predicate;
      for ( i = 0; i < garity[w->fact->predicate]; i++ ) {
	tmp2->preconds[m].args[i] = w->fact->args[i];
      }
      m++;
    }
    tmp2->effects = instantiate_Effect( o->effects );
    tmp2->next = ghard_mixed_operators;
    ghard_mixed_operators = tmp2;
    gnum_hard_mixed_operators++;
    break;
  case ATOM:
    tmp2 = new_MixedOperator( o );
    for ( i = 0; i < o->num_vars; i++ ) {
      tmp2->inst_table[i] = linst_table[i];
    }
    tmp2->preconds = ( Fact * ) calloc( 1, sizeof( Fact ) );
    tmp2->num_preconds = 1;
    tmp2->preconds[0].predicate = tmp1->fact->predicate;
    for ( i = 0; i < garity[tmp1->fact->predicate]; i++ ) {
      tmp2->preconds[0].args[i] = tmp1->fact->args[i];
    }
    tmp2->effects = instantiate_Effect( o->effects );
    tmp2->next = ghard_mixed_operators;
    ghard_mixed_operators = tmp2;
    gnum_hard_mixed_operators++;
    break;
  case TRU:
    tmp2 = new_MixedOperator( o );
    for ( i = 0; i < o->num_vars; i++ ) {
      tmp2->inst_table[i] = linst_table[i];
    }
    tmp2->effects = instantiate_Effect( o->effects );
    tmp2->next = ghard_mixed_operators;
    ghard_mixed_operators = tmp2;
    gnum_hard_mixed_operators++;
    break;
  default:
    printf("\n\nillegal connective %d in parsing DNF precond.\n\n",
	   tmp1->connective);
    exit( 1 );
  }

  free_WffNode( tmp1 );

}