void MyIconView::updateSelection(){ QBrush brb(QColor(150, 200, 255)); QBrush brw; if(marked) brw = QBrush(QColor(238, 255, 238)); else brw = QBrush(QColor(255, 255, 255)); QFont sel_font, base_font; base_font.setFamily("Verdana"); sel_font.setFamily("Helvetica"); sel_font.setUnderline(true); sel_font.setLetterSpacing(QFont::AbsoluteSpacing, 2); repairPath(path); for(int i = 0; i < rowCount(); ++i){ for(int j = 0; j < columnCount(); ++j){ if(item(i, j) != nullptr){ if(multi_selection.find(path + item(i, j)->text().toStdString()) != multi_selection.end()){ item(i, j)->setBackground(brb); item(i, j)->setFont(sel_font); }else{ if(OSInterface::isDir(path + OSInterface::dir_sep + item(i, j)->text().toStdString())) base_font.setBold(true); item(i, j)->setBackground(brw); item(i, j)->setFont(base_font); base_font.setBold(false); } } } } }
int main(int argc, char *argv[]) { struct rlimit core_limits; core_limits.rlim_cur = 0; core_limits.rlim_max = 0; setrlimit( RLIMIT_CORE, &core_limits ); ECArgs args( argc, argv ); assert(args.nargs() == 2); conditionedType = args.arg(0); cerr << "start trainRs: " << conditionedType << endl; ECString path(args.arg(1)); repairPath(path); if(args.isset('M')) Feature::setLM(); if(args.isset('L')) Term::Language = args.value('L'); Term::init(path); readHeadInfo(path); Pst pst(path); if(Feature::isLM) ClassRule::readCRules(path); addSubFeatureFns(); Feature::init(path, conditionedType); whichInt = Feature::whichInt; int ceFunInt = Feature::conditionedFeatureInt[Feature::whichInt]; Feature::conditionedEvent = SubFeature::Funs[ceFunInt]; Feat::Usage = PARSE; ECString ftstr(path); ftstr += conditionedType; ftstr += ".g"; ifstream fts(ftstr.c_str()); if(!fts) { cerr << "Could not find " << ftstr << endl; assert(fts); } tRoot = new FeatureTree(fts); //puts it in root; cout.precision(3); cerr.precision(3); lamInit(); InputTree* trainingData[1001]; int usedCount = 0; sentenceCount = 0; for( ; ; sentenceCount++) { // cerr << "sentence number " << sentenceCount << ", used " << usedCount << endl; if(0&&sentenceCount%1000==1) { cerr << conditionedType << ".tr " << sentenceCount << endl; } if(usedCount >= 1000) break; InputTree* correct = new InputTree; cin >> (*correct); if(correct->length() == 0) break; if(!cin) break; EcSPairs wtList; correct->make(wtList); InputTree* par; par = correct; trainingData[usedCount++] = par; } if(Feature::isLM) pickLogBases(trainingData,sentenceCount); procGSwitch = true; for(pass = 0 ; pass < 10 ; pass++) { if(pass%2 == 1) cout << "Pass " << pass << endl; goThroughSents(trainingData, sentenceCount); updateLambdas(); //printLambdas(cout); zeroData(); } ECString resS(path); resS += conditionedType; resS += ".lambdas"; ofstream res(resS.c_str()); res.precision(3); printLambdas(res); printLambdas(cout); cout << "Total params = " << FeatureTree::totParams << endl; }
void OSInterface::getDirInfo(std::string path, std::string pattern){ WIN32_FIND_DATA data; repairPath(path); path.append("*"); std::wstring ppath, whole_name; ppath.assign(path.begin(), path.end()); path.pop_back(); dirEntryT *de; HANDLE hFile = FindFirstFile(ppath.c_str(), &data); if ((hFile == INVALID_HANDLE_VALUE) && (GetLastError() != ERROR_FILE_NOT_FOUND)) return; //throw new OSException(path, "Failed to open dir."); std::string name, tmpname; while(FindNextFile(hFile, &data) != 0 || GetLastError() != ERROR_NO_MORE_FILES) { de = new dirEntryT(); whole_name = whole_name = data.cFileName; name.assign(whole_name.begin(), whole_name.end()); tmpname = path + name; std::cout << name << std::endl; whole_name.assign(tmpname.begin(), tmpname.end()); de->ext_name = getExtension(name); WIN32_FILE_ATTRIBUTE_DATA fileInfo; if(!GetFileAttributesEx(whole_name.c_str(), GetFileExInfoStandard, &fileInfo)) continue; DWORD ftype = fileInfo.dwFileAttributes; if (ftype == INVALID_FILE_ATTRIBUTES) continue; // throw new OSException(name, "Invalid file"); if((name == ".") || name == "..") continue; if((!matchExpression(name, pattern)) && !isDir(name)) continue; de->name = name; if((ftype & FILE_ATTRIBUTE_NORMAL) || (ftype & FILE_ATTRIBUTE_SYSTEM) || (ftype & FILE_ATTRIBUTE_COMPRESSED)){ de->type = de->FILE; de->type_name = "FILE"; }else if(ftype & FILE_ATTRIBUTE_DIRECTORY){ de->type = de->DIR; de->type_name = "DIR"; }else if(ftype & FILE_ATTRIBUTE_VIRTUAL){ de->type = de->LINK; de->type_name = "LINK"; }else{ de->type = de->UNKNOWN; de->type_name = "UNKNOWN"; } if(isArch(de->ext_name)){ de->type_name = "ARCHIVE"; de->type = de->ARCHIVE; } de->byte_size = getSize(name); SYSTEMTIME stUTC, stLocal; LPTSTR lpszString; FileTimeToSystemTime(&fileInfo.ftLastWriteTime, &stUTC); SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal); char buf[255]; sprintf(buf, "%02d.%02d.%d %02d:%02d", stLocal.wDay, stLocal.wMonth, stLocal.wYear, stLocal.wHour, stLocal.wMinute); de->mod_time = std::string(buf); dirs.push_back(de); } std::sort(dirs.begin(), dirs.end(),[=](dirEntryT *d1, dirEntryT *d2){ if ((d1->type == d1->DIR) && (d2->type != d2->DIR)) return true; else if ((d1->type != d1->DIR) && (d2->type == d2->DIR)) return false; else return d1->name < d2->name; }); }
std::string MyIconView::getSelected(){ repairPath(path); if(currentItem()) return path + currentItem()->text().toStdString() ; else return ""; }
ompl::base::PlannerStatus ompl::geometric::LightningRetrieveRepair::solve(const base::PlannerTerminationCondition &ptc) { bool solved = false; // Check if the database is empty if (!experienceDB_->getExperiencesCount()) { OMPL_INFORM("LightningRetrieveRepair: Experience database is empty so unable to run LightningRetrieveRepair algorithm."); return base::PlannerStatus::ABORT; } // Restart the Planner Input States so that the first start and goal state can be fetched pis_.restart(); // Get a single start state TODO: more than one const base::State *startState = pis_.nextStart(); const base::State *goalState = pis_.nextGoal(ptc); // Error check start/goal states if (!startState || !goalState) { OMPL_ERROR("LightningRetrieveRepair: Start or goal states are null"); return base::PlannerStatus::UNRECOGNIZED_GOAL_TYPE; } // Search for previous solution in database nearestPaths_ = experienceDB_->findNearestStartGoal(nearestK_, startState, goalState); // Check if there are any solutions if (nearestPaths_.empty()) { OMPL_INFORM("LightningRetrieveRepair: No similar path founds in nearest neighbor tree, unable to retrieve repair"); return base::PlannerStatus::TIMEOUT; // The planner failed to find a solution } ompl::base::PlannerDataPtr chosenPath; // Filter top n paths to 1 // TODO Rather than selecting 1 best path, you could also spawn n (n<=k) threads and repair the top n paths. if (!findBestPath(startState, goalState, chosenPath)) { return base::PlannerStatus::ABORT; } // All saved trajectories should be at least 2 states long assert(chosenPath->numVertices() >= 2); // Convert chosen PlannerData experience to an actual path ompl::geometric::PathGeometric *primaryPath = new PathGeometric(si_); // Add start primaryPath->append(startState); // Add old states for (std::size_t i = 0; i < chosenPath->numVertices(); ++i) { primaryPath->append(chosenPath->getVertex(i).getState()); } // Add goal primaryPath->append(goalState); // All save trajectories should be at least 2 states long, and then we append the start and goal states assert(primaryPath->getStateCount() >= 4); // Repair chosen path if (!repairPath(ptc, *primaryPath)) { OMPL_INFORM("LightningRetrieveRepair: repairPath failed or aborted"); return base::PlannerStatus::ABORT; } // Smooth the result OMPL_INFORM("LightningRetrieveRepair solve: Simplifying solution (smoothing)..."); time::point simplifyStart = time::now(); std::size_t numStates = primaryPath->getStateCount(); psk_->simplify(*primaryPath, ptc); double simplifyTime = time::seconds(time::now() - simplifyStart); OMPL_INFORM("LightningRetrieveRepair: Path simplification took %f seconds and removed %d states", simplifyTime, numStates - primaryPath->getStateCount()); // Finished pdef_->addSolutionPath(base::PathPtr(primaryPath), false, 0., getName()); solved = true; return base::PlannerStatus(solved, false); }