Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Diff of /trunk/gadget/ecosystem.cc
[mareframe] / trunk / gadget / ecosystem.cc Repository:
ViewVC logotype

Diff of /trunk/gadget/ecosystem.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 15, Tue Sep 1 19:14:33 2015 UTC revision 19, Wed May 25 16:36:33 2016 UTC
# Line 1  Line 1 
1  #include "ecosystem.h"  #include "ecosystem.h"
2  #include "runid.h"  #include "runid.h"
3  #include "global.h"  #include "global.h"
4  #ifndef NO_OPENMP  #include <ctime>
5    #ifdef _OPENMP
6  #include <omp.h>  #include <omp.h>
7  #endif  #endif
8    
9  #ifndef NO_OPENMP  #ifdef _OPENMP
10  extern Ecosystem** EcoSystems;  extern Ecosystem** EcoSystems;
11  //extern StochasticData* data;  //extern StochasticData* data;
12  #endif  #endif
13    extern volatile int interrupted_print;
14    
15    time_t starttime, stoptime;
16    
17  Ecosystem::Ecosystem(const MainInfo& main) : printinfo(main.getPI()) {  Ecosystem::Ecosystem(const MainInfo& main) : printinfo(main.getPI()) {
18    
19    funceval = 0;    funceval = 0;
20    interrupted = 0;    //interrupted = 0;
21    likelihood = 0.0;    likelihood = 0.0;
22    keeper = new Keeper;    keeper = new Keeper;
23    
# Line 111  Line 115 
115  void Ecosystem::Optimise() {  void Ecosystem::Optimise() {
116    int i;    int i;
117    for (i = 0; i < optvec.Size(); i++) {    for (i = 0; i < optvec.Size(); i++) {
118  #ifndef NO_OPENMP            time(&starttime);
119    #ifdef _OPENMP
120            int j, numThr = omp_get_max_threads ( );            int j, numThr = omp_get_max_threads ( );
121            DoubleVector v = this->getValues();            DoubleVector v = this->getValues();
122            for (j = 0; j < numThr; j++)            for (j = 0; j < numThr; j++)
# Line 122  Line 127 
127  #else  #else
128            optvec[i]->OptimiseLikelihood();            optvec[i]->OptimiseLikelihood();
129  #endif  #endif
130              time(&stoptime);
131      this->writeOptValues();      this->writeOptValues();
132    }    }
133  }  }
# Line 169  Line 175 
175      tmpvec[i] = likevec[i]->getUnweightedLikelihood();      tmpvec[i] = likevec[i]->getUnweightedLikelihood();
176    
177    int iters = 0;    int iters = 0;
178  #ifndef NO_OPENMP  #ifdef _OPENMP
179    int numThr = omp_get_max_threads ( );    int numThr = omp_get_max_threads ( );
180      for (i = 0; i < numThr; i++)      for (i = 0; i < numThr; i++)
181            iters += EcoSystems[i]->getFuncEval();            iters += EcoSystems[i]->getFuncEval();
# Line 182  Line 188 
188      handle.logMessage(LOGINFO, "\nThe overall likelihood score is", keeper->getBestLikelihoodScore());      handle.logMessage(LOGINFO, "\nThe overall likelihood score is", keeper->getBestLikelihoodScore());
189    else    else
190      handle.logMessage(LOGINFO, "\nThe overall likelihood score is", this->getLikelihood());      handle.logMessage(LOGINFO, "\nThe overall likelihood score is", this->getLikelihood());
191    
192      handle.logMessage(LOGINFO, "\n Runtime for the algorithm was ", difftime(stoptime, starttime)," seconds\n");
193  }  }
194    
195  void Ecosystem::writeInitialInformation(const char* const filename) {  void Ecosystem::writeInitialInformation(const char* const filename) {
# Line 194  Line 202 
202  }  }
203    
204  void Ecosystem::writeParams(const char* const filename, int prec) const {  void Ecosystem::writeParams(const char* const filename, int prec) const {
205    if ((funceval > 0) && (interrupted == 0)) {    if ((funceval > 0) && (interrupted_print == 0)) {
206      //JMB - print the final values to any output files specified      //JMB - print the final values to any output files specified
207      //in case they have been missed by the -print value      //in case they have been missed by the -print value
208      if (printinfo.getPrint())      if (printinfo.getPrint())
209        keeper->writeValues(likevec, printinfo.getPrecision());        keeper->writeValues(likevec, printinfo.getPrecision());
210    }    }
211    keeper->writeParams(optvec, filename, prec, interrupted);    keeper->writeParams(optvec, filename, prec, interrupted_print);
212  }  }

Legend:
Removed from v.15  
changed lines
  Added in v.19

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge