1. WSN Model
In recent years, with the development of distributed environment such as peer-to-peer network, cloud computing and grid computing, wireless sensor network (WSN) has been widely used.Is a new computing and network mode that can be defined as a network of tiny, small, expensive and highly intelligent devices called sensor nodes. Sensor nodes are located in different locations in the observed space and exchange data collected from the monitoring area through wireless communication channels. The collected data is sent to the sink node, which is either local or local.Processing data, or sending data to other networks with greater processing power.
One of the most basic challenges in wireless sensor networks is node positioning. There are many examples of node positioning problems, which are NP-hard optimization problems. Traditional deterministic techniques and algorithms cannot solve NP-hard problems within a reasonable computing time. In this case, it is better to use non-deterministic (random) algorithms, such as meta-heuristic algorithms.
Group Intelligence Metaheuristic algorithms simulate biological groups in nature, such as those of birds and fish, bees and ants, bats and azaleas. These algorithms are population-based, random and iterative search methods based on four self-organizing principles: positive feedback, negative feedback, multiple interactions and fluctuations.
1.2 Location issues in Wireless Sensor Networks
Location is one of the most studied problems in wireless sensor networks because coverage, power and routing cannot be optimized if the location of sensor nodes is unknown. Location is the key to wireless sensor networks. The location of some sensor nodes can be determined by Global Positioning System (GPS).To define, these nodes are called anchor nodes or beacon nodes, while other sensor nodes are randomly distributed in the search space. These nodes are called unknown nodes or sensor nodes. Because of the factors such as battery life, cost, climate conditions of each node, only a few nodes'positions are determined by GPS coordinates, while the locations of other nodes need to be improved by localization algorithm.Line estimate.
For positioning of sensor nodes in wireless sensor networks, two positioning algorithms, anchor node and unknown node, are proposed. The first phase is called ranging phase, and the algorithm determines the distance between unknown nodes and adjacent anchor nodes. For positioning of sensor nodes in wireless sensor networks, two positioning algorithms, anchor node and unknown node, are proposed. The first phase is called detection.In the second phase, the algorithm determines the distance between unknown nodes and adjacent anchor nodes. In the second phase, the location of nodes is estimated by collecting ranging information using various methods in the first phase, such as angle of arrival (AOA), time of arrival (TOA), time of arrival (TDOA), round-trip time (RTT), wireless signal strength (RSS).
1.3 Question Statement
In a wireless sensor network consisting of M sensor nodes, the target of the positioning problem is to estimate the position of N unknown nodes within the transmission range of R using the location information of M-N anchor nodes. If a sensor node is within the transmission range of three or more anchor nodes, it is considered to be positioned. This is a two-dimensional positioning problem with a total coordinate number of 2n.
This paper uses the RSS method to estimate the distance between nodes. An imprecise measurement may occur regardless of the ranging method used. Location estimation of N unknown node coordinates can be expressed as an optimization problem involving the minimization of the objective function that represents the positioning error of nodes . The objective function of this problem is expressed by the squares of errors between N unknown nodes and M N adjacent anchor nodes..
With the advent of RSS, trilateral measurement will be used to solve the positioning problem in WSN. The principle of this method is based on the known positions of three anchor nodes. The positions of unknown nodes can be estimated within the transmission range of three anchor nodes.
Each node is estimated to have a distance of d_=d i+ni to the first anchor point, where Ni is a Gaussian noise and D I is the actual distance calculated using the following equation:
The objective function that should be minimized is expressed as the mean square error (MSE) between calculating the actual and estimated distances of the node coordinates and the actual node coordinates:
Where d I is the actual distance, d_i is the estimated distance (the value d I measured from the noise range), M is greater than or equal to 3 (the location of the sensor node requires at least three anchors within the transmission range R).
Since distance measurement in node positioning is noisy, optimization methods such as swarm intelligence metaheuristics are used to estimate sufficient distance between nodes.
2. Genetic Algorithms
* Genetic Algorithm (GA) is an evolutionary algorithm based on the principle of mimicking the evolutionary rules of "natural selection, survival of the fittest" in the biological world. It was originally proposed by Professor J. Holland of Michigan University in the United States in 1967. * Genetic algorithm is a population representing the potential solutions to a problem.First, a population consists of a certain number of individuals encoded by a gene. Therefore, the first step is to map phenotypes to genotypes, that is, coding. After the first generation of a population, generation follows the principles of survival of the fittest, survival of the fittest, and elimination of the fittest.Evolution produces better and better approximations, choosing individuals based on their fitness in the problem domain and using genetic operators in natural genetics each generation.Combining crossovers and variations produces a population that represents a new solution set. This process will result in a population that, like natural evolution, is more adaptable to the environment than its predecessors, and the best individual in the last generation is decoded to act as an approximate optimal solution to the problem.
* Genetic algorithms have three basic operations: Selection, Crossover, and Mutation.;(1)Selection. The purpose of selection is to select good individuals from the current population so that they have the opportunity to reproduce as parents and descendants for the next generation. Based on the fitness values of individual individuals, select some good individuals from the previous generation to the next generation according to certain rules or methods. Selection is based on strong adaptability.Individuals have a high probability of contributing one or more offspring to the next generation. ((2) Crossing. A new generation of individuals can be obtained by crossover, which combines the characteristics of the parent. Individuals in a population are randomly paired and some of their chromosomes are exchanged with crossover probability for each individual. ((3)Variation. For each individual in a population, the probability of mutation changes the value of a gene at one or more loci to another allele. As in the biological world, mutation occurs at a low probability and offers an opportunity for new individuals.
The basic steps of the genetic algorithm:
1) Coding: GA expresses the solution data of solution space as genotype string structure data of genetic space before searching, and the same combination of these string structure data forms the same point. 2) Generation of initial population: N initial string structure data are generated randomly, each string structure data is called an individual and NIndividuals form a group. GA begins to evolve with N-structured data as its starting point. 3) Fitness evaluation: Fitness indicates the superiority or inferiority of an individual or solution. Fitness functions are defined in the same way as problems.
4) Selection: The purpose of selection is to select good individuals from the current population so that they have the opportunity to reproduce their offspring as parents. The genetic algorithm reflects this idea through the selection process, and the principle of selection is that highly adaptable individuals have a high probability of contributing one or more offspring to the next generation. Selection reflects Darwin's principle of survival of the fittest.5) Crossing: Crossing is the most important genetic operation in genetic algorithms. A new generation of individuals can be obtained by crossing, which combines the characteristics of their parents. Crossing reflects the idea of information exchange. 6) Variation: mutation first randomly selects an individual in a population and randomly changes the selected individual with a certain probability.The value of a string in string structure data. As in the biological world, the probability of mutation occurring in GA is low and the value is usually small.
Genetic algorithm toolbox:
* MATLAB Embedded Genetic Algorithms Toolbox: gadst * Sheffield University Genetic Algorithms Toolbox: gatbx * University of North Carolina Genetic Algorithms Toolbox: gaot
The genetic algorithm optimizes the initial weights and thresholds of the BP network:
%%Genetic algorithm main function clc; clear all; close all; warning off %%Genetic algorithm parameters maxgen=200; %Evolutionary algebra, that is, the number of iterations sizepop=20; %Population size, number of individuals, or chromosome number pcross=[0.6]; %The crossover probability,[0,1]Why are they written as arrays? pmutation=[0.01];%Probability of Variation, ,1]Between lenchrom=[1 1 1 1 1];%String length of each variable is 1 if it is a floating-point variable bound=[0,0.9*pi; 0,0.9*pi; 0,0.9*pi; 0,0.9*pi; 0,0.9*pi]; %%Initialization of individuals=struct('fitness',zeros(1,sizepop),'chrom',);%Population Structures avgfitness=0;%Average fitness of population bestfitness=0;%Population Best Fitness bestchrom=;%Best Fit Chromosomes bf=;%Recording population best fitness af=;%Record Population Average Fitness %%Initialize Population for i=1:sizepop individuals.chrom(i,:)=Code(lenchrom,bound);%Randomly produce a population x=individuals.chrom(i,:); individuals.fitness(i)=fun(x);%Computing chromosome fitness end %The initialization of the population is completed above, and the fitness of each individual in the initialization population is calculated. %%Finding the Best Chromosome [bestfitness bestindex]=min(individuals.fitness);%The minimum fitness function value and location of the initialization population are obtained. (The function value is the smallest, then the reciprocal, that is, the fitness, is the largest.),Count down the roulette operation) bestchrom=individuals.chrom(bestindex,:);%The best fitness is the chromosome number with the smallest function value avgfitness=sum(individuals.fitness)/sizepop;%Average chromosome fitness trace=;%Records the best and average fitness in each generation of evolution and can be used to plot whether premature convergence occurs %%Beginning of Evolution for i=1:maxgen %Choice individuals=Select(individuals,sizepop);%Return selected chromosomes sizepop Fitness of bars to selected chromosomes avgfitness=sum(individuals.fitness)/sizepop;%Average fitness of selected population %overlapping individuals.chrom=Cross(pcross,lenchrom,individuals.chrom,sizepop,bound);%Return to the crossed chromosome group %variation individuals.chrom=Mutation(pmutation,lenchrom,individuals.chrom,sizepop,[i,maxgen],bound); %%Nonlinear optimization can be commented out, followed by general genetic algorithms %For each 10 generations of evolution, non-linear optimization is performed by taking the resulting values as initial values, which combines a genetic algorithm with a function optimization algorithm for non-linear programming. nonlinear if(mod(i,10)==0) individuals.chrom=nonlinear(individuals.chrom,sizepop); end %%Calculate Fitness for j=1:sizepop x=individuals.chrom(j,:); individuals.fitness(j)=fun(x); end %Find the best chromosomes and their location in the population [newbestfitness,newbestindex]=min(individuals.fitness); %Update to replace the best chromosome in the last evolution if bestfitness>newbestfitness %If the function value of the new generation chromosome is small, the fitness is high. bestfitness=newbestfitness; %Then assign the new fitness to bestfitness bestchrom=individuals.chrom(newbestindex,:);%Give the new best current chromosome to bestchrom end avgfitness=sum(individuals.fitness)/sizepop; bf=[bf bestfitness]; af=[af avgfitness]; %trace=[trace,avgfitness bestfitness];%Recording the best and average fitness for each generation of evolution end %End of Evolution %Drawing Image Analysis [r,c]=size(bf); plot([1:c],bf,'r-',[1:c],af,'b--','LineWidth',2); title(['Function-Valued Curve' 'Terminate algebra=' num2str(maxgen)]); xlabel('Evolutionary Algebra'); ylabel('function value'); ylim([1.5 8]); legend('Best value for each generation','Average of each generation'); disp('function value variable'); grid on %Window display disp([bestfitness x]); % %Drawing Image Analysis % [r c]=size(trace);%Calculation trace Rows and columns % figure(1) % plot([1:r]',trace(:,1),'r-',[1:r]',trace(:,2),'b--'); % title(['Function-Valued Curve' 'Terminate algebra=' num2str(maxgen)]); % xlabel('Evolutionary Algebra'); % ylabel('function value'); % legend('Average of each generation','Best value for each generation'); % disp('function value variable'); % grid on % %Window display % disp([bestfitness x]);