这是一个遗传算法的一部分,在程序运行后,出现:??? Error: File: D:/MATLAB6p5/work/Untitled2.m Line: 1Column: 1Missing variable or function.不知道为什么。 #include<stdio.h>#include<stdlib.h>#include<math.h>#include<alloc.h>#include<conio.h>#include<float.h>#include<time.h>#include<graphics.h>#include<bios.h>#define maxpop 100#define maxstring 100struct pp{unsigned char chrom[maxstring]; float x,fitness; unsigned int parent1,parent2,xsite; };struct pp *oldpop,*newpop,*p1;unsigned int popsize,lchrom,gem,maxgen,co_min,jrand;unsigned int nmutation,ncross,jcross,maxpp,minpp,maxxy;float pcross,pmutation,sumfitness,avg,max,min,seed,maxold,oldrand[maxstring];unsigned char x[maxstring],y[maxstring];float *dd,ff,maxdd,refpd,fm[201];FILE *fp,*fp1;float objfunc(float);void statistics();int select();int flip(float);int crossover();void generation();void initialize();void report();float decode();void crtinit();void inversion();float random1();void randomize1();main(){unsigned int gen,k,j,tt;char fname[10];float ttt;clrscr();co_min=0;if((oldpop=(struct pp *)farmalloc(maxpop*sizeof(struct pp)))==NULL){printf("memory requst fail!/n");exit(0);}if((dd=(float *)farmalloc(maxstring*maxstring*sizeof(float)))==NULL){printf("memory requst fail!/n");exit(0);}if((newpop=(struct pp *)farmalloc(maxpop*sizeof(struct pp)))==NULL){printf("memory requst fail!/n");exit(0);}if((p1=(struct pp *)farmalloc(sizeof(struct pp)))==NULL){printf("memory requst fail!/n");exit(0);}for(k=0;k<maxpop;k++) oldpop[k].chrom[0]='{MAIN_FORM}';for(k=0;k<maxpop;k++) newpop[k].chrom[0]='{MAIN_FORM}';printf("Enter Result Data Filename:");gets(fname);if((fp=fopen(fname,"w+"))==NULL){printf("cannot open file/n");exit(0);}
第一行的第一个空格去了 没有变化. 这是在网上直接下载的程序,据说是matlab。还有,哪位高手会编写基于遗传算法排的课表的matlab程序?我初学matlab,很多不懂。
|