ga.h

来自「遗传自适应算法的源代码」· C头文件 代码 · 共 62 行

H
62
字号
// GA.h: interface for the GA class.
//
//////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include "global.h"
#include "powermodel.h"
#include "pressmodel.h"
#include "slipmodel.h"
#include "speedmodel.h"
#include "torquemodel.h"

#include "de_dragmodel.h"
#define N 3  // number of variables
#define M 1  // number of objectives
#define TYPE -1 // 1=max;-1=min
#define GEN 500 // maximum generation number
#define POP_SIZE 30
#define P_MUTATION 0.05
#define P_CROSSOVER 0.1

#if !defined(AFX_GA_H__D6D67BD2_5B24_46A3_A56C_EA4EFD193040__INCLUDED_)
#define AFX_GA_H__D6D67BD2_5B24_46A3_A56C_EA4EFD193040__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000



class GA  
{
public:
	GA();
	virtual ~GA();
	
	double  OBJECTIVE[POP_SIZE+1][M+1];
	double  q[POP_SIZE+1];
	double *GA_1(global y);
protected:
	void  initialization(double H0,double h4,global y);
	void  evaluation(int gen,global y);
	void  selection(void);
	void  crossover(global y);
	void  crossover2(global y,int k);
	void  mutation(global y,double pp[POP_SIZE+1],int kk);
	void  objective_function(global y);
	double *cross_probability(int i);
	double *mutation_probability(int i);
	int   constraint_check(double x[],global y);
	double myu(double a, double b); // Uniform Distribution
	double  CHROMOSOME[POP_SIZE+1][N+1];

	

};

#endif // !defined(AFX_GA_H__D6D67BD2_5B24_46A3_A56C_EA4EFD193040__INCLUDED_)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?