• 【优化调度】基于与学算法实现库存优化控制问题附matlab代码


     1 内容介绍

    简要分析了群智能优化算法的研究现状,重点对"教与学"优化算法作了详细的描述,并分析了"教与学"算法的性能及其优缺点;随后介绍了几种改进的"教与学"优化算法,对"教与学"优化算法的应用研究情况进行了论述。最后,说明了目前"教与学"优化算法中存在的问题,并指出"教与学"优化算法未来的研究方向。

    2 仿真代码

    % TLBO Optimal Inventory Control

    %------------------------------------------
    clc;
    clear;
    close all;
    warning('off');
    %%-----------------------------------------
    model=CreateM();                        % Create Model
    model.Umax=100;
    CostFunction=@(xhat) MyCost(xhat,model);    % Cost Function
    VarSize=[model.K model.H];   % Size of Decision Variables Matrix
    nVar=prod(VarSize);    % Number of Decision Variables
    VarMin=0;         % Lower Bound of Variables
    VarMax=1;         % Upper Bound of Variables
    %% TLBO Parameters
    MaxIt = 250;        % Maximum Number of Iterations
    nPop = 150;           % Population Size
    %% Start
    % Empty Structure for Individuals
    empty_individual.Position = [];
    empty_individual.Cost = [];
    empty_individual.Sol=[];
    % Initialize Population Array
    pop = repmat(empty_individual, nPop, 1);
    % Initialize Best Solution
    BestSol.Cost = inf;
    % Initialize Population Members
    for i = 1:nPop
    pop(i).Position = unifrnd(VarMin, VarMax, VarSize);
    [pop(i).Cost, pop(i).Sol]= CostFunction(pop(i).Position);
    if pop(i).Cost < BestSol.Cost
    BestSol = pop(i);
    end
    end
    % Initialize Best Cost Record
    BestCosts = zeros(MaxIt, 1);
    %% TLBO Body
    for it = 1:MaxIt
    % Calculate Population Mean
    Mean = 0;
    for i = 1:nPop
    Mean = Mean + pop(i).Position;
    end
    Mean = Mean/nPop;
    % Select Teacher
    Teacher = pop(1);
    for i = 2:nPop
    if pop(i).Cost < Teacher.Cost
    Teacher = pop(i);
    end
    end
    % Teacher Phase
    for i = 1:nPop
    % Create Empty Solution
    newsol = empty_individual;
    % Teaching Factor
    TF = randi([1 2]);
    % Teaching (moving towards teacher)
    newsol.Position = pop(i).Position ...
    + rand(VarSize).*(Teacher.Position - TF*Mean);
    % Clipping
    newsol.Position = max(newsol.Position, VarMin);
    newsol.Position = min(newsol.Position, VarMax);
    % Evaluation
    [newsol.Cost, newsol.Sol]= CostFunction(newsol.Position);
    % Comparision
    if newsol.Cost pop(i) = newsol;
    if pop(i).Cost < BestSol.Cost
    BestSol = pop(i);
    end
    end
    end
    % Learner Phase
    for i = 1:nPop
    A = 1:nPop;
    A(i) = [];
    j = A(randi(nPop-1));
    Step = pop(i).Position - pop(j).Position;
    if pop(j).Cost < pop(i).Cost
    Step = -Step;
    end
    % Create Empty Solution
    newsol = empty_individual;
    % Teaching (moving towards teacher)
    newsol.Position = pop(i).Position + rand(VarSize).*Step;
    % Clipping
    newsol.Position = max(newsol.Position, VarMin);
    newsol.Position = min(newsol.Position, VarMax);
    % Evaluation
    [newsol.Cost, newsol.Sol]= CostFunction(newsol.Position);
    % Comparision
    if newsol.Cost pop(i) = newsol;
    if pop(i).Cost < BestSol.Cost
    BestSol = pop(i);
    end
    end
    end
    % Store Record for Current Iteration
    BestCosts(it) = BestSol.Cost;
    % Show Iteration Information
    disp(['In Iteration ' num2str(it) ': TLBO Best Cost Is = ' num2str(BestCosts(it))]);
    figure(1);
    PlotSol(BestSol.Sol,model);
    pause(0.01);
    end
    title('TLBO Optimal Inventory Control');
    %% Plot
    figure;
    semilogy(BestCosts,'k', 'LineWidth', 2);
    xlabel('Iteration');
    ylabel('Best Cost');
    grid on;

    function PlotSol(sol,model)
    K=model.K;
    H=model.H;
    I0=model.I0;
    X0=zeros(K,1);
    u=model.u;
    Umax=model.Umax;
    UC0=sum(u.*I0);

    X=sol.X;
    I=sol.I;
    UC=sol.UC;

    subplot(3,1,1);
    stairs(0:H,[X X0]',':','LineWidth',3);
    xlabel('Time');
    ylabel('Order Amount');

    subplot(3,1,2);
    stairs(0:H,[I0 I]','LineWidth',1);
    xlabel('Time');
    ylabel('Inventory ');

    subplot(3,1,3);
    stairs(0:H,[UC0 UC],'LineWidth',1);
    hold on;
    plot([0 H],[Umax Umax],'c:','LineWidth',3);
    hold off;
    xlabel('Time');
    ylabel('Used Capacity');

    end

    3 运行结果

    4 参考文献

    [1]程亚维. 基于教与学优化算法的模糊柔性作业车间的调度问题[J]. 新乡学院学报, 2021, 38(9):6.

    [2]杨文明, 顾幸生. 基于混沌优化算法的连续生产过程重调度与库存优化[J]. 华东理工大学学报:自然科学版, 2006, 32(7):4.

    博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

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

  • 相关阅读:
    计算机毕设(附源码)JAVA-SSM基于健身房管理系统
    Linux查看程序和动态库依赖的动态库
    VB-14
    如何用jxTMS开发一个功能(三)
    滑动谜题 -- BFS
    二、JavaScript
    2023年【道路运输企业安全生产管理人员】考试题库及道路运输企业安全生产管理人员模拟考试题库
    word批量修改表格样式
    js异步编程面试题你能答上来几道
    vue与es6的知识点
  • 原文地址:https://blog.csdn.net/matlab_dingdang/article/details/126093985