基于共识的捆绑算法CBBA实现多无人机多任务调度附matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法       神经网络预测       雷达通信       无线传感器        电力系统

信号处理              图像处理               路径规划       元胞自动机        无人机 

⛄ 内容介绍

Theorem 1. Provided that the scoring function is DMG (Diminishing Marginal Gain), the CBBA process with a conflflict resolution phase over a static communication network with diameter D satisfifiesthe following:

1. CBBA produces the same solution as SGA(sequentional greedy algo) with the corresponding winning bid values and winning agent information being shared across the flfleet ​

2. The convergence time Tc is bounded above by NminD.

⛄ 部分代码

% Runs consensus between neighbors

% Checks for conflicts and resolves among agents

%---------------------------------------------------------------------%

function [CBBA_Data t] = CBBA_Communicate(CBBA_Params, CBBA_Data, Graph, old_t, T)

% Copy data

for n = 1:CBBA_Params.N,

    old_z(n,:) = CBBA_Data(n).winners;

    old_y(n,:) = CBBA_Data(n).winnerBids;    

end

z = old_z;

y = old_y;

t = old_t;

epsilon = 10e-6;

% Start communication between agents

% sender   = k

% receiver = i

% task     = j

for k=1:CBBA_Params.N

    for i=1:CBBA_Params.N

        if( Graph(k,i) == 1 )

            for j=1:CBBA_Params.M

                % Implement table for each task

                

                if( old_z(k,j) == k ) % Entries 1 to 4: Sender thinks he has the task

                

                    % Entry 1: Update or Leave

                    if( z(i,j) == i ) 

                        if( old_y(k,j) - y(i,j) > epsilon )  % Update

                            z(i,j) = old_z(k,j);

                            y(i,j) = old_y(k,j);

                        elseif( abs(old_y(k,j) - y(i,j)) <= epsilon )  % Equal scores

                            if( z(i,j) > old_z(k,j) )  % Tie-break based on smaller index

                                z(i,j) = old_z(k,j);

                                y(i,j) = old_y(k,j);

                            end

                        end

                        

                    % Entry 2: Update

                    elseif( z(i,j) == k ) 

                        z(i,j) = old_z(k,j);

                        y(i,j) = old_y(k,j);

                    

                    % Entry 3: Update or Leave

                    elseif( z(i,j) > 0 ) 

                        if( old_t(k,z(i,j)) > t(i,z(i,j)) )  % Update

                            z(i,j) = old_z(k,j);

                            y(i,j) = old_y(k,j);

                        elseif( (old_y(k,j) - y(i,j)) > epsilon )  % Update

                            z(i,j) = old_z(k,j);

                            y(i,j) = old_y(k,j);

                        elseif( abs(old_y(k,j) - y(i,j)) <= epsilon )  % Equal scores

                            if( z(i,j) > old_z(k,j) )  % Tie-break based on smaller index

                                z(i,j) = old_z(k,j);

                                y(i,j) = old_y(k,j);

                            end

                        end

                

                    % Entry 4: Update

                    elseif( z(i,j) == 0 )

                        z(i,j) = old_z(k,j);

                        y(i,j) = old_y(k,j);

                        

                    else

                        disp('Unknown winner value: Should not be here, please revise')

                    end

                    

                elseif( old_z(k,j) == i ) % Entries 5 to 8: Sender thinks receiver has the task

                    % Entry 5: Leave

                    if( z(i,j) == i ) 

                        % Do nothing

                        

                     % Entry 6: Reset

                    elseif( z(i,j) == k ) 

                        z(i,j) = 0;

                        y(i,j) = 0;

                   

                     % Entry 7: Reset or Leave

                    elseif( z(i,j) > 0 ) 

                        if( old_t(k,z(i,j)) > t(i,z(i,j)) )  % Reset

                            z(i,j) = 0;

                            y(i,j) = 0;

                        end

                        

                    % Entry 8: Leave

                    elseif( z(i,j) == 0 )

                        % Do nothing

                        

                    else

                        disp('Unknown winner value: Should not be here, please revise')

                    end

                   

                elseif( old_z(k,j) > 0 ) % Entries 9 to 13: Sender thinks someone else has the task

                    

                    % Entry 9: Update or Leave

                    if( z(i,j) == i ) 

                        if( old_t(k,old_z(k,j)) > t(i,old_z(k,j)) )

                            if ( (old_y(k,j) - y(i,j)) > epsilon )

                                z(i,j) = old_z(k,j);  % Update

                                y(i,j) = old_y(k,j);

                            elseif( abs(old_y(k,j) - y(i,j)) <= epsilon )  % Equal scores

                                if( z(i,j) > old_z(k,j) )  % Tie-break based on smaller index

                                    z(i,j) = old_z(k,j);

                                    y(i,j) = old_y(k,j);

                                end

                            end

                        end

                        

                     % Entry 10: Update or Reset

                    elseif( z(i,j) == k ) 

                        if( old_t(k,old_z(k,j)) > t(i,old_z(k,j)) )  % Update

                            z(i,j) = old_z(k,j);

                            y(i,j) = old_y(k,j);

                        else  % Reset

                            z(i,j) = 0;

                            y(i,j) = 0;

                        end

                        

                    % Entry 11: Update or Leave

                    elseif( z(i,j) == old_z(k,j) ) 

                        if( old_t(k,old_z(k,j)) > t(i,old_z(k,j)) )  % Update

                            z(i,j) = old_z(k,j);

                            y(i,j) = old_y(k,j);

                        end

                     

                    % Entry 12: Update, Reset or Leave

                    elseif( z(i,j) > 0 ) 

                        if( old_t(k,z(i,j)) > t(i,z(i,j)) )

                            if( old_t(k,old_z(k,j)) >= t(i,old_z(k,j)) )  % Update

                                z(i,j) = old_z(k,j);

                                y(i,j) = old_y(k,j);

                            elseif( old_t(k,old_z(k,j)) < t(i,old_z(k,j)) ) % Reset

                                z(i,j) = 0;

                                y(i,j) = 0;

                            else

                                disp('Should not be here, please revise')

                            end

                        else

                            if( old_t(k,old_z(k,j)) > t(i,old_z(k,j)) )

                                if( (old_y(k,j) - y(i,j)) > epsilon )  % Update

                                    z(i,j) = old_z(k,j);

                                    y(i,j) = old_y(k,j);

                                elseif( abs(old_y(k,j) - y(i,j)) <= epsilon )  % Equal scores

                                    if( z(i,j) > old_z(k,j) )   % Tie-break based on smaller index

                                        z(i,j) = old_z(k,j);

                                        y(i,j) = old_y(k,j);

                                    end

                                end

                            end

                        end

                    % Entry 13: Update or Leave

                    elseif( z(i,j) == 0 )

                        if( old_t(k,old_z(k,j)) > t(i,old_z(k,j)) )  % Update

                            z(i,j) = old_z(k,j);

                            y(i,j) = old_y(k,j);

                        end

                        

                    else

                        disp('Unknown winner value: Should not be here, please revise')

                    end

                    

                elseif( old_z(k,j) == 0 ) % Entries 14 to 17: Sender thinks no one has the task

                    % Entry 14: Leave

                    if( z(i,j) == i ) 

                        % Do nothing

                        

                     % Entry 15: Update

                    elseif( z(i,j) == k ) 

                        z(i,j) = old_z(k,j);

                        y(i,j) = old_y(k,j);

                   

                     % Entry 16: Update or Leave

                    elseif( z(i,j) > 0 ) 

                        if( old_t(k,z(i,j)) > t(i,z(i,j)) )  % Update

                            z(i,j) = old_z(k,j);

                            y(i,j) = old_y(k,j);

                        end

                        

                    % Entry 17: Leave

                    elseif( z(i,j) == 0 )

                        % Do nothing

                        

                    else

                        disp('Unknown winner value: Should not be here, please revise')

                    end

                    

                    % End of table

                    

                else

                    disp('Unknown winner value: Should not be here, please revise')

                end

            end

            

            % Update timestamps for all agents based on latest comm

            for n=1:CBBA_Params.N

                if( n ~= i && t(i,n) < old_t(k,n) )

                    t(i,n) = old_t(k,n);

                end

            end

            t(i,k) = T;

            

        end

    end

end

% Copy data

for n = 1:CBBA_Params.N,

    CBBA_Data(n).winners    = z(n,:);

    CBBA_Data(n).winnerBids = y(n,:);

end​

end

⛄ 运行结果

⛄ 参考文献

⛳️ 代码获取关注我

❤️部分理论引用网络文献,若有侵权联系博主删除

❤️ 关注我领取海量matlab电子书和数学建模资料

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值