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

📄 moead.m

📁 基于微分的多目标优化问题
💻 M
字号:
function pareto = moead( mop, varargin)%MOEAD runs moea/d algorithms for the given mop.%   Detailed explanation goes here%   The mop must to be minimizing.%   The parameters of the algorithms can be set through varargin. including%   popsize: The subproblem's size.%   niche: the neighboursize, must less then the popsize.%   iteration: the total iteration of the moead algorithms before finish.%   method: the decomposition method, the value can be 'ws' or 'ts'.    starttime = clock;    %global variable definition.    global params idealpoint objDim parDim itrCounter;    %set the random generator.    rand('state',10);        %Set the algorithms parameters.    paramIn = varargin;    [objDim, parDim, idealpoint, params, subproblems]=init(mop, paramIn);        itrCounter=1;    while ~terminate(itrCounter)        tic;        subproblems = evolve(subproblems, mop, params);        disp(sprintf('iteration %u finished, time used: %u', itrCounter, toc));        itrCounter=itrCounter+1;    end        %display the result.    pareto=[subproblems.curpoint];    pp=[pareto.objective];    scatter(pp(1,:), pp(2,:));    disp(sprintf('total time used %u', etime(clock, starttime)));endfunction [objDim, parDim, idealp, params, subproblems]=init(mop, propertyArgIn)%Set up the initial setting for the MOEA/D.    objDim=mop.od;    parDim=mop.pd;        idealp=ones(objDim,1)*inf;        %the default values for the parameters.    params.popsize=100;params.niche=30;params.iteration=100;    params.dmethod='ts';    params.F = 0.5;    params.CR = 0.5;        %handle the parameters, mainly about the popsize    while length(propertyArgIn)>=2        prop = propertyArgIn{1};        val=propertyArgIn{2};        propertyArgIn=propertyArgIn(3:end);        switch prop            case 'popsize'                params.popsize=val;            case 'niche'                params.niche=val;            case 'iteration'                params.iteration=val;            case 'method'                params.dmethod=val;            otherwise                warning('moea doesnot support the given parameters name');        end    end        subproblems = init_weights(params.popsize, params.niche, objDim);    params.popsize = length(subproblems);        %initial the subproblem's initital state.    inds = randompoint(mop, params.popsize);    [V, INDS] = arrayfun(@evaluate, repmat(mop, size(inds)), inds, 'UniformOutput', 0);    v = cell2mat(V);    idealp = min(idealp, min(v,[],2));        %indcells = mat2cell(INDS, 1, ones(1,params.popsize));    [subproblems.curpoint] = INDS{:};    clear inds INDS V indcells;end    function subproblems = evolve(subproblems, mop, params)    global idealpoint;       for i=1:length(subproblems)        %new point generation using genetic operations, and evaluate it.        ind = genetic_op(subproblems, i, mop.domain, params);        [obj,ind] = evaluate(mop, ind);        %update the idealpoint.        idealpoint = min(idealpoint, obj);                %update the neighbours.        neighbourindex = subproblems(i).neighbour;        subproblems(neighbourindex)=update(subproblems(neighbourindex),ind, idealpoint);        %clear ind obj neighbourindex neighbours;                clear ind obj neighbourindex;    endendfunction subp =update(subp, ind, idealpoint)    newobj=subobjective([subp.weight], ind.objective,  idealpoint, 'te');    oops = [subp.curpoint];    oldobj=subobjective([subp.weight], [oops.objective], idealpoint, 'te' );        C = newobj < oldobj;    [subp(C).curpoint]= deal(ind);    clear C newobj oops oldobj;endfunction y =terminate(itrcounter)    global params;    y = itrcounter>params.iteration;end

⌨️ 快捷键说明

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