/***************************************************************************
 *   Copyright (C) 2006 by Yves Fomekong Nanfack, F.219,+31 20 525 7530,   *
 *   yvesf@science.uva.nl   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef GA_OPT_INCLUDED
#define GA_OPT_INCLUDED

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>

#include <float.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>                       /* for command line option stuff */

#include "global.h"

typedef struct{
double stepsize;
int ndigits;
int precision;
double accuracy;

char   *simulationSol;
char   *inname;                           /* filename of input file */
char   *outname;                         /* filename of output file */
char   *outDir;
char   *ga_config;  
}OptParam;

typedef struct Range {       
  double   lower;    
  double   upper;    
} Range;


 typedef enum EVOLTYPE { 
   MuLambda,//0
   MuPlusLambda //1 
}EVOLTYPE;
 
 
  typedef enum LSTYPE { 
   SHHSCH, //o
   SMDSCH,//1   
   NMSCH,//2
   EDHJ,//3
   HJ,//4
   NLESS,//5
   COMPSS,//6
   COORD,//7
   HNM //8
}LSTYPE;
  


 
typedef struct
{
  int restart;
  
  char *configName;
  char *configOut;
  char *programName;
  char *inname;
  char *outname;
  char *outNamePop;
  char *outNameLandscapeFirst;
  char *outNameLandscapeSec;
  
  char   *outDir;  
  
   
  EVOLTYPE evoltype;
  LSTYPE lstype;
  
  int  scheme;
  int  elit;
  int strategy;
  

  unsigned seed;
  
  int nbPopulation;  
  int populationSize;
  int num_chrom;
  int len_chrom;
  
  double crossover;  
  double mutation;
  double migration;
  double replace;

  int nbGeneration;
  int minGeneration;
  int steadyGen ;
  int maxFuncEval;
  
  double convergence;
  double popConvergence;
  
  int monOut;
  int fileOut;
  int plotOut;
  
  int popPrint;
  int histoPrint;
  
  double lambda_rate;
  int mu;
  
  int    mix_interval; 

  double energy_threshold;
  int count_threshold;
  int check_interval;

/* These were marked "Application program must set these." in the code     */
/* from Greening/Lam; only progname is used at the moment; we kept them    */
/* mainly for historical reasons (and to write funny things into tunename) */

  char   progname[128];                                 /* name of my prog */
  int    debuglevel;                                          /* who cares */
  char   tunename[128];                                         /* nothing */
  FILE   *tunefile;                                                /* NULL */

} GAType;


typedef struct{
 int nbIterations; 
 double mu;
 double epsilon1;
 double epsilon2;
 double epsilon3;
 double delta;
}LocalParam;
  
typedef struct {
  GAType  tune;
  LocalParam lmParam;
} NucStateType, *NucStatePtr;  


typedef enum StopStyle {
  proportional_freeze,
  absolute_freeze,
  absolute_energy     
} StopStyle;

void Objective_LM(double  *p, double *x, int m, int n, void *data) ;

#endif

