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 );
65 bool paraq::inParas( vector<double>& paraVec, double& tofind )
67 for( vector<double>::iterator it = paraVec.begin(); it < paraVec.end(); ++it)
68 if( fabs(*it - tofind) < 0.0000000001 ) return true;
72 void paraq::initJobList()
74 if( ! jobListInitialized ) {
75 map<string,double> jobZero;
76 jobList.push_back( jobZero );
78 for( map< string, vector< double > >::iterator paraIt = paraMap.begin(); paraIt != paraMap.end(); ++paraIt )
79 while( jobList.begin()->find(paraIt->first) == jobList.begin()->end() ) {
80 for( vector<double>::iterator valIt = paraIt->second.begin(); valIt != paraIt->second.end(); ++valIt ) {
81 jobList.push_back( *jobList.begin() );
82 jobList.back()[paraIt->first] = *valIt;
84 jobList.erase( jobList.begin() );
86 jobListInitialized = true;
90 int paraq::nextParas()
99 if( jobList.begin()->size() == 0 ) return 0;
101 if( thisjob < jobList.size() ) return 1;
106 double& paraq::operator[] (string paraid) {
107 if( jobList[thisjob].find(paraid) != jobList[thisjob].end() ) {
108 return jobList[thisjob][paraid];
111 if( defaultPara.find(paraid) != defaultPara.end() ) {
112 return defaultPara[paraid];
115 return masterdefault;
118 int paraq::getTotalJobs() {
120 return jobList.size();