11 paraq::paraq(int _nprocs, const int _rank)
17 jobListInitialized = false;
20 void paraq::addRange(const string& paraid, char *range)
25 for( int pos=0; pos<strlen(range); pos++ )
26 if( range[pos] == ':' ) nargs++;
28 for(int i=0; i<3; i++) goodrange[i] = strtod(range, NULL);
30 goodrange[0] = strtod(strtok(range, ":"), NULL);
31 for(int i=0; i<nargs; i++) goodrange[i+1] = strtod(strtok(NULL, ":"), NULL);
34 addRange(paraid, goodrange[0], goodrange[1], goodrange[2]);
37 string paraq::rangeString()
39 stringstream rangestring;
41 for( map< string, vector<double*> >::iterator paraIt = rangeMap.begin(); paraIt != rangeMap.end(); ++paraIt )
42 if( paraIt->second.size() > 0 )
43 for( vector<double*>::iterator rangeIt = paraIt->second.begin(); rangeIt != paraIt->second.end(); ++rangeIt)
44 rangestring << "-" << paraIt->first << (*rangeIt)[0] << "_" << (*rangeIt)[1] << "_" << (*rangeIt)[2];
46 for( map<string,double>::iterator defIt = defaultPara.begin(); defIt != defaultPara.end(); ++defIt )
47 if( rangeMap.find(defIt->first) == rangeMap.end() )
48 rangestring << "-" << defIt->first << defIt->second;
50 return rangestring.str();
53 void paraq::addRange(const string& paraid, double min, double max, double step)
55 double *newrange = new double[3];
59 rangeMap[paraid].push_back( newrange );
61 for( double paraval = min; paraval <= max+0.5*step; paraval += step+(step==0) )
62 if( ! inParas(paraMap[paraid], paraval) ) paraMap[paraid].push_back( paraval );
64 uniqueAllParaIdsAdd(paraid);
67 bool paraq::inParas( vector<double>& paraVec, double& tofind )
69 for( vector<double>::iterator it = paraVec.begin(); it < paraVec.end(); ++it)
70 if( fabs(*it - tofind) < 0.0000000001 ) return true;
74 void paraq::initJobList()
76 if( ! jobListInitialized ) {
77 map<string,double> jobZero;
78 jobList.push_back( jobZero );
80 for( map< string, vector< double > >::iterator paraIt = paraMap.begin(); paraIt != paraMap.end(); ++paraIt )
81 while( jobList.begin()->find(paraIt->first) == jobList.begin()->end() ) {
82 for( vector<double>::iterator valIt = paraIt->second.begin(); valIt != paraIt->second.end(); ++valIt ) {
83 jobList.push_back( *jobList.begin() );
84 jobList.back()[paraIt->first] = *valIt;
86 jobList.erase( jobList.begin() );
88 jobListInitialized = true;
92 int paraq::nextParas()
101 if( jobList.begin()->size() == 0 ) return 0;
103 if( thisjob < jobList.size() ) return 1;
108 double& paraq::operator[] (string paraid) {
109 if( jobList[thisjob].find(paraid) != jobList[thisjob].end() ) {
110 return jobList[thisjob][paraid];
113 if( defaultPara.find(paraid) != defaultPara.end() ) {
114 return defaultPara[paraid];
117 return masterdefault;
120 int paraq::getTotalJobs() {
122 return jobList.size();
125 void paraq::uniqueAllParaIdsAdd(const string& paraid) {
126 for (vector<string>::iterator allparait = allParaIds.begin(); allparait != allParaIds.end(); ++allparait)
127 if ( *allparait == paraid )
130 allParaIds.push_back(paraid);