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

📄 rounder.m

📁 国外专家做的求解LMI鲁棒控制的工具箱,可以相对高效的解决LMI问题
💻 M
字号:
function [upper,x_min] = rounder(p,relaxedsolution)

% Extremely simple heuristic for finding integer
% solutions.
%
% Rounds up and down, fixes etc.

% This was the relaxed solution
x = relaxedsolution.Primal;

% Assume we fail
upper = inf;
x_min = x;

% These should be integer
intvars = [p.integer_variables(:);p.binary_variables(:)];
p.options.rounding = [1 1 1 1];
if p.options.rounding(1)
    % Round, update nonlinear terms, and compute feasibility
    xtemp = x;xtemp(intvars) = round(xtemp(intvars));
    xtemp = setnonlinearvariables(p,xtemp);  
    res = computeconstraintresiduals(p,xtemp);
    
    % Allow some error
    if res>-p.options.bnb.feastol
        x_min = xtemp;
        upper = p.f+x_min'*p.Q*x_min + p.corig'*x_min;
        return
    end
end

if p.options.rounding(2)
    % Do same using fix instead
    xtemp = x;xtemp(intvars) = fix(xtemp(intvars));
    xtemp = setnonlinearvariables(p,xtemp);  
    res = computeconstraintresiduals(p,xtemp);
    if res>-p.options.bnb.feastol
        x_min = xtemp;
        upper = p.f+x_min'*p.Q*x_min + p.corig'*x_min;
        return
    end
end

if p.options.rounding(3)
    % ...or ceil
    xtemp = x;xtemp(intvars) = ceil(xtemp(intvars));
    xtemp = setnonlinearvariables(p,xtemp);  
    res = computeconstraintresiduals(p,xtemp);
    if res>-p.options.bnb.feastol
        x_min = xtemp;
        upper = p.f+x_min'*p.Q*x_min + p.corig'*x_min;
        return
    end
end

if p.options.rounding(4)
    % or floor
    xtemp = x;xtemp(intvars) = floor(xtemp(intvars));
    xtemp = setnonlinearvariables(p,xtemp);  
    res = computeconstraintresiduals(p,xtemp);
    if res>-p.options.bnb.feastol
        x_min = xtemp;
        upper = p.f+x_min'*p.Q*x_min + p.corig'*x_min;
        return
    end
end

⌨️ 快捷键说明

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