A brief introduction to immune algorithms

The word “Immune” is derived from Latin. It has long been noted that people who recover from infectious diseases have varying degrees of immunity to the disease. In medicine, immunity refers to a physiological response of the body in contact with antigenic foreign bodies. In 1958, Burnet, an Australian scholar, first proposed A theory related to Immune Algorithm (I A) — clonal selection principle [1]. In 1973, Jer Ne proposed the model of immune system [2]. Based on Burnet’s clonal selection theory, he initiated the theory of unique type network, provided the mathematical framework of immune system, and adopted differential equation modeling to simulate the dynamic changes of lymphocytes. In 1986, Farm Al et al. constructed a dynamic model of the immune system based on the immune network theory, which demonstrated the possibility of combining the immune system with other artificial intelligence methods and pioneered the study of the immune system. They first use of a set of random differential equation set up artificial immune system, and through the adoption of fitness threshold filtering method removes the inappropriate differential equation equations, preserved the differential equation of stay is use the genetic operations such as crossover and mutation, reverse cause a new differential equation, through constant iterative calculation, until find the best of a set of differential equations. Since then, the research on immune algorithm has aroused more and more scholars’ interest in the world. Over the decades, the related research achievements have been involved in nonlinear optimization, combinatorial optimization, control engineering, robotics, fault diagnosis, image processing and many other fields [3-6]. Immune algorithm is a new intelligent optimization algorithm artificially constructed by imitating biological immune mechanism and combining with gene evolution mechanism. It has the characteristics of the general immune system, adopts the population search strategy, and finally obtains the optimal solution with a high probability through iterative calculation. Compared with other algorithms, immune algorithm makes use of its own characteristics of generating diversity and maintaining mechanism to ensure the diversity of population, overcomes the inevitable “premature” problem in general optimization process (especially multi-peak optimization process), and can obtain the global optimal solution. Immune algorithm has the advantages of adaptability, randomness, parallelism, global convergence and population diversity.

Biological immune system is a complex adaptive system. The immune system recognizes pathogens and has the ability to learn, remember and recognize patterns, so its information processing mechanisms can be borrowed to solve scientific and engineering problems. Immune algorithm is based on the learning mechanism of biological immune system to recognize external pathogens and generate antibodies to fight against pathogens, thus giving birth to a new research direction of intelligent optimization methods based on immune principles.

2.1 Biological Immune System Traditional immunity refers to the body’s defense ability against infection, while modern immunity refers to the body’s immune system’s recognition and elimination of antigenic foreign bodies, so as to maintain the body’s physiological balance and stability. Immunity is a physiological response of the body. When pathogens (i.e. antigens) enter the body, these antigens will stimulate immune cells (lymphocytes B cells, T cells) to produce a special protein-antibody against the pathogen. Antibodies can destroy the pathogen and remain in the human body after the elimination of the pathogen. When the same pathogen invades the human body again, it will be quickly destroyed by the antibodies remaining in the body [7]. Immunity is the sum of biological effects produced in the process of recognition and response of the body and itself. Under normal circumstances, it is a physiological function to maintain the stable circulation of the body. The organism recognizes foreign antigens, produces immune response to them and removes them. The body does not produce an immune response to its own antigens. Antigen An antigen is a substance that stimulates and binds to an immune response. It is not an organic part of the immune system, but it is the initiating factor that initiates the immune response. Antibody Antibody is an immune molecule that can specifically identify and clear antigens. It has globulin substances with anti-bacterial and anti-toxin immune functions, so antibody is also called immunoglobulin molecules. It is produced by plasma cells differentiated into B cells. T cells and B cells T cells and B cells are the main components of lymphocytes. Stimulated by antigen, B cells can proliferate and differentiate into a large number of plasma cells, which have the function of synthesizing and secreting antibodies. However, B cells cannot recognize most antigens, so helper T cells that can recognize antigens must be used to assist B cell activation and produce antibodies. Biological immune system is a complex system composed of immune molecules, immune tissues and immune cells. These tissues and organs that make up the immune system are distributed throughout the body and used to perform various immune defense functions. They are known as lymphoid organs and lymphoid tissues. Immune recognition immune recognition is the main function of the immune system, the essence of recognition is to distinguish “self” and “non self”. Immune recognition is achieved through the binding of antigen receptors on lymphocytes. Immune learning Immune recognition process is also a learning process, the result of learning is the improvement of individual affinity of immune cells, the expansion of population size, and the optimal individuals are preserved in the form of immune memory. Immune memory When the immune system encounters an antigen for the first time, lymphocytes need time to adjust to better recognize the antigen and retain their memory of the antigen in the form of optimal antibodies after recognition. When the immune system encounters the same or similar antigen again, its response speed is greatly increased under the action of associative memory. Clonal selection immune responses and proliferation of immune cells occur above a specific matching threshold. When a lymphocyte recognizes an antigen, the B cell is activated and multiplies to produce a cloned B cell, which then undergoes a mutation process to produce antigen-specific antibodies. Individual diversity According to immunology, the immune system has more than 100 different proteins, but there are more than 1000 kinds of potential antigens and patterns to be recognized outside. To achieve an order of magnitude larger than their own antigen recognition, effective diversity of individual generation mechanisms are needed. The biological mechanism of antibody diversity mainly includes combinatorial reforming of immune receptor library somatic high-frequency mutation and gene conversion. The distributed nature of distributed and adaptive immune systems first depends on the distributed nature of pathogens, that is, pathogens are dispersed within the body. The adaptive nature of the immune system is further enhanced by the distributed nature of the immune system because the immune response mechanism is based on local cellular interactions without centralized control. All of these important information processing features of the immune system provide powerful support for information and computing applications.

2.2 Concept of immune algorithmImmune algorithm is a new intelligent search algorithm inspired by biological immune system. It is a heuristic random search algorithm which combines deterministic and stochastic selection and has the ability of “exploration” and “mining”. In the immune algorithm, the problem to be optimized corresponds to the antigen in the immune response, the feasible solution corresponds to the antibody (B cell), and the quality of the feasible solution corresponds to the affinity between the immune cell and the antigen. In this way, the optimization process of the optimization problem can be corresponded with the process of biological immune system recognizing antigen and realizing antibody evolution, and the evolutionary process of biological immune response can be abstracted into a mathematical evolutionary optimization process, and an intelligent optimization algorithm can be formed. Immune algorithm is abstracted from the mechanism of biological immune system. Many concepts and operators in the algorithm correspond to the concepts and mechanisms of immune system. The corresponding relationship between immune algorithm and biological immune system concept is shown in Table 1. Since antibodies are produced by B cells, antibodies and B cells are not distinguished in the immune algorithm, which correspond to the feasible solution of the optimization problem. Table 1 Corresponding relationship between immune algorithm and biological immune system conceptAccording to the above correspondence, the process of simulating biological immune response forms an immune algorithm for optimal calculation. The algorithm mainly includes the following modules: (1) antigen recognition and initial antibody generation. According to the characteristics of the problem to be optimized, an appropriate antibody coding rule is designed and the priori knowledge of the problem is used to generate the initial antibody population. (2) Antibody evaluation. The quality of antibodies is evaluated, and the evaluation criteria are mainly antibody affinity and individual concentration. The high-quality antibodies obtained from the evaluation will undergo evolutionary immune operation, and the inferior antibodies will be updated. (3) Immunization operation. By using immune selection, clone, mutation, clone suppression, population refresh and other operators to simulate various immune operations in biological immune response, the evolutionary rules and methods based on clonal selection principle of biological immune system are formed to realize optimization search for various optimization problems.

2.3 Characteristics of Immune Algorithm Immune algorithm is an adaptive intelligent system inspired by immunology that simulates the functions and principles of biological immune system to solve complex problems. It retains several characteristics of biological immune system [8], including: (1) global search ability. Imitate the process of immune response of immune algorithm is an optimization algorithm with global search ability, immune algorithm in local search was carried out on the high quality antibodies neighborhood at the same time using the mutation operator and population constantly refresh the operator to generate new individuals, explore new areas of the range of feasible solution, ensure search algorithm in the full range of feasible solution, has the performance of global convergence. (2) Diversity maintenance mechanism. Immune algorithm using the diversity preservation mechanism of biological immune system, the concentration of antibody, concentration calculation and the result was recognized as an important antibody of individual fitness evaluation standard: it makes the high concentration of antibody inhibited, guarantees antibody has the very good population diversity, this is the global convergence performance of the algorithm is an important aspect. (3) Strong robustness. Immune algorithm based on biological immune mechanism is not for a specific problem, and does not emphasize algorithm parameter Settings and the quality of the initial solution, using the heuristic intelligent search mechanism, even started to inferior solution, finally also can search the global optimal solution to the problem, the problem and the dependence of the initial solution is not strong, has the very strong adaptability and robustness. (4) Parallel distributed search mechanism. Immune algorithm does not need centralized control and can realize parallel processing. Moreover, the optimization process of immune algorithm is a parallel multi-process optimization, which can obtain multiple sub-optimal solutions while searching for the optimal solution of the problem, that is, in addition to finding the best solution of the problem, it can also get several better alternatives, especially suitable for multi-modal optimization problems.

2.4 Immune algorithm operatorSimilar to other intelligent optimization algorithms such as genetic algorithm, the evolutionary optimization process of immune algorithm is realized by operator. Operators of immune algorithm include: affinity evaluation operator, antibody concentration evaluation operator, excitation calculation operator, immune selection operator, clone operator, mutation operator, clone suppression operator and population refresh operator [9]. Because the encoding mode of the algorithm may be real number encoding, discrete encoding, etc., the algorithm operator under different encoding mode will be different.Affinity evaluation operatorAffinity represents the binding strength of immune cells to antigen, similar to fitness in genetic algorithm. The affinity evaluation operator is usually a function aff(x) : SER, where S is the feasible solution interval of the problem and R is the real number field. The input of the function is an antibody individual (feasible solution), and the output is the evaluation result of affinity. The evaluation of affinity is specific to the problem. For different optimization problems, we should define the evaluation function of affinity according to the characteristics of the problem on the premise of understanding the essence of the problem. Generally, function optimization problems can be evaluated by function values or simple processing of function values (such as reciprocal, negative, etc.), while for combinatorial optimization problems or more complex optimization problems in applications, it needs to be analyzed on a case-by-case basis.Antibody concentration evaluation operatorAntibody concentration indicates the diversity of antibody population. High antibody concentration means that there are a large number of very similar individuals in the population, so the optimization search will focus on a region of the feasible solution interval, which is not conducive to global optimization. Therefore, the high concentration of individuals should be suppressed in the optimization algorithm to ensure the diversity of individuals. Antibody concentration is usually defined as: Immune selection operatorThe immune selection operator determines which antibodies to select into clonal selection operation according to the excitation degree of antibodies. The antibody individuals with high excitation degree in the antibody population have better quality, are more likely to be selected for clonal selection operation, and have more search value in the search space.The clone operator Discrete coding algorithm mutation operatorThe discrete coding algorithm is mainly binary coding, and its mutation strategy is to randomly select several bits from the mutation source antibody string, change the value of the bit (inverse), so that it falls in the neighborhood of the mutation source in discrete space.Clone suppression operatorClonal inhibition operator is used to re-select the mutant clones, suppress the antibodies with low affinity, and reserve the antibodies with high affinity to enter the new antibody population. In the process of clone suppression, the source antibody operated by the clone operator and the immediate antibody group obtained by the mutation operator of the clone form a set together, and the clone suppression operation will retain the antibody with the highest affinity in this set and inhibit other antibodies. Because the source antibody operated by clonal mutation operator is the high quality antibody in the population, and the temporary antibody set operated by clonal suppression operator contains the parent source antibody, the operator operation of immune algorithm implies the optimal individual retention mechanism.Population refresh operatorThe population refresh operator is used to refresh the antibody with low excitation degree in the population, delete these antibodies from the antibody population and replace them with randomly generated new antibodies, which is beneficial to maintain the diversity of antibodies, realize global search and explore new feasible solution space region.

3 Types of immune algorithms 3.1 Clonal selection Algorithm Castro proposed a clonal selection algorithm based on clonal selection theory of immune system [10], which is an evolutionary algorithm simulating the learning process of immune system. The immune response to produce antibodies is a learning process of the immune system. The antigen is recognized by some B cells that match it, and these B cells divide, producing daughter B cells that change on the basis of the mother cell, in search of B cells that better match the antigen, and then dividing daughter B cells that better match the antigen… The cycle repeats, and finally B cells that are exactly matched with the antigen are found, and THE B cells turn into plasma cells and produce antibodies. This process is the clonal selection process, and the clonal selection algorithm simulates this process for optimization. 3.2 Immune Genetic Algorithm Chun et al. proposed an immune algorithm, which is essentially an improved genetic algorithm [11]. The selection operation of genetic algorithm is improved according to somatic cell and immune network theory, so as to keep the diversity of population and improve the global optimization ability of genetic algorithm. By adding immune memory function into the algorithm, the convergence speed of the algorithm is improved. The immune genetic algorithm regards antigen as the objective function, antibody as the feasible solution of the problem, and the affinity between antibody and antigen as the fitness of the feasible solution. Immune genetic algorithm introduces the concept of antibody concentration and uses information entropy to describe the number of similar feasible solutions in the population. The immune genetic algorithm performs selection operation according to the affinity between antibody and antigen and the concentration of antibody, and the antibody with high affinity and low concentration has a high selection rate, so as to suppress the high concentration of antibody in the population and maintain the diversity of the population. 3.3 reverse selection algorithm of T cells in the immune system development in the thymus, immature T cells react with their protein was destroyed, so mature T cells with a patient’s own nature, does not react with their protein, only react with foreign proteins, in order to identify “yourself” and “f”, this is called reverse selection principle. Forrest proposed a reverse selection algorithm based on the principle of reverse selection for anomaly detection [12]. The algorithm mainly consists of two steps: first, a set of detectors is generated, in which each detector does not match the protected data; second, each detector in the set is constantly compared with the protected data. If the detector matches the protected data, the data is judged to have changed.

3.4 Vaccine Immune Algorithm Jiao Licheng et al. proposed vaccine-based immune algorithm based on the theory of immune system [13]. In this algorithm, immune operator is added to genetic algorithm to improve convergence speed and prevent population degradation. The immune operator includes vaccination and immune selection, the former to improve affinity, the latter to prevent population degradation. Theoretical analysis shows that the immune algorithm is convergent. The basic steps of vaccine immune algorithm are: randomly generating NP individuals to form the initial parent population; Extraction of vaccines based on prior knowledge; Calculate the affinity degree of all individuals in the current parent population, and judge the stopping conditions: mutate the current parent population to generate the offspring population; vaccinate the offspring population to get the new population; The new population was selected by immune selection to obtain a new generation of fathers and enter the immune cycle.

At present, there is no unified immune algorithm and block diagram. Here is an algorithm flow containing the immune operator in Section 4.2.4, which is divided into the following steps: (1) Firstly, antigen identification is carried out, that is, understanding the problem to be optimized, conducting feasibility analysis on the problem, extracting prior knowledge, constructing appropriate affinity function, and formulating various constraints. (2) Then the initial antibody group is generated. The feasible solution of the problem is expressed as the antibody in the solution space through coding, and an initial population is randomly generated in the solution space. (3) Evaluate the affinity degree of each feasible solution in the population. (4) Determine whether the algorithm termination conditions are met: If the conditions are met, terminate the algorithm optimization process and output the calculation results; otherwise, continue the optimization operation. (5) Calculate antibody concentration and excitation degree. (6) Immune treatment, including immune selection, cloning, mutation and cloning inhibition.

Immune selection: select high-quality antibodies according to the results calculated by the affinity and concentration of antibodies in the population, and activate them: clone: clone and duplicate the activated antibodies to get several copies; Mutation: to clone the copy of the mutation operation, so that the affinity mutation; Clonal inhibition: the results of mutation are re-selected to suppress the antibody with low affinity and retain the results of mutation with high affinity.

(7) Population refresh. The antibody with low excitation degree in the population is replaced by the randomly generated new antibody to form a new generation of antibody, and then go to Step (3). The process of immune algorithm is shown in Figure 1.The evolutionary operation of immune algorithm is realized by using evolutionary operators based on immune principle, such as immune selection, cloning, mutation and so on. In addition, the calculation of antibody concentration and excitation degree is added in the algorithm, and the antibody concentration is taken as a standard to evaluate individual quality, which is beneficial to maintain individual diversity and achieve global optimization.

5 Key Parameter Description The following describes the main parameters of immune algorithm, which plays an important role in program design and debugging. The immune algorithm mainly includes the following key parameters: antibody population size NP antibody population retains the diversity of immune cells, intuitively, the larger the population, the better the global search ability of the immune algorithm, but the calculation of each generation of the algorithm also increases accordingly. For most problems, NP is 10, 100, usually less than 200. Proportion of immune selection The higher the number of immunoselected antibodies, the more clones will be produced, the stronger their search power, but will increase the computational load per generation. Generally, 10% and 50% of the antibody population size NP can be taken. Multiple of clonal antibody amplification The multiple of clonal determines the number of cells amplified by clonal, which determines the search ability of the algorithm, mainly local search ability. The larger the value of clone multiple is, the better the local search ability is, and the global search ability is also improved to a certain extent, but the calculation amount also increases, generally 5 or 10 times. Population refresh ratio cell selection and renewal is an important mechanism to generate antibody diversity, so it has an important impact on the global search ability of immune algorithms. No more than 50% of the antibody population is generally renewed in each generation. Maximum evolution algebra G is a parameter that represents the end condition of the operation of the immune algorithm. It means that the immune algorithm stops running after it reaches the specified evolution algebra and outputs the best individual in the current population as the optimal solution of the problem to be solved. In general, 6 is 100, 500. 1.1 Shortest Path Planning Path planning refers to finding a collision-free path from the initial state to the target state according to certain evaluation criteria in an environment with obstacles. The shortest path planning problem is a classical algorithm of graph theory, its purpose is to find the shortest path between two nodes in a graph (composed of nodes and paths). The specific form of the problem is as follows: (1) determine the starting point of the shortest path problem: given the starting node, find the shortest path problem. (2) The shortest path problem to determine the end point: contrary to the problem to determine the starting point, this problem is the problem to find the shortest path given the end point. In undirected graphs the problem is exactly equivalent to the problem of determining the starting point, and in directed graphs it is equivalent to the problem of determining the starting point by reversing the direction of all paths. (3) Determine the shortest path of the starting point and end point: given the starting point and end point, find the shortest path between two nodes. (4) Global shortest path problem: find all shortest paths in the graph. Let P(u, v) be the path from u to v in the map, then the sum of edge weights on the path is called the weight of the path, denoted by w(P). The path from u to v, P*(u, v) with the least weight, is called the shortest path from u to v.

Two, some source code


clear;
% RUN=10;
% for run=1:RUN % Initializes generation=0; % Number of machines m=5; % Number of jobs n=10; % Initial antibody Pop_size=40; N=Pop_size; % replace antibody number Ns=30; % Clone selection probability Pa=0.7; % Number of cell clones M=80; % concentration, clone suppression radius Py=0.7; % excitation coefficient Pb=100; % variation probability Pz=0.6;
Pc=0.3;
Ps=0.3;
Pi=0.3;
Pm=0.05; % concentration selection rate Pn=0.7; % % feedback probability % Pr=1; % Number of iterations IterativeTime=60;
OperationTime=[25 17 41  74 37  72  11 31  32  27 
               15 41 155 12 95  34  77 39  92  114  
               12 22 83  24 72  62  31 141 42  21  
               40 36 121 48 52  32  26 56  74  90 
               60 58 160 78 153 162 32 79  102 52]; % generate initial population P=zeros(N, N);for i=1:N
    for j=1:n P(i,:)=randperm(n); End End % Calculate target value [MakeP,CL,ST]= Calculate (m,n, n, P,OperationTime); % calculate affinity Aff=Affcalculate(N,MakeP); % Calculate similarity Ayy=Aycalculate(P,n, n); % Calculate the concentration of each antibody AA =0;
for i=1:N
    for j=1:N
        if Ayy(i,j)>Py
            aa=aa+1;
        end
    end
    Nong(1,i)=aa/N;
    aa=0; End % find the best individual bestmax=MakeP(1.1);
for i=1:N
    if bestmax>=MakeP(1,i)
        bestmax=MakeP(1,i); positionP=i; Best =P(positionP,:); bestStarttime=ST(:,:,positionP); bestEndtime=CL(:,:,positionP); Best=best; BestStarttime=bestStarttime; BestEndtime=bestEndtime; Bestmax=bestmax; Makespan=zeros(1,IterativeTime);
BestMake=zeros(1,IterativeTime);
Aff_PP=zeros(1,IterativeTime); % Save Last generation population Last=P; generation=0;
while(generation<IterativeTime)
       generation=generation+1;
   Makespan(1,generation)=bestmax;
   BestMake(1,generation)=Bestmax; % sort by affinity size (clone selection) [f1,index1]=sort(Aff,'descend'); % in descending order N1=Pa*N; B=zeros(N1,n);for i=1:N1
       for j=1:n
           B(i,:)=P(index1(i),:);
       end
   end
   ff1=0;
   for i=1:N1 ff1=ff1+f1(i); End % Clone the antibody in B according to the affinity of each antibody MM=0;
   for i=1:N1 Mn(i)=round(M*f1(i)/ff1); % Store the number of individuals to be cloned for each antibody in Mn(I) MM=MM+Mn(I); % Number of actual clones; End % Start cloning, population size is MM (cell cloning) sum=0;
   C=zeros(MM,n);
   for k=1:N1
       for j=1:Mn(k)
           C_Swarm((sum+j),:)=B(k,:);
       end
       sum=sum+Mn(k);
   end
   for i=1:MM C(i,:)=C_Swarm(i,:); End % To calculate the affinity after cloning [MakePC,CL,ST]=calculateC(m,n,MM,C,OperationTime); Aff_MM1=Aff_MM1calculate(MM,MakePC); C_Swarm2=C; % clone recombinationif rand(1)<Pz
       for i=1:round(MM/2)
           Tw=zeros(2,n);
           Tw(1,:)=C(i,:);
           Tw(2,:)=C(MM-i+1, :); % randomly generates a cross bit j_bit=0;
           for s=0:n- 1
               if (((rand(1.1)*n)<s+1)&((rand(1.1)*n)>=s))
                   j_bit=s;
               end
           end
           j=j_bit+1;
           for k=1:n
               if Tw(1,k)~=Tw(2.1:j_bit);
                   Tw(2,j)=Tw(1,k);
                   j=j+1;
               end
           end
           j=j_bit+1;
           for k=1:n
           if Tw(2,k)~=Tw(1.1:j_bit);
               Tw(1,j)=Tw(2,k); 
               j=j+1;
           end
           end
       C(i,:)=Tw(1, :); C(MM-i+1,:)=Tw(2, :); End End % To calculate the affinity of each antibody after mutation [MakePC,CL,ST]=calculateC(m, N,MM,C,OperationTime); Aff_MM3=Aff_MM3calculate(MM,MakePC); % before and after the variation is compared to determine whether to deletefor i=1:MM
    if Aff_MM1(1,i)>Aff_MM3(1,i)
        C(i,:)=C_Swarm2(i,:);
        Aff_MM1(1,i)=Aff_MM3(1,i); Pc switches genes between two points according to a certain exchange probability;for i=1:MM
       if rand(1)<Pc C(i,:)=change(C(i,:),n); End % Order the genes between two points in reverse order according to a certain probability Pi;if rand(1)<Pi
        C(i,:)=inverse(C(i,:),n); End % shifts the gene segment between two points according to a certain probability Ps;if rand(1)<Ps
        C(i,:)=shift(C(i,:),n); End End % Clone suppression % To calculate the affinity of each antibody after mutation [MakePC,CL,ST]=calculateC(m, N,MM,C,OperationTime); Aff_MM2=Aff_MM2calculate(MM,MakePC); Compare the antibodies before and after mutation to decide whether to delete;for i=1:MM
    if Aff_MM1(1,i)>Aff_MM2(1,i)
        C(i,:)=C_Swarm(i,:);
        Aff_MM1(1,i)=Aff_MM2(1,i); end end % C_Swarm2=C; According to a certain probability of antibody one or more points for variation; %for i=1:MM
%        if rand(1)<Pm % C(i,:)=mutation(C(i,:),n); % MakePC,CL,ST]=calculateC(m, N,MM,C,OperationTime); % Aff_MM3=Aff_MM3calculate(MM,MakePC); Compare % % before and after variation to determine whether to delete %for i=1:MM
%     if Aff_MM1(1,i)>Aff_MM3(1,i)
%         C(i,:)=C_Swarm2(i,:);
%         Aff_MM1(1,i)=Aff_MM3(1,i); Ayy_MM=Aycalculate(C,n,MM); aa=0;
Nong_MM=zeros(1,MM);
for i=1:MM
    for j=1:MM
        if Ayy_MM(i,j)>Py
            aa=aa+1;
        end
    end
    Nong_MM(1,i)=aa/MM;
    aa=0;
end
fn1=zeros(MM);
indexfn=zeros(MM);
Nc=round(Pn*MM);
D=zeros(Nc,n);
[fn1,indexfn]=sort(Nong_MM);
for i=1:Nc
            D(i,:)=C(indexfn(i),:);
            Nong_D(1,i)=Nong_MM(1,indexfn(i));
            Aff_D(1,i)=Aff_MM1(1,indexfn(i)); End % To calculate the affinity of D antibody NNc=N+Nc; The antibody group E of NNc complex was obtained by combining P and D antibody groups. E(i,:)=D(i,:); Aff_E(1,i)=Aff_D(1,i);
        Nong_E(1,i)=Nong_D(1,i);
    end
    if i>Nc
       E(i,:)=P(i-Nc,:);
       Aff_E(1,i)=Aff(1,i-Nc); 
       Nong_E(1,i)=Nong(1,i-Nc); End end % Calculates the excitation degreefor i=1:NNc
    act(1,i)= Aff_E(1,i)*exp(-Nong_E(1,i)/Pb); F_AE = ZerOS (NNc); index3=zeros(NNc); [f_AE,index3]=sort(Aff_E,'descend'); %, select the first N antibody groups F [f_E,index2]=sort(act,'descend');
 inumber=2;
    for i=1:NNc- 1
    if f_E(i)>f_E(i+1)
    F(inumber,:)=E(index2(i),:);
    inumber=inumber+1;
    end
    if inumber==N+1

    end
F(1,:)=E(index3(1), :); % calculate antibody affinity, and sort % calculate target value [MakeP,CL,ST]= Calculate (m,n,N,F,OperationTime); Aff_F=Affcalculate(N,MakeP); [f_F,index4]=sort(Aff_F,'descend');
for i=1:N G(i,:)=F(index4(i),:); End % randomly generated antibody G replaces F in the excitation degree of the last0.1*N antibody %if generation<50
    for i=1:Ns

bbb=0;
for i=1:N
    bbb=bbb+MakeP(1,i); end Make_P=bbb/N; % find the best individual bestmax=MakeP(1.1);
for i=1:N
    if bestmax>=MakeP(1,i)
        bestmax=MakeP(1,i); positionP=i; Best =P(positionP,:); bestStarttime=ST(:,:,positionP); bestEndtime=CL(:,:,positionP); % find the global best solutionif bestmax<Bestmax
Bestmax=bestmax;
BestStarttime=bestStarttime;
BestEndtime=bestEndtime;
Best=best;
end
 Aff_PP(1,generation)=Aff_P;
 Make_PP(1,generation)=Make_P;
end
BestStarttime1=BestStarttime(:,:,1);
BestEndtime1=BestEndtime(:,:,1); % painting Gantte figure picturegantchart (m, n, Bestmax, Best BestStarttime1, BestEndtime1); figure(2);
plot(Makespan);
figure(3);
plot(BestMake);
figure(4);
plot(Aff_PP);
figure(5);
plot(Make_PP);
% seg(run,1)=Bestmax;
% end
%     

Copy the code

3. Operation results

Matlab version and references

1 matlab version 2014A

[1] Yang Baoyang, YU Jizhou, Yang Shan. Intelligent Optimization Algorithm and Its MATLAB Example (2nd Edition) [M]. Publishing House of Electronics Industry, 2016. [2] ZHANG Yan, WU Shuigen. MATLAB Optimization Algorithm source code [M]. Tsinghua University Press, 2017.