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

📄 reduce_bilinear_branching_variables.m

📁 matlab波形优化算法经常要用到的matlab toolbox工具箱:yalmip
💻 M
字号:
function p = reduce_bilinear_branching_variables(p);
if p.solver.lowersolver.objective.quadratic.convex & isempty(p.evalMap)
    % Setup quadratic
    Q_ = p.Q;
    for i = 1:size(p.bilinears,1)
        if p.c(p.bilinears(i,1))
            Q_(p.bilinears(i,2),p.bilinears(i,3)) = p.c(p.bilinears(i,1))/2;
            Q_(p.bilinears(i,2),p.bilinears(i,3)) = Q_(p.bilinears(i,3),p.bilinears(i,2))+p.c(p.bilinears(i,1))/2;
        end
    end
    if nnz(Q_)>0 & all(eig(full(Q_))>-1e-12)
        Used_in_F = find(any(p.F_struc(:,2:end),1));
        Used_in_F = intersect(Used_in_F,p.bilinears(:,1));
      %  old_branch =  p.branch_variables;
        p.branch_variables = [];
        for i = 1:size(p.bilinears,1)
            j = p.bilinears(i,1);
            if ismember(j,Used_in_F)
                p.branch_variables = [p.branch_variables p.bilinears(i,2:3)];
            end
        end
        p.branch_variables = unique(p.branch_variables);
     %   p.branch_variables = intersect(old_branch,p.branch_variables);
    end
end

% Do not branch in auxilliary variables introduced to simply normalize the
% nonlinear operators, such as cos(2x + y) replaced with cos(z), z==2x+y
% if ~isempty(p.evalMap)
%     if p.K.f > 0
%         allInArg = [];
%         for i = 1:length(p.evalMap)
%             allInArg = [allInArg p.evalMap{i}.variableIndex];
%         end
%         rmv = [];
%         for i = 1:length(p.evalMap)
%             inArg = p.evalMap{i}.variableIndex;
%             if length(inArg) == 1
%                 coeffs = p.F_struc(:,1 + inArg);
%                 pos = find(coeffs);
%                 if length(pos) == 1 & pos<=p.K.f
%                     watch out for x1+x2==1, minimize sin(x1)+sin(x2)
%                     a = p.F_struc(pos,2:end);
%                     a(inArg)=0;
%                     if ~any(ismember(find(a),allInArg))
%                         rmv = [rmv inArg];
%                     end
%                 end
%             end
%         end
%         p.branch_variables = setdiff( p.branch_variables,rmv);
%     end
% end

⌨️ 快捷键说明

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