#include<stdio.h>
#include<stdlib.h>
#include<dirent.h>
#include<vector>
#include<string>
#include<algorithm>
#include<limits.h>
#include"xtalcomp.h"
#include"variant_command.h"
#include"afterprocess.h"
#include"generate.h"
#include"variant.h"
#include"tools.h"
#define PARENT_NUM 300
#define precision  1e-4
#define MAX_LOOP 15
#define TOOi  0
using namespace std;
namespace EVO {
	typedef struct
	{
		int generation;
		char min_poscar[MAX_FNAME];
		double min_energy;
		char max_poscar[MAX_FNAME];
		double max_energy;
		double averge_energy;
	}ConInfo;

	class Population
	{
	private:
		vector<Account>population;
		vector<Account>population_child;
		int POPULATION_NUM;
		int Generation;
		int maxiterator;
		vector<double> single_energy;
		vector<string> init_element;
		vector<int> init_atom;
		double init_volume;
		int max_formula_atom;
		double maxcaltime;
	public:
		Population();
		~Population() {}
		void first_generation(bool R_flag);
		inline void Sort();
		void Renew(char label[]);
		void derive();
		void JudgeVaspComplete();
		void Record();
		void Pso(char current[], char last[], char pbest[], char gbest[], double w, int Generation, int num);
		void control();
		void Command(int argc, char* argv[]);
		void MultiFile_Variant(int argc, char* argv[]);
		int COMPARE(char const* fp1, char const* fp2, double tolerance1, double tolerance2);
		int MultiFile_COMPARE(int argc, char* argv[]);
	};
}
#pragma once
