Exemplo n.º 1
0
  Lit heuristic::getSuggestion(){
  DREAL_LOG_INFO << "heuristic::getSuggestion()";
 
  if(!m_is_initialized)
    return lit_Undef;

  if (trail->size() > lastTrailEnd){
    pushTrailOnStack();
    //}

    //if (!m_is_initialized ||  backtracked){
    getSuggestions();
    backtracked = false;
  }
  if (!m_suggestions.empty()){
      std::pair<Enode *, bool> *s = m_suggestions.back();
      m_suggestions.pop_back();
      Enode *e = s->first;


    if ( e == NULL )
      return lit_Undef;



    DREAL_LOG_INFO << "heuristic::getSuggestion() " << e << " = " << s->second;
    if (theory_handler == NULL)
      DREAL_LOG_INFO << "heuristic::getSuggestion() NULL";
    Var v = theory_handler->enodeToVar(e);
    delete s;
    return Lit( v, !s->second );
    } else {
      return lit_Undef;
    }
  }
Exemplo n.º 2
0
  bool plan_heuristic::getSuggestions()  {
    if (!m_suggestions.empty()) {
      return true;
    }
    DREAL_LOG_INFO << "plan_heuristic::getSuggestions()";
    displayTrail();


    if (trail->size() > lastTrailEnd)
      pushTrailOnStack();

    bool suggestion_consistent = isStackConsistentWithSuggestion();



  bool found_path = false;
  bool path_possible = true;
  // bool suggest_defaults = true;

   if(!m_suggestions.empty() && suggestion_consistent)  {
     return true;
   } else if(!suggestion_consistent || backtracked)  {
     path_possible = unwind_path();
   }


   while (!found_path && path_possible) {
     if (path_possible) {
       found_path = expand_path();
     }
     if (!found_path) {
       path_possible = pbacktrack();
     }
   }

   if (m_decision_stack.size() == 0)
     return false;




    completeSuggestionsForTrail();

  //  for (int time = m_depth; time >= 0; time--) {
  //    DREAL_LOG_DEBUG << "Depth = " << time;
  //      for (auto & p : *time_event_enodes[time]) {
  //        Enode* ev = p.second;
  //        // ev->setDecPolarity(l_True);
  //        m_suggestions.push_back(ev);
  //      }
  //    }

  //    for (int time = 0; time <= m_depth; time++) {
  //      for (auto & p : *time_process_enodes[time]) {
  //        Enode* proc = p.second;
  //        // proc->setDecPolarity(l_True);
  //        m_suggestions.push_back(proc);
  //      }
  //    }

  //    for (int time = 0; time <= m_depth; time++) {
  //      for (auto & p : *time_act_enodes[time]) {
  //        Enode* proc = p.second;
  //        // proc->setDecPolarity(l_True);
  //        m_suggestions.push_back(proc);
  //      }
  //    }
  //    for (int time = 0; time <= m_depth; time++) {
  //      for (auto & p : *time_duract_enodes[time]) {
  //        Enode* proc = p.second;
  //        // proc->setDecPolarity(l_True);
  //        m_suggestions.push_back(proc);
  //      }
  //    }

      //  for (auto e : m_suggestions)  {
    DREAL_LOG_INFO << "plan_heuristic::getSuggestions(): Suggesting ";
      //                   << (e->getPolarity() == l_True ? "     " : "(not ")
      //                   << e
      //                   << (e->getPolarity() == l_True ? "" : ")")
      //                   << " = "
      //                   << (e->getDecPolarity() == l_True ?
      //                       " True" :
      //                       (e->getDecPolarity() == l_False ? " False" : " Unknown"))
      //                   << endl;
      //  }
    return true;
}