#include <algorithm>
#include <iostream>
#include <math.h>
+#include <string.h>
+#include <sstream>
using namespace std;
jobListInitialized = false;
}
+void paraq::addRange(const string& paraid, char *range)
+{
+ int nargs=0;
+ double goodrange[3];
+
+ for( int pos=0; pos<strlen(range); pos++ )
+ if( range[pos] == ':' ) nargs++;
+ if(nargs==0)
+ for(int i=0; i<3; i++) goodrange[i] = strtod(range, NULL);
+ else{
+ goodrange[0] = strtod(strtok(range, ":"), NULL);
+ for(int i=0; i<nargs; i++) goodrange[i+1] = strtod(strtok(NULL, ":"), NULL);
+ }
+
+ addRange(paraid, goodrange[0], goodrange[1], goodrange[2]);
+}
+
+string paraq::rangeString()
+{
+ stringstream rangestring;
+
+ for( map< string, vector<double*> >::iterator paraIt = rangeMap.begin(); paraIt != rangeMap.end(); ++paraIt )
+ if( paraIt->second.size() > 0 )
+ for( vector<double*>::iterator rangeIt = paraIt->second.begin(); rangeIt != paraIt->second.end(); ++rangeIt)
+ rangestring << "-" << paraIt->first << (*rangeIt)[0] << "_" << (*rangeIt)[1] << "_" << (*rangeIt)[2];
+
+ for( map<string,double>::iterator defIt = defaultPara.begin(); defIt != defaultPara.end(); ++defIt )
+ if( rangeMap.find(defIt->first) == rangeMap.end() )
+ rangestring << "-" << defIt->first << defIt->second;
+
+ return rangestring.str();
+}
+
void paraq::addRange(const string& paraid, double min, double max, double step)
{
+ double *newrange = new double[3];
+ newrange[0] = min;
+ newrange[1] = max;
+ newrange[2] = step;
+ rangeMap[paraid].push_back( newrange );
+
for( double paraval = min; paraval <= max+0.5*step; paraval += step+(step==0) )
if( ! inParas(paraMap[paraid], paraval) ) paraMap[paraid].push_back( paraval );
}
int nextParas();
double& operator[] (string paraid);
void addRange(const string& paraid, double range[3]) { addRange(paraid, range[0], range[1], range[2]); }
+ void addRange(const string& paraid, char *range);
void setDefault(const string& paraid, double value) { defaultPara[paraid] = value; }
int getTotalJobs();
+ string rangeString();
private:
int nprocs, rank;
int thisjob;
map<string,double> defaultPara;
map< string, vector<double> > paraMap;
+ map< string, vector<double*> > rangeMap;
vector< map<string,double> > jobList;
void initJobList();
bool inParas(vector<double>& paraVec, double& tofind);