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 19, Wed May 25 16:36:33 2016 UTC revision 20, Fri Apr 7 09:20:55 2017 UTC
# Line 55  Line 55 
55        optvec.resize(new OptInfoHooke());        optvec.resize(new OptInfoHooke());
56      }      }
57    }    }
58    #ifdef _OPENMP
59      runParallel=main.runParallel();
60      if (!omp_in_parallel()){
61            if (main.runOptimise())
62            {
63                    switch(runParallel){
64                            case SPECULATIVE:
65                                    handle.logMessage(LOGINFO, "\nFinished reading model data files, starting to run parallel speculative optimisation with ", omp_get_max_threads(), " threads");
66                                    break;
67                            case REPRODUCIBLE:
68                                    handle.logMessage(LOGINFO, "\nFinished reading model data files, starting to run parallel reproducible optimisation with ", omp_get_max_threads(), " threads");
69                                    break;
70                            default:
71                                    handle.logMessage(LOGINFO, "\nFinished reading model data files, starting to serial optimisation with ", omp_get_num_threads() , "threads");
72                    }
73            }
74            else
75                    handle.logMessage(LOGINFO, "\nFinished reading model data files, starting to run simulation ", omp_get_num_threads(), " threads");
76            handle.logMessage(LOGMESSAGE, "");  //write blank line to log file
77      }
78    #else
79    if (main.runOptimise())    if (main.runOptimise())
80      handle.logMessage(LOGINFO, "\nFinished reading model data files, starting to run optimisation");      handle.logMessage(LOGINFO, "\nFinished reading model data files, starting to run optimisation");
81    else    else
82      handle.logMessage(LOGINFO, "\nFinished reading model data files, starting to run simulation");      handle.logMessage(LOGINFO, "\nFinished reading model data files, starting to run simulation");
83    handle.logMessage(LOGMESSAGE, "");  //write blank line to log file    handle.logMessage(LOGMESSAGE, "");  //write blank line to log file
84    #endif
85  }  }
86    
87  Ecosystem::~Ecosystem() {  Ecosystem::~Ecosystem() {
# Line 117  Line 138 
138    for (i = 0; i < optvec.Size(); i++) {    for (i = 0; i < optvec.Size(); i++) {
139            time(&starttime);            time(&starttime);
140  #ifdef _OPENMP  #ifdef _OPENMP
141            int j, numThr = omp_get_max_threads ( );            if (runParallel){
142            DoubleVector v = this->getValues();                  //int j, numThr = omp_get_max_threads ( ); //AGT REMOVED
143            for (j = 0; j < numThr; j++)                  //DoubleVector v = this->getValues();
144                    EcoSystems[j]->Update(v);                  //for (j = 0; j < numThr; j++)
145  #endif                  //      EcoSystems[j]->Update(v);
146  #ifdef SPECULATIVE                  if(runParallel==SPECULATIVE)
147                    {
148                            handle.logMessage(LOGINFO, "\nCalling Speculative Optimization");
149            optvec[i]->OptimiseLikelihoodOMP();            optvec[i]->OptimiseLikelihoodOMP();
150                    }
151                    else
152                    {
153                            handle.logMessage(LOGINFO, "\nCalling Reproducible parallel Optimization");
154                            optvec[i]->OptimiseLikelihoodREP();
155                    }
156              }
157              else
158              {
159                            handle.logMessage(LOGINFO, "\nCalling Reproducible serial Optimization");
160                     optvec[i]->OptimiseLikelihood();
161            }
162  #else  #else
163    //#ifdef SPECULATIVE
164    //        optvec[i]->OptimiseLikelihoodOMP();
165    //#else
166            optvec[i]->OptimiseLikelihood();            optvec[i]->OptimiseLikelihood();
167  #endif  #endif
168            time(&stoptime);            time(&stoptime);
# Line 141  Line 179 
179      currentval.resize(keeper->numVariables(), 0.0);      currentval.resize(keeper->numVariables(), 0.0);
180      optflag.resize(keeper->numVariables(), 0);      optflag.resize(keeper->numVariables(), 0);
181      keeper->getOptFlags(optflag);      keeper->getOptFlags(optflag);
182    
183    }    }
184    
185    j = 0;    j = 0;
# Line 176  Line 215 
215    
216    int iters = 0;    int iters = 0;
217  #ifdef _OPENMP  #ifdef _OPENMP
218      if (runParallel){
219    int numThr = omp_get_max_threads ( );    int numThr = omp_get_max_threads ( );
220      for (i = 0; i < numThr; i++)      for (i = 0; i < numThr; i++)
221            iters += EcoSystems[i]->getFuncEval();            iters += EcoSystems[i]->getFuncEval();
222      }
223  #endif  #endif
224    handle.logMessage(LOGINFO, "\nAfter a total of", funceval+iters, "function evaluations the best point found is");    handle.logMessage(LOGINFO, "\nAfter a total of", funceval+iters, "function evaluations the best point found is");
225    keeper->writeBestValues();    keeper->writeBestValues();

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

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

Powered By FusionForge