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

📄 savegeneticalgorithmproblem.m

📁 遗传算法工具包
💻 M
字号:
function saveGeneticAlgorithmProblem(problem)
%private to gatool, gaguiimportproblem

%   Copyright 2004 The MathWorks, Inc. 
%   $Revision: 1.2 $  $Date: 2004/01/16 16:51:11 $

%Create a temporary structure to save in appdata
if validrandstates(problem)
    tempstruct.randstate = problem.randstate;
    tempstruct.randnstate = problem.randnstate;
else
    tempstruct.randstate = [];
    tempstruct.randnstate = [];
end

if isfield(problem,'fitnessfcn') 
    tempstruct.fitnessfcn = problem.fitnessfcn;
else
    tempstruct.fitnessfcn = [];
end
if isfield(problem,'nvars')
    tempstruct.nvars = problem.nvars;
else
    tempstruct.nvars = [];
end
setappdata(0,'gads_gatool_problem_data',tempstruct);
%Save options;
if isfield(problem, 'options')
    setappdata(0,'gads_gatool_options_data',problem.options);
end
%------------------------------------------------------------------------
function valid = validrandstates(problem)
    valid = false;
    if isfield(problem, 'randstate') && isfield(problem, 'randnstate') && ...
       isa(problem.randstate, 'double') && isequal(size(problem.randstate),[35, 1]) && ...
       isa(problem.randnstate, 'double') && isequal(size(problem.randnstate),[2, 1])
        valid = true;
    end

⌨️ 快捷键说明

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