report.m ( File view )

  • By xuhongyanphp 2016-05-19
  • View(s):0
  • Download(s):0
  • Point(s): 1
			function report(fname,chr,a,time)
aprint(a);
[n m]=size(chr);
if (n==1)
  print('Generation 1',fname,chr,a);
else	
  fid=fopen(strcat(fname,'.html'),'w');
  fprintf(fid,'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">');
  fprintf(fid,'<html><head>');
  fprintf(fid,'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
  fprintf(fid,'<title>');
  fprintf(fid,'MGA RESULT');
  fprintf(fid,'</title></head>');
  fprintf(fid,'<body>');
  fprintf(fid,'Test started: ');
  fprintf(fid,time);
  fprintf(fid,strcat('&nbsp;ended&nbsp;', datestr(now)));
  fprintf(fid,'<hr>');
  fprintf(fid,'<b>Figures:</b>&nbsp;');
  fprintf(fid,'<a href="fig1.eps.gz">Max and average fitness</a>&nbsp;&nbsp');
  fprintf(fid,'<a href="fig2.eps.gz">Maximum of the Species</a>&nbsp;&nbsp');
  fprintf(fid,'<a href="fig3.eps.gz">Distribution of members</a>');
  fprintf(fid,'<hr>');
  fprintf(fid,'<b>Species:</b>&nbsp;&nbsp;');
  
  for k=1:length(a)
    dname=get(a(k),'name');
    fprintf(fid,'<a href="');
    fprintf(fid,strcat(dname,'.html','">',dname,'</a>','&nbsp;&nbsp;&nbsp;'));
  end
  fprintf(fid,'<hr>');
  

  fprintf(fid,'<b>Optimized  species:</b>&nbsp;&nbsp;&nbsp;');
  for k=1:length(a)
    dname=get(a(k),'name');
    for l=n:-1:1
      if find(chr(l,:),dname)
	fprintf(fid,'<a href="');
	fprintf(fid,strcat('mga_node',num2str(l),'.html#',dname,'">',dname,'</a>','&nbsp;&nbsp;&nbsp;'));
	break;
      end
    end
  end
  fprintf(fid,'<hr>');


  [mx g_max]=max(chr(n,:));
  fprintf(fid,'<h4>Maximum fitness: %g ',mx);fprintf(fid,'<br>');
  fprintf(fid,'Average fitness: %g ',mean(chr(n,:)));fprintf(fid,'<br>');
  fprintf(fid,'Minimum fitness: %g ',min(chr(n,:)));fprintf(fid,'</h4>'); 
  fprintf(fid,'<hr>');
  fprintf(fid,'<b>Best Design</b><br>');
  write(fid,g_max);
  fprintf(fid,'<hr>');
    
  fprintf(fid,'<b>Generations</b><br>');		
  for k=n:-1:1
    fprintf(fid,'<a href="./');
    fprintf(fid,strcat('mga_node',num2str(k),'">'));
    fprintf(fid,strcat('Generation&nbsp; ',num2str(k)));
    fprintf(fid,'</a><br>');		
    if(k==n)
      tprint(strcat('Generation&nbsp;',num2str(n)),strcat('mga_node',num2str(n),'.html'),chr(n,:),a,1,0);    
    elseif(k==1)
      tprint(strcat('Generation&nbsp;',num2str(k)),strcat('mga_node',num2str(k),'.html'),chr(k,:),a,0,1);
    else
      tprint(strcat('Generation&nbsp;',num2str(k)),strcat('mga_node',num2str(k),'.html'),chr(k,:),a,1,1);
    end
    
  end	
  fclose(fid);		

end


function write(fid,c)
% SAVE_CHROM - saves a chromosome to file
%   

for j=1:length(c)
 fprintf(fid,'Name: %s',get(c(j),'name'));fprintf(fid,'<br>'); 
  txt=sprintf('Fitness: %g',get(c(j),'fitness'));
  fprintf(fid,'%s',txt); fprintf(fid,'<br>');		


  fprintf(fid,'Design variables:<br>');

  cdvs=get(c(j),'cdvs');
  if (~isempty(cdvs))
   for k=1:length(cdvs)
     fprintf(fid,'%s = %g',get(cdvs(k),'name'),get(cdvs(k),'value'));
     fprintf(fid,'<br>');	
   end
  end
	
  ddvs=get(c(j),'ddvs');
  if (~isempty(ddvs))
   for k=1:length(ddvs)
     fprintf(fid,'%s = %g',get(ddvs(k),'name'),get(ddvs(k),'value'));	
     fprintf(fid,'<br>');	
   end
  end
  fprintf(fid,'----------------------<br>');	
end


function tprint(tit,fname,chr,arch,prev,next)
% PRINT - Prints a summary of a generation  to a file specified by 'fname'
%   print('fname',chr,arch) saves the generation chr to file 'fname'
%   arch is the prototypes for the species.
% See also LOGBOOK
chr=sort(chr);
chr=fliplr(chr);
fid=fopen(fname,'w');
fprintf(fid,'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">');
fprintf(fid,'<html>');
fprintf(fid,'<head>');
fprintf(fid,'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
fprintf(fid,'<title>');
fprintf(fid,tit);
fprintf(fid,'</title></head>');
fprintf(fid,'<body>');

node=sscanf(tit(17:end),'%i');
if(prev==1)
  tmp='<a href="';
  tmp=strcat(tmp,strcat('mga_node',num2str(node-1),'.html">'),'prev</a>&nbsp;&nbsp;');	
  fprintf(fid,tmp);
end

if(next==1)
  tmp='<a hr
...
...
(Please download the complete source code to view)
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
cdv.m842.00 B28-04-07|18:21
display.m313.00 B28-04-07|18:21
get.m399.00 B28-04-07|18:21
set.m408.00 B28-04-07|18:21
chrom.m1.38 kB28-04-07|18:21
display.m447.00 B28-04-07|18:21
eq.m127.00 B28-04-07|18:21
export.m1.36 kB28-04-07|18:21
find.m305.00 B28-04-07|18:21
ge.m147.00 B28-04-07|18:21
get.m1.08 kB28-04-07|18:21
gt.m138.00 B28-04-07|18:21
impfit.m398.00 B28-04-07|18:21
import.m603.00 B28-04-07|18:21
import_values.m225.00 B28-04-07|18:21
init.m540.00 B28-04-07|18:21
le.m143.00 B28-04-07|18:21
lt.m132.00 B28-04-07|18:21
max.m648.00 B28-04-07|18:21
mean.m365.00 B28-04-07|18:21
median.m357.00 B28-04-07|18:21
min.m626.00 B28-04-07|18:21
nmbr_of_members.m197.00 B28-04-07|18:21
plot.m1.61 kB28-04-07|18:21
plus.m590.00 B28-04-07|18:21
pmga.m214.00 B28-04-07|18:21
print.m2.56 kB28-04-07|18:21
replace.m749.00 B28-04-07|18:21
report.m5.84 kB28-04-07|18:21
set.m1.02 kB28-04-07|18:21
sort.m370.00 B28-04-07|18:21
std.m562.00 B28-04-07|18:21
tagem.m220.00 B28-04-07|18:21
ddv.m1.40 kB28-04-07|18:21
display.m271.00 B28-04-07|18:21
get.m342.00 B28-04-07|18:21
set.m277.00 B28-04-07|18:21
convert.m312.00 B28-04-07|18:21
display.m131.00 B28-04-07|18:21
eq.m303.00 B28-04-07|18:21
find.m286.00 B28-04-07|18:21
gen.m612.00 B28-04-07|18:21
get.m1.11 kB28-04-07|18:21
init.m823.00 B28-04-07|18:21
isempty.m205.00 B28-04-07|18:21
ne.m311.00 B28-04-07|18:21
plus.m1.00 kB28-04-07|18:21
bin2int.m93.00 B28-04-07|18:21
set.m1.09 kB28-04-07|18:21
children.m796.00 B28-04-07|18:21
cload.m2.90 kB28-04-07|18:21
Contents.m2.15 kB28-04-07|18:21
csave.m1.86 kB28-04-07|18:21
load_chrom.m1.12 kB28-04-07|18:21
load_mut.m742.00 B28-04-07|18:21
logbook.m614.00 B28-04-07|18:21
mailme355.35 kB28-04-07|18:21
mailme.m265.00 B28-04-07|18:21
morph.m1.44 kB28-04-07|18:21
mutate.m1.03 kB28-04-07|18:21
parents.m6.60 kB28-04-07|18:21
probmut.m2.10 kB28-04-07|18:21
save_chrom.m1.93 kB28-04-07|18:21
ui_chrom.m4.67 kB28-04-07|18:21
ui_gen.m8.41 kB28-04-07|18:21
ui_mutate.m2.24 kB28-04-07|18:21
private0.00 B03-06-07|15:47
@cdv0.00 B03-06-07|15:47
@chrom0.00 B03-06-07|15:47
@ddv0.00 B03-06-07|15:47
@gen0.00 B03-06-07|15:47
多目标遗传算法工具箱0.00 B03-06-07|15:47
...
Sponsored links

report.m (121.73 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D