void unify_easy_inertia_preconds( int curr_inertia ) { int p, i, j, af, hh; int args[MAX_VARS]; int affected_params[MAX_VARS]; int num_affected_params = 0; if ( curr_inertia == lnum_inertia_conds ) { multiply_easy_non_constrained_op_parameters( 0 ); return; } p = lo->preconds[linertia_conds[curr_inertia]].predicate; for ( i = 0; i < garity[p]; i++ ) { args[i] = lo->preconds[linertia_conds[curr_inertia]].args[i]; if ( args[i] < 0 ) { hh = DECODE_VAR( args[i] ); if ( lo->inst_table[hh] != -1 ) { args[i] = lo->inst_table[hh]; } else { affected_params[num_affected_params++] = hh; } } } for ( i = 0; i < gnum_initial_predicate[p]; i++ ) { af = 0; for ( j = 0; j < garity[p]; j++ ) { if ( args[j] >= 0 ) { if ( args[j] != ginitial_predicate[p][i].args[j] ) { break; } else { continue; } } /* check whether that constant has the correct type for that * parameter (can be not fulfilled due to encoding of unary inertia */ if ( !gis_member[ginitial_predicate[p][i].args[j]][lo->var_types[affected_params[af]]] ) { break; } /* legal constant; set op parameter instantiation to it */ lo->inst_table[affected_params[af++]] = ginitial_predicate[p][i].args[j]; } if ( j < garity[p] ) { continue; } unify_easy_inertia_preconds( curr_inertia + 1 ); } for ( i = 0; i < num_affected_params; i++ ) { lo->inst_table[affected_params[i]] = -1; } }
void multiply_easy_op_parameters( void ) { int i, j, k, l, p; NormOperator *o; geasy_templates = NULL; gnum_easy_templates = 0; for ( i = 0; i < gnum_easy_operators; i++ ) { lo = geasy_operators[i]; lnum_inertia_conds = 0; for ( j = 0; j < lo->num_preconds; j++ ) { if ( !gis_added[lo->preconds[j].predicate] && !gis_deleted[lo->preconds[j].predicate] ) { linertia_conds[lnum_inertia_conds++] = j; } } lnum_multiply_parameters = 0; for ( j = 0; j < lo->num_vars; j++ ) { for ( k = 0; k < lnum_inertia_conds; k++ ) { p = lo->preconds[linertia_conds[k]].predicate; for ( l = 0; l < garity[p]; l++ ) { if ( lo->preconds[linertia_conds[k]].args[l] == ENCODE_VAR( j ) ) { break; } } if ( l < garity[p] ) { break; } } if ( k < lnum_inertia_conds ) { continue; } lmultiply_parameters[lnum_multiply_parameters++] = j; } unify_easy_inertia_preconds( 0 ); } /* now remove inertia preconditions from operator schemata */ for ( i = 0; i < gnum_easy_operators; i++ ) { o = geasy_operators[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++; } } } }
void unify_easy_inertia_preconds( int curr_inertia ) { int p, i, j, k, af, hh; int args[MAX_VARS]; int affected_params[MAX_VARS]; int num_affected_params = 0; if ( curr_inertia == lnum_inertia_conds ) { multiply_easy_non_constrained_op_parameters( 0 ); return; } p = lo->preconds[linertia_conds[curr_inertia]].predicate; for ( i = 0; i < garity[p]; i++ ) { args[i] = lo->preconds[linertia_conds[curr_inertia]].args[i]; if ( args[i] < 0 ) { hh = DECODE_VAR( args[i] ); if ( lo->inst_table[hh] != -1 ) { args[i] = lo->inst_table[hh]; } else { affected_params[num_affected_params++] = hh; } } } for ( i = 0; i < gnum_initial_predicate[p]; i++ ) { af = 0; for ( j = 0; j < garity[p]; j++ ) { if ( args[j] >= 0 ) { if ( args[j] != ginitial_predicate[p][i].args[j] ) { break; } else { continue; } } /* see if we have that constant already in instantiation; * if so, skip this inertia: op params are assumed different! */ /* if ( lused_constant[ginitial_predicate[p][i].args[j]] ) { break; } */ /* legal constant; set op parameter instantiation to it */ lo->inst_table[affected_params[af++]] = ginitial_predicate[p][i].args[j]; lused_constant[ginitial_predicate[p][i].args[j]] = TRUE; } if ( j < garity[p] ) { for ( k = 0; k < af; k++ ) { lused_constant[lo->inst_table[affected_params[k]]] = FALSE; } continue; } unify_easy_inertia_preconds( curr_inertia + 1 ); for ( j = 0; j < num_affected_params; j++ ) { lused_constant[lo->inst_table[affected_params[j]]] = FALSE; } } for ( i = 0; i < num_affected_params; i++ ) { lo->inst_table[affected_params[i]] = -1; } }