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

📄 buildmodel.m

📁 This matlab code on reed solomon and BCH encoding and different decoding algorithms. Also errors and
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% File: buildModel.m
%
% Description: Build the marginal product model using greedy search heuristic.
%
% @param ranges is the a vector containing the cardinality of each of the
% alphabet. For example if all variables are binary then ranges(1:ell) = 2.
%
% @param population is the population of candidate solutions
%
% @return mpm is a cell array with the local-best marginal product model,
% the subsolutions across all partitions present in the population, the
% associated frequencies of the the different subsolutions, and the MDL
% score.
%
% Author: Kumara Sastry
%
% Date: March 2007
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function mpm = buildModel(ranges, population)

ell = length(ranges);
n = size(population,1);

% First evaluate the independent model = {[1], [2], ... [m]}
clear model;
for i=1:ell
    model{i} = [i];
end

modelParameters = evaluateModel(model, population, ranges);

% Test all the pairwise additions of the models and get the one with lowest
% MDL score.
orderCombination=2;
while size(model,2) > 1,
    % Create a list of all possible two substructure merges
    clear arrayModels;
    arrayModels = createCombinations(model, orderCombination);

    % Evaluate the models and search for the best (lowest MDL) model
    clear newModel;
    clear newModelResults;
    newBestModel = arrayModels{1};
    newBestModelParameters = evaluateModel(newBestModel, population, ranges);
    for i = 2:size(arrayModels,2)
        clear newModel;
        clear newModelResults;
        newModel = arrayModels{i};
        newModelParameters = evaluateModel(newModel, population, ranges);
        if(newModelParameters.MDL < newBestModelParameters.MDL)
            newBestModel = newModel;
            newBestModelParameters = newModelParameters;
        end
    end
    % If the best model has lower MDL score than the lower than the
    % previous model accept it as the current best model and continue the
    % merging process
    if(newBestModelParameters.MDL < modelParameters.MDL)
        model = newBestModel;
        modelParameters = newBestModelParameters;
    else
        % None of the pairwise merges have lower MDL score than the current
        % best model. Therefore the current best model is the most
        % accurate, least complex model. 
        break;
    end
end

% Return the model, the subsolutions present, the frequency of the
% subsolutions, and the MDL score of the model
mpmContents = {model, modelParameters.SubSolutions, ...
    modelParameters.Probabilities, modelParameters.MDL};
mpmLabel = {'SubStructures', 'SubSolutions', 'Probabilities', 'MDL'};
mpm = cell2struct(mpmContents, mpmLabel, 2);

⌨️ 快捷键说明

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