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

📄 evaluate_nonlinear.m

📁 matlab波形优化算法经常要用到的matlab toolbox工具箱:yalmip
💻 M
字号:
function x = evaluate_nonlinear(p,x,qq)

% FIX: We have to apply computations to make sure we are evaluating
% expressions such as log(1+sin(x.^2).^2) correctly

if ~isempty(p.bilinears) & all(p.variabletype <= 2) & length(p.evalMap)==0
    x(p.bilinears(:,1)) = x(p.bilinears(:,2)).*x(p.bilinears(:,3));
else
    oldx = 0*p.c;old(1:length(x))=x;
    %try
    x = process_polynomial(x,p);
    %catch
    %    1
    %end
    x = process_evaluations(x,p);
    while norm(x - oldx)>1e-8
        oldx = x;
        x = process_polynomial(x,p);
        x = process_evaluations(x,p);
    end
end

function x = process_evaluations(x,p)
for i = 1:length(p.evalMap)
    arguments = {p.evalMap{i}.fcn,x(p.evalMap{i}.variableIndex)};
    arguments = {arguments{:},p.evalMap{i}.arg{2:end-1}};
    x(p.evalVariables(i)) = feval(arguments{:});
    if ~isempty(p.bilinears)
        x = process_bilinear(x,p);
    end
end

function x = process_bilinear(x,p)
x(p.bilinears(:,1)) = x(p.bilinears(:,2)).*x(p.bilinears(:,3));

function x = process_polynomial(x,p)
x = x(1:length(p.c));
nonlinear = find(p.variabletype);
x(nonlinear) = prod(repmat(x(:)',length(nonlinear),1).^p.monomtable(nonlinear,:),2);

⌨️ 快捷键说明

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