#include "Math/GeneticMinimizer.h"

#include "TMVA/GeneticAlgorithm.h"
#include "TMVA/IFitterTarget.h"

#include "Math/IFunction.h"
#include "Math/GenAlgoOptions.h"

#include "TError.h"

#include <cassert>

namespace ROOT {
namespace Math {


// wrapper class for TMVA interface to evaluate objective function
class MultiGenFunctionFitness : public TMVA::IFitterTarget {
private:
   unsigned int fNCalls;
   unsigned int fNFree;
   const ROOT::Math::IMultiGenFunction& fFunc;
   std::vector<int> fFixedParFlag;
   mutable std::vector<double> fValues;

public:
   MultiGenFunctionFitness(const ROOT::Math::IMultiGenFunction& function) : fNCalls(0),
                                                                            fFunc(function)
   { fNFree = fFunc.NDim(); }

   unsigned int NCalls() const { return fNCalls; }
   unsigned int NDims() const { return fNFree; }

   unsigned int NTotal() const { return fFunc.NDim(); }

   void FixParameter(unsigned int ipar, double value, bool fix = true) {

      if (fValues.size() != fFunc.NDim() ) {
         fValues.resize(fFunc.NDim() );
         fFixedParFlag.resize(fFunc.NDim());
      }

      if (ipar >= fValues.size() ) return;

      // first find if it has been already fixed
      fFixedParFlag[ipar] = fix;
      fValues[ipar] = value;
      // count number of fixed params
      for (unsigned int i = 0; i < fFixedParFlag.size(); ++i)
         if (!fFixedParFlag[i] ) fNFree++;

   }

   // transfrom from internal parameters (not fixed to external vector which include the fixed ones)
   const std::vector<double> & Transform( const std::vector<double> & factors) const {
      unsigned int n = fValues.size();
      if (n == 0 || fNFree == n )
         return factors;

      // in case of fixed parameters
      for (unsigned int i = 0, j = 0; i < n ; ++i) {
         if (!fFixedParFlag[i] ) {
            assert (j < fNFree);
            fValues[i] = factors[j];
            j++;
         }
      }
      return fValues;
   }

   Double_t Evaluate(const std::vector<double> & factors ) const {
      const std::vector<double> & x = Transform( factors);
      return fFunc(&x[0]);
   }

   Double_t EstimatorFunction(std::vector<double> & factors ){
      fNCalls += 1;
      return Evaluate( factors);
   }
};

GeneticMinimizerParameters::GeneticMinimizerParameters()
{
   // constructor of parameters with default values (use 100 is max iterations is not defined)
   int defmaxiter = ROOT::Math::MinimizerOptions::DefaultMaxIterations();
   fNsteps   =  (defmaxiter > 0) ?  defmaxiter : 100;
   fPopSize  =300;
   fCycles   = 3;
   fSC_steps =10;
   fSC_rate  =5;
   fSC_factor=0.95;
   fConvCrit =10.0 * ROOT::Math::MinimizerOptions::DefaultTolerance(); // default is 0.001
   if (fConvCrit <=0 ) fConvCrit = 0.001;
   fSeed=0;  // random seed
}

// genetic minimizer class

GeneticMinimizer::GeneticMinimizer(int ):
   fFitness(0),
   fMinValue(0),
   fParameters(GeneticMinimizerParameters() )
{

   // check with default minimizer options
   ROOT::Math::IOptions * geneticOpt = ROOT::Math::MinimizerOptions::FindDefault("Genetic");
   if (geneticOpt) {
      ROOT::Math::MinimizerOptions opt; // create using default options
      opt.SetExtraOptions(*geneticOpt);
      this->SetOptions(opt);
   }

   // set the parameters
   SetTolerance(0.1 * fParameters.fConvCrit);
   SetMaxIterations( fParameters.fNsteps);
 }

GeneticMinimizer::~GeneticMinimizer()
{
   if ( fFitness )
   {
      delete fFitness;
      fFitness = 0;
   }
}

void GeneticMinimizer::Clear()
{
   fRanges.clear();
   fResult.clear();
   if ( fFitness )
   {
      delete fFitness;
      fFitness = 0;
   }
}

void GeneticMinimizer::SetFunction(const ROOT::Math::IMultiGenFunction & func)
{
   Clear();

   fFitness = new MultiGenFunctionFitness(func);
   fResult = std::vector<double>(func.NDim() );
   assert(fResult.size() == NDim() );
}

bool GeneticMinimizer::SetLimitedVariable(unsigned int , const std::string & , double , double , double lower , double upper )
{
   fRanges.push_back( new TMVA::Interval(lower,upper) );

   return true;
}

bool GeneticMinimizer::SetVariable(unsigned int, const std::string& name, double value, double step)
{
   //It does nothing! As there is no variable if it has no limits!
   double lower = value - (50 * step);
   double upper = value + (50 * step);
   Info("GeneticMinimizer::SetVariable", "Variables should be limited - set automatic range to 50 times step size for %s : [%f, %f]",
        name.c_str(),lower,upper);
   fRanges.push_back( new TMVA::Interval(lower, upper ) );

   return true;
}

bool GeneticMinimizer::SetFixedVariable(unsigned int par, const std::string& name, double value) {
   // set a fixed variable
   if (!fFitness) {
      Error("GeneticMinimizer::SetFixedVariable", "Function has not been set - cannot set fixed variables %s",name.c_str());
      return false;
   }

   static_cast<MultiGenFunctionFitness*>(fFitness)->FixParameter(par, value);
   return true;
}


void GeneticMinimizer::SetParameters(const GeneticMinimizerParameters & params )
{
   fParameters  = params;
   // set also the one defined in Minimizer
   SetTolerance( 0.1 * fParameters.fConvCrit);
   SetMaxIterations( fParameters.fNsteps );
}

ROOT::Math::MinimizerOptions GeneticMinimizer::Options() const {
   ROOT::Math::MinimizerOptions opt;
   GetGeneticOptions(opt);
   return opt;
}

void  GeneticMinimizer::GetGeneticOptions(ROOT::Math::MinimizerOptions & opt) const {
   // get  the genetic options of the class and return them in the MinimizerOptions class
   opt.SetTolerance(fParameters.fConvCrit/10); // use a factor of 10 to have default as Minuit
   opt.SetPrintLevel(PrintLevel() );
   opt.SetMaxIterations(fParameters.fNsteps);
   // use fixed or dammy value for the other options
   opt.SetMinimizerType("Genetic");
   opt.SetMaxFunctionCalls(0);
   opt.SetStrategy(-1);
   opt.SetErrorDef(0);
   opt.SetPrecision(0);
   opt.SetMinimizerAlgorithm("");

   ROOT::Math::GenAlgoOptions geneticOpt;
   geneticOpt.SetValue("PopSize",fParameters.fPopSize);
   geneticOpt.SetValue("Steps",fParameters.fNsteps);
   geneticOpt.SetValue("Cycles",fParameters.fCycles);
   geneticOpt.SetValue("SC_steps",fParameters.fSC_steps);
   geneticOpt.SetValue("SC_rate",fParameters.fSC_rate);
   geneticOpt.SetValue("SC_factor",fParameters.fSC_factor);
   geneticOpt.SetValue("ConvCrit",fParameters.fConvCrit);
   geneticOpt.SetValue("RandomSeed",fParameters.fSeed);

   opt.SetExtraOptions(geneticOpt);
}

void GeneticMinimizer::SetOptions(const ROOT::Math::MinimizerOptions & opt)
{
   SetTolerance(opt.Tolerance() );
   SetPrintLevel(opt.PrintLevel() );
   //SetMaxFunctionCalls(opt.MaxFunctionCalls() );
   SetMaxIterations(opt.MaxIterations() );

   fParameters.fConvCrit = 10.*opt.Tolerance(); // use a factor of 10 to have default as Minuit

   // set genetic parameter from minimizer options
   const ROOT::Math::IOptions * geneticOpt = opt.ExtraOptions();
   if (!geneticOpt) {
      Warning("GeneticMinimizer::SetOptions", "No specific genetic minimizer options have been set");
      return;
   }

   // if options are not existing values will not be set
   geneticOpt->GetValue("PopSize",fParameters.fPopSize);
   geneticOpt->GetValue("Steps",fParameters.fNsteps);
   geneticOpt->GetValue("Cycles",fParameters.fCycles);
   geneticOpt->GetValue("SC_steps",fParameters.fSC_steps);
   geneticOpt->GetValue("SC_rate",fParameters.fSC_rate);
   geneticOpt->GetValue("SC_factor",fParameters.fSC_factor);
   geneticOpt->GetValue("ConvCrit",fParameters.fConvCrit);
   geneticOpt->GetValue("RandomSeed",fParameters.fSeed);

   // use same of options in base class
   int maxiter = opt.MaxIterations();
   if (maxiter > 0 && fParameters.fNsteps > 0 && maxiter !=  fParameters.fNsteps  )    {
      Warning("GeneticMinimizer::SetOptions", "max iterations value given different than  than Steps - set equal to Steps %d",fParameters.fNsteps);
   }
   if (fParameters.fNsteps > 0) SetMaxIterations(fParameters.fNsteps);

}

bool GeneticMinimizer::Minimize()
{

   if (!fFitness) {
      Error("GeneticMinimizer::Minimize","Fitness function has not been set");
      return false;
   }

   // sync parameters
   if (MaxIterations() > 0) fParameters.fNsteps = MaxIterations();
   if (Tolerance() > 0) fParameters.fConvCrit = 10* Tolerance();

   TMVA::GeneticAlgorithm mg( *fFitness, fParameters.fPopSize, fRanges, fParameters.fSeed );

   if (PrintLevel() > 0) {
      std::cout << "GeneticMinimizer::Minimize  - Start iterating - max iterations = " <<  MaxIterations()
                << " conv criteria (tolerance) =  "   << fParameters.fConvCrit << std::endl;
   }

   fStatus = 0;
   unsigned int niter = 0;
   do {
      mg.Init();

      mg.CalculateFitness();

      // Just for debugging options
      //mg.GetGeneticPopulation().Print(0);

      mg.GetGeneticPopulation().TrimPopulation();

      mg.SpreadControl( fParameters.fSC_steps, fParameters.fSC_rate, fParameters.fSC_factor );

      if (PrintLevel() > 2) {
         std::cout << "New Iteration " << niter << " with  parameter values :" << std::endl;
         TMVA::GeneticGenes* genes = mg.GetGeneticPopulation().GetGenes( 0 );
         if (genes) {
            std::vector<Double_t> gvec;
            gvec = genes->GetFactors();
            for (unsigned int i = 0; i < gvec.size(); ++i) {
               std::cout << gvec[i] << "    ";
            }
            std::cout << std::endl;
            std::cout << "\tFitness function value = " <<  static_cast<MultiGenFunctionFitness*>(fFitness)->Evaluate(gvec) << std::endl;
         }
      }
      niter++;
      if ( niter > MaxIterations() && MaxIterations() > 0) {
         if (PrintLevel() > 0) {
            Info("GeneticMinimizer::Minimize","Max number of iterations %d reached - stop iterating",MaxIterations());
         }
         fStatus = 1;
         break;
      }

   } while (!mg.HasConverged( fParameters.fNsteps, fParameters.fConvCrit ));  // converged if: fitness-improvement < CONVCRIT within the last CONVSTEPS loops

   TMVA::GeneticGenes* genes = mg.GetGeneticPopulation().GetGenes( 0 );
   std::vector<Double_t> gvec;
   gvec = genes->GetFactors();


   // transform correctly gvec on fresult in case there are fixed parameters
   const std::vector<double> & transVec = static_cast<MultiGenFunctionFitness*>(fFitness)->Transform(gvec);
   std::copy(transVec.begin(), transVec.end(), fResult.begin() );
   fMinValue = static_cast<MultiGenFunctionFitness*>(fFitness)->Evaluate(gvec);


   if (PrintLevel() > 0) {
      if (PrintLevel() > 2) std::cout << std::endl;
          std::cout << "Finished Iteration (niter = " << niter << "  with fitness function value = " << MinValue() << std::endl;
      for (unsigned int i = 0; i < fResult.size(); ++i) {
         std::cout << " Parameter-" << i << "\t=\t" << fResult[i] << std::endl;
      }
   }

   return true;
}

double GeneticMinimizer::MinValue() const
{
   return (fFitness) ? fMinValue : 0;
}

const double *  GeneticMinimizer::X() const {
   return (fFitness) ? &fResult[0] : 0;
}

unsigned int GeneticMinimizer::NCalls() const
{
   if ( fFitness )
      return static_cast<MultiGenFunctionFitness*>(fFitness)->NCalls();
   else
      return 0;
}

unsigned int GeneticMinimizer::NDim() const
{
   if ( fFitness )
      return static_cast<MultiGenFunctionFitness*>(fFitness)->NTotal();
   else
      return 0;
}
unsigned int GeneticMinimizer::NFree() const
{
   if ( fFitness )
      return static_cast<MultiGenFunctionFitness*>(fFitness)->NDims();
   else
      return 0;
}

// Functions we don't need...
const double *  GeneticMinimizer::MinGradient() const { return 0; }
bool GeneticMinimizer::ProvidesError() const { return false; }
const double * GeneticMinimizer::Errors() const { return 0; }
double GeneticMinimizer::Edm() const { return 0; }
double GeneticMinimizer::CovMatrix(unsigned int, unsigned int) const { return 0; }

}
}
 GeneticMinimizer.cxx:1
 GeneticMinimizer.cxx:2
 GeneticMinimizer.cxx:3
 GeneticMinimizer.cxx:4
 GeneticMinimizer.cxx:5
 GeneticMinimizer.cxx:6
 GeneticMinimizer.cxx:7
 GeneticMinimizer.cxx:8
 GeneticMinimizer.cxx:9
 GeneticMinimizer.cxx:10
 GeneticMinimizer.cxx:11
 GeneticMinimizer.cxx:12
 GeneticMinimizer.cxx:13
 GeneticMinimizer.cxx:14
 GeneticMinimizer.cxx:15
 GeneticMinimizer.cxx:16
 GeneticMinimizer.cxx:17
 GeneticMinimizer.cxx:18
 GeneticMinimizer.cxx:19
 GeneticMinimizer.cxx:20
 GeneticMinimizer.cxx:21
 GeneticMinimizer.cxx:22
 GeneticMinimizer.cxx:23
 GeneticMinimizer.cxx:24
 GeneticMinimizer.cxx:25
 GeneticMinimizer.cxx:26
 GeneticMinimizer.cxx:27
 GeneticMinimizer.cxx:28
 GeneticMinimizer.cxx:29
 GeneticMinimizer.cxx:30
 GeneticMinimizer.cxx:31
 GeneticMinimizer.cxx:32
 GeneticMinimizer.cxx:33
 GeneticMinimizer.cxx:34
 GeneticMinimizer.cxx:35
 GeneticMinimizer.cxx:36
 GeneticMinimizer.cxx:37
 GeneticMinimizer.cxx:38
 GeneticMinimizer.cxx:39
 GeneticMinimizer.cxx:40
 GeneticMinimizer.cxx:41
 GeneticMinimizer.cxx:42
 GeneticMinimizer.cxx:43
 GeneticMinimizer.cxx:44
 GeneticMinimizer.cxx:45
 GeneticMinimizer.cxx:46
 GeneticMinimizer.cxx:47
 GeneticMinimizer.cxx:48
 GeneticMinimizer.cxx:49
 GeneticMinimizer.cxx:50
 GeneticMinimizer.cxx:51
 GeneticMinimizer.cxx:52
 GeneticMinimizer.cxx:53
 GeneticMinimizer.cxx:54
 GeneticMinimizer.cxx:55
 GeneticMinimizer.cxx:56
 GeneticMinimizer.cxx:57
 GeneticMinimizer.cxx:58
 GeneticMinimizer.cxx:59
 GeneticMinimizer.cxx:60
 GeneticMinimizer.cxx:61
 GeneticMinimizer.cxx:62
 GeneticMinimizer.cxx:63
 GeneticMinimizer.cxx:64
 GeneticMinimizer.cxx:65
 GeneticMinimizer.cxx:66
 GeneticMinimizer.cxx:67
 GeneticMinimizer.cxx:68
 GeneticMinimizer.cxx:69
 GeneticMinimizer.cxx:70
 GeneticMinimizer.cxx:71
 GeneticMinimizer.cxx:72
 GeneticMinimizer.cxx:73
 GeneticMinimizer.cxx:74
 GeneticMinimizer.cxx:75
 GeneticMinimizer.cxx:76
 GeneticMinimizer.cxx:77
 GeneticMinimizer.cxx:78
 GeneticMinimizer.cxx:79
 GeneticMinimizer.cxx:80
 GeneticMinimizer.cxx:81
 GeneticMinimizer.cxx:82
 GeneticMinimizer.cxx:83
 GeneticMinimizer.cxx:84
 GeneticMinimizer.cxx:85
 GeneticMinimizer.cxx:86
 GeneticMinimizer.cxx:87
 GeneticMinimizer.cxx:88
 GeneticMinimizer.cxx:89
 GeneticMinimizer.cxx:90
 GeneticMinimizer.cxx:91
 GeneticMinimizer.cxx:92
 GeneticMinimizer.cxx:93
 GeneticMinimizer.cxx:94
 GeneticMinimizer.cxx:95
 GeneticMinimizer.cxx:96
 GeneticMinimizer.cxx:97
 GeneticMinimizer.cxx:98
 GeneticMinimizer.cxx:99
 GeneticMinimizer.cxx:100
 GeneticMinimizer.cxx:101
 GeneticMinimizer.cxx:102
 GeneticMinimizer.cxx:103
 GeneticMinimizer.cxx:104
 GeneticMinimizer.cxx:105
 GeneticMinimizer.cxx:106
 GeneticMinimizer.cxx:107
 GeneticMinimizer.cxx:108
 GeneticMinimizer.cxx:109
 GeneticMinimizer.cxx:110
 GeneticMinimizer.cxx:111
 GeneticMinimizer.cxx:112
 GeneticMinimizer.cxx:113
 GeneticMinimizer.cxx:114
 GeneticMinimizer.cxx:115
 GeneticMinimizer.cxx:116
 GeneticMinimizer.cxx:117
 GeneticMinimizer.cxx:118
 GeneticMinimizer.cxx:119
 GeneticMinimizer.cxx:120
 GeneticMinimizer.cxx:121
 GeneticMinimizer.cxx:122
 GeneticMinimizer.cxx:123
 GeneticMinimizer.cxx:124
 GeneticMinimizer.cxx:125
 GeneticMinimizer.cxx:126
 GeneticMinimizer.cxx:127
 GeneticMinimizer.cxx:128
 GeneticMinimizer.cxx:129
 GeneticMinimizer.cxx:130
 GeneticMinimizer.cxx:131
 GeneticMinimizer.cxx:132
 GeneticMinimizer.cxx:133
 GeneticMinimizer.cxx:134
 GeneticMinimizer.cxx:135
 GeneticMinimizer.cxx:136
 GeneticMinimizer.cxx:137
 GeneticMinimizer.cxx:138
 GeneticMinimizer.cxx:139
 GeneticMinimizer.cxx:140
 GeneticMinimizer.cxx:141
 GeneticMinimizer.cxx:142
 GeneticMinimizer.cxx:143
 GeneticMinimizer.cxx:144
 GeneticMinimizer.cxx:145
 GeneticMinimizer.cxx:146
 GeneticMinimizer.cxx:147
 GeneticMinimizer.cxx:148
 GeneticMinimizer.cxx:149
 GeneticMinimizer.cxx:150
 GeneticMinimizer.cxx:151
 GeneticMinimizer.cxx:152
 GeneticMinimizer.cxx:153
 GeneticMinimizer.cxx:154
 GeneticMinimizer.cxx:155
 GeneticMinimizer.cxx:156
 GeneticMinimizer.cxx:157
 GeneticMinimizer.cxx:158
 GeneticMinimizer.cxx:159
 GeneticMinimizer.cxx:160
 GeneticMinimizer.cxx:161
 GeneticMinimizer.cxx:162
 GeneticMinimizer.cxx:163
 GeneticMinimizer.cxx:164
 GeneticMinimizer.cxx:165
 GeneticMinimizer.cxx:166
 GeneticMinimizer.cxx:167
 GeneticMinimizer.cxx:168
 GeneticMinimizer.cxx:169
 GeneticMinimizer.cxx:170
 GeneticMinimizer.cxx:171
 GeneticMinimizer.cxx:172
 GeneticMinimizer.cxx:173
 GeneticMinimizer.cxx:174
 GeneticMinimizer.cxx:175
 GeneticMinimizer.cxx:176
 GeneticMinimizer.cxx:177
 GeneticMinimizer.cxx:178
 GeneticMinimizer.cxx:179
 GeneticMinimizer.cxx:180
 GeneticMinimizer.cxx:181
 GeneticMinimizer.cxx:182
 GeneticMinimizer.cxx:183
 GeneticMinimizer.cxx:184
 GeneticMinimizer.cxx:185
 GeneticMinimizer.cxx:186
 GeneticMinimizer.cxx:187
 GeneticMinimizer.cxx:188
 GeneticMinimizer.cxx:189
 GeneticMinimizer.cxx:190
 GeneticMinimizer.cxx:191
 GeneticMinimizer.cxx:192
 GeneticMinimizer.cxx:193
 GeneticMinimizer.cxx:194
 GeneticMinimizer.cxx:195
 GeneticMinimizer.cxx:196
 GeneticMinimizer.cxx:197
 GeneticMinimizer.cxx:198
 GeneticMinimizer.cxx:199
 GeneticMinimizer.cxx:200
 GeneticMinimizer.cxx:201
 GeneticMinimizer.cxx:202
 GeneticMinimizer.cxx:203
 GeneticMinimizer.cxx:204
 GeneticMinimizer.cxx:205
 GeneticMinimizer.cxx:206
 GeneticMinimizer.cxx:207
 GeneticMinimizer.cxx:208
 GeneticMinimizer.cxx:209
 GeneticMinimizer.cxx:210
 GeneticMinimizer.cxx:211
 GeneticMinimizer.cxx:212
 GeneticMinimizer.cxx:213
 GeneticMinimizer.cxx:214
 GeneticMinimizer.cxx:215
 GeneticMinimizer.cxx:216
 GeneticMinimizer.cxx:217
 GeneticMinimizer.cxx:218
 GeneticMinimizer.cxx:219
 GeneticMinimizer.cxx:220
 GeneticMinimizer.cxx:221
 GeneticMinimizer.cxx:222
 GeneticMinimizer.cxx:223
 GeneticMinimizer.cxx:224
 GeneticMinimizer.cxx:225
 GeneticMinimizer.cxx:226
 GeneticMinimizer.cxx:227
 GeneticMinimizer.cxx:228
 GeneticMinimizer.cxx:229
 GeneticMinimizer.cxx:230
 GeneticMinimizer.cxx:231
 GeneticMinimizer.cxx:232
 GeneticMinimizer.cxx:233
 GeneticMinimizer.cxx:234
 GeneticMinimizer.cxx:235
 GeneticMinimizer.cxx:236
 GeneticMinimizer.cxx:237
 GeneticMinimizer.cxx:238
 GeneticMinimizer.cxx:239
 GeneticMinimizer.cxx:240
 GeneticMinimizer.cxx:241
 GeneticMinimizer.cxx:242
 GeneticMinimizer.cxx:243
 GeneticMinimizer.cxx:244
 GeneticMinimizer.cxx:245
 GeneticMinimizer.cxx:246
 GeneticMinimizer.cxx:247
 GeneticMinimizer.cxx:248
 GeneticMinimizer.cxx:249
 GeneticMinimizer.cxx:250
 GeneticMinimizer.cxx:251
 GeneticMinimizer.cxx:252
 GeneticMinimizer.cxx:253
 GeneticMinimizer.cxx:254
 GeneticMinimizer.cxx:255
 GeneticMinimizer.cxx:256
 GeneticMinimizer.cxx:257
 GeneticMinimizer.cxx:258
 GeneticMinimizer.cxx:259
 GeneticMinimizer.cxx:260
 GeneticMinimizer.cxx:261
 GeneticMinimizer.cxx:262
 GeneticMinimizer.cxx:263
 GeneticMinimizer.cxx:264
 GeneticMinimizer.cxx:265
 GeneticMinimizer.cxx:266
 GeneticMinimizer.cxx:267
 GeneticMinimizer.cxx:268
 GeneticMinimizer.cxx:269
 GeneticMinimizer.cxx:270
 GeneticMinimizer.cxx:271
 GeneticMinimizer.cxx:272
 GeneticMinimizer.cxx:273
 GeneticMinimizer.cxx:274
 GeneticMinimizer.cxx:275
 GeneticMinimizer.cxx:276
 GeneticMinimizer.cxx:277
 GeneticMinimizer.cxx:278
 GeneticMinimizer.cxx:279
 GeneticMinimizer.cxx:280
 GeneticMinimizer.cxx:281
 GeneticMinimizer.cxx:282
 GeneticMinimizer.cxx:283
 GeneticMinimizer.cxx:284
 GeneticMinimizer.cxx:285
 GeneticMinimizer.cxx:286
 GeneticMinimizer.cxx:287
 GeneticMinimizer.cxx:288
 GeneticMinimizer.cxx:289
 GeneticMinimizer.cxx:290
 GeneticMinimizer.cxx:291
 GeneticMinimizer.cxx:292
 GeneticMinimizer.cxx:293
 GeneticMinimizer.cxx:294
 GeneticMinimizer.cxx:295
 GeneticMinimizer.cxx:296
 GeneticMinimizer.cxx:297
 GeneticMinimizer.cxx:298
 GeneticMinimizer.cxx:299
 GeneticMinimizer.cxx:300
 GeneticMinimizer.cxx:301
 GeneticMinimizer.cxx:302
 GeneticMinimizer.cxx:303
 GeneticMinimizer.cxx:304
 GeneticMinimizer.cxx:305
 GeneticMinimizer.cxx:306
 GeneticMinimizer.cxx:307
 GeneticMinimizer.cxx:308
 GeneticMinimizer.cxx:309
 GeneticMinimizer.cxx:310
 GeneticMinimizer.cxx:311
 GeneticMinimizer.cxx:312
 GeneticMinimizer.cxx:313
 GeneticMinimizer.cxx:314
 GeneticMinimizer.cxx:315
 GeneticMinimizer.cxx:316
 GeneticMinimizer.cxx:317
 GeneticMinimizer.cxx:318
 GeneticMinimizer.cxx:319
 GeneticMinimizer.cxx:320
 GeneticMinimizer.cxx:321
 GeneticMinimizer.cxx:322
 GeneticMinimizer.cxx:323
 GeneticMinimizer.cxx:324
 GeneticMinimizer.cxx:325
 GeneticMinimizer.cxx:326
 GeneticMinimizer.cxx:327
 GeneticMinimizer.cxx:328
 GeneticMinimizer.cxx:329
 GeneticMinimizer.cxx:330
 GeneticMinimizer.cxx:331
 GeneticMinimizer.cxx:332
 GeneticMinimizer.cxx:333
 GeneticMinimizer.cxx:334
 GeneticMinimizer.cxx:335
 GeneticMinimizer.cxx:336
 GeneticMinimizer.cxx:337
 GeneticMinimizer.cxx:338
 GeneticMinimizer.cxx:339
 GeneticMinimizer.cxx:340
 GeneticMinimizer.cxx:341
 GeneticMinimizer.cxx:342
 GeneticMinimizer.cxx:343
 GeneticMinimizer.cxx:344
 GeneticMinimizer.cxx:345
 GeneticMinimizer.cxx:346
 GeneticMinimizer.cxx:347
 GeneticMinimizer.cxx:348
 GeneticMinimizer.cxx:349
 GeneticMinimizer.cxx:350
 GeneticMinimizer.cxx:351
 GeneticMinimizer.cxx:352
 GeneticMinimizer.cxx:353
 GeneticMinimizer.cxx:354
 GeneticMinimizer.cxx:355
 GeneticMinimizer.cxx:356
 GeneticMinimizer.cxx:357
 GeneticMinimizer.cxx:358
 GeneticMinimizer.cxx:359
 GeneticMinimizer.cxx:360
 GeneticMinimizer.cxx:361
 GeneticMinimizer.cxx:362
 GeneticMinimizer.cxx:363
 GeneticMinimizer.cxx:364
 GeneticMinimizer.cxx:365
 GeneticMinimizer.cxx:366
 GeneticMinimizer.cxx:367
 GeneticMinimizer.cxx:368
 GeneticMinimizer.cxx:369
 GeneticMinimizer.cxx:370
 GeneticMinimizer.cxx:371
 GeneticMinimizer.cxx:372