📄 main.cpp
字号:
#include "matlib.h"
#pragma hdrstop
#include "main.h"
#include "ga.h"
#include "initializega.h"
#include "calcbits.h"
#include "parse.h"
#include "b2f.h"
Mm main() {
begin_scope
dMm(bounds); dMm(p); dMm(endPop); dMm(bestSols); dMm(trace_);
call_stack_begin;
// nargin, nargout entry code
double old_nargin=nargin_val; if (!nargin_set) nargin_val=0.0;
nargin_set=0;
double old_nargout=nargout_val; if (!nargout_set) nargout_val=0.0;
nargout_set=0;
// translated code
//n=2
//设置边界条件
bounds = ones(2.0,1.0)*(BR(-1.0),1.0);
//遗传算法优化
/*[p,endPop,bestSols,trace_] = */
ga(bounds,TM("f552"),i_o,p,endPop,bestSols,trace_);
//性能跟踪
display( plot((CL(trace_(c_p,1.0)),trace_(c_p,3.0),TM("b-"))) );
hold(TM("on"));
display( plot((CL(trace_(c_p,1.0)),trace_(c_p,2.0),TM("r-"))) );
xlabel((CL(TM("Generation"))));
ylabel((CL(TM("Fittness"))));
legend((CL(TM("解的变化")),TM("种群的变化")));
call_stack_end;
// nargin, nargout exit code
nargin_val=old_nargin; nargout_val=old_nargout;
// function exit code
return x_M;
end_scope
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -