From: Alex Schmidt Date: Wed, 5 Jun 2013 10:59:21 +0000 (+0200) Subject: implemented parameter linking. X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/commitdiff_plain/1b842b9fcf404b5973c01ce883eafc53553b83c9 implemented parameter linking. --- diff --git a/paraq.cpp b/paraq.cpp index 87ec773..93496fc 100644 --- a/paraq.cpp +++ b/paraq.cpp @@ -43,9 +43,22 @@ string paraq::rangeString() for( vector::iterator rangeIt = paraIt->second.begin(); rangeIt != paraIt->second.end(); ++rangeIt) rangestring << "-" << paraIt->first << (*rangeIt)[0] << "_" << (*rangeIt)[1] << "_" << (*rangeIt)[2]; + for (vector< pair >::iterator linkit = linkedParas.begin(); linkit != linkedParas.end(); ++linkit) + rangestring << "-" << linkit->first << "->" << linkit->second; + for( map::iterator defIt = defaultPara.begin(); defIt != defaultPara.end(); ++defIt ) - if( rangeMap.find(defIt->first) == rangeMap.end() ) - rangestring << "-" << defIt->first << defIt->second; + if( rangeMap.find(defIt->first) == rangeMap.end() ) { + bool linkedpara = false; + + for (vector< pair >::iterator linkit = linkedParas.begin(); linkit != linkedParas.end(); ++linkit) + if (linkit->first == defIt->first) { + linkedpara = true; + break; + } + + if (!linkedpara) + rangestring << "-" << defIt->first << defIt->second; + } return rangestring.str(); } @@ -81,7 +94,13 @@ void paraq::initJobList() while( jobList.begin()->find(paraIt->first) == jobList.begin()->end() ) { for( vector::iterator valIt = paraIt->second.begin(); valIt != paraIt->second.end(); ++valIt ) { jobList.push_back( *jobList.begin() ); + jobList.back()[paraIt->first] = *valIt; + + /* also set linked parameters */ + for (vector< pair >::iterator linkit = linkedParas.begin(); linkit != linkedParas.end(); ++linkit) + if (linkit->second == paraIt->first) + jobList.back()[linkit->first] = *valIt; } jobList.erase( jobList.begin() ); } diff --git a/paraq.h b/paraq.h index 6dc582d..0167bcb 100644 --- a/paraq.h +++ b/paraq.h @@ -16,6 +16,8 @@ class paraq { 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; uniqueAllParaIdsAdd(paraid); } + + void linkParas(const string& paraid1, const string ¶id2) { linkedParas.push_back( make_pair(paraid1,paraid2) ); } int getTotalJobs(); string rangeString(); vector allParaIds; @@ -28,6 +30,7 @@ class paraq { map defaultPara; map< string, vector > paraMap; map< string, vector > rangeMap; + vector< pair > linkedParas; vector< map > jobList; void initJobList(); bool inParas(vector& paraVec, double& tofind);