in grolp/gen/ff_planner/main.c [641:1022]
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;
Bool found_plan;
int i;
float cost;
Bool prev_gcost_rplans;
times ( &lstart );
/* command line treatment
*/
gcmd_line.display_info = 1;
gcmd_line.debug = 0;
/* search settings
*/
gcmd_line.search_config = 5;
gcmd_line.cost_rplans = TRUE;
gcmd_line.w = 5;
gcmd_line.cost_bound = -1;
memset(gcmd_line.ops_file_name, 0, MAX_LENGTH);
memset(gcmd_line.fct_file_name, 0, MAX_LENGTH);
memset(gcmd_line.path, 0, MAX_LENGTH);
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_and_fluents();
times( &end );
TIME( grelev_time );
/* now transform problem to additive normal form,
* if possible
*/
times( &start );
if ( !transform_to_LNF() ) {
printf("\n\nThis is not a linear task!\n\n");
exit( 1 );
}
times( &end );
TIME( gLNF_time );
times( &start );
/* now build globally accessable connectivity graph
*/
build_connectivity_graph();
/* now check for acyclic := effects (in expressions.c)
*/
check_assigncycles();
/* set the relevanc info (in expressions.c)
*/
determine_fl_relevance();
times( &end );
TIME( gconn_time );
/***********************************************************
* we are finally through with preprocessing and can worry *
* bout finding a plan instead. *
***********************************************************/
if ( gcmd_line.display_info ) {
printf("\n\nff: search configuration is ");
switch ( gcmd_line.search_config ) {
case 0:
printf("Enforced Hill-Climbing, if that fails then best-first search.\nMetric is plan length.");
printf("\nNO COST MINIMIZATION");
if ( !gcost_rplans ) {
printf(" (and no cost-minimizing relaxed plans).");
} else {
printf("\nDEBUG ME: cost min rplans in non-cost minimizing search config?\n\n");
exit( 1 );
}
break;
case 1:
printf("best-first search.\nMetric is plan length.");
printf("\nNO COST MINIMIZATION");
if ( !gcost_rplans ) {
printf(" (and no cost-minimizing relaxed plans).");
} else {
printf("\nDEBUG ME: cost min rplans in non-cost minimizing search config?\n\n");
exit( 1 );
}
break;
case 2:
printf("best-first search with helpful actions pruning.\nMetric is plan length.");
printf("\nNO COST MINIMIZATION.");
if ( !gcost_rplans ) {
printf(" (and no cost-minimizing relaxed plans).");
} else {
printf("\nDEBUG ME: cost min rplans in non-cost minimizing search config?\n\n");
exit( 1 );
}
break;
case 3:
printf("weighted A* with weight %d.", gcmd_line.w);
if ( goptimization_established ) {
printf("\nMetric is ");
print_LnfExpNode( &glnf_metric );
} else {
printf(" plan length");
}
printf("\nCOST MINIMIZATION DONE");
if ( !gcost_rplans ) {
printf(" (WITHOUT cost-minimizing relaxed plans).");
} else {
printf(" (WITH cost-minimizing relaxed plans).");
}
break;
case 4:
printf("A*epsilon with weight %d.", gcmd_line.w);
if ( goptimization_established ) {
printf("\nMetric is ");
print_LnfExpNode( &glnf_metric );
} else {
printf("\nError! Optimization criterion not established.\nA*epsilon not defined.\n\n");
exit( 1 );
}
printf("\nCOST MINIMIZATION DONE");
if ( !gcost_rplans ) {
printf(" (WITHOUT cost-minimizing relaxed plans).");
} else {
printf(" (WITH cost-minimizing relaxed plans).");
}
break;
case 5:
printf("Enforced Hill-Climbing, then A*epsilon with weight %d.", gcmd_line.w);
if ( goptimization_established ) {
printf("\nMetric is ");
print_LnfExpNode( &glnf_metric );
} else {
printf("\nError! Optimization criterion not established.\nA*epsilon not defined.\n\n");
exit( 1 );
}
printf("\nCOST MINIMIZATION DONE");
if ( !gcost_rplans ) {
printf(" (WITHOUT cost-minimizing relaxed plans).");
} else {
printf(" (WITH cost-minimizing relaxed plans).");
}
break;
default:
printf("\n\nUnknown search configuration: %d\n\n", gcmd_line.search_config );
exit( 1 );
}
} else {
if ( gcmd_line.search_config == 4 && !goptimization_established ) {
exit( 1 );
}
}
times( &start );
/* need to evaluate derived predicates in initial state!
*/
do_axiom_update( &ginitial_state );
if ( !gcost_rplans ) {
gcmd_line.cost_bound = -1;
}
switch ( gcmd_line.search_config ) {
case 0:
found_plan = do_enforced_hill_climbing();
if ( found_plan ) {
if ( gcmd_line.display_info ) {
print_plan();
}
} else {
if ( gcmd_line.display_info ) {
printf("\n\nEnforced Hill-climbing failed !");
printf("\nswitching to Best-first Search now.\n");
}
do_best_first_search();
}
break;
case 1:
case 2:
do_best_first_search();
break;
case 3:
do_weighted_Astar();
break;
case 4:
do_Astar_epsilon();
break;
case 5:
/* gcost_rplans controls whether or not we compute cost-minimal relaxed plans
* gcost_minimizing is only used in h fn to decide whether or not we
* need to count the weights of the operators in the relaxed plan.
*
* gcost_rplans may be false even for search options 3,4,5, namely if there are
* numeric preconditions/goals which make this relaxed plan variant invalid.
* hence we need to remember, when switching it off for EHC, whether or not
* it was previously on.
*/
prev_gcost_rplans = gcost_rplans;
gcost_rplans = FALSE;
gcost_minimizing = FALSE;
found_plan = do_enforced_hill_climbing();
if ( found_plan ) {
print_plan();
} else {
if ( gcmd_line.display_info ) {
printf("\n\nEnforced Hill-climbing not successful.");
printf("\nSwitching to A*epsilon now.");
}
gcost_rplans = prev_gcost_rplans;
gcost_minimizing = TRUE;
do_Astar_epsilon();
}
break;
default:
printf("\n\nUnknown search configuration: %d\n\n", gcmd_line.search_config );
exit( 1 );
}
times( &end );
TIME( gsearch_time );
output_planner_info();
printf("\n\n");
exit( 0 );
}