




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 西电人工智能大作业 八数码难题一.实验目的 八数码难题:在3×3的方格棋盘上,摆放着1到8这八个数码,有1个方格是空的,其初始状态如图1所示,要求对空格执行空格左移、空格右移、空格上移和空格下移这四个操作使得棋盘从初始状态到目标状态。例如:2831231484765765(a) 初始状态 (b) 目标状态图1 八数码问题示意图请任选一种盲目搜索算法(深度优先搜索或宽度优先搜索)或 任选一种启发式搜索方法(A 算法或 A* 算法)编程求解八数码问题(初始状态任选),并对实验结果进行分析,得出合理的结论。 本实验选择宽度优先搜索:选择一个起点,以接近起始点的程度依次扩展节点,逐层搜索,
2、再对下一层节点搜索之前,必先搜索完本层节点。二.实验设备及软件环境Microsoft Visual C+,(简称Visual C+、MSVC、VC+或VC)微软公司的C+开发工具,具有集成开发环境,可提供编辑C语言,C+以及C+/CLI等编程语言。3. 实验方法 算法描述: (1)将起始点放到OPEN表; (2)若OPEN空,无解,失败;否则继续; (3)把第一个点从OPEN移出,放到CLOSE表;(4)拓展节点,若无后继结点,转(2);(5)把n的所有后继结点放到OPEN末端,提供从后继结点回到n的指针;(6)若n任意后继结点是目标节点,成功,输出;否则转(2)。 流程图:代码:#inclu
3、de <stdlib.h>#include <stdio.h>typedef struct Node int num9; /棋盘状态 int deepth; /派生的深度 g(n) int diffnum; /不在位的数目 h(n) int value; /耗散值 f(n)=g(n)+h(n) struct Node * pre; struct Node * next; struct Node * parent;numNode; /* - end of struct numNode - */int origin9; /棋盘初始状态int target9; /棋盘目标状态
4、int numNode_num,total_step;numNode *open,*close; /Open表和Close表numNode *create_numNode() return (numNode *)malloc(sizeof(numNode);numNode *open_getfirst(numNode *head); /返回第一项,并从Open表中删除void open_insert(numNode *head,numNode *item); /向Open表中按序插入新节点void close_append(numNode *head,numNode *item); /向Clo
5、se表中插入新节点int expand(numNode *item); /扩展节点int print_result(numNode *item); /打印结果numNode *copy_numNode(numNode *orgin);char isNewNode(numNode *open,numNode *close,int num9); /是否在Open表或Close表中void print_num(int num9); /打印棋盘状态int diff(int num9); /求不在位棋子的个数void init(); /初始化,获得棋盘初始状态和目标状态void swap(int *a,
6、int *b);int operate(int num,int op);void free_list(numNode *head);/* * Name: 主函數 * Description: 程序入口 */ Int main ( int argc, char *argv ) /初始化Open表和Close表 open=create_numNode(); close=create_numNode(); open->pre=open->next=close->pre=close->next=NULL; init(); /由用户输入初始和目标状态 /初始化初始节点 numNo
7、de *p1; p1=create_numNode(); p1->parent=NULL; p1->deepth=0; int i=0; for ( i=0; i<9; i+) p1->numi=origini; open_insert(open,p1); numNode_num=1; p1=open_getfirst(open); while (p1!=NULL) close_append(close,p1); if(expand(p1) return EXIT_SUCCESS; p1=open_getfirst(open); printf("No solu
8、tion!n"); return EXIT_SUCCESS; /* - end of function main - */ voidinit ( ) while(1) printf("Please input opriginal status:nFor example:123456780 stands forn" "1 2 3n" "4 5 6n" "7 8 0n"); char temp10; scanf("%s",&temp); int i=0; for ( i=0;i&l
9、t;9 && tempi-'0'>=0 && tempi-'0'<=8; i+) origini=tempi-'0' printf("Please input target status:n"); scanf("%s",&temp); int j=0; for ( j=0; j<9 && tempj-'0'>=0 && tempj-'0'<=8; j+) targetj=te
10、mpj-'0' system("cls"); if ( i=9&&j=9) break; /* - end of function init - */ voidopen_insert (numNode *head,numNode *item) numNode *p,*q; p=head->next; q=head; while ( p!=NULL && item->value > p->value ) q=p; p=p->next; q->next=item; item->pre=q;
11、 item->next=p; if(p!=NULL) p->pre=item; /* - end of function open_insert - */ numNode *open_getfirst (numNode *head) numNode *p; if ( head->next = NULL ) return NULL; p=head->next; head->next=p->next; if ( p->next != NULL ) p->next->pre=head; p->pre=NULL; p->next=NUL
12、L; return p; /* - end of function open_getfirst - */ voidclose_append (numNode *head,numNode *item) item->next=head->next; item->pre=head; head->next=item; if ( item->next!=NULL ) item->next->pre=item; /* - end of function close_append - */ intexpand (numNode *p1) numNode * p2;
13、int op=1; for ( op=1; op<=4; op+) p2=copy_numNode(p1); operate(p2->num,op); if(isNewNode(open,close,p2->num)='N') p2->parent=p1; p2->deepth=p1->deepth+1; p2->diffnum=diff(p2->num); p2->value=p2->deepth+p2->diffnum; if(p2->diffnum=0) total_step=print_result
14、(p2); printf("Total step: %dn",total_step); free_list(open); free_list(close); return 1; else numNode_num+; open_insert(open,p2); else free(p2); return 0; /* - end of function expand - */ intoperate(int m, int op) int blank; blank=0; while (mblank!=0 && blank<9 ) +blank; if (bla
15、nk=9) return 1; switch (op) case 1: /* up */ if (blank>2) swap(m+blank,m+blank-3); break; case 2: /* down */ if (blank<6) swap(m+blank,m+blank+3); break; case 3: /* left */ if (blank!=0 && blank!=3 && blank!=6) swap(m+blank,m+blank-1); break; case 4: /* right */ if (blank!=2 &a
16、mp;& blank!=5 && blank!=8) swap(m+blank,m+blank+1); break; default : return 1; return 0; voidswap(int *a, int *b) int c; c=*a; *a=*b; *b=c; numNode *copy_numNode (numNode *origin) numNode *p; p=create_numNode(); p->deepth=origin->deepth; p->diffnum=origin->diffnum; p->valu
17、e=origin->value; int i; for ( i=0; i<9; i+) (p->num)i=(origin->num)i; return p; /* - end of function copy_numNode - */ intdiff (int num9) int i,diffnum=0; for(i=0;i<9;i+) if(numi!=targeti) diffnum+; return diffnum; /* - end of function diff - */ charisNewNode (numNode *open,numNode *c
18、lose,int num9) numNode *p; int i=0; p=open->next; while ( p!=NULL ) for ( i=0; i<9; i+) if(p->numi!=numi) break; if(i=9) return 'O' /Open p=p->next; p=close->next; while ( p!=NULL ) for ( i=0; i<9; i+) if(p->numi!=numi) break; if(i=9) return 'C' /Close p=p->ne
19、xt; return 'N' /* - end of function isNewNode - */ voidfree_list (numNode *head) numNode *p,*q; p=head->next; while ( p!=NULL ) q=p->next; free(p); p=q; free(head); /* - end of function free_list - */ voidprint_num (int num9) int i; for ( i=0; i<9; i+) printf("%dt",numi);
20、if(i%3)=2) printf("n"); /* - end of function print_num - */ intprint_result ( numNode *item) numNode *p; int step; p=item; if(p!=NULL) step=print_result(p->parent); printf("nStep %d:n",step+1); print_num(p->num); return step+1; else return -1; 4. 结果: 下图实验结果中,一步代表一层的搜索结果中的最优
21、解;八数码难题的宽度优先搜索树:5. 实验分析宽度优先搜索属于一种盲目搜索算法,可以系统的展开所有节点,理论上一定能达到搜寻目的。但是,倘若搜索步骤太多,则会十分费时,所以应考虑具体问题具体改进。 本实验结果中,一步代表一层的搜索结果中的最优解;以简化输出显示,实验耗时也在可以接受的程度。 6. 结论 经过分析和查询相关资料,本报告决定采用宽度优先搜索来求解问题,划定流程图及明确算法步骤之后,经多次调试和修改,最终得出有效结论,找出了八数码难题的解。 本报告严格依照实验和报告的要求进行,从分析查找到最终得出阶段性结论的过程中,收获了宝贵的经验。 人工神经网络和神经模糊技术,在用图像处理甜樱桃果
22、实成熟过程中,检测抗氧化活性与花青素的量时的潜力评估摘要背景本文介绍了一种别样的思路,糅合了图像处理技术和两种人工智能技术,在樱桃成熟的不同阶段,检测抗氧化活性与花青素的量。与普通的冗长实验理论相比,本方法有重要贡献,它更经济,更快捷。精确地人工神经网络技术(ANN),和自适应神经模糊推理系统理论(ANFIS),被用以检测输出。ANN and ANFIS使用的敏感性分析和主成分分析,分别指出了输出的有效属性。RESULTS结果Among the designed ANNs, two hidden layer networks with 11-14-9-1 and 11-6-20-1 archi
23、tectures had the highest correlation coefficients and lowest error values for modeling antioxidant activity (R = 0.93) and anthocyanin content (R = 0.98) respectively. ANFIS models with triangular and two-term Gaussian membership functions gave the best results for antioxidant activity (R = 0.87) an
24、d anthocyanin content (R = 0.90) respectively.所设计的神经网络中,两个隐层的网络体系结构和11-6-20-1 11-14-9-1,具有最高的相关系数和最低误差值,抗氧化活性(R = 0.93)和花青素含量(R = 0.98)。ANFIS模型的三角函数和两项高斯隶属函数,给出了最好的结果,分别是:抗氧化活性(R = 0.87)和花青素含量(R = 0.90)。CONCLUSION结论Comparison of the models showed that ANN outperformed ANFIS for this case. By conside
25、ring the advantages of the applied system and the accuracy obtained in somewhat similar studies, it can be concluded that both techniques presented here have good potential to be used as estimators of proposed attributes. © 2013 Society of Chemical Industry模型的比较表明,人工神经网络优于ANFIS这个案子。考虑到类似的研究应用系统
26、和精度的优点,可以得出这样的结论:这里介绍的技术有很好的潜力被用作估计该属性。©2013化学工业协会简介甜樱桃(Prunus avium)是一种流行的水果,无论新鲜的还是加工过的。,伊朗被评为世界第三大甜樱桃生产国,每年生产约241117MT。Humans live in a highly oxidative environment, and many processes involved in metabolism may result in the production of excess free radicals, which can lead to health probl
27、ems.2 Oxidation causes the formation of toxic compounds that are harmful to human health, such as reactive oxygen species and free radicals, which can lead to carcinogenesis, mutagenesis, inflammation, DNA changes, aging, cardiovascular disease and nutritional loss.3-5 In addition, oxidation may res
28、ult in unpleasant flavor and rancid taste.6, 7 There is growing interest among food producers and consumers in the use of natural antioxidants because of their protective role against oxidation.8 Thus it may be beneficial to find a rapid and non-destructive way for estimating this attribute in fruit
29、s as an important source of antioxidants.人类生活在一个高度氧化的环境,参与许多代谢过程可能会导致过量的自由基的产生,从而导致健康问题。氧化导致有毒化合物的形成,如活性氧和自由基,从而导致致癌,诱变,炎症,基因的变化,老化,心血管疾病和营养损失,对人类的健康是有害的。另外,氧化可能会导致不愉快的味道和腐臭。含有天然抗氧化剂的食品,因为其抗氧化保护作用,越来越受生产商和消费者的欢迎。可以有利于发现估计这个属性在水果作为一种重要的的。寻找一种快速的,非破坏性的方式,检测水果的这个属性,作为抗氧化剂的重要来源,有利可图。花青素,植物颜料中这是最常见的,似乎有多
30、种功能。例如,作为着色剂和食品质量控制指标。最近,增近对它的了解,发现对人体健康有利,已经导致花青素研究加剧。近年来,Various data mining/artificial intelligence (DM/AI) techniques such as decision trees, artificial neural networks (ANNs), genetic algorithms, fuzzy sets, expert systems, etc. have been increasingly applied in combination with machine vision
31、(MV) for agricultural product quality evaluation in recent years各种数据挖掘、人工智能(DM / AI)技术,如决策树,人工神经网络(ANN),遗传算法,模糊集,专家系统等,已被越来越多地应用于机器视觉的组合(MV),以进行农产品质量评价。农产品的图像处理的一个新领域被用来估计一些质量属性,如植物色素的抗氧化活性。采用独立分量分析的西红柿光谱图像,估计番茄红素和叶绿素浓度。最近,taghadomi萨贝里等人,结合图像处理和人工神经网络技术,在酸樱桃在成熟过程中,估计抗氧化活性与花青素含量。Given the facts that
32、antioxidants have an important role in human life nowadays and that conventional methods for their determination are expensive, destructive and time-consuming, this study aims to propose, devise and evaluate the possibility of using an intelligent system based on a combination of MV and two widely u
33、sed DM techniques for estimating the antioxidant activity and anthocyanin content of sweet cherries during ripening.目前,传统的检测方法是昂贵的,破坏性的,耗时的,鉴于抗氧化剂在人类生活中有重要作用,本研究提出设计和评估的可能性,使用智能系统相结合的基础上的MV和两种广泛使用的数据挖掘技术,估计甜蜜樱桃成熟期的,抗氧化活性与花青素的含量。结论本文提出了一种低成本的,非破坏性的和快速的方法,来估计甜樱桃成熟过程中,抗氧化活性和花青素含量。反向传播人工神经网络与trainlm作为训练函数,tansig作为传递函数。与11-14-9-1和11-6-20-1网络架构了最好的结果,模型的抗氧化活性和花色苷含量分别为(R = 0.93,0.98)。一个神经模糊技术也适用于建模提出的属性。其中,三角函数和两项高斯磁场给了最好的结果,抗氧化活性与花色素苷含量分别为(R = 0.93,0.98)。基于统计标准,人工
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论