很难找的基于模糊控制的程序源代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include

#include

#include

#include

struct Fzb

{

int yyz; //语言之

int ly; //论域

float lsd; //隶属值

struct Fzb *next;

};

class Fuzzy

{

private:

int g[49][3]; //定义了规则库,用于函数间调用

float R[169][13]; //定义了关系矩阵,用于函数间调用

float H[13][13]; //定义了查询表矩阵,用于函数间的调用public:

struct Fzb * Creatfzb(); //建立赋值表函数

void Printfzb(struct Fzb *head1); //输出赋值表

void Inputgzk(); //导入规则库

void jlgx(struct Fzb*E,struct Fzb*EC,struct Fzb*U); //建立关系矩阵void jlcxb(struct Fzb*E,struct Fzb*EC,struct Fzb*U); //建立查询表};

struct Fzb *Fuzzy::Creatfzb()

{

float f[8][14]={

{0,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6},

{-3,1,0.5,0,0,0,0,0,0,0,0,0,0,0},

{-2,0,0.5,1,0.5,0,0,0,0,0,0,0,0,0},

{-1,0,0,0,0.5,1,0.5,0,0,0,0,0,0,0},

{0,0,0,0,0,0,0.5,1,0.5,0,0,0,0,0},

{1,0,0,0,0,0,0,0,0.5,1,0.5,0,0,0},

{2,0,0,0,0,0,0,0,0,0,0.5,1,0.5,0},

{3,0,0,0,0,0,0,0,0,0,0,0,0.5,1}}; //默认输入赋值表

int i,k,j;

fstream in,out;

struct Fzb *head,*p1,*p2;

int n=0;

head=NULL;

p1=new(Fzb);

for(k=1;k<8;k++)

for(j=1;j<14;j++)

{

n++;

p1->lsd=f[k][j];

p1->yyz=(int)f[k][0];

p1->ly=(int)f[0][j];

if(1==n) head=p1;

p2=p1;

p1=new(Fzb);

p2->next=p1;

}

p2->next=NULL;

int m=0;

return (head);

}

void Fuzzy::Inputgzk()

{

int G[49][3]={

{-3,-3,-3},{-3,-2,-3},{-3,-1,-3},{-3,0,-3},

{-3,1,-2},{-3,2,0},{-3,3,0},{-2,-3,-3},

{-2,-2,-3},{-2,-1,-3},{-2,0,-3},{-2,1,-2},

{-2,2,0},{-2,3,0},{-1,-3,-2},{-1,-2,-2},

{-1,-1,-2},{-1,0,-2},{-1,1,0},{-1,2,1},

{-1,3,1},{0,-3,-2},{0,-2,-2},{0,-1,-1},

{0,0,0},{0,1,1},{0,2,2},{0,3,2},{1,-3,-1},

{1,-2,-1},{1,-1,0},{1,0,2},{1,1,2},{1,2,2},

{1,3,2},{2,-3,0},{2,-2,0},{2,-1,2},{2,0,3},

{2,1,3},{2,2,3},{2,3,3},{3,-3,0},{3,-2,0},

{3,-1,2},{3,0,3},{3,1,3},{3,2,3},{3,3,3}}; //默认输入规则库int i,j;

int n=0;

for(i=0;i<49;i++)

for(j=0;j<3;j++)

{

n++;

g[i][j]=G[i][j];

cout<

if(3==n) {cout<

}

}

void Fuzzy::Printfzb(struct Fzb *head1)

{

struct Fzb *p;

p=head1;

int n,i,j;

float a[8][14];

while(NULL!=p)

{

a[p->yyz+4][p->ly+7]=p->lsd;

p=p->next;

}

p=head1;

while (NULL!=p)

{

a[0][p->ly+7]=p->ly;

p=p->next;

}

p=head1;

while (NULL!=p)

{

a[p->yyz+4][0]=p->yyz;

p=p->next;

}

a[0][0]=0;

int k;

for(i=0;i<8;i++) //用于输出标准形式的赋值表{

n=0;

for(j=0;j<14;j++)

{

n++;

if(0==j&&0!=i)

{

switch((int)a[i][j]) {

case -3:

cout<

break;

case -2:

cout<

break;

case -1:

cout<

break;

case 0:

cout<

break;

case 1:

cout<

break;

相关文档
最新文档