int main() { int t = inp(), n, i, len; char c, p; while(t--) { for(i = 0; i <= 255; i++) rule[i] = 0; n = inp(); for(i = 0; i < n; i++) { c = gtc; while(c < 33 || c > 126) c = gtc; p = gtc; while(p < 33 || p > 126) p = gtc; rule[c] = p; } len = inpstr(str); if(end < start) ptc('0'); for(i = start; i <= end ; i++) ptc(str[i]); ptc('\n'); } return 0; }
bool ompl::control::LTLPlanner::explore(const std::vector<ProductGraph::State *> &lead, Motion *&soln, double duration) { bool solved = false; base::PlannerTerminationCondition ptc = base::timedPlannerTerminationCondition(duration); base::GoalPtr goal = pdef_->getGoal(); while (!ptc() && !solved) { ProductGraph::State *as = availDist_.sample(rng_.uniform01()); ++abstractInfo_[as].numSel; updateWeight(as); PDF<Motion *> &motions = abstractInfo_[as].motions; Motion *v = motions.sample(rng_.uniform01()); PDF<Motion *>::Element *velem = abstractInfo_[as].motionElems[v]; double vweight = motions.getWeight(velem); if (vweight > 1e-20) motions.update(velem, vweight / (vweight + 1.)); Control *rctrl = ltlsi_->allocControl(); controlSampler_->sampleNext(rctrl, v->control, v->state); unsigned int cd = controlSampler_->sampleStepCount(ltlsi_->getMinControlDuration(), ltlsi_->getMaxControlDuration()); base::State *newState = si_->allocState(); cd = ltlsi_->propagateWhileValid(v->state, rctrl, cd, newState); if (cd < ltlsi_->getMinControlDuration()) { si_->freeState(newState); ltlsi_->freeControl(rctrl); continue; } auto *m = new Motion(); m->state = newState; m->control = rctrl; m->steps = cd; m->parent = v; // Since the state was determined to be valid by SpaceInformation, we don't need to check automaton states m->abstractState = ltlsi_->getProdGraphState(m->state); motions_.push_back(m); abstractInfo_[m->abstractState].addMotion(m); updateWeight(m->abstractState); // update weight if hl state already exists in avail if (abstractInfo_[m->abstractState].pdfElem != nullptr) availDist_.update(abstractInfo_[m->abstractState].pdfElem, abstractInfo_[m->abstractState].weight); else { // otherwise, only add hl state to avail if it already exists in lead if (std::find(lead.begin(), lead.end(), m->abstractState) != lead.end()) { PDF<ProductGraph::State *>::Element *elem = availDist_.add(m->abstractState, abstractInfo_[m->abstractState].weight); abstractInfo_[m->abstractState].pdfElem = elem; } } solved = goal->isSatisfied(m->state); if (solved) { soln = m; break; } } return solved; }