⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evaluate_tree.m

📁 The Source of Genetic Programming developed in Matlab
💻 M
字号:
function ret=evalutate_tree(tree,X)
%EVALUATE_TREE    Alternative to using 'eval' in 'regfitness' in GPLAB.
%   EVALUATE_TREE(TREE,X) evaluates a GPLAB tree when the "nesting 32"
%   error is issued by the 'eval' function in the 'regfitness.m' function.
%   It returns the same as 'eval' would. This is only needed in the most
%   recent MATLAB releases.
%
%   See also REGFITNESS
%
%   Created (2007) by Marco Medori (marco.medori@poste.it) and Bruno Morelli
%   This file is part of the GPLAB Toolbox

    [tmp ll]=size(X);
    op=tree.op;
    if isempty(tree.kids)
        for i=1:ll
            op=strrep(op,strcat('X',num2str(i)),strcat('X(:,',num2str(i),')'));
        end       
        ret=op;
        return    
    end
    op=strcat(tree.op,'(');
    ll=length(tree.kids);
    for i=1:ll
        argument=evaluate_tree(tree.kids{1,i},X);
        op=strcat(op,argument);
        if i<ll
            op=strcat(op,',');
        end
    end
    op=strcat(op,')');
    ret=mat2str(eval(op));
return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -