📄 pddl.c
字号:
case NOT: return any_predicate_contained(e,p->sons); case TRU: return FALSE; case ATOM: /* printf("? Ist im Effekt\n"); *//* print_plnode( e ,0); *//* print_plnode( p ,0); */ if (single_predicate_contained(e,p)) { /* printf("TRUE"); */ return TRUE; } /* printf("FALSE"); */ return FALSE; default: spec_error("any_predicate_contained"); return TRUE; } } char *get_type(char *var, PlNode * p){ PlNode * i_pl; char *str; /* printf("looking for %s in :",var); *//* print_plnode(p,0); */ switch (p->connective) { case AND: case OR: case WHEN: for (i_pl=p->sons;i_pl!=NULL;i_pl=i_pl->next) { str=get_type(var,i_pl); if (!(NULL==str)) { return str; } } return NULL; case ALL: case EX: if (SAME==strcmp(var,p->atom->item)) { return p->atom->next->item; } return get_type(var,p->sons); case NOT: return get_type(var,p->sons); case TRU: case ATOM: return NULL; default: spec_error("get_type"); return NULL; }}voidaxioms_to_operators(void){PlNode * atom_pl, * i_pl, * j_pl, * new_pl;PlOperator * op_list, * i_axiom, * i_plop, * tmp_op;TokenList * i_tl;FactList * i_fl;char * str_type, * var_;op_list=gloaded_ops;for (i_axiom=gloaded_axioms;i_axiom!=NULL; ) { if (0 && gcmd_line.display_info>=15) { fprintf(stdout, "\nipp: transforming axiom to operator: "); print_tokenlist(i_axiom->name, " "); fprintf(stdout, "\n"); } for (i_plop=op_list; i_plop!=NULL; i_plop = i_plop->next ) { if (TRUE==any_predicate_contained(i_plop->effects,i_axiom->preconds)) { printf("\nNOw\n"); print_plnode( i_plop->effects ,0); printf("\nis contained in \n"); print_plnode( i_axiom->preconds ,0); atom_pl=copy_pl_node(i_axiom->effects); j_pl=new_pl_node(NOT); j_pl->sons=atom_pl; for (i_tl=atom_pl->atom->next;i_tl!=NULL; i_tl = i_tl->next ) { var_=i_tl->item; /* free(i_tl->item); */ i_tl->item=new_token(LOG_Q_NUMBER); sprintf(i_tl->item,"??%d",snr_quantifiers); i_pl=new_pl_node(ALL); i_pl->sons=j_pl; i_pl->atom=new_token_list(); i_pl->atom->item=new_token(LOG_Q_NUMBER); sprintf(i_pl->atom->item,"??%d",snr_quantifiers); /* get type */ str_type=""; /* get type in var list */ for (i_fl=i_axiom->params; i_fl!=NULL; i_fl = i_fl->next ) { if (SAME==strcmp(i_fl->item->item,var_)) { str_type=i_fl->item->next->item; } } if (SAME==strcmp(str_type,"")) { /* get type , search in quantifiers */ printf("scheisse"); exit(1); str_type=get_type(var_,i_plop->effects); } if (NULL==str_type) { printf("scheisse"); exit(1); } printf("%s",str_type); i_pl->atom->next=new_token_list(); i_pl->atom->next->item=(char * )calloc(strlen(str_type)+1,sizeof(char)); sprintf(i_pl->atom->next->item,"%s",str_type); snr_quantifiers++; j_pl=i_pl; } /* add this list */ new_pl=new_pl_node(AND); new_pl->sons=i_plop->effects; new_pl->sons->next=j_pl; i_plop->effects=new_pl; } } /* add axiom to op_list */ tmp_op = i_axiom->next; i_axiom->next=op_list; op_list=i_axiom; i_axiom=tmp_op; gloaded_ops=op_list; if (0 && gcmd_line.display_info>=15) { fprintf(stdout, "\n... done\n"); } }}/******************** main ***************************//********************************************************************* * Main function of the pddl-tree simplification * USING *********************************************************************/void pddl_outer(void){ PlOperator * i_plop; PlNode *i_pl; /************* Operator output ************/ if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\n----------1--------------------------------\n"); fprintf(stdout, "\nLOADED OPERATORS:\n"); print_plops(gloaded_ops); fprintf(stdout, "\nLOADED AXIOMS:\n"); print_plops(gloaded_axioms); fprintf(stdout,"\n------------------------------------------\n"); fprintf(stdout,"\nipp: merging axioms into operators...\n"); }/* purify_new_leaks(); *//* purify_printf("1 "); */ /************* axiom quantifier renaming ********/ snr_quantifiers=1; for ( i_plop = gloaded_axioms; i_plop!=NULL; i_plop = i_plop->next ) { if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\nOpName: %s",i_plop->name->item); fprintf(stdout,"\npreconditions:\n"); } if (NULL!=i_plop->preconds) { rename_all_quantifiers(i_plop->preconds);/* *** */ } } for ( i_plop = gloaded_ops; i_plop!=NULL; i_plop = i_plop->next ) { if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\nOpName: %s",i_plop->name->item); fprintf(stdout,"\npreconditions:\n"); } if (NULL!=i_plop->preconds) { rename_all_quantifiers(i_plop->preconds);/* *** */ } if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\neffects:\n"); } if (NULL!=i_plop->effects) { rename_all_quantifiers(i_plop->effects);/* *** */ } } /************* Operator output ************/ if (0 && gcmd_line.display_info>=5) { fprintf(stdout,"\n-----------2-------------------------------\n"); fprintf(stdout, "\nLOADED OPERATORS:\n"); print_plops(gloaded_ops); fprintf(stdout, "\nLOADED AXIOMS:\n"); print_plops(gloaded_axioms); fprintf(stdout,"\n------------------------------------------\n"); fprintf(stdout,"\nipp: merging axioms into operators...\n"); } /************* axioms_to_operators ************/ axioms_to_operators();/* *** */ /************* Operator output ************/ if (0 && gcmd_line.display_info>=5) { fprintf(stdout,"...done\n"); fprintf(stdout,"\n------------3------------------------------\n"); fprintf(stdout, "\nOPERATORS BEFORE pddl_outer:\n"); print_plops(gloaded_ops); fprintf(stdout,"\n------------------------------------------\n"); fprintf(stdout,"\nipp: simplifying operators (pddl_outer)...\n"); } /************* melting multiple whens etc. ********/ for ( i_plop = gloaded_ops; i_plop!=NULL; i_plop = i_plop->next ) { if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\nOpName: %s",i_plop->name->item); fprintf(stdout,"\npreconditions:\n"); } if (NULL!=i_plop->preconds) { rename_all_quantifiers(i_plop->preconds);/* *** */ } if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\neffects:\n"); } if (NULL!=i_plop->effects) { ands_to_top(i_plop->effects);/* *** */ } } if (0 && gcmd_line.display_info>=5) { fprintf(stdout,"\n------------4------------------------------\n"); } for ( i_plop = gloaded_ops; i_plop!=NULL; i_plop = i_plop->next ) { /************* quantifier movement of operators' precondition ********/ if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\nOpName: %s",i_plop->name->item); fprintf(stdout,"\npreconditions:\n"); } if (NULL!=i_plop->preconds) { nots_down(i_plop->preconds);/* *** */ } /********* quantifier movement of ************/ /********(both conditional and unconditional) effects' precondition ***/ if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\neffects:\n"); } if (NULL!=i_plop->effects) { if (AND!=i_plop->effects->connective) { spec_error("No AND node"); } for(i_pl=i_plop->effects->sons;NULL!=i_pl;i_pl=i_pl->next) { if (WHEN!=i_pl->connective) { /* step through quantifiers */ while (ALL==i_pl->connective ) { i_pl=i_pl->sons; } } if (WHEN!=i_pl->connective) { spec_error("No WHEN node"); } nots_down(i_pl->sons);/* *** */ } } } /************* quantifier movement of goals ********/ if (NULL!=gorig_goal_facts) { nots_down(gorig_goal_facts);/* *** */ } /************* Operator output ************/ if (0 && gcmd_line.display_info>=5) { fprintf(stdout,"...done\n"); fprintf(stdout,"\n-----------------5------------------------\n"); fprintf(stdout, "\nOPERATORS AFTER pddl_outer(pl):\n"); print_plops(gloaded_ops); fprintf(stdout,"\n------------------------------------------\n"); fprintf(stdout,"\nipp: transformation to code_nodes...\n"); }}voidpddl_inner(void){ CodeOperator * i_codeop; CodeNode * i_code,*j_code; /************* Operator output ************/ if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\n...done\n"); fprintf(stdout,"\n------------------6-----------------------\n"); fprintf(stdout, "\nOPERATOREN BEFORE pddl_inner(code):\n"); for ( i_codeop =gcode_operators; i_codeop!=NULL; i_codeop = i_codeop->next ) { print_CodeOperator(i_codeop); } fprintf(stdout,"\n-----------------------------------------\n"); } for ( i_codeop = gcode_operators; i_codeop!=NULL; i_codeop = i_codeop->next ) { /************* dnf of operators' precondition ************/ if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\nOpName: %s",i_codeop->name); fprintf(stdout,"\npreconditions:\n"); } if (NULL!=i_codeop->preconds) { if (TRU!=i_codeop->preconds->connective) { /* step through quantifiers */ i_code=i_codeop->preconds; while ((ALL==i_code->connective)|| (EX==i_code->connective)) { i_code=i_code->sons; } dnf(i_code);/* *** */ } } /************* dnf of conditional effects' precondition ************/ if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\nconditional effects:\n"); } if (NULL!=i_codeop->conditionals) { if (AND!=i_codeop->conditionals->connective) { spec_error("No AND node"); } for(i_code=i_codeop->conditionals->sons;NULL!=i_code;i_code=i_code->next) { j_code=i_code; if (WHEN!=j_code->connective) { /* step through quantifiers */ while ((ALL==j_code->connective)||(EX==j_code->connective)) { j_code=j_code->sons; } } if (WHEN!=j_code->connective) { spec_error("No WHEN node"); } if (TRU!=j_code->sons->connective) { /* step through quantifiers */ while ((ALL==j_code->sons->connective)|| (EX==j_code->sons->connective)) { j_code=j_code->sons; } dnf(j_code->sons);/* *** */ } } } } /************* output of goals ************/ if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\n-----------------------------------------\n"); fprintf(stdout, "\nGOALS:\n"); print_CodeNode(gcode_goal_state,0); fprintf(stdout,"\n-----------------------------------------\n"); } /************* dnf of goals ************/ if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\ngoals:\n"); } j_code=gcode_goal_state; /* step through quantifiers */ if (NULL!=j_code->sons) { while ((ALL==j_code->sons->connective)|| (EX==j_code->sons->connective)) { j_code=j_code->sons; } dnf(j_code->sons);/* *** */ } else dnf(j_code);/* *** */ /************* Operator output ************/ if (0 && gcmd_line.display_info>=15) { fprintf(stdout,"\n...done\n"); fprintf(stdout,"\n------------------7----------------------\n"); fprintf(stdout, "\nOPERATOREN AFTER ALL:\n"); for ( i_codeop =gcode_operators; i_codeop!=NULL; i_codeop = i_codeop->next ) { print_CodeOperator(i_codeop); } fprintf(stdout,"\n-----------------------------------------\n"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -