TEST(state, new_values_arent_visible) { auto x = make_state(42); x.set(13); EXPECT_EQ(x.get(), 42); x.set(16); EXPECT_EQ(x.get(), 42); x.set(19); EXPECT_EQ(x.get(), 42); }
TEST(state, holds_avalue) { { auto x = make_state(1); EXPECT_EQ(x.get(), 1); } { auto x = make_state("hello"); EXPECT_EQ(x.get(), "hello"); } { auto x = state<int> {}; EXPECT_EQ(x.get(), 0); } { auto x = make_state(no_default_ctr { 42 }); EXPECT_EQ(x.get(), no_default_ctr { 42 }); } }
TEST(state, commit_idempotence) { auto x = make_state(42); x.set(13); commit(x); EXPECT_EQ(x.get(), 13); commit(x); EXPECT_EQ(x.get(), 13); commit(x); EXPECT_EQ(x.get(), 13); }
TEST(state, watche_notified_on_commit) { auto x = make_state(42); auto s = testing::spy(); watch(x, s); x.set(13); EXPECT_EQ(s.count(), 0); commit(x); EXPECT_EQ(s.count(), 1); }
TEST(state, commit_makes_latest_value_visible) { auto x = make_state(42); x.set(13); commit(x); EXPECT_EQ(x.get(), 13); x.set(8); x.set(5); x.set(3); commit(x); EXPECT_EQ(x.get(), 3); }
EhcNode *new_EhcNode( void ) { EhcNode *result = ( EhcNode * ) calloc( 1, sizeof( EhcNode ) ); CHECK_PTR(result); make_state( &(result->S), gnum_ft_conn, gnum_fl_conn ); result->father = NULL; result->next = NULL; return result; }
void initialize_rewardgoals() { printf("%d==%d",gnum_relevant_facts,gnum_ft_conn); int i; Fact F; gnum_reward_goals=0; for(i=0;i<gnum_relevant_facts;i++) { F=grelevant_facts[i]; /*(RGOAL G20)*/ if((F.predicate>=0) && (strcmp(gpredicates[F.predicate],"RGOAL")==0)) { int points=0; points=atoi( gconstants[F.args[0]] + 1); if(points>0){ printf("reward goal #%d :\n",gnum_reward_goals); make_state(&greward_goals[gnum_reward_goals].goal_state,1); greward_goals[gnum_reward_goals].goal_state.num_F=1; greward_goals[gnum_reward_goals].goal_state.F[0]=i; greward_goals[gnum_reward_goals].reward=points; greward_goals[gnum_reward_goals].ignore=0; printf("reward goal: %s:%d \n", gconstants[F.args[0]], greward_goals[gnum_reward_goals].reward); gnum_reward_goals++; } } } }
TEST(atted, modifying_attributes_of_immutable) { auto st = make_state(machine { "car", 4 }); auto x = attred(&machine::name, st); auto y = attred(&machine::wheels, st); y.set(3u); commit(st); EXPECT_EQ(st.get(), (machine { "car", 3 })); EXPECT_EQ(x.get(), "car"); EXPECT_EQ(y.get(), 3); x.set("tricar"); commit(st); EXPECT_EQ(st.get(), (machine { "tricar", 3 })); EXPECT_EQ(x.get(), "tricar"); EXPECT_EQ(y.get(), 3); }
TEST(state, capsule_carries_its_own_watchers) { auto sig = std::shared_ptr<detail::state_up_down_signal<int>>{}; auto s = testing::spy(); { auto st = make_state(42); sig = detail::access::signal(st); watch(st, s); sig->push_down(12); sig->send_down(); sig->notify(); EXPECT_EQ(1, s.count()); } sig->push_down(7); sig->send_down(); sig->notify(); EXPECT_EQ(1, s.count()); EXPECT_TRUE(sig->observers().empty()); }
int expand_first_node( int h ) { static Bool fc = TRUE; static State S_; int h_, i, g; if ( fc ) { make_state( &S_, gnum_ft_conn ); S_.max_F = gnum_ft_conn; fc = FALSE; } h_ = get_1P_and_H( &(lehc_current_start->S), &lcurrent_goals ); if ( h_ == INFINITY ) { lehc_current_start = lehc_current_start->next; return h_; } if ( lehc_current_start->new_goal != -1 && new_goal_gets_deleted( lehc_current_start ) ) { lehc_current_start = lehc_current_start->next; return INFINITY; } if ( h_ < h ) { return h_; } for ( i = 0; i < gnum_H; i++ ) { g = result_to_dest( &S_, &(lehc_current_start->S), gH[i] ); add_to_ehc_space( &S_, gH[i], lehc_current_start, g ); } lehc_current_start = lehc_current_start->next; return h_; }
int expand_first_node( int h ) { static Bool fc = TRUE; static State S_; int h_, i; if ( fc ) { make_state( &S_, gnum_ft_conn ); fc = FALSE; } h_ = get_1P_and_H( &(lehc_current_start->S), &lscurrent_goals, lehc_current_start->father, NULL, lehc_current_start->op ); if ( h_ == INFINITY ) { lehc_current_start = lehc_current_start->next; return h_; } if ( h_ < h ) { return h_; } for ( i = 0; i < gnum_H; i++ ) { if ( !result_to_dest( &S_, lehc_current_start, NULL, gH[i] ) ) continue; add_to_ehc_space( &S_, gH[i], lehc_current_start ); } lehc_current_start = lehc_current_start->next; return h_; }
/************************************* * Jovi: update for multiple purpose * * BEST FIRST SEARCH IMPLEMENTATION * *************************************/ Bool do_best_first_search_for_multiple_purpose ( void ) { static Bool fc_for_multiple_purpose = TRUE; /*first round*/ static State S; BfsNode *first; int i, min = INFINITY; Bool start = TRUE; if ( fc_for_multiple_purpose ) { make_state( &S, gnum_ft_conn ); S.max_F = gnum_ft_conn; fc_for_multiple_purpose = FALSE; } lbfs_space_head = new_BfsNode(); lbfs_space_had = NULL; for ( i = 0; i < BFS_HASH_SIZE; i++ ) { lbfs_hash_entry[i] = NULL; } add_to_bfs_space_for_multiple_purpose( &ginitial_state, -1, NULL ); while ( TRUE ) { if ( (first = lbfs_space_head->next) == NULL ) { printf("\n\nbest first search space empty! problem proven unsolvable.\n\n"); return FALSE; } lbfs_space_head->next = first->next; if ( first->next ) { first->next->prev = lbfs_space_head; } if ( LESS( first->h, min ) ) { min = first->h; if ( start ) { printf("\nadvancing to distance : %4d", min); start = FALSE; } else { printf("\n %4d", min); } /* * modified by JC: return ealier */ if(is_solved_state( &first->S )){ printf("\nstate have seen. return!\n"); break; } } if ( first->h == 0 ) { break; } get_A( &(first->S) ); for ( i = 0; i < gnum_A; i++ ) { /*if(g_is_strong){*/ /*JC: dismiss invalid actions*/ int k; Bool found = FALSE; for(k = 0; k < gnum_IV; k++){ if(gA[i] == gInvActs[k].act){ found = TRUE; break; } } /*}*/ if(found) continue; result_to_dest( &S, &(first->S), gA[i] ); add_to_bfs_space_for_multiple_purpose( &S, gA[i], first ); } first->next = lbfs_space_had; lbfs_space_had = first; } extract_plan( first ); return TRUE; }
/* breath first search */ int expand_first_node( int h ) { static Bool fc = TRUE; static State S_; int h_, i, g; if ( fc ) { make_state( &S_, gnum_ft_conn ); S_.max_F = gnum_ft_conn; fc = FALSE; } h_ = get_1P_and_H( &(lehc_current_start->S), &lcurrent_goals ); if ( h_ == INFINITY ) { lehc_current_start = lehc_current_start->next; return h_; } if ( lehc_current_start->new_goal != -1 && new_goal_gets_deleted( lehc_current_start ) ) { lehc_current_start = lehc_current_start->next; return INFINITY; } if ( h_ < h ) { return h_; } for ( i = 0; i < gnum_H; i++ ) { /*JC: dismiss invalid actions*/ int k; Bool found = FALSE; for(k = 0; k < gnum_IV; k++){ if(same_state(&gInvActs[k].state, &(lehc_current_start->S)) && gH[i] == gInvActs[k].act){ found = TRUE; break; } } if(found) continue; if(is_D_action(gop_conn[gH[i]].action->name)) continue; g = result_to_dest( &S_, &(lehc_current_start->S), gH[i] ); add_to_ehc_space( &S_, gH[i], lehc_current_start, g ); } for ( i = 0; i < gnum_H; i++ ) { /*JC: dismiss invalid actions*/ int k; Bool found = FALSE; for(k = 0; k < gnum_IV; k++){ if(same_state(&gInvActs[k].state, &(lehc_current_start->S)) && gH[i] == gInvActs[k].act){ found = TRUE; break; } } if(found) continue; if(!is_D_action(gop_conn[gH[i]].action->name)) continue; g = result_to_dest( &S_, &(lehc_current_start->S), gH[i] ); add_to_ehc_space( &S_, gH[i], lehc_current_start, g ); } lehc_current_start = lehc_current_start->next; return h_; }
/************************************************* * FUNCTIONS FOR BREADTH FIRST SEARCH IN H SPACE * *************************************************/ Bool search_for_better_state_for_multiple_purpose ( State *S, int h, State *S_, int *h_ ) { static Bool first_call_for_multiple_purpose = TRUE; static State S__; int i, h__, depth = 0, g; EhcNode *tmp; if ( first_call_for_multiple_purpose ) { make_state( &S__, gnum_ft_conn ); S__.max_F = gnum_ft_conn; first_call_for_multiple_purpose = FALSE; } /* don't hash states, but search nodes. * this way, don't need to keep states twice in memory */ tmp = new_EhcNode(); copy_source_to_dest( &(tmp->S), S); hash_ehc_node( tmp ); lehc_current_end = lehc_space_head->next; for ( i = 0; i < gnum_H; i++ ) { int k; Bool found = FALSE; for(k = 0; k < gnum_IV; k++){ if(same_state(&gInvActs[k].state, S) && gH[i] == gInvActs[k].act){ found = TRUE; break; } } if(found) continue; if(is_D_action(gop_conn[gH[i]].action->name)) continue; g = result_to_dest( &S__, S, gH[i] ); add_to_ehc_space( &S__, gH[i], NULL, g ); } for ( i = 0; i < gnum_H; i++ ) { int k; Bool found = FALSE; for(k = 0; k < gnum_IV; k++){ if(same_state(&gInvActs[k].state, S) && gH[i] == gInvActs[k].act){ found = TRUE; break; } } if(found) continue; if(!is_D_action(gop_conn[gH[i]].action->name)) continue; /* D_cation, not in the gH */ g = result_to_dest( &S__, S, gH[i] ); add_to_ehc_space( &S__, gH[i], NULL, g ); } lehc_current_start = lehc_space_head->next; while ( TRUE ) { if ( lehc_current_start == lehc_current_end ) { reset_ehc_hash_entrys(); free( tmp ); return FALSE; } if ( lehc_current_start->depth > depth ) { depth = lehc_current_start->depth; if ( depth > gmax_search_depth ) { gmax_search_depth = depth; } printf("[%d]", depth); fflush( stdout ); } h__ = expand_first_node( h ); if ( LESS( h__, h ) ) { break; } } reset_ehc_hash_entrys(); free( tmp ); extract_plan_fragment( S ); source_to_dest( S_, &(lehc_current_start->S) ); *h_ = h__; return TRUE; }
/* jovi: add for multiple purpose */ Bool do_enforced_hill_climbing_for_multiple_purpose ( State *start, State *end ) { if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: do_enforced_hill_climbing_for_multiple_purpose \n"); printf("start:"); print_state(*start); printf("\n\nend:"); print_state(*end); } static Bool first_call_for_multiple_purpose = TRUE; static State S, S_; int i, h, h_; if ( first_call_for_multiple_purpose ) { make_state( &S, gnum_ft_conn ); S.max_F = gnum_ft_conn; make_state( &S_, gnum_ft_conn ); S_.max_F = gnum_ft_conn; make_state( &lcurrent_goals, gnum_ft_conn ); lcurrent_goals.max_F = gnum_ft_conn; first_call_for_multiple_purpose = FALSE; } /* start enforced Hill-climbing */ source_to_dest( &lcurrent_goals, end ); source_to_dest( &S, start ); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: in function do_enforced_hill_climbing_for_multiple_purpose() \n"); printf("lcurrent_goals is:"); print_state(lcurrent_goals); } /*seems get a heuristic*/ h = get_1P_and_H_for_multiple_purpose ( &S, &lcurrent_goals ); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: get_1P_and_H_for_multiple_purpose get heuristic: %4d\n", h); } if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: Current goal is "); print_state(lcurrent_goals); printf("\n"); } if ( h == INFINITY ) { return FALSE; } if ( h == 0 ) { return TRUE; } printf("\n\nCueing down from goal distance: %4d into depth", h); while ( h != 0 ) { if ( !search_for_better_state_for_multiple_purpose( &S, h, &S_, &h_ ) ) { return FALSE; } /* * modified by Jason Huang: return ealier */ if(is_solved_state( &S_ )) { printf("\nstate have seen. h = %d. return\n", h); return TRUE; } source_to_dest( &S, &S_ ); h = h_; printf("\n %4d ", h); } return TRUE; }
Bool do_enforced_hill_climbing( State *start, State *end ) { static Bool first_call = TRUE; static State S, S_; int i, h, h_; if ( first_call ) { /* on first call, initialize plan hash table, search space, search hash table */ for ( i = 0; i < PLAN_HASH_SIZE; i++ ) { lplan_hash_entry[i] = NULL; } /* on subsequent calls, the start is already hashed, as it's the end of the previous calls */ hash_plan_state( start, 0 ); lehc_space_head = new_EhcNode(); lehc_space_end = lehc_space_head; for ( i = 0; i < EHC_HASH_SIZE; i++ ) { lehc_hash_entry[i] = NULL; lnum_ehc_hash_entry[i] = 0; lchanged_ehc_entry[i] = FALSE; } lnum_changed_ehc_entrys = 0; make_state( &S, gnum_ft_conn ); S.max_F = gnum_ft_conn; make_state( &S_, gnum_ft_conn ); S_.max_F = gnum_ft_conn; make_state( &lcurrent_goals, gnum_ft_conn ); lcurrent_goals.max_F = gnum_ft_conn; first_call = FALSE; } /* start enforced Hill-climbing */ source_to_dest( &lcurrent_goals, end ); source_to_dest( &S, start ); /*seems get a heuristic*/ h = get_1P_and_H( &S, &lcurrent_goals ); if ( h == INFINITY ) { return FALSE; } if ( h == 0 ) { return TRUE; } printf("\n\nCueing down from goal distance: %4d into depth", h); while ( h != 0 ) { if ( !search_for_better_state( &S, h, &S_, &h_ ) ) { return FALSE; } /* * modified by Jason Huang: return ealier */ if(is_solved_state( &S_ )) { printf("\nstate have seen. h = %d. return\n", h); return TRUE; } source_to_dest( &S, &S_ ); h = h_; printf("\n %4d ", h); } return TRUE; }
Bool do_best_first_search( void ) { static Bool fc = TRUE; static State S; BfsNode *first; int i, min = INFINITY; Bool start = TRUE; if ( fc ) { make_state( &S, gnum_ft_conn ); fc = FALSE; } lbfs_space_head = new_BfsNode(); lbfs_space_had = NULL; add_to_bfs_space( &ginitial_state, -1, NULL ); while ( TRUE ) { if ( (first = lbfs_space_head->next) == NULL ) { printf("\n\nbest first search space empty! problem proven unsolvable.\n\n"); return FALSE; } lbfs_space_head->next = first->next; if ( first->next ) { first->next->prev = lbfs_space_head; } if ( LESS( first->h, min ) ) { min = first->h; if ( start ) { printf("\nadvancing to distance : %4d", min); start = FALSE; fflush(stdout); } else { printf("\n %4d", min); fflush(stdout); } } if ( first->h == 0 ) { break; } get_A( &(first->S) ); for ( i = 0; i < gnum_A; i++ ) { if ( !result_to_dest( &S, NULL, first, gA[i] ) ) continue; add_to_bfs_space( &S, gA[i], first ); } first->next = lbfs_space_had; lbfs_space_had = first; } extract_plan( first ); return TRUE; }
void collect_relevant_facts( void ) { Action *a; NormOperator *no; NormEffect *ne; int i, j, adr; PseudoAction *pa; PseudoActionEffect *pae; /* mark all deleted facts; such facts, that are also pos, are relevant. */ for ( a = gactions; a; a = a->next ) { if ( a->norm_operator ) { no = a->norm_operator; for ( ne = no->effects; ne; ne = ne->next ) { for ( i = 0; i < ne->num_dels; i++ ) { lp = ne->dels[i].predicate; for ( j = 0; j < garity[lp]; j++ ) { largs[j] = ( ne->dels[i].args[j] >= 0 ) ? ne->dels[i].args[j] : a->inst_table[DECODE_VAR( ne->dels[i].args[j] )]; } adr = fact_adress(); lneg[lp][adr] = 1; if ( lpos[lp][adr] && !luse[lp][adr] ) { luse[lp][adr] = 1; lindex[lp][adr] = gnum_relevant_facts; if ( gnum_relevant_facts == MAX_RELEVANT_FACTS ) { printf("\nincrease MAX_RELEVANT_FACTS! (current value: %d)\n\n", MAX_RELEVANT_FACTS); exit( 1 ); } grelevant_facts[gnum_relevant_facts].predicate = lp; for ( j = 0; j < garity[lp]; j++ ) { grelevant_facts[gnum_relevant_facts].args[j] = largs[j]; } lindex[lp][adr] = gnum_relevant_facts; gnum_relevant_facts++; } } } } else { pa = a->pseudo_action; for ( pae = pa->effects; pae; pae = pae->next ) { for ( i = 0; i < pae->num_dels; i++ ) { lp = pae->dels[i].predicate; for ( j = 0; j < garity[lp]; j++ ) { largs[j] = pae->dels[i].args[j]; } adr = fact_adress(); lneg[lp][adr] = 1; if ( lpos[lp][adr] && !luse[lp][adr] ) { luse[lp][adr] = 1; lindex[lp][adr] = gnum_relevant_facts; if ( gnum_relevant_facts == MAX_RELEVANT_FACTS ) { printf("\nincrease MAX_RELEVANT_FACTS! (current value: %d)\n\n", MAX_RELEVANT_FACTS); exit( 1 ); } grelevant_facts[gnum_relevant_facts].predicate = lp; for ( j = 0; j < garity[lp]; j++ ) { grelevant_facts[gnum_relevant_facts].args[j] = largs[j]; } lindex[lp][adr] = gnum_relevant_facts; gnum_relevant_facts++; } } } } } if ( gcmd_line.display_info == 119 ) { printf("\n\nfacts selected as relevant:\n\n"); for ( i = 0; i < gnum_relevant_facts; i++ ) { printf("\n%d: ", i); print_Fact( &(grelevant_facts[i]) ); } } lnum_effects = 0; /* first make place for initial and goal states. * (one artificial fact might still be added here) */ make_state( &ggoal_state, gnum_relevant_facts + 1 ); ggoal_state.max_F = gnum_relevant_facts + 1; make_state( &ginitial_state, gnum_relevant_facts + 1 ); ginitial_state.max_F = gnum_relevant_facts + 1; create_final_goal_state(); create_final_initial_state(); create_final_actions(); if ( gcmd_line.display_info == 120 ) { printf("\n\nfinal domain representation is:\n\n"); for ( i = 0; i < gnum_operators; i++ ) { printf("\n\n------------------operator %s-----------\n\n", goperators[i]->name); for ( a = gactions; a; a = a->next ) { if ( ( !a->norm_operator && !a->pseudo_action ) || ( a->norm_operator && a->norm_operator->operator != goperators[i] ) || ( a->pseudo_action && a->pseudo_action->operator != goperators[i] ) ) { continue; } print_Action( a ); } } printf("\n\n--------------------GOAL REACHED ops-----------\n\n"); for ( a = gactions; a; a = a->next ) { if ( !a->norm_operator && !a->pseudo_action ) { print_Action( a ); } } printf("\n\nfinal initial state is:\n\n"); for ( i = 0; i < ginitial_state.num_F; i++ ) { print_ft_name( ginitial_state.F[i] ); printf("\n"); } printf("\n\nfinal goal state is:\n\n"); for ( i = 0; i < ggoal_state.num_F; i++ ) { print_ft_name( ggoal_state.F[i] ); printf("\n"); } } }
struct flow *parse(char **string) { struct flow *last = 0; struct flow *result = malloc(sizeof(struct flow)); result->end = result->start = make_state(); char lcc = 0; struct state *for_range = 0; while(**string) { switch(**string) { case '[': (*string)++; if (last) { free(last); } last = parse(string); for(int i=0;i<256;i++) { (result->end->next)[i] = (last->start->next)[i]; } last->start = result->end; result->end = last->end; break; case ']': return result; case '+': if (last->start->name) { (last->end->next)[(int)(last->start->name)] = last->start; } else { for(int i=0;i<256;i++) { struct state *tmp = (last->start->next)[i]; if (tmp) { (last->end->next)[i] = tmp; } } } break; case '-': (*string)++; if (!lcc) { return 0; } for(;lcc<=**string;lcc++) { (for_range->next)[(int)lcc] = result->end; } break; case '\\': (*string)++; //intentional fallthrough default: lcc = **string; for_range = result->end; if (last) { free(last); } last = malloc(sizeof(struct flow)); last->start = last->end = make_state(); last->start->name = **string; (result->end->next)[(int)**string] = last->end; result->end = last->end; break; } (*string)++; } return result; }
/*********************************** * FUNCTIONS ACCESSED FROM OUTSIDE * ***********************************/ void initialize_relax( void ) { make_state( &lcurrent_goals, gnum_ft_conn ); lcurrent_goals.max_F = gnum_ft_conn; }
Bool do_enforced_hill_climbing( State *start, State *end ) { static Bool first_call = TRUE; static State S, S_; int i, h, h_; if ( first_call ) { /* on first call, initialize plan hash table, search space, search hash table */ for ( i = 0; i < PLAN_HASH_SIZE; i++ ) { lplan_hash_entry[i] = NULL; } lehc_space_head = new_EhcNode(); lehc_space_end = lehc_space_head; make_state( &S, gnum_ft_conn ); make_state( &S_, gnum_ft_conn ); make_state( &lscurrent_goals, gnum_ft_conn ); first_call = FALSE; } /* start enforced Hill-climbing */ source_to_dest( &lscurrent_goals, end ); source_to_dest( &S, start ); h = get_1P_and_H( &S, &lscurrent_goals, NULL, NULL, -1 ); if ( h == INFINITY ) { return FALSE; } if ( h == 0 ) { return TRUE; } printf("\n\nCueing down from goal distance: %4d into depth ", h); fflush(stdout); while ( h != 0 ) { if ( !search_for_better_state( &S, h, &S_, &h_ ) ) { /* printf("\nswitch to no H %4d ", h); */ /* get_A(&S); */ /* for ( i = 0; i < gnum_H; i++ ) { */ /* gop_conn[gH[i]].is_in_H = FALSE; */ /* } */ /* for ( i = 0; i < gnum_A; i++ ) { */ /* gH[i] = gA[i]; */ /* gop_conn[gH[i]].is_in_H = TRUE; */ /* } */ /* gnum_H = gnum_A; */ /* gcmd_line.help = FALSE; */ /* if ( !search_for_better_state( &S, h, &S_, &h_ ) ) { */ for ( i = 0; i < gnum_clauses; i++ ) { gclause_length[i] = 0; } gnum_fixed_clauses = 0; gnum_clauses = 0; for ( i = 1; i <= gnum_fixed_c; i++ ) { gcodes[gct[i]][gcf[i]] = -1; } gnum_fixed_c = 0; extend_fixed_clauses_base( 0, 0 ); extend_fixed_clauses_base_encoding( 0 ); return FALSE; /* } else { */ /* gcmd_line.help = TRUE; */ /* } */ } source_to_dest( &S, &S_ ); h = h_; printf("\n %4d ", h); fflush(stdout); } return TRUE; }
Bool search_for_better_state( State *S, int h, State *S_, int *h_ ) { static Bool first_call = TRUE; static State S__; int i, h__, depth = 0; EhcNode *tmp; if ( first_call ) { make_state( &S__, gnum_ft_conn ); first_call = FALSE; } /* don't hash states, but search nodes. * this way, don't need to keep states twice in memory */ tmp = new_EhcNode(); copy_source_to_dest( &(tmp->S), S); hash_ehc_node( tmp ); lehc_current_end = lehc_space_head->next; for ( i = 0; i < gnum_H; i++ ) { /* see result-to-dest params explanation at fn header */ if ( !result_to_dest( &S__, tmp, NULL, gH[i] ) ) continue; add_to_ehc_space( &S__, gH[i], tmp ); } lehc_current_start = lehc_space_head->next; while ( TRUE ) { if ( lehc_current_start == lehc_current_end ) { reset_ehc_hash_entrys(); free( tmp ); return FALSE; } if ( lehc_current_start->depth > depth ) { depth = lehc_current_start->depth; if ( depth > gmax_search_depth ) { gmax_search_depth = depth; } printf("[%d]", depth); fflush( stdout ); /* HACK: if this is going to more than 15, then most likely this is just a stupid * effect of helpful actions pruning, and we won't get anywhere anyway. */ if ( depth > 15 ) { reset_ehc_hash_entrys(); free( tmp ); return FALSE; } } h__ = expand_first_node( h ); if ( LESS( h__, h ) ) { break; } } reset_ehc_hash_entrys(); free( tmp ); extract_plan_fragment( S ); source_to_dest( S_, &(lehc_current_start->S) ); *h_ = h__; return TRUE; }
void manual_control( void ) { static Bool fc = TRUE; static State S; int i, j, h, choice; BfsNode *tmp, *curr; if ( fc ) { make_state( &S, gnum_ft_conn ); fc = FALSE; } tmp = new_BfsNode(); copy_source_to_dest( &(tmp->S), &ginitial_state ); tmp->op = -1; curr = tmp; if ( gcmd_line.dominating ) { hash_bfs_node( curr ); } while ( TRUE ) { if ( !curr ) break; h = get_1P_and_H( &(curr->S), &ggoal_state, NULL, curr->father, curr->op ); get_A( &(curr->S) ); while ( TRUE ) { printf("\n\n\n-------------state h = %d", h); if ( h > 0 ) printf(" (resp. %d actions)", h - 1); printf(", info level %d, %d applicable actions", gcmd_line.debug, gnum_A); if ( gcmd_line.debug >= 1 ) { print_state( curr->S ); } if ( 0 ) { printf("\nH:"); for ( i = 0; i < gnum_H; i++ ) { printf(" "); print_op_name( gH[i] ); } } printf("\n"); for ( i = 0; i < gnum_A; i++ ) { printf("\n%3d ", i); for ( j = 0; j < gnum_H; j++ ) { if ( gA[i] == gH[j] ) break; } if ( j < gnum_H ) { printf("H: "); } else { printf(" : "); } print_op_name( gA[i] ); } printf("\n\n -1: retract last choice"); printf("\n -2: set info level"); printf("\n\nchoice: "); scanf("%d", &choice); if ( choice >= -2 && choice < gnum_A ) break; } if ( choice >= 0 ) { if ( !result_to_dest( &S, NULL, curr, gA[choice] ) ) { printf("\naction not applicable!"); continue; } if ( gcmd_line.dominating && bfs_state_hashed( &S, curr, gA[choice] ) ) { printf("\nthis state is dominated!\n\n"); } tmp = new_BfsNode(); copy_source_to_dest( &(tmp->S), &S ); tmp->father = curr; tmp->op = gA[choice]; curr = tmp; if ( gcmd_line.dominating ) { hash_bfs_node( curr ); } continue; } if ( choice == -1 ) { curr = curr->father; continue; } printf("\nlevel : "); scanf("%d", &gcmd_line.debug); } }
Bool search_for_better_state( State *S, int h, State *S_, int *h_ ) { static Bool first_call = TRUE; static State S__; int i, h__, depth = 0, g; EhcNode *tmp; if ( first_call ) { make_state( &S__, gnum_ft_conn ); S__.max_F = gnum_ft_conn; first_call = FALSE; } /* don't hash states, but search nodes. * this way, don't need to keep states twice in memory */ tmp = new_EhcNode(); copy_source_to_dest( &(tmp->S), S); hash_ehc_node( tmp ); lehc_current_end = lehc_space_head->next; for ( i = 0; i < gnum_H; i++ ) { g = result_to_dest( &S__, S, gH[i] ); add_to_ehc_space( &S__, gH[i], NULL, g ); } lehc_current_start = lehc_space_head->next; while ( TRUE ) { if ( lehc_current_start == lehc_current_end ) { reset_ehc_hash_entrys(); free( tmp ); return FALSE; } if ( lehc_current_start->depth > depth ) { depth = lehc_current_start->depth; if ( depth > gmax_search_depth ) { gmax_search_depth = depth; } printf("[%d]", depth); fflush( stdout ); } h__ = expand_first_node( h ); if ( LESS( h__, h ) ) { break; } } reset_ehc_hash_entrys(); free( tmp ); extract_plan_fragment( S ); source_to_dest( S_, &(lehc_current_start->S) ); *h_ = h__; return TRUE; }
int main(void) { int n, m; char **maze = read_maze(&n, &m); // initialization fringe *f = fringe_init(); fringe_enqueue(f, make_fringe_item(make_state(0, 0), NULL)); int **closed_set = init_closed_set(n, m); // set up search helper-variables fringe_item *current_item; state *current_state; action *current_strategy; state *next_state; int num_actions, i; int *available_actions; int strategy_found = 0; action *strategy; // perform breadth first search while (!is_empty(f)) { current_item = fringe_dequeue(f); current_state = current_item->state; current_strategy = current_item->strategy; // goal state-check if (is_goal_state(current_state, n, m)) { strategy = current_strategy; strategy_found = 1; break; } // only proceed if the node has not been visited if (is_in_closed_set(current_state, closed_set)) { // free item? continue; } // put the current node into the closed set insert_into_closed_set(current_state, closed_set); // expand current node available_actions = get_actions(current_state, maze, &num_actions); for (i = 0; i < num_actions; i++) { next_state = apply(current_state, available_actions[i]); // add this state/action-pair to the fringe action *new_action = make_action(available_actions[i], current_strategy); fringe_enqueue(f, make_fringe_item(next_state, new_action)); } free(current_item); } if (!strategy_found) { // don't do anything } else { display_and_free(reverse(strategy), make_state(0, 0)); printf("[%d, %d]\n", n - 1, m - 1); } // free maze memory return 0; }
inline auto parse(Parser const& parser, Cursor cursor) { auto start_state = make_state(empty_list, std::move(cursor)); auto end_state = parser.parse(std::move(start_state)); return parse_impl::get_result(std::move(end_state.values)); }
int main( int argc, char *argv[] ) { /* resulting name for ops file */ char ops_file[MAX_LENGTH] = ""; /* same for fct file */ char fct_file[MAX_LENGTH] = ""; /* name for additional goal file */ char mul_file[MAX_LENGTH] = ""; struct timeb start, end; State current_start, current_end; int i, j; Bool found_plan; Bool found_plan_for_multiple_purpose; /*times ( &lstart );*/ ftime(&lstart); /* command line treatment*/ if ( argc == 1 || ( argc == 2 && *++argv[0] == '?' ) ) { ff_usage(); exit( 1 ); } if ( !process_command_line( argc, argv ) ) { ff_usage(); exit( 1 ); } /* make file names */ /* one input name missing */ if ( !gcmd_line.ops_file_name || !gcmd_line.fct_file_name || !gcmd_line.mul_file_name ) { fprintf(stdout, "\nmul-fip : three input files needed\n"); ff_usage(); exit( 1 ); } /* add path info, complete file names will be stored in * ops_file and fct_file */ sprintf(ops_file, "%s%s", gcmd_line.path, gcmd_line.ops_file_name); sprintf(fct_file, "%s%s", gcmd_line.path, gcmd_line.fct_file_name); sprintf(mul_file, "%s%s", gcmd_line.path, gcmd_line.mul_file_name); /* parse the input files */ /* start parse & instantiation timing*/ /*times( &start );*/ ftime(&start); /* domain file (ops) */ /* it is important for the pddl language to define the domain before * reading the problem */ load_ops_file( ops_file ); /* problem file (facts) */ if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: parsing problem file.\n"); } load_fct_file( fct_file ); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: original purpose fact file done.\n"); } load_mul_file( mul_file ); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: multiple purpose fact file done.\n"); } /* This is needed to get all types.*/ /* modified by jovi: adding supprot for addtional constant */ build_orig_constant_list(); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: build_orig_constant_list() done.\n"); } /* last step of parsing: see if it's an ADL domain! */ if ( !make_adl_domain() ) { printf("\nmul-fip: this is not an ADL problem!"); printf("\n\tcan't be handled by this version.\n\n"); exit( 1 ); } if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: make_adl_domain() done.\n"); } /* now instantiate operators; */ /*JC: initialize the array*/ gInvActs = (StateActionPair*)calloc(MAX_INVALID_ACTIONS, sizeof(StateActionPair)); /************************** * first do PREPROCESSING * **************************/ /* start by collecting all strings and thereby encoding * the domain in integers. */ encode_domain_in_integers(); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: encode_domain_in_integers() done.\n"); } /* inertia preprocessing, first step: * - collect inertia information * - split initial state into * _ arrays for individual predicates * - arrays for all static relations * - array containing non - static relations */ do_inertia_preprocessing_step_1(); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: do_inertia_preprocessing_step_1() done.\n"); } /* normalize all PL1 formulae in domain description: * (goal, preconds and effect conditions) * - simplify formula * - expand quantifiers * - NOTs down */ normalize_all_wffs(); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: normalize_all_wffs() done.\n"); } /* translate negative preconds: introduce symmetric new predicate * NOT-p(..) (e.g., not-in(?ob) in briefcaseworld) */ translate_negative_preconds(); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: translate_negative_preconds() done.\n"); } /* split domain in easy (disjunction of conjunctive preconds) * and hard (non DNF preconds) part, to apply * different instantiation algorithms */ split_domain(); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: split_domain() done.\n"); } /*********************************************** * PREPROCESSING FINISHED * * * * NOW MULTIPLY PARAMETERS IN EFFECTIVE MANNER * ***********************************************/ /*jovi: updated for multiple purpose */ build_easy_action_templates(); build_hard_action_templates(); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: build_easy_action_template() done.\n"); } /*times( &end );*/ ftime(&end); TIME( gtempl_time ); /*times( &start );*/ ftime(&start); /* perform reachability analysis in terms of relaxed fixpoint */ perform_reachability_analysis(); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: perform_reachability_analysis() done.\n"); } /*times( &end );*/ ftime(&end); TIME( greach_time ); /*times( &start );*/ ftime(&start); /* collect the relevant facts and build final domain * and problem representations.*/ collect_relevant_facts(); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: collect_relevant_facts.\n"); } /*times( &end );*/ ftime(&end); TIME( grelev_time ); /*times( &start );*/ ftime(&start); /* now build globally accessable connectivity graph */ build_connectivity_graph(); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: build_connectivity_graph().\n"); } /*times( &end );*/ ftime(&end); TIME( gconn_time ); /*********************************************************** * we are finally through with preprocessing and can worry * * bout finding a plan instead. * ***********************************************************/ ftime(&mystart); /*times( &start );*/ ftime(&start); /* another quick preprocess: approximate goal orderings and split * goal set into sequence of smaller sets, the goal agenda */ compute_goal_agenda(); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: compute_goal_agenda().\n"); } /*debugit(&ginitial_state);*/ /* make space in plan states info, and relax * make sapce is initialize the space for gplan_states and * initialzie the variable */ for ( i = 0; i < MAX_PLAN_LENGTH + 1; i++ ) { make_state( &(gplan_states[i]), gnum_ft_conn ); gplan_states[i].max_F = gnum_ft_conn; } make_state( ¤t_start, gnum_ft_conn ); current_start.max_F = gnum_ft_conn; make_state( ¤t_end, gnum_ft_conn ); current_end.max_F = gnum_ft_conn; initialize_relax(); /* need to read the agenda paper */ source_to_dest( &(gplan_states[0]), &ginitial_state ); source_to_dest( ¤t_start, &ginitial_state ); source_to_dest( ¤t_end, &(ggoal_agenda[0]) ); for ( i = 0; i < gnum_goal_agenda; i++ ) { /* JC add a hashtable creating in do_enforced_hill_climbling*/ if (!do_enforced_hill_climbing(¤t_start, ¤t_end)) { if (gcmd_line.display_info >= 1) { printf("\nDebugInfo: do_enforced_hill_climbling() exit .\n"); } break; } source_to_dest( ¤t_start, &(gplan_states[gnum_plan_ops]) ); if ( i < gnum_goal_agenda - 1 ) { for ( j = 0; j < ggoal_agenda[i+1].num_F; j++ ) { current_end.F[current_end.num_F++] = ggoal_agenda[i+1].F[j]; } } } found_plan = ( i == gnum_goal_agenda ) ? TRUE : FALSE; if ( !found_plan ) { printf("\nDebugInfo: switching to Best-first Search now.\n"); reset_ff_states(); found_plan = do_best_first_search(); } if ( gcmd_line.display_info >= 1 ) { printf("\n************************************************\n"); printf("\n* mul-fip: fip plan finished for single goal. *\n"); printf("\n************************************************\n"); } print_plan(); if ( !found_plan ) { /*print_plan();*/ /* D action add to group */ build_action_group(); gfipPlan.num_sons = 0; gfipPlan.action = -1; print_plan(); /*put the ultimate goal to the solved set*/ StateActionPair *g = new_StateActionPair(); make_state(&g->state, gnum_ft_conn); g->state.max_F = gnum_ft_conn; source_to_dest(&g->state, &ggoal_state); g->state.num_L = 1; g->state.L[0] = 10000000; /*make it the biggest*/ add_solved_state(g); /*ugly, but work*/ convert_ff_plan_to_fip_plan( &gfipPlan ); solve_unsolved_states(); if(!gsolved_states) { printf("No solutions are found! The problem is unsolvable.\n"); exit(0); } else if(g_is_strong) { StateActionPair *ptr = gsolved_states; Bool valid = FALSE; while(ptr) { if(ptr->state.num_L == 1 && ptr->state.L[0] == 1) { valid = TRUE; break; } ptr = ptr->next; } if(!valid) { printf("The initial state is a dead-end! The problem is unsolvable.\n"); exit(0); } } printf("##########################################\n"); printf("##### PROCEDURE-LIKE CODE ############\n"); printf("##########################################\n"); /* print_fip_plan_1( is_solved_state(&ginitial_state) , &gfipPlan, 1); */ /* times( &end ); */ ftime(&end); TIME( gsearch_time ); /* myend = clock(); */ ftime(&myend); /* printf("my cac is %7.3f\n", 1.0*(myend.millitm - mystart.millitm)/1000.0); */ print_fip_plan_2(); if(to_print_state) print_all_states(); /* print_fip_plan_3( &gfipPlan, 0 ); */ } printf("The total searching time is %7.3f\n", (myend.time - mystart.time) + (myend.millitm - mystart.millitm)/1000.0); output_planner_info(); /******************************************** * Multiple Purpose Planning * ********************************************/ if ( gcmd_line.display_info >= 1 ) { printf("\n************************************************\n"); printf("\n* mul-fip: multiple purpose planning *\n"); printf("\n************************************************\n"); } set_global_variables_for_multiple_purpose(); ftime(&start); update_reachability_analysis_for_multiple_purpose (); ftime(&end); TIME( gadd_reach_time ); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: update_reachability_analysis_for_multiple_purpose() finished\n"); } ftime(&start); update_relevant_facts_for_multiple_purpose (); ftime(&end); TIME( gadd_relev_time ); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: update_relevant_facts_for_multiple_purpose() finished\n"); } ftime(&start); update_connectivity_graph_for_multiple_purpose(); ftime(&end); TIME( gadd_conn_time ); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: update_connectivity_graph_for_multiple_purpose() finished\n"); } compute_goal_agenda_for_multiple_purpose (); if ( gcmd_line.display_info >= 1 ) { printf("\nDebugInfo: compute_goal_agenda_for_multiple_purpose() finished\n"); } for ( i = 0; i < MAX_PLAN_LENGTH + 1; i++ ) { make_state( &(gadd_plan_states[i]), gnum_ft_conn ); gadd_plan_states[i].max_F = gnum_ft_conn; } source_to_dest( ¤t_end, &(gadd_goal_agenda[0]) ); for ( i = 0; i < gadd_num_goal_agenda; i++ ) { /* JC add a hashtable creating in do_enforced_hill_climbling*/ if ( !do_enforced_hill_climbing_for_multiple_purpose ( ¤t_start, ¤t_end ) ) { break; } source_to_dest( ¤t_start, &(gplan_states[gnum_plan_ops]) ); if ( i < gnum_goal_agenda - 1 ) { for ( j = 0; j < ggoal_agenda[i+1].num_F; j++ ) { current_end.F[current_end.num_F++] = ggoal_agenda[i+1].F[j]; } } } found_plan_for_multiple_purpose = ( i == gadd_num_goal_agenda ) ? TRUE : FALSE; if ( !found_plan_for_multiple_purpose ) { printf("\n\nEnforced Hill-climbing failed !"); printf("\nswitching to Best-first Search now.\n"); reset_ff_states_for_multiple_purpose(); found_plan_for_multiple_purpose = do_best_first_search_for_multiple_purpose(); } if ( gcmd_line.display_info >= 1 ) { printf("\n************************************************\n"); printf("\n* mul-fip: fip plan finished for multiple goal. *\n"); printf("\n************************************************\n"); } print_plan(); if ( !found_plan_for_multiple_purpose ) { /*print_plan();*/ /* D action add to group */ build_action_group(); gfipPlan.num_sons = 0; gfipPlan.action = -1; print_plan(); /*put the ultimate goal to the solved set*/ StateActionPair *g = new_StateActionPair(); make_state(&g->state, gnum_ft_conn); g->state.max_F = gnum_ft_conn; source_to_dest(&g->state, &ggoal_state); g->state.num_L = 1; g->state.L[0] = 10000000; /*make it the biggest*/ add_solved_state(g); /*ugly, but work*/ convert_ff_plan_to_fip_plan( &gfipPlan ); solve_unsolved_states(); if(!gsolved_states) { printf("No solutions are found! The problem is unsolvable.\n"); exit(0); } else if(g_is_strong) { StateActionPair *ptr = gsolved_states; Bool valid = FALSE; while(ptr) { if(ptr->state.num_L == 1 && ptr->state.L[0] == 1) { valid = TRUE; break; } ptr = ptr->next; } if(!valid) { printf("The initial state is a dead-end! The problem is unsolvable.\n"); exit(0); } } printf("##########################################\n"); printf("##### PROCEDURE-LIKE CODE ############\n"); printf("##########################################\n"); /* print_fip_plan_1( is_solved_state(&ginitial_state) , &gfipPlan, 1); */ /* times( &end ); */ ftime(&end); TIME( gsearch_time ); /* myend = clock(); */ ftime(&myend); /* printf("my cac is %7.3f\n", 1.0*(myend.millitm - mystart.millitm)/1000.0); */ print_fip_plan_2(); if(to_print_state) print_all_states(); /* print_fip_plan_3( &gfipPlan, 0 ); */ } /*****************************************************************************************/ output_planner_info(); printf("\n\n"); exit( 0 ); }
int main( int argc, char *argv[] ) { /* resulting name for ops file */ char ops_file[MAX_LENGTH] = ""; /* same for fct file */ char fct_file[MAX_LENGTH] = ""; struct tms start, end; State current_start, current_end; int i, j; Bool found_plan; times ( &lstart ); /* command line treatment */ if ( argc == 1 || ( argc == 2 && *++argv[0] == '?' ) ) { ff_usage(); exit( 1 ); } if ( !process_command_line( argc, argv ) ) { ff_usage(); exit( 1 ); } /* make file names */ /* one input name missing */ if ( !gcmd_line.ops_file_name || !gcmd_line.fct_file_name ) { fprintf(stdout, "\nff: two input files needed\n\n"); ff_usage(); exit( 1 ); } /* add path info, complete file names will be stored in * ops_file and fct_file */ sprintf(ops_file, "%s%s", gcmd_line.path, gcmd_line.ops_file_name); sprintf(fct_file, "%s%s", gcmd_line.path, gcmd_line.fct_file_name); /* parse the input files */ /* start parse & instantiation timing */ times( &start ); /* domain file (ops) */ if ( gcmd_line.display_info >= 1 ) { printf("\nff: parsing domain file"); } /* it is important for the pddl language to define the domain before * reading the problem */ load_ops_file( ops_file ); /* problem file (facts) */ if ( gcmd_line.display_info >= 1 ) { printf(" ... done.\nff: parsing problem file"); } load_fct_file( fct_file ); if ( gcmd_line.display_info >= 1 ) { printf(" ... done.\n\n"); } /* This is needed to get all types. */ build_orig_constant_list(); /* last step of parsing: see if it's an ADL domain! */ if ( !make_adl_domain() ) { printf("\nff: this is not an ADL problem!"); printf("\n can't be handled by this version.\n\n"); exit( 1 ); } /* now instantiate operators; */ /************************** * first do PREPROCESSING * **************************/ /* start by collecting all strings and thereby encoding * the domain in integers. */ encode_domain_in_integers(); /* inertia preprocessing, first step: * - collect inertia information * - split initial state into * _ arrays for individual predicates * - arrays for all static relations * - array containing non - static relations */ do_inertia_preprocessing_step_1(); /* normalize all PL1 formulae in domain description: * (goal, preconds and effect conditions) * - simplify formula * - expand quantifiers * - NOTs down */ normalize_all_wffs(); /* translate negative preconds: introduce symmetric new predicate * NOT-p(..) (e.g., not-in(?ob) in briefcaseworld) */ translate_negative_preconds(); /* split domain in easy (disjunction of conjunctive preconds) * and hard (non DNF preconds) part, to apply * different instantiation algorithms */ split_domain(); /*********************************************** * PREPROCESSING FINISHED * * * * NOW MULTIPLY PARAMETERS IN EFFECTIVE MANNER * ***********************************************/ build_easy_action_templates(); build_hard_action_templates(); times( &end ); TIME( gtempl_time ); times( &start ); /* perform reachability analysis in terms of relaxed * fixpoint */ perform_reachability_analysis(); times( &end ); TIME( greach_time ); times( &start ); /* collect the relevant facts and build final domain * and problem representations. */ collect_relevant_facts(); times( &end ); TIME( grelev_time ); times( &start ); /* now build globally accessable connectivity graph */ build_connectivity_graph(); times( &end ); TIME( gconn_time ); /*********************************************************** * we are finally through with preprocessing and can worry * * bout finding a plan instead. * ***********************************************************/ times( &start ); /* another quick preprocess: approximate goal orderings and split * goal set into sequence of smaller sets, the goal agenda */ compute_goal_agenda(); /* make space in plan states info, and relax */ for ( i = 0; i < MAX_PLAN_LENGTH + 1; i++ ) { make_state( &(gplan_states[i]), gnum_ft_conn ); gplan_states[i].max_F = gnum_ft_conn; } make_state( ¤t_start, gnum_ft_conn ); current_start.max_F = gnum_ft_conn; make_state( ¤t_end, gnum_ft_conn ); current_end.max_F = gnum_ft_conn; initialize_relax(); source_to_dest( &(gplan_states[0]), &ginitial_state ); source_to_dest( ¤t_start, &ginitial_state ); source_to_dest( ¤t_end, &(ggoal_agenda[0]) ); for ( i = 0; i < gnum_goal_agenda; i++ ) { if ( !do_enforced_hill_climbing( ¤t_start, ¤t_end ) ) { break; } source_to_dest( ¤t_start, &(gplan_states[gnum_plan_ops]) ); if ( i < gnum_goal_agenda - 1 ) { for ( j = 0; j < ggoal_agenda[i+1].num_F; j++ ) { current_end.F[current_end.num_F++] = ggoal_agenda[i+1].F[j]; } } } found_plan = ( i == gnum_goal_agenda ) ? TRUE : FALSE; if ( !found_plan ) { printf("\n\nEnforced Hill-climbing failed !"); printf("\nswitching to Best-first Search now.\n"); found_plan = do_best_first_search(); } times( &end ); TIME( gsearch_time ); if ( found_plan ) { print_plan(); } output_planner_info(); printf("\n\n"); exit( 0 ); }