Drilling fluid demagnetizing device parameter optimization method based on genetic algorithm and related device
By optimizing the parameters of the drilling fluid demagnetizing device using a genetic algorithm, the problem of insufficient adaptability of the existing device was solved, and efficient removal of magnetic materials and improvement of device performance were achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2026-03-10
AI Technical Summary
Existing drilling fluid demagnetization devices lack automated control, cannot adjust parameters as needed, have limited adaptability, and are difficult to cope with complex production demands, resulting in problems such as high equipment failure rate, low adsorption rate, and waste of drilling fluid.
Genetic algorithms are used to optimize the parameters of drilling fluid demagnetizing devices. By obtaining the device structure and process parameters and converting them into individual codes for the genetic algorithm, a fitness function is constructed, and selection, crossover, and mutation operations are performed to generate a new generation of individuals. This optimizes the device parameters to improve adsorption efficiency and adaptability.
It improves the flexibility and applicability of drilling fluid demagnetization devices, reduces operational difficulty, enhances work efficiency and safety, and meets diverse production needs.
Smart Images

Figure CN121637948A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of drilling fluid iron removal equipment, in particular to a drilling fluid magnetic removal device parameter optimization method based on a genetic algorithm and related devices. BACKGROUND
[0002] In the field of oil exploitation, drilling fluid, as a key working fluid, is widely used in drilling, well repair and other processes. However, traditional drilling fluid often contains magnetic substances such as iron filings, iron sand, magnetic impurities, etc. These substances are often adsorbed on downhole power equipment, causing equipment failure, damage, increasing economic losses and drilling cycle, and producing many negative effects. Artificial removal of magnetic substances requires a lot of time and labor, and the removal amount is small and the efficiency is low, so it is necessary to use automatic equipment to control the equipment with appropriate algorithms to efficiently remove magnetic substances from drilling fluid.
[0003] The existing drilling fluid magnetic removal machine is a simple mechanical device driven by a motor without automatic control components. The device includes a rack, a box, a track, a rotating roller assembly and a magnet assembly. The box is arranged on the rack, the upper part of one end of the box is provided with a feeding port, and the bottom of the other end is provided with a receiving hopper. The magnet assembly is arranged on the outer bottom surface of the box for adsorbing iron filings on the inner bottom surface of the box. The track is arranged in the box, and a plurality of scrapers are arranged on the surface of the bottom of the box. The rotating roller assembly is arranged on the box to drive the track to rotate, thereby driving the scrapers to scrape the iron filings on the inner bottom surface of the box to the receiving hopper. There is also a stepping motor to drive the equipment to perform repetitive work. The equipment is provided with a permanent magnet iron removal structure, an adjusting structure, a transportation structure and a waste adsorption transportation structure. The equipment can only be erected in a specific drilling fluid tank to perform continuous motion operation, cannot be parameter set, and is not suitable for variable field conditions.
[0004] These devices cannot be called real automatic control equipment because they do not have program algorithms and intelligent control elements, have limited adaptability, can only perform simple actions, cannot adjust parameters and complex situations as needed, also have problems such as sewage discharge, drilling fluid waste, low adsorption rate, high equipment failure rate, difficulty in dealing with different working conditions, and difficulty in meeting variable production needs. SUMMARY
[0005] The present application provides a drilling fluid magnetic removal device parameter optimization method based on a genetic algorithm and related devices to solve the problems of the prior art that cannot adjust parameters as needed and cannot adapt to production needs in complex situations.
[0006] To achieve the above-mentioned purpose, the present application adopts the following technical solutions:
[0007] In a first aspect, the present application provides a genetic algorithm-based parameter optimization method for a drilling fluid demagnetization device, comprising:
[0008] Obtaining the structure and process parameters of the drilling fluid demagnetization device and converting them into individual codes of the genetic algorithm, obtaining the design parameters of the drilling fluid demagnetization device as gene codes, and each individual representing a device configuration parameter;
[0009] Based on the adsorption efficiency, processing capacity and cost of the drilling fluid demagnetization device, an fitness function is constructed;
[0010] Based on the fitness function, the fitness of each individual is evaluated, and selection, crossover and mutation operations are performed on the population to generate a new generation of individuals. When the predetermined evolution generation or the fitness reaches the predetermined threshold, the optimization is completed.
[0011] Further, obtaining the structure and process parameters of the drilling fluid demagnetization device and converting them into individual codes of the genetic algorithm includes the following parameters:
[0012] Drilling fluid flow rate, drilling fluid viscosity, volume percentage of ferromagnetic material in drilling fluid, diameter of magnetic rod, center distance between magnetic rods, magnetic field strength of single magnetic rod, ferromagnetic material particle size and ferromagnetic material volume fraction; The design parameters of the drilling fluid demagnetization device include: the number of magnetic rods, the arrangement mode, the material of the magnetic rod and the design parameters of the mud scraping plate.
[0013] Further, based on the adsorption efficiency, processing capacity and cost of the drilling fluid demagnetization device, an fitness function is constructed:
[0014] The adsorption efficiency, processing capacity and cost factors are combined in the form of weights, specifically:
[0015] Fitness=w1*adsorption efficiency+w2*processing capacity-w3*cost
[0016] Wherein, w1, w2, w3 are weight coefficients.
[0017] Further, the population is selected, crossed and mutated, including:
[0018] According to the fitness, a certain number of individuals are selected as parents, the selected parents are crossed to generate new individuals, and the newly generated individuals are mutated to introduce new parameter combinations.
[0019] Further, the selection process is carried out by roulette selection or tournament selection; the crossover is carried out in the form of single-point crossover or multi-point crossover.
[0020] Further, a new generation of individuals is generated, including:
[0021] Create an empty set P newFor storing new generation of individuals; selecting high fitness individuals from current population P directly reserved to new generation population P new Add the selected parent individual set P' to the new generation population P new ;
[0022] Add the mutated child individual set C' to the new generation population P new ;
[0023] If |P new |>N, remove some low fitness individuals from P new Until |P new |=N;
[0024] If |P new |<N, copy some high fitness individuals from P' or C', until |P new |=N.
[0025] Further, when reaching a predetermined evolution number or fitness reaching a predetermined threshold, the optimization is completed:
[0026] Set current generation g=1, select or randomly generate initial population P; enter the loop, when not reaching the termination condition, execute: fitness evaluation on the current population P, select a part of individuals from the current population P as parents P' according to fitness, perform cross operation on the selected parents P', generate new child individual set C, perform mutation operation on the newly generated children C, obtain the mutated child individual set C';
[0027] Generate new generation population P new from P' and C';
[0028] Find the individual with the highest fitness from P and P new , update the best individual B; set P=P new , G=g+1, where G is the maximum generation, output the found best individual B and its fitness, the best individual B and its fitness, which is the optimal solution found by the genetic algorithm.
[0029] In a second aspect, the present application provides a drilling fluid demagnetization device parameter optimization system based on genetic algorithm, comprising:
[0030] A parameter acquisition module is configured to acquire the structure and process parameters of the drilling fluid demagnetization device, convert them into individual codes of the genetic algorithm, acquire the design parameters of the drilling fluid demagnetization device as gene codes, and acquire each individual to represent a device configuration parameter.
[0031] An fitness function construction module is configured to construct an fitness function based on the adsorption efficiency, processing capacity and cost of the drilling fluid demagnetization device.
[0032] An iteration output module is configured to evaluate the fitness of each individual based on the fitness function, perform selection, crossover and mutation operations on the population to generate a new generation of individuals, and complete optimization when a predetermined number of evolution generations is reached or the fitness reaches a predetermined threshold.
[0033] In a third aspect, the present application provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the genetic algorithm-based drilling fluid demagnetization device parameter optimization method when executing the computer program.
[0034] In a fourth aspect, the present application provides a computer-readable storage medium storing a computer program, wherein the computer program implements the steps of the genetic algorithm-based drilling fluid demagnetization device parameter optimization method when executed by a processor.
[0035] Compared with the prior art, the present application has the following technical effects:
[0036] The present application first obtains the structure and process parameters of the drilling fluid demagnetization device and converts them into individual codes of the genetic algorithm. This includes the flow rate, viscosity, and volume percentage of ferromagnetic substances of the drilling fluid, as well as the diameter, center distance, and magnetic field strength of the magnetic rod design parameters. These parameters are coded as genes, and each individual represents a device configuration parameter, providing a basis for subsequent genetic algorithm operations. This technical solution allows adjustment of various parameters according to actual conditions to adapt to different types of fluids containing magnetic substances. This enhances the flexibility and applicability of the device, enabling it to cope with different geological conditions and working environments.
[0037] The present application constructs a fitness function based on the adsorption efficiency, processing capacity, and cost of the drilling fluid demagnetization device. This function combines these three factors in the form of weights to evaluate the fitness of each individual.
[0038] The present application performs selection, crossover, and mutation operations on the population to generate a new generation of individuals. Selection is performed by roulette selection or tournament selection, and crossover is performed by single-point crossover or multi-point crossover. These operations simulate the process of natural selection and inheritance, making it more likely that individuals with high fitness will be retained and produce better offspring.
[0039] The present application generates a new generation of population through a series of operations and retains individuals with high fitness. When a predetermined number of evolution generations is reached or the fitness reaches a predetermined threshold, optimization is completed. The best individual found and its fitness are output, which is the optimal solution found by the genetic algorithm.
[0040] The optimization design and algorithm application simplify the operation process in the magnetic removal process, reduce the need for human intervention, reduce the operation difficulty, and improve the operation efficiency and safety.
[0041] In summary, the technical scheme optimizes the design parameters of the drilling fluid magnetic removal device through a genetic algorithm, thereby improving the device performance and simplifying the operation process. This is of great significance for improving the working efficiency of the drilling fluid magnetic removal device and reducing costs. BRIEF DESCRIPTION OF DRAWINGS
[0042] Figure 1 The flowchart of the present application.
[0043] Figure 2 The system structure diagram of the present application. DETAILED DESCRIPTION
[0044] The present application is further described below in conjunction with the accompanying drawings:
[0045] Example 1, please refer to Figure 1 The genetic algorithm-based drilling fluid magnetic removal device parameter optimization method includes:
[0046] The structure and process parameters of the drilling fluid magnetic removal device are obtained and converted into individual codes of the genetic algorithm. The design parameters of the drilling fluid magnetic removal device are obtained as gene codes, and each individual represents a device configuration parameter.
[0047] An adaptability function is constructed based on the adsorption efficiency, processing capacity and cost of the drilling fluid magnetic removal device.
[0048] Based on the adaptability function, the adaptability of each individual is evaluated, and selection, crossover and mutation operations are performed on the population to generate a new generation of individuals. When the predetermined evolution number or the adaptability reaches the predetermined threshold, the optimization is completed.
[0049] The parameter optimization algorithm used in the present application allows adjustment of various parameters according to actual conditions to adapt to different types of fluid containing magnetic substances.
[0050] It is highly flexible and widely applicable, and can cope with different geological conditions and working environments to ensure the reliability and stability of the device.
[0051] Example 2, the present application provides a genetic algorithm-based drilling fluid magnetic removal device parameter optimization method, which includes:
[0052] First, the structure and key parameters of the drilling fluid magnetic removal device are converted into individual codes of the genetic algorithm for operation in the algorithm.
[0053] The number of magnetic rods, arrangement, material of the magnetic rods, design of the mud scraping plate and other parameters are used as gene codes, and each individual represents a device configuration parameter.
[0054] The optimization process of genetic algorithm starts with the generation of an initial population, where each individual represents a possible set of device configuration parameters. By evaluating the fitness of each individual, i.e., its performance in terms of magnetic efficiency, processing capacity, and cost, the population undergoes selection, crossover, and mutation operations to generate a new generation of individuals.
[0055] These operations simulate the process of natural selection, genetic crossover, and mutation, gradually evolving better device configuration parameters. During each generation of evolution, based on the fitness evaluation, the genetic algorithm will tend to retain better-performing individuals, gradually converging on a better combination of device structure and parameters. Through multiple generations of evolution, the genetic algorithm is expected to find the optimal device configuration, making the drilling fluid magnetic removal device optimal in terms of adsorption efficiency, processing capacity, and cost.
[0056] This genetic algorithm-based optimization process can efficiently search the parameter space and find device configuration parameters that may be overlooked in traditional trial-and-error methods. By introducing genetic algorithms, the interactive effects of multiple key parameters can be fully considered, thereby achieving comprehensive performance optimization of the drilling fluid magnetic removal device. The optimized magnetic removal device includes two sets of symmetrical magnetic rod groups, a mud scraping plate, and a moving slag receiving disc. The magnetic rod group uses neodymium iron boron material with strong magnetic force permanent magnet, arranged in a "pin" shape, and the surface of the magnetic rod is made of corrosion-resistant stainless steel. The drilling fluid flows between the magnetic rods in an "S" shape, which can adsorb magnetic substances in the drilling fluid. The mud scraping plate and the moving slag receiving disc work together to scrape and collect the magnetic sludge adsorbed on the surface of the magnetic rod. The rack and the cover are designed to be stable, the rack is made of stainless steel square steel, and the cover is made of stainless steel, which is convenient for installation and maintenance. The electrical control part realizes automatic operation and remote monitoring through PLC and HMI.
[0057] Individual encoding: Map the key parameters of the device to the genes of the genetic algorithm. Each individual represents a combination of device parameters. In this device, the parameters used are:
[0058] Drilling fluid flow rate (FS): encoded as a real number, the range is set according to actual conditions.
[0059] Drilling fluid viscosity (V): encoded as a real number, the range is set according to actual conditions.
[0060] Volume percentage of ferromagnetic material in drilling fluid (IV): encoded as a real number, the range is set according to actual conditions.
[0061] Diameter of magnetic rod (RD): encoded as a real number, the range is set according to actual conditions.
[0062] Center distance between magnetic rods (RS): encoded as a real number, the range is set according to actual conditions.
[0063] Magnetic field strength (MFS) of single magnetic bar: encoded with real number, range set according to actual situation.
[0064] Particle size (PS) and volume fraction (PVF) of ferromagnetic substance: encoded with real number, range set according to actual situation.
[0065] The specific coding design is as follows:
[0066] Assuming using binary coding, each parameter is represented by a b-bit binary number. Then, the coding length of an individual (i.e. a configuration of magnetic shielding device) will be 8 x b.
[0067] Individual Encoding = FS || V || IV || RD || RS || MFS || PS || PVF
[0068] Wherein, || represents series.
[0069] Specific coding example: assuming assigning 4-bit binary number to each parameter (b = 4), the coding of an individual will be a 32-bit binary string, such as:
[0070] Drilling fluid flow rate: 0000 represents the lowest flow rate, 1111 represents the highest flow rate
[0071] Drilling fluid viscosity: 0000 represents the lowest viscosity, 1111 represents the highest viscosity
[0072] Volume percentage of ferromagnetic substance in drilling fluid: 0000 represents 0%, 1111 represents 100%
[0073] Diameter of magnetic bar: 0000 represents the smallest diameter, 1111 represents the largest diameter
[0074] Center distance between magnetic bars: 0000 represents the smallest distance, 1111 represents the largest distance
[0075] Magnetic field strength of single magnetic bar: 0000 represents low magnetic field strength, 1111 represents high magnetic field strength Particle size of ferromagnetic substance: 0000 represents small particle size, 1111 represents large particle size
[0076] Volume fraction of ferromagnetic substance: 0000 represents low volume fraction, 1111 represents high volume fraction
[0077] Individual example:
[0078] An individual (configuration of magnetic shielding device) is shown as follows (each parameter is represented by 4 bits):
[0079] Individual = 01001100001110010101111000101101
[0080] S1. Initialize population: Randomly generate a set of initial individuals, each individual being a combination of device parameters.
[0081] Objective: Generate an initial population of N individuals. Each individual is a combination of device parameters.
[0082] Population size: N (e.g., 50); Encoding length: L (e.g., 32 bits, 4 bits per parameter).
[0083] The steps are as follows:
[0084] 1.1 Allocate memory:
[0085] Allocate a two-dimensional array of size N x L for the initial population: Population initial = Array[N][L]
[0086] 1.2 Randomly generate encodings:
[0087] For each individual i (i = 1, 2,..., N): For each parameter j (j = 1, 2,..., 8):
[0088] Randomly generate a 4-bit binary number (b = 4).
[0089] RandomBits j = Random(0000,1111)
[0090] Concatenate the 8 4-bit binary numbers to form a 32-bit binary string.
[0091] Individual i = RandomBits1 ∥ RandomBits2 ∥... ∥ RandomBits8
[0092] Store the generated 32-bit binary string in the population array, Populationinitial initial [i] = Individual i
[0093] 1.3 Confirm population:
[0094] Confirm that all N individuals are randomly generated and stored in Populationinitial initial .
[0095] Output an initial population of N individuals, Populationinitial initial
[0096] S2. Fitness evaluation: For each individual, calculate its fitness in terms of adsorption efficiency, processing capacity, and cost, etc. using a suitable evaluation function.
[0097] The fitness function f(x) is used to calculate the fitness of individual x. Here, x is a configuration of the magnetic device.
[0098] f(x) = w1 x AE(x) + w2 x PC(x) - w3 x C(x)
[0099] w1, w2, w3 are fitness weights, for example, can be set to 0.5, 0.3 and 0.2 respectively.
[0100] AE is the adsorption efficiency, a value between 0 and 1, representing the efficiency of the magnetic device in removing ferromagnetic materials.
[0101] AE(x) = Total amount of iron removed / Total amount of iron in the drilling fluid Amount of iron removed
[0102] Total amount of iron
[0103] PC is the processing capacity, a positive number, representing the amount of drilling fluid processed per unit time.
[0104] PC(x) = Flow speed x Cross-sectional area of pipe
[0105] C is the cost, a positive number, representing the total cost of the magnetic device, including material, operating and maintenance costs.
[0106] C(x) = Material cost + Operating cost + Maintenance cost
[0107] The fitness evaluation steps are as follows:
[0108] 2.1 Calculate each factor:
[0109] For each individual x, calculate AE(x), PC(x), and C(x).
[0110] 2.2 Apply fitness function: Use the fitness function f(x) to calculate the fitness of each individual.
[0111] 2.3 Store fitness values: Store the fitness value f(x) of each individual x for subsequent selection, crossover and mutation operations.
[0112] 2.4 Output the fitness value f(x) of each individual, stored in an array of length N.
[0113] S3. Selection operation: Select some individuals as parents based on fitness. Selection can be done by roulette wheel selection or tournament selection, etc.
[0114] Roulette Wheel Selection steps are as follows:
[0115] Calculate fitness probability: For each individual xi, calculate its probability of being selected p(xi).
[0116]
[0117] Generate cumulative probability distribution: Calculate the cumulative probability c(xi) for each individual.
[0118]
[0119] Randomly select parents: Generate a random number r between 0 and 1; find the first individual xi that satisfies c(xi) > r, and add it to the parent set P.
[0120] Tournament Selection steps are as follows:
[0121] Set tournament size: Choose a tournament size T (e.g., 3 or 5).
[0122] Randomly select candidates: Randomly select T individuals from the current population as candidates.
[0123] Select the best individual: Among these T candidates, select the individual with the highest fitness as the parent.
[0124] Add to parent set: Add the selected best individual to the parent set P.
[0125] Output: The selected parent individual set P, which will be used for subsequent crossover and mutation operations.
[0126] S4. Crossover operation: Perform crossover operation on the selected parents to generate new individuals. Crossover can be done by single-point crossover or multi-point crossover, etc.
[0127] Single-Point Crossover steps are as follows:
[0128] Select crossover point: Randomly select a crossover point k, where 1 ≤ k ≤ L.
[0129] Perform crossover: For each pair of parents (Pi, Pj):
[0130] Split the two parents into two parts at the crossover point k.
[0131] Swap these two parts to generate two new offspring:
[0132] C1 = Pi1:k || Pj(k+1):L
[0133] C2 = Pj1:k || Pi(k+1):L
[0134] Add to offspring set: Add the newly generated offspring C1 and C2 to the offspring set C.
[0135] The Multi-Point Crossover step is as follows:
[0136] Select crossover points: Randomly select multiple crossover points 1, 2, …, k1, k2, …, km, where 1 ≤ ≤ ki < L.
[0137] Perform crossover: For each pair of parents (Pi, Pj): Split the two parents into multiple segments at the multiple crossover points 1, 2, …, k1, k2, …, km.
[0138] Swap these segments to generate two new offspring.
[0139] Add to offspring set: Add the newly generated offspring to the offspring set C.
[0140] Output: The newly generated set of offspring individuals C, which will be used for subsequent mutation operations and population construction for the next generation.
[0141] S5. Mutation operation: Perform mutation operations on the newly generated individuals to introduce new parameter combinations. Mutation can randomly modify certain parameter values.
[0142] Mutation operations are typically random and have a predefined mutation probability. Here are the specific steps:
[0143] 5.1 Iterate over each offspring: For each offspring individual Ci (i = 1, 2, …, |C|):
[0144] 5.2 Iterate over each gene position: For each gene position j of Ci (j = 1, 2, …, L):
[0145] 5.3 Apply mutation probability: Generate a random number r between 0 and 1. If r < pm, apply mutation, where pm is the mutation probability, e.g., 0.01.
[0146] 5.4 Perform mutation: If it is decided to mutate, flip the jth gene position of Ci.
[0147] Ci[j] = NOT(Ci[j])
[0148] 5.5 Store the mutation results: Store the mutated offspring Ci in C'.
[0149] Output: The set C' of mutated offspring individuals, which will be used to construct the new generation of population.
[0150] S6. Formation of the new generation: Generate individuals of the new generation according to the selection, crossover, and mutation operations. The specific method is as follows:
[0151] 6.1 Initialize the new generation population: Create an empty set P new to store individuals of the new generation.
[0152] 6.2 Parent retention (optional): Select a part of the individuals with high fitness from the current population P and directly retain them in the new generation population P new in.
[0153] 6.3 Add the selected parents: Add the set P' of selected parent individuals to the new generation population P new in.
[0154] 6.4 Add the mutated offspring: Add the set C' of mutated offspring individuals to the new generation population P new in.
[0155] 6.5 Population size adjustment:
[0156] If ∣P new ∣ > N, remove some individuals with lower fitness from P new until ∣P new ∣ = N.
[0157] If ∣P new ∣ < N, copy some individuals with higher fitness from P' or C' until ∣P new ∣ = N.
[0158] Output: The new generation population P new , which will be used for the next round of genetic algorithm operations.
[0159] S7. Repeat evolution and termination: Repeat the selection, crossover, and mutation operations to generate individuals in multiple generations and gradually optimize the parameters. Specifically, it includes the following steps:
[0160] 7.1 Initialize the parameters: Set the current generation number g = 1, and select or randomly generate the initial population P.
[0161] 7.2 Enter the loop:
[0162] When the termination condition is not reached, execute the following steps:
[0163] Fitness evaluation: Evaluate the fitness of the current population P.
[0164] Selection: Select a portion of individuals from the current population P as parents P'.
[0165] Crossover: Perform crossover operation on the selected parents P' to generate a new set of offspring C.
[0166] Mutation: Perform mutation operation on the new set of offspring C to get a mutated set of offspring C'.
[0167] New generation: Generate a new generation population P from P' and C'. new .
[0168] Update best individual: Find the individual with the highest fitness from P and P new , and update the best individual B.
[0169] Update current population and generation: Set P = P new , and G = g + 1, where G is the maximum number of generations.
[0170] 7.3 Output the best solution: Output the best individual B found and its fitness.
[0171] Output: The best individual B and its fitness, which is the optimal solution found by the genetic algorithm.
[0172] Termination condition: Terminate the algorithm when the predetermined number of generations is reached or the fitness reaches a predetermined threshold.
[0173] Result analysis: Select the individual with the optimal fitness from all the generated generations as the best parameter combination. These parameters will constitute the optimal configuration of the drilling fluid magnetic removal device. Specifically, it includes:
[0174] Determine the best individual: Select the individual with the highest fitness from all the generated generations as the best individual B.
[0175] Calculate the optimal fitness: Calculate the fitness f beat of the best individual B.
[0176] Decode the optimal parameter combination: Decode the best individual B into the actual parameter combination P beat .
[0177] P beat = Decode(B)
[0178] where P beat includes: drilling fluid flow rate, drilling fluid viscosity, volume percentage of ferromagnetic material in drilling fluid, diameter of magnetic rod, center distance between magnetic rods, magnetic field strength of single magnetic rod, ferromagnetic material particle size, and ferromagnetic material volume fraction, etc.
[0179] Evaluate the optimal solution: Evaluate the optimal parameter combination P using predetermined evaluation indicators (e.g., adsorption efficiency, treatment capacity, and cost, etc.) beat
[0180] Result interpretation and recommendation: According to f beat and P beat , explain why this is a good solution, and recommend using these parameters for the optimal configuration of the drilling fluid magnetic removal device.
[0181] Output: Optimal parameter combination P beat and its corresponding optimal fitness f beat .
[0182] Drilling fluid flow rate = minimum flow rate + (gene value * (maximum flow rate - minimum flow rate)) (gene value range is between [0, 1], actual parameter value is obtained through various mathematical conversion relationships).
[0183] Crossover and mutation operations: Crossover and mutation operations may require some random number generation, as well as fine-tuning of parameters (including but not limited to using random numbers, fitness information, environmental pressure, etc. to fine-tune parameters). For example: new gene value = original gene value + random number * (maximum value - minimum value) * mutation rate (this algorithm can also be adjusted according to other optimization objectives and constraints to adapt to different application scenarios).
[0184] Comparative example
[0185] Take Particle Swarm Optimization (PSO) as an example to compare the advantages of Genetic Algorithm (GA).
[0186] I. Initialize the particle swarm:
[0187] Generate particles: Randomly generate a set of initial particles For each particle, randomly initialize the following parameters: drilling fluid flow rate; drilling fluid viscosity; volume percentage of ferromagnetic material in drilling fluid; diameter of magnetic rod; center distance between magnetic rods; magnetic field strength of single magnetic rod; ferromagnetic material particle size; volume fraction of ferromagnetic material.
[0188] Example initialization process:
[0189] For each parameter y, yinit = ymin + rand() · (ymax - ymin)
[0190] Where: yinit is the initial value of parameter y; ymin and ymax are the minimum and maximum values of parameter y, respectively; rand() generates a random number between [0, 1].
[0191] For example, if the possible range of drilling fluid flow rate is [1, 10] m / s, its initialization can be shown as:
[0192] drilling fluid flow rate init = 1 + rand() · (10 - 1)
[0193] In this way, each parameter will get a random initial value within its possible range. This process is repeated for each particle in the particle swarm optimization algorithm to generate the initial particle swarm.
[0194] Velocity initialization: Assign an initial velocity to each particle, which can usually be set to 0 or a small random value.
[0195] For each particle i and each dimension d (each parameter), the velocity vi, d can be initialized as follows in this example:
[0196]
[0197] is the initial velocity of particle i in dimension d; rand() generates a random number between [0, 1]; vmax is the maximum possible value of velocity, which can usually be set to a fraction of the parameter range.
[0198] Initially, the best position of each particle is its initial position
[0199] The personal best position pbesti of each particle i is set to its initial position
[0200] Among all particles, find the particle with the highest fitness, and set it as the global best position gb
[0201]
[0202] is the fitness value of the initial position of particle i.
[0203] argmax returns the particle position that maximizes the fitness function
[0204] II. Fitness evaluation
[0205] Define fitness function: construct a fitness function that should consider factors such as adsorption efficiency, processing capacity, and cost.
[0206] Calculate fitness: use the fitness function to calculate the fitness value of each particle.
[0207] Fitness function example: w1 × adsorption efficiency + w2 × processing capacity - w3 × cost
[0208] III. Update velocity and position
[0209] Update individual best position: If the fitness value of the current position is better than the previous individual best fitness value, update the individual best position.
[0210] Update global best position: If the fitness value of the current position is better than the previous global best fitness value, update the global best position.
[0211] Velocity and position update formula example:
[0212] Vnew = ω × Vold + c1 × r1 × (pbest - xold) + c2 × r2 × (gbest - xold)
[0213] xnew = xold + Vnew
[0214] Where: Vnew: New velocity of the particle. It is the value that needs to be calculated for updating the position of the particle; w: Inertia weight. Controls the degree to which the particle maintains its current velocity, helping to balance global and local search; Vold: Old velocity of the particle. This is the velocity of the particle in the previous iteration; c1 and c2: Learning factors. They control the degree to which the particle learns from the personal best position and the global best position; r1 and r2: Random numbers in the range [0, 1]. Introduce randomness, helping the algorithm to jump out of local optimum; pbest: Best position of the particle. It is the position that the individual particle has visited with the highest fitness value; gbest: Global best position. It is the position that all particles have visited with the highest fitness value; xold: Old position of the particle. The position of the particle in the previous iteration; xnew: New position of the particle. It is the value that needs to be calculated, representing the position of the particle after velocity update.
[0215] Four. Iterative optimization
[0216] Termination condition: Set a termination condition, such as the maximum number of iterations or the change in fitness value is less than a certain threshold.
[0217] Iteration process: Repeat steps two and three until the termination condition is met.
[0218] Five. Result output
[0219] Optimal parameter combination: Output the parameter combination of the individual with the optimal fitness.
[0220] Fitness value: Output the fitness value of the optimal individual.
[0221] Comparison between genetic algorithm and particle swarm optimization:
[0222] Advantages of genetic algorithm:
[0223] Diversity: Genetic algorithms maintain diversity in the population through crossover and mutation operations, which helps avoid getting stuck in local optima.
[0224] Decodability: Genetic algorithms have a coding mechanism that makes it easier to handle complex and discrete parameter spaces.
[0225] Global and Local Search: Genetic algorithms perform both global and local search through selection, crossover, and mutation operations, while particle swarm optimization mainly focuses on local search.
[0226] Parallelism: Genetic algorithms have good parallelism because each individual can be evaluated independently.
[0227] Limitations of Particle Swarm Optimization:
[0228] Prone to Local Optima: Particle swarm optimization is prone to getting stuck in local optima, especially in high-dimensional and complex problem spaces.
[0229] Continuous Space: Particle swarm optimization is generally more suitable for continuous parameter spaces rather than discrete parameter spaces.
[0230] Social Factors: Particle swarm optimization relies on social factors (i.e., global best solution), which can cause the algorithm to converge prematurely.
[0231] In conclusion, genetic algorithms generally perform better in handling complex, multi-modal, and discrete problem spaces due to their diversity, decodability, global and local search capabilities, and parallelism. These features make genetic algorithms an ideal choice for drilling fluid magnetic removal device parameter optimization.
[0232] In another embodiment of the present invention, a genetic algorithm-based drilling fluid magnetic removal device parameter optimization system is provided, which can be used to implement the above-mentioned genetic algorithm-based drilling fluid magnetic removal device parameter optimization method. Specifically, the system includes:
[0233] A parameter acquisition module is configured to acquire the structure and process parameters of the drilling fluid magnetic removal device, convert them into individual codes of the genetic algorithm, acquire the design parameters of the drilling fluid magnetic removal device as gene codes, and represent each individual as a device configuration parameter.
[0234] An adaptive function construction module is configured to construct an adaptive function based on the adsorption efficiency, processing capacity, and cost of the drilling fluid magnetic removal device.
[0235] An iteration output module is configured to evaluate the fitness of each individual based on the adaptive function, perform selection, crossover, and mutation operations on the population, generate a new generation of individuals, and complete optimization when a predetermined number of evolution generations is reached or the fitness reaches a predetermined threshold.
[0236] The division of the modules in the embodiments of the present application is illustrative, and is merely logical function division, and another division manner can be used in actual implementation, and each function module in each embodiment of the present application can be integrated in a processor, or can be physically separated, or two or more modules can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software function module.
[0237] In still another embodiment of the present application, a computer device is provided, which comprises a processor and a memory, the memory is used to store a computer program, the computer program comprises program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc., which are the computing core and control core of the terminal, and are suitable for implementing one or more instructions, and are particularly suitable for loading and executing one or more instructions in the computer storage medium to implement a corresponding method flow or a corresponding function; the processor in the embodiments of the present application can be used for the operation of the drilling fluid demagnetization device parameter optimization method based on the genetic algorithm.
[0238] In still another embodiment of the present application, the present application also provides a storage medium, specifically a computer readable storage medium (Memory), which is a memory device in a computer device, used for storing programs and data. It can be understood that the computer readable storage medium herein can include the built-in storage medium in the computer device, and of course can also include the expansion storage medium supported by the computer device. The computer readable storage medium provides a storage space, which stores the operating system of the terminal. Moreover, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space, and the instructions can be one or more computer programs (including program codes). It should be noted that the computer readable storage medium herein can be a high-speed RAM memory, or a non-volatile memory such as at least one disk memory. The one or more instructions stored in the computer readable storage medium can be loaded and executed by the processor to realize the corresponding steps of the drilling fluid demagnetization device parameter optimization method based on the genetic algorithm in the above embodiment.
[0239] Those skilled in the art will appreciate that embodiments of the present application can be readily used as a method, a system or a computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable program code thereon.
[0240] The present application is described in reference to the flowcharts and / or block diagrams of the method, device (system) and computer program product according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general purpose computer, a special purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 an apparatus that carries out the functions specified in one or more flows and / or blocks.
[0241] These computer program instructions can also be stored in a computer readable memory that can direct the computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce a product including instruction apparatus, which realizes the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocksFigure 1 the function specified in the one or more blocks.
[0242] These computer program instructions can also be loaded into computer or other programmable data processing devices, so that a series of operation steps are performed on the computer or other programmable data processing devices to generate computer-implemented processes, thus the instructions executed on the computer or other programmable data processing devices provide a process for implementing the flow Figure 1 the flow or flows and / or blocks Figure 1 the steps of the function specified in the one or more blocks.
[0243] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application rather than limit it. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that the specific embodiments of the present application can be modified or replaced equivalently without departing from the spirit and scope of the present application, and any modification or equivalent replacement without departing from the spirit and scope of the present application should be covered in the protection scope of the claims of the present application.
Claims
1. A method for optimizing parameters of a drilling fluid demagnetization device based on a genetic algorithm, characterized in that, The method comprises the following steps: Obtaining the structure and process parameters of the drilling fluid demagnetization device, converting them into individual codes of the genetic algorithm, obtaining the design parameters of the drilling fluid demagnetization device as gene codes, and each individual representing a device configuration parameter; Based on the adsorption efficiency, processing capacity and cost of the drilling fluid demagnetization device, an fitness function is constructed; Based on the fitness function, the fitness of each individual is evaluated by combining individual codes and gene codes, and selection, crossover and mutation operations are performed on the population to generate a new generation of individuals. When the predetermined evolution number or the fitness reaches the predetermined threshold, the optimization is completed.
2. The genetic algorithm-based drilling fluid de-magnetic device parameter optimization method of claim 1, wherein, Obtaining the structure and process parameters of the drilling fluid demagnetization device, converting them into individual codes of the genetic algorithm, including the following parameters: Drilling fluid flow rate, drilling fluid viscosity, volume percentage of ferromagnetic material in drilling fluid, diameter of magnetic rod, center distance between magnetic rods, magnetic field strength of single magnetic rod, ferromagnetic material particle size and ferromagnetic material volume fraction; The design parameters of the drilling fluid demagnetization device include: the number of magnetic rods, the arrangement mode, the material of the magnetic rod and the design parameters of the mud scraping plate.
3. The genetic algorithm-based drilling fluid demagnetizer parameter optimization method of claim 1, wherein, Based on the adsorption efficiency, processing capacity and cost of the drilling fluid demagnetization device, an fitness function is constructed: The adsorption efficiency, processing capacity and cost factors are combined in the form of weights, specifically: Fitness=w1*adsorption efficiency+w2*processing capacity-w3*cost Wherein, w1, w2, w3 are weight coefficients.
4. The genetic algorithm-based drilling fluid demagnetizer parameter optimization method of claim 1, wherein, Selection, crossover and mutation operations are performed on the population, including: According to the fitness, a certain number of individuals are selected as parents, crossover operation is performed on the selected parents to generate new individuals, and mutation operation is performed on the newly generated individuals to introduce new parameter combinations.
5. The genetic algorithm-based drilling fluid de-magnetic device parameter optimization method of claim 4, wherein, The selection process is carried out by roulette selection or tournament selection; The crossover adopts single-point crossover or multi-point crossover.
6. The genetic algorithm-based drilling fluid de-magnetic device parameter optimization method of claim 4, wherein, Generating a new generation of individuals, including: Create an empty set P new For storing new generation of individuals; select high fitness individuals from current population P directly reserved to new generation population P new Add selected parent individual set P' to new generation population P new adding the mutated offspring individual set C' to the new generation population P new in the middle; If |P new | > N, remove some individuals with low fitness from P new until |P new | = N. If |P new | < N, copy the individuals with high fitness from P' or C' into P until |P new | = N.
7. The genetic algorithm-based drilling fluid de-magnetic device parameter optimization method of claim 4, wherein, When the predetermined evolution number or the fitness reaches the predetermined threshold, the optimization is completed: Set the current generation number g=1, select or randomly generate an initial population P; Enter the loop, when the termination condition is not reached, execute: fitness evaluation on the current population P, select a part of individuals from the current population P as parents P' according to the fitness, crossover operation is performed on the selected parents P' to generate new offspring individual set C, mutation operation is performed on the newly generated offspring C to obtain the mutated offspring individual set C'; According to P' and C', a new generation population P is generated new ; Find the best individual B from P and P new Update the best individual B; Set P = P new , G = g + 1, where G is the maximum generation number, output the best individual B and its fitness, the best individual B and its fitness is the optimal solution found by the genetic algorithm.
8. A drilling fluid demagnetization device parameter optimization system based on a genetic algorithm, characterized in that, Including: A parameter acquisition module is configured to obtain the structure and process parameters of the drilling fluid demagnetization device, convert them into individual codes of the genetic algorithm, obtain the design parameters of the drilling fluid demagnetization device as gene codes, and each individual representing a device configuration parameter; An fitness function construction module is configured to construct an fitness function based on the adsorption efficiency, processing capacity and cost of the drilling fluid demagnetization device; An iteration output module is configured to evaluate the fitness of each individual based on the fitness function, perform selection, crossover and mutation operations on the population to generate a new generation of individuals, and complete the optimization when the predetermined evolution number or the fitness reaches the predetermined threshold.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor executes the computer program to realize the steps of the genetic algorithm-based drilling fluid demagnetization device parameter optimization method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 9. The computer program is executed by a processor to realize the steps of the genetic algorithm-based drilling fluid demagnetization device parameter optimization method according to any one of claims 1 to 7.