X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/b57bffe30e8f531f21f0d50e4dc5f58275d8522e..da120f552639e7e742161a2a4d6f88ca5277df8e:/paraq.cpp?ds=inline diff --git a/paraq.cpp b/paraq.cpp index b1e3292..0892962 100644 --- a/paraq.cpp +++ b/paraq.cpp @@ -41,11 +41,24 @@ string paraq::rangeString() for( map< string, vector >::iterator paraIt = rangeMap.begin(); paraIt != rangeMap.end(); ++paraIt ) if( paraIt->second.size() > 0 ) for( vector::iterator rangeIt = paraIt->second.begin(); rangeIt != paraIt->second.end(); ++rangeIt) - rangestring << "-" << paraIt->first << (*rangeIt)[0] << "_" << (*rangeIt)[1] << "_" << (*rangeIt)[2]; + rangestring << "_" << paraIt->first << (*rangeIt)[0] << "-" << (*rangeIt)[1] << "-" << (*rangeIt)[2]; + for (vector::iterator linkit = linkedParas.begin(); linkit != linkedParas.end(); ++linkit) + rangestring << "_" << linkit->first << "--" << linkit->linktype << "--" << 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::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(); } @@ -60,6 +73,8 @@ void paraq::addRange(const string& paraid, double min, double max, double step) for( double paraval = min; paraval <= max+0.5*step; paraval += step+(step==0) ) if( ! inParas(paraMap[paraid], paraval) ) paraMap[paraid].push_back( paraval ); + + uniqueAllParaIdsAdd(paraid); } bool paraq::inParas( vector& paraVec, double& tofind ) @@ -79,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::iterator linkit = linkedParas.begin(); linkit != linkedParas.end(); ++linkit) + if (linkit->second == paraIt->first) + jobList.back()[linkit->first] = linkTypeFunction(*valIt, linkit->linktype); } jobList.erase( jobList.begin() ); } @@ -87,6 +108,18 @@ void paraq::initJobList() } } +double paraq::linkTypeFunction (double linkval, int linktype) { + switch (linktype) { + + case LINK_1TO1: + return linkval; + + case LINK_NEGATIVE: + return -linkval; + + } +} + int paraq::nextParas() { if( thisjob == -1 ) { @@ -112,10 +145,40 @@ double& paraq::operator[] (string paraid) { return defaultPara[paraid]; } - return masterdefault; + cerr << "PARAQ: Parameter " << paraid << " does not exist!" << endl << flush; + exit(1); } int paraq::getTotalJobs() { initJobList(); return jobList.size(); } + +void paraq::uniqueAllParaIdsAdd(const string& paraid) { + for (vector::iterator allparait = allParaIds.begin(); allparait != allParaIds.end(); ++allparait) + if ( *allparait == paraid ) + return; + + allParaIds.push_back(paraid); +} + +string paraq::getParaNames() { + stringstream paranames; + + for (vector::iterator parait = allParaIds.begin(); parait != allParaIds.end(); ++parait) + paranames << *parait << ":"; + + return paranames.str(); +} + +string paraq::getParaVals() { + stringstream paravals; + + for (vector::iterator parait = allParaIds.begin(); parait != allParaIds.end(); ++parait) { + if ( parait != allParaIds.begin() ) + paravals << "\t"; + paravals << (*this)[*parait]; + } + + return paravals.str(); +}