
************ Source Code Package of History-driven Evolutionary Algorithm (HdEA) ************

based on [1] Chi Kin Chow and Shiu Yin Yuen, An evolutionary algorithm that makes decision based on the entire previous search history,
IEEE Trans. on Evolutionary Computation, vol. 15, no. 6, pp. 741-769, 2011.

-----------------------------------------------------------------------------------------------


				~~~~~~~~ PART 1 ~~~~~~~~


The package contains five source files:

1. HdEA_Kernel.C - Functions involved in HdEA
2. HdEA_Kernel.H - Function prototypes

3. HdEA_Main.C - An example of optimization by HdEA

4. Optimization_TestFunction_Kernel.C - The tested function appeared in [1]
5. Optimization_TestFunction_Kernel.H - Function prototypes

They are written in C language
-----------------------------------------------------------------------------------------------


				~~~~~~~~ PART 2 ~~~~~~~~


Procedure of calling HdEA


1. Define varaible for HdEA. In this example, the variable is 'cur_HdEA'

	HdEA cur_HdEA;


2. Construct a struct of HdEA and assign the struct to 'cur_HdEA'

	HdEA_Construction(&cur_HdEA, no_dimension, population_size, population_size, crossover_rate);

	i.   no_dimension: function dimension
	ii.  population_size: population size
	iii. crossover_rate: crossover rate


3. Define the search space of the objective function. In this example, the search space is [0,1]^D where D is the function dimension

	for(i=0; i< no_dimension; ++i)
	{
		cur_HdEA.EA_Info.SearchSpace[i][0] = 0.0;
		cur_HdEA.EA_Info.SearchSpace[i][1] = 1.0;
	}

4. Execute HdEA

	HdEA_Kernel(&cur_HdEA, optimization_mode, terminate_mode, terminate_parameter, MyObjectiveFunction);

	i.  optimization_mode: 0 = minimization, 1 = maximization

	ii. terminate_mode: 0 = terminate after 'terminate_parameter' generations
			    1 = terminate when the best-found fitness reaches 'terminate_parameter'

	iii terminate_parameter: = max. no. of generations if terminate_mode = 0
				 = target fitness if terminate_mode = 1

	iv. MyObjectiveFunction = function pointer of the objective function.
				  The valid function format of objective function is discussed in Part 3



5. Get the best found solution and the corresponding fitness

	Best found solution = cur_HdEA.EA_Info.Optimal_Individual
	Best found fitness  = cur_HdEA.EA_Info.Optimal_Fitness

6. Destruct the struct of HdEA

	HdEA_Destruction(cur_HdEA)




----------------------------------------------------------------------------------------------


				~~~~~~~~ PART 3 ~~~~~~~~


Function prototype of objective function:

	
	double MyProblem(double*)


Example:


	double MyProblem(double *X)
	{
		int i;
		double f;

		f = 0.0;
		for(i=0; i< 2; ++i)
			f += pow(X[i]-MyProblem_Parameter[i],2);

		return f;
	}


Note that, in the objective function, all variables that are indpendent of the optimizationprocess should be implemented
as global variable so that the prototype can be standardized. In the above example, the bias 'MyProblem_Parameter[]'
should be declared as global variable.


============ MyProblem.h ============ 

double MyProblem_Parameter[2];

double MyProblem(double*);


============ MyProblem.c ============

#include<MyProblem.h>

double MyProblem(double *X)
{
	int i;
	double f;

	f = 0.0;
	for(i=0; i< 2; ++i)
		f += pow(X[i]-MyProblem_Parameter[i],2);

	return f;
}




----------------------------------------------------------------------------------------------


				~~~~~~~~ PART 4 ~~~~~~~~


Procedure of call the test function in "Optimization_TestFunction_Kernel.C"


1. Include "Optimization_TestFunction_Kernel.H" in the main .C file


2. Assign function dimension

	Optimization_TestFunction_Dimension = no_dimension;


3. Allocate memory for the test function

	Optimization_TestFunction_Construction();


4. Initialize the internal information of the function

	Optimization_TestFunction_Manager_RealValued(testfunction_index, testfunction_name);

	i.  testfunction_index = Index of test function. Details can be found in [1]
	ii. testfunction_name = a character array pointer. The function returns the name of the test function to it.
	

	char testfunction_name[256];

	testfunction_name = ??????

	Optimization_TestFunction_Manager_RealValued(1,testfunction_name);

	testfunction_name = 'Spherical'


5. Free the memory occupied by "Optimization_TestFunction_Kernel.C"

	Optimization_TestFunction_Destruction();


*** To simplify the experiment in [1], the search spaces of the test functions in "Optimization_TestFunction_Kernel.C" are
    external fixed as [0,1]^D and the solution is scaled to the true range in each function. Therefore, one will find that
    the search space range defined for HdEA is as:

	for(i=0; i< no_dimension; ++i)
	{
		cur_HdEA.EA_Info.SearchSpace[i][0] = 0.0;
		cur_HdEA.EA_Info.SearchSpace[i][1] = 1.0;
	}



