/*
 * Creation.h
 *
 *  Created on: Jul 29, 2015
 *      Author: jjpalacios
 */

#ifndef SRC_ECOPERATORS_CREATION_H_
#define SRC_ECOPERATORS_CREATION_H_

#include "../heading.h"
#include "../ecObjects/Population.h"

namespace clbDEB {


//=============================================================================
//
//	Abstract class Creation
//
//=============================================================================
/**
 * This class provides the framework to implement different strategies
 * to create initial populations
 *
 * @author jjpalacios
 *
 */
class Creation {
	//=========================================================================
	//		CONSTRUCTORS / INITIALIZERS
	//=========================================================================
public:
	/**
	 * Default constructor
	 */
	explicit Creation(ParameterDB *parameters = NULL);

	/**
	 * Loads the needed parameters: No parameters needed by default
	 */
	virtual void setup(ParameterDB *parameters) { }

	/**
	 * Destructor
	 */
	virtual ~Creation() { }; 	// Nothing to destroy here



	//=========================================================================
	//		METHODS
	//=========================================================================
public:
	/**
	 * Creates an initial population using the given individual type and the
	 * size of the population
	 *
	 * @param individualType Type of individuals to create
	 * @param size Number of individuals to create
	 * @param svars Shared variables for the algorithm
	 * @return A bunch of filthy individuals
	 */
	virtual Population * createPopulation(typeOfIndividual individualType,
			const int genomeLength, const int size,
			const SharedVars *svars) const;

	/**
	 * Creates an individual
	 *
	 * @param individualType Type of individuals to create
	 * @param svars Shared variables for the algorithm
	 * @return A new born individual
	 */
	virtual Individual * createIndividual(typeOfIndividual individualType,
			const int genomeLength, const SharedVars *svars) const=0;

	/**
	 * Get the name and setup of the operator
	 *
	 * @return A string of parameter values. The first string is the name of
	 * the operator
	 */
	virtual std::vector<std::string> getName() const=0;

};





//=============================================================================
//
//	Class RandomCreation
//
//=============================================================================
/**
 * This class generates an initial population by creating individuals with
 * random genes
 *
 * @author jjpalacios
 *
 */
class RandomCreation : public Creation {
	//=========================================================================
	//		CONSTRUCTORS / INITIALIZERS
	//=========================================================================
public:
	/**
	 * Default constructor
	 */
	explicit RandomCreation(ParameterDB *parameters = NULL)
		: Creation(parameters) { }

	/**
	 * Destructor
	 */
	virtual ~RandomCreation() { }; 	// Nothing to destroy here



	//=========================================================================
	//		METHODS
	//=========================================================================
public:
	/**
	 * Creates an individual
	 *
	 * @param individualType Type of individuals to create
	 * @param svars Shared variables for the algorithm
	 * @return A new born individual
	 */
	virtual Individual * createIndividual(typeOfIndividual individualType,
				const int genomeLength, const SharedVars *svars) const;

	/**
	 * Get the name and setup of the operator
	 *
	 * @return A string of parameter values. The first string is the name of
	 * the operator
	 */
	virtual std::vector<std::string> getName() const {
		std::vector<std::string> setup;
		setup.push_back("Random");
		return setup;
	}
};



}


#endif /* SRC_ECOPERATORS_CREATION_H_ */
