1. Basic concepts
(1) Quantum genetic algorithm (QGA) is an intelligent optimization algorithm combining quantum computing and genetic algorithm, proposed by K.H.Han et al., which introduces quantum concepts such as quantum state, quantum gate, quantum state properties and probability amplitude into genetic algorithm. Quantum genetic algorithm is also a probabilistic search algorithm, which uses qubits to represent genes. The gene expressed by genetic algorithm is a certain information, while the gene expressed by quantum genetic algorithm contains all possible information due to the superposition of quantum information.
(2) in quantum computation, quantum bit 1 > > and | | 0 microscopic particles of two basic state, according to the principle of superposition, the superposition of quantum information can be expressed as the linear combination of two basic states, namely | bits of > = alpha beta | | 0 > + 1 >, type of alpha and beta is plural, said the qubit state probability amplitude, Where, and respectively represent the probability that | ψ > collapse to | 0 > state and | 1 > state due to measurement, and meet the normalization condition
(3) In the quantum genetic algorithm, chromosomes are encoded by the probability amplitude of qubits, and the coding scheme is as follows:
θ is the phase of the qubit, n is the number of chromosomes, k is the number of qubits, i.e. the dimension of the solution space, and rand is a random number in the range [0,1]. Each qubit is divided into two rows, corresponding to the probability amplitude of two quantum basic states respectively, which meets the normalization conditions. Therefore, each individual contains two cultural gene chains up and down, and each gene chain is a candidate solution to the optimization problem. Therefore, when the population size remains unchanged, the number of candidate solutions of quantum genetic algorithm is twice that of genetic algorithm, which increases the diversity of knowledge space and improves the probability of successful optimization.
(4) In the quantum genetic algorithm, the quantum revolving gate is used to change the phase of the quantum bit, so as to update the probability amplitude of the qubit, so as to achieve the effect of gene mutation.
2. Basic steps of quantum genetic algorithm:
Step1: initialize the paternal chromosome
Step2: Measure the gene locations of each chromosome, namely qubits, to obtain a state. Fitness was calculated for each state, and the best individual and fitness were recorded.
Step3: Algebra set by genetic evolution, in which the quantum revolving door is used to carry out genetic variation on each generation of chromosomes.
Step4: reach the termination condition, output the best individual and fitness.
Image enhancement using quantum genetic algorithm CLC, Clear All; close all; %% read picture img=rgb2gray(imread('test1.jpg')); Img = imresize (img, 0.7); figure(1); imhist(img); % Original image histogram Figure (2); imshow(img); Img =double(img); [row,colume]=size(img); Num_pixel =row*colume; MAX_Geneic=20; MAX_Geneic=20; % genetic algebra sizePopu=10; % Initial population number tic; best=QGA_Sharpen(img,MAX_Geneic,sizePopu); disp(['The total time is ' num2str(toc) 's']); fprintf('The final alpha is %f\n',best.B(1)); fprintf('The final beta is %f\n',best.B(2)); fprintf('The best fitness value is %f\n',best.fitnessVal); Graph the non-linear function (Beta function) x=0:0.01:1; y=pdf('beta',x,best.B(1),best.B(2)); figure(4); plot(x,y); %% image gray value img_sharp=best. SharpImg; figure(5); imhist(uint8(img_sharp)); % Sharpening image histogram Figure (6); imshow(uint8(img_sharp)); % Uint8 (Cameraman),'test2_opt.jpg');Copy the code
References and codes for private message bloggers