void ProofControlInit(ProofState_p state,ProofControl_p control, HeuristicParms_p params, FVIndexParms_p fvi_params, PStack_p wfcb_defs, PStack_p hcb_defs) { PStackPointer sp; Scanner_p in; assert(control && control->wfcbs); assert(state && state->axioms && state->signature); assert(params); assert(!control->ocb); assert(!control->hcb); SpecFeaturesCompute(&(control->problem_specs), state->axioms,state->signature); control->ocb = TOSelectOrdering(state, params, &(control->problem_specs)); in = CreateScanner(StreamTypeInternalString, DefaultWeightFunctions, true, NULL); WeightFunDefListParse(control->wfcbs, in, control->ocb, state); DestroyScanner(in); for(sp = 0; sp < PStackGetSP(wfcb_defs); sp++) { in = CreateScanner(StreamTypeOptionString, PStackElementP(wfcb_defs, sp) , true, NULL); WeightFunDefListParse(control->wfcbs, in, control->ocb, state); DestroyScanner(in); } in = CreateScanner(StreamTypeInternalString, DefaultHeuristics, true, NULL); HeuristicDefListParse(control->hcbs, in, control->wfcbs, control->ocb, state); DestroyScanner(in); for(sp = 0; sp < PStackGetSP(hcb_defs); sp++) { in = CreateScanner(StreamTypeOptionString, PStackElementP(hcb_defs, sp) , true, NULL); HeuristicDefListParse(control->hcbs, in, control->wfcbs, control->ocb, state); DestroyScanner(in); } control->heuristic_parms = *params; control->fvi_parms = *fvi_params; control->hcb = GetHeuristic(params->heuristic_name, state, control, params); if(!control->heuristic_parms.split_clauses) { control->fvi_parms.symbol_slack = 0; } }
// Reference code (it's in document) void AStar::FindPath(Node *start, Node *end) { start->SetF(0); start->SetG(0); start->SetH(0); this->PushNode(start); while (open.count() > 0) { // Find node by lowest F value Node *node = this->PopNode(); this->IncreaseNodeCount(); if (node == end) { this->ReconstructPath(end); return; } closed.append(node); for (int i = 0; i < node->GetConnectors().count(); i++) { Connector *connector = node->GetConnectors().at(i); Node *neighbour = connector->GetChild(); if (this->closed.contains(neighbour)) continue; double g = node->GetG() + GetCost(node,connector); if (!open.contains(neighbour) || g < neighbour->GetG()) { neighbour->SetParent(node); neighbour->SetG(g); neighbour->SetH(GetHeuristic(neighbour,end)); neighbour->SetF(neighbour->GetG() + neighbour->GetH()); //this->IncreaseNodeCount(); if (!this->open.contains(neighbour)) this->PushNode(neighbour); } } } this->ReconstructPath(end); }
void ProofStateInit(ProofState_p state, ProofControl_p control) { Clause_p handle, new; HCB_p tmphcb; PStack_p traverse; Eval_p cell; OUTPRINT(1, "# Initializing proof state\n"); assert(ClauseSetEmpty(state->processed_pos_rules)); assert(ClauseSetEmpty(state->processed_pos_eqns)); assert(ClauseSetEmpty(state->processed_neg_units)); assert(ClauseSetEmpty(state->processed_non_units)); tmphcb = GetHeuristic("Uniq", state, control, &(control->heuristic_parms)); assert(tmphcb); ClauseSetReweight(tmphcb, state->axioms); traverse = EvalTreeTraverseInit(PDArrayElementP(state->axioms->eval_indices,0),0); while((cell = EvalTreeTraverseNext(traverse, 0))) { handle = cell->object; new = ClauseCopy(handle, state->terms); ClauseSetProp(new, CPInitial); HCBClauseEvaluate(control->hcb, new); DocClauseQuoteDefault(6, new, "eval"); ClausePushDerivation(new, DCCnfQuote, handle, NULL); if(control->heuristic_parms.prefer_initial_clauses)