#include "parameters.h"

Parameters::Parameters() {

	//Simulation
	simNr = 10016;
	reps =5;
	gens =500;

	//Landscape

	K = 50; // carrying capacity


	// Chromosome and Biology of Mutations 
	
	R = 10; // length of the chromosome
	
	//---> recombination
	COd = 1.0;
	//---> mutational effects, number of mutations
	shape_mut = 1.0; // ->shape parameter k (or alpha)
	mean_mut = 0.01; //  -> mean parameter u,  mean = shape parameter* scale parameter (in R) -> scale= mean/shape
	initial_nMut = 0; // initiate individuals with mutations
	
	s_const = 0; // if selection coef constant for deleterious mutations
	
	mean_hd = 0.37; // mean dominance effect for mildly deleterious mutations
	Ud = 1.0; // number of deleterious mutations occuring in offspring  --> currently with 1, gives error when 0
	Ub = 0.05; // number of beneficial mutations
	Ur = 0.05; // probability of del mut reversing (backmutation)

	neut_mu = 1.0; // probability of neutral mutation occuring per individual per generation -> per locus mutation rate = neut_mu/2
	neut_Veffect = 1.0; // variance from which to sample neutral mutation value, should be chosen so Vm is exactly 1
						//-> Vm= 2*nloci*neut_mu*neut_effect=1

	// Condition 
	add_error = true; // if noise is added to condition
	sd_error = 0.01; // if 0, then add_error has to be false

	// Survival 
	dens_ind_sel = true; // density independent survival
	strength_sel = 1.0; // determining the shape of the function how deleterious mutations affect survival, 1 is linear

	// Sexual selection 
	deme_size = 1; // deme size, number of competing males
	alpha = 1.0; //male-male competition

	//---> offspring production
	fecundity_selection = false;
	r = 4.0; // number of offspring
	fec_par = 1.0;

	noff_det = 1;

	// output
	pop_slim = true;
	out_pop_interval = 10; // interval for population output every X generations
	out_pop_interval2 = 2000; // new pop interval
	
	out_ind_interval = 100000; // interval indivudal output every X generations
	out_ind_interval2 = 100000; // new ind interval
	
	out2_limit = 2000; // limit when to switch to new output interval

	mutout_on = 0;
	dload_out_start =1; // for popmut output 
	dload_interval =100000; // for dirft load output
	
	full_mutmap_interval = 1; //
	full_mutmap_start = 1000;

	out_Ne = 0;
	out_Ne_start = 1000;
	out_Ne_interval = 10;

	W_critical = 0.6;


// make model deterministic 
	seed = 2.0; 

}

/*
void Parameters::outPara(string name) {

	ofstream out;

	out.open(name.c_str());
	
	//Simulation

	out << "SimNr\t" << simNr << endl; // simulation ID
	out << "rep\t" << reps << endl; //replicates
	out << "gen\t" << gens << endl; //generations
	out << "determ\t" << DET << endl; // determinisitc model
	out << "dominance\t" << DOM << endl; // dominance model
	out << "benmut\t" << BENMUT << endl; // beneficial mutations modelled
	out << "revmut\t" << BACKMUT << endl; // reverse mutations modelled

	// Landscape
	out << "seed\t" << seed << endl; //set seed for deterministic model
	out << "K\t" << K << endl; //carrying capacity

	// Genetics
	out << "R\t" << R << endl; //length of chromosome
	out << "COlength\t" << COd << endl; //length of CO region
	out << "initMut\t" << initial_nMut << endl; //initial number of mutations present
	out << "shapeMut_effect\t" << shape_mut << endl; //shape parameter of mutational effect distribution
	out << "meanMut_effect\t" << mean_mut << endl; //mean of mutational effect distribution-> scale= mean/shape
	out << "Udel\t" << Ud << endl; //number of del mut per generation per genom
	out << "Uben\t" << Ub << endl; //number of benefical mut per generation per genom
	out << "Urev\t" << Ur << endl; //number of reverse mut per gen/per genom
	out << "mean_hd\t" << mean_hd << endl; //goes into determining domiance coef h via calculation of k, mean domiance
	

	// Condition
	out << "c_error\t" << add_error << endl; // add  random error to condition
	out << "c_sderror\t" << sd_error << endl; //width of error distribution
	
	//Suvivial
	out << "dens_ind_sel\t" << dens_ind_sel << endl; //is natural selection density independent
	out << "strength_nat_sel\t" << strength_sel << endl; //strength of nat selection

	// Sexual selection
	out << "deme_size\t" << deme_size << endl; //males in a deme
	out << "alpha\t" << alpha << endl; //potential for mate monoplisation

	// Offspring production
	out << "fec_sel\t" << fecundity_selection << endl; //fecundity selection true
	out << "mean_fec\t" << r << endl; //mean number of offspring
	out << "fec_par\t" << fec_par << endl; //scaling fecundity to condition

	// output variables
	out << "out_ind1\t" << out_ind_interval << endl; //
	out << "out_ind2\t" << out_ind_interval2 << endl; //
	out << "out_pop1\t" << out_pop_interval << endl; //
	out << "out_pop2\t" << out_pop_interval2 << endl; //
	out << "out_limit\t" << out2_limit << endl; //
	out << "mutout_on\t" << mutout_on << endl; //
	out << "out_start\t" << out_start << endl; //
	out << "Popmut_interval\t" << PopMut_interval << endl; //

	out.close();
}
*/

void Parameters::outPara(string name) {

	ofstream out;

	out.open(name.c_str());

	//Simulation

	out << "SimNr\t"
		<< "rep\t" //replicates
		<< "gen\t"  //generations
		<< "determ\t" // determinisitc model
		<< "dominance\t" // dominance model
		<< "benmut\t"   // beneficial mutations modelled
		<< "revmut\t"   // reverse mutations modelled
		<< "delmut\t"   // reverse mutations modelled
		
						// Landscape
		<< "seed\t"  //set seed for deterministic model
		<< "K\t"  //carrying capacity

		// Genetics
	    << "R\t"  //length of chromosome
		<< "COlength\t"  //length of CO region
		<< "initMut\t"  //initial number of mutations present
		<< "shapeMut_effect\t"  //shape parameter of mutational effect distribution
		<< "meanMut_effect\t"  //mean of mutational effect distribution-> scale= mean/shape
		<< "constant_s\t" // if cosntant s true
		<< "Udel\t"  //number of del mut per generation per genom
		<< "Uben\t"  //number of benefical mut per generation per genom
		<< "Urev\t"  //number of reverse mut per gen/per genom
		<< "mean_hd\t"  //goes into determining domiance coef h via calculation of k, mean domiance
		<< "neut_mu\t" //
		<< "neut_Veffect\t" //

	   // Condition
		<< "c_error\t"  // add  random error to condition
		<< "c_sderror\t"  //width of error distribution

	   //Suvivial
		<< "dens_ind_sel\t" //is natural selection density independent
		<< "strength_nat_sel\t"  //strength of nat selection

	   // Sexual selection
		<< "deme_size\t"  //males in a deme
		<< "alpha\t"  //potential for mate monoplisation

	   // Offspring production
		<< "fec_sel\t"  //fecundity selection true
		<< "mean_fec\t" //mean number of offspring
		<< "fec_par\t"  //scaling fecundity to condition
		<< "noff_det\t" //fecudnity a constant

	   // output variables
		<< "out_ind1\t"  //
		<< "out_ind2\t"  //
		<< "out_pop1\t"  //
		<< "out_pop2\t"  //
		<< "out_limit\t" //
		<< "mutout_on\t"  //
		<< "out_start\t"  //
		<< "Popmut_interval\t" //
		
		<< "out_Ne\t"  //
		<< "out_Ne_start\t"  //
		<< "out_Ne_interval\t" << endl;  //

	// INPUT VARIABLES

	//Simulation

		out << simNr << "\t"   // simulation ID
			<< reps << "\t" //replicates
			<< gens << "\t" //generations
			<< DET << "\t" // determinisitc model
			<< DOM << "\t" // dominance model
			<< BENMUT << "\t" // beneficial mutations modelled
			<< BACKMUT << "\t" // reverse mutations modelled
			<< DELMUT << "\t" // reverse mutations modelled
			
			// Landscape
			<< seed << "\t" //set seed for deterministic model
			<< K << "\t" //carrying capacity

			// Genetics
			<< R << "\t"  //length of chromosome
			<< COd << "\t" //length of CO region
			<< initial_nMut << "\t" //initial number of mutations present
			<< shape_mut << "\t" //shape parameter of mutational effect distribution
			<< mean_mut << "\t" //mean of mutational effect distribution-> scale= mean/shape
			<< s_const << "\t" // constant s coef
			<< Ud << "\t"//number of del mut per generation per genom
			<< Ub << "\t" //number of benefical mut per generation per genom
			<< Ur << "\t" //number of reverse mut per gen/per genom
			<< mean_hd << "\t" //goes into determining domiance coef h via calculation of k, mean domiance

			<< neut_mu << "\t" //
			<< neut_Veffect << "\t" //

			// Condition
			<< add_error << "\t" // add  random error to condition
			<< sd_error << "\t" //width of error distribution

			//Suvivial
			<< dens_ind_sel << "\t" //is natural selection density independent
			<< strength_sel << "\t" //strength of nat selection

			// Sexual selection
			<< deme_size << "\t" //males in a deme
			<< alpha << "\t" //potential for mate monoplisation

			// Offspring production
			<< fecundity_selection << "\t" //fecundity selection true
			<< r << "\t"//mean number of offspring
			<< fec_par << "\t" //scaling fecundity to condition
			<< noff_det << "\t"//mean number of offspring

			// output variables
			<< out_ind_interval << "\t" //
			<< out_ind_interval2 << "\t" //
			<< out_pop_interval << "\t" //
			<< out_pop_interval2 << "\t" //
			<< out2_limit << "\t" //
			<< mutout_on << "\t" //
			<< dload_out_start << "\t" //
			<< dload_interval << "\t" //
			
			<< out_Ne << "\t" //
			<< out_Ne_start << "\t" //
			<< out_Ne_interval << endl; //

	out.close();
}

Parameters::~Parameters()
{
}