High-reliability dispensing method of automatic dispensing machine based on self-adaptive genetic algorithm
By adopting a combination solution of adaptive genetic algorithm and LRU cache mechanism in the automatic drug delivery machine, the scoring and drug delivery strategy of drugs are optimized, and the problems of inefficient Chinese drug delivery and drug waste in the existing technology are solved, achieving more efficient and reliable drug management.
Patent Information
- Application Number
- CN202510155408.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-12
- Publication Date
- 2025-05-02
AI Technical Summary
The existing automatic drug delivery machine cannot correctly formulate the optimal drug delivery strategy when distributing drugs, resulting in poor drug delivery and low efficiency.
A dynamic weight scoring mechanism based on adaptive genetic algorithm is adopted, and weighted calculations are combined with the remaining effective days and transmission distance of the drug to determine the score of the drug, and the maximum heap with the Least Recently Used (LRU) cache mechanism is used to store drug information to optimize the drug issuing algorithm.
Through multi-factor priority treatment, we ensure that the drug issuing process is more accurate and reasonable, reduce drug waste, improve drug delivery efficiency, and quickly respond to drug shortages through the backup layer mechanism to reduce drug delivery delays.
Smart Images

Figure CN119919066A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of medicine dispensing machine control, and in particular relates to a high-reliability medicine dispensing method of an automatic medicine dispensing machine based on an adaptive genetic algorithm. Background Art
[0002] In recent years, with the advancement of medical technology and the growth of population, the types and quantities of medicines in hospitals, pharmacies and other medical institutions have continued to increase, and medicine management has become increasingly complex. The existing automatic medicine dispensing machines are inefficient and prone to errors, omissions and delays. These problems have been effectively solved by improving the dispensing methods and systems of medicine dispensing machines, and the accuracy and efficiency of medicine management have been improved by improving dispensing strategies and optimizing dispensing algorithms.
[0003] As the demand for hospital drugs increases, the difficulty of drug management is also increasing. The traditional drug distribution methods currently on the market cannot quickly analyze and process the information of drugs in large-scale inventory, which may lead to management chaos. When faced with complex inventory, the operation is unstable and it is difficult to formulate the optimal drug distribution strategy, which can easily lead to low drug distribution efficiency and affect the work efficiency of hospital pharmacies, outpatient clinics and other places. Summary of the invention
[0004] The purpose of the present invention is to provide a highly reliable drug dispensing method for an automatic drug dispensing machine based on an adaptive genetic algorithm, so as to solve the problem that the existing drug dispensing method cannot correctly formulate the optimal drug dispensing strategy when dispensing drugs, the drug dispensing effect is not ideal, and the drug dispensing efficiency is low.
[0005] To achieve the above object, the technical solution adopted by the present invention is:
[0006] A highly reliable medicine dispensing method for an automatic medicine dispensing machine based on an adaptive genetic algorithm, the highly reliable medicine dispensing method for an automatic medicine dispensing machine based on an adaptive genetic algorithm comprising:
[0007] Determine the conveying distance of the medicines in the regular layer when dispensing the medicines according to the medicine placement strategy, wherein the medicine placement strategy includes setting one or more layers of the automatic medicine dispensing machine as standby layers and the remaining layers as regular layers;
[0008] Adaptive genetic algorithm is used to adjust date weight and distance weight regularly;
[0009] Get the remaining effective days of the drug, use the date weight and distance weight to weight the remaining effective days and the transmission distance respectively, and calculate the score of each drug in the conventional layer;
[0010] Using a maximum heap with a Least Recently Used (LRU) cache mechanism to store drug information of each drug in the conventional layer, the drug information includes factory information, ratings, and positions in the conventional layer;
[0011] According to the prescription information, the drug with the highest score among the corresponding drugs is determined from the largest heap with an LRU cache mechanism, and the automatic dispensing machine is controlled to dispense the drugs according to the position of the drugs in the regular layer. If the automatic dispensing machine fails to dispense the drugs, the corresponding drugs are obtained from the backup layer for dispensing; if the automatic dispensing machine successfully dispenses the drugs, the next drug is dispensed until all drugs are dispensed.
[0012] Several optional methods are also provided below, but they are not intended to be additional limitations on the above-mentioned overall solution, but are merely further supplements or preferences. Under the premise that there are no technical or logical contradictions, each optional method can be combined with the above-mentioned overall solution separately, and multiple optional methods can also be combined.
[0013] Preferably, the scoring calculation formula of the drug is as follows:
[0014]
[0015] In the formula, scoring represents the score of the drug, w1 represents the date weight, expiration represents the remaining effective days of the drug, w2 represents the distance weight, and distance represents the transmission distance.
[0016] Preferably, the method of using an adaptive genetic algorithm to adjust the date weight and the distance weight comprises:
[0017] (1) Given a population size N, the basic crossover probability P b , mutation probability P m and the total number of iterations T;
[0018] (2) Initialize N individuals, each of which contains the initial values of date weight and distance weight. N individuals constitute the initial population, and set the current iteration number t = 1;
[0019] (3) Calculate the fitness of each individual in the population;
[0020] (4) If the current number of iterations t is greater than the total number of iterations T, the output of the individual with the largest fitness in the population is taken to obtain the optimal date weight and distance weight, and the process ends; otherwise, the next step is executed;
[0021] (5) According to the selection probability, one individual is randomly selected from the population each time and replicated, and a total of N selections and replications are performed. Then, the N replicated individuals form a population S1;
[0022] (6) According to the crossover probability, randomly select e individuals from population S1 and pair them up. Calculate the fitness difference ratio based on the fitness of the two parents in all pairs. Determine the crossover operation to be used based on the fitness difference ratio. Replace the original individuals with the new individuals generated by the crossover operation to obtain population S2. b Update the crossover probability with the fitness difference ratio;
[0023] (7) According to the mutation probability P m Randomly select m individuals from population S2 for mutation operation, and replace the original individuals with the generated new individuals to obtain population S3;
[0024] (8) Take population S3 as the new generation population, set the current number of iterations t = t + 1, and re-execute step (3).
[0025] Preferably, the fitness difference ratio is calculated based on the fitness of the two parents in all pairings, comprising:
[0026]
[0027] Where R is the fitness difference ratio, R∈[0,1], f1 and f2 are the fitness of the two parents in the pairing, and max is the maximum value operation.
[0028] Preferably, the crossover operation to be adopted is determined according to the fitness difference ratio, comprising:
[0029] When the fitness difference ratio R>0.5, the parent with higher fitness among the two parents is copied as a new individual, and the parent with higher fitness among the two parents is mutated to obtain another new individual. When the fitness difference ratio R<0.3, a multi-point crossover operation is performed. When the fitness difference ratio is 0.3≤R≤0.5, a weighted average crossover operation is performed.
[0030] As a preference, the method according to the basic crossover probability P b The crossover probability is updated based on the fitness difference ratio, including:
[0031] P c =P b ×(1-R)
[0032] Where P c represents the crossover probability, and R is the fitness difference ratio.
[0033] Preferably, the method of using a maximum heap with an LRU cache mechanism to store drug information of each drug in a conventional layer includes:
[0034] Define a max heap of data structures to store drug information for each drug in the general layer;
[0035] The LRU cache mechanism is implemented using a bidirectional linked list to store the drug information taken from the largest heap but not issued. The head of the bidirectional linked list stores the drug information with the most recent entry time, and the tail of the bidirectional linked list stores the drug information with the longest entry time.
[0036] Preferably, the method of determining the drug with the highest score among the corresponding drugs from the largest heap with an LRU cache mechanism according to the prescription information, and controlling the automatic drug dispensing machine to dispense the drugs according to the position of the drugs in the conventional layer, comprises:
[0037] Check whether the corresponding drug information is recorded in the LRU cache mechanism according to the prescription information;
[0038] If the corresponding drug information is recorded in the LRU cache mechanism, the automatic drug dispensing machine is controlled to dispense the drug according to the location of the drug information record. If the automatic drug dispensing machine successfully dispenses the drug, it is determined whether the dispensed drug is the drug with the corresponding drug information recorded in the LRU cache mechanism. If so, the corresponding drug information in the LRU cache mechanism is deleted; otherwise, the corresponding drug information in the LRU cache mechanism is not deleted; if the automatic drug dispensing machine fails to dispense the drug, the corresponding drug information in the LRU cache mechanism is not deleted;
[0039] If the corresponding drug information is not recorded in the LRU cache mechanism, the drug information with the highest score in the corresponding drugs is taken out from the maximum heap according to the prescription information. If drug information with the same score exists, the drug information closest to the drug dispensing point is taken, and the automatic dispensing machine is controlled to dispense the drugs according to the location of the drug information record; if the automatic dispensing machine successfully dispenses the drugs, it is determined whether the dispensed drugs correspond to the drug information taken from the maximum heap this time. If so, the dispensing of the drugs is completed; otherwise, the drug information taken from the maximum heap this time is recorded in the LRU cache mechanism; if the automatic dispensing machine fails to dispense the drugs, the drug information taken from the maximum heap this time is recorded in the LRU cache mechanism.
[0040] The present invention provides a highly reliable drug dispensing method for an automatic drug dispensing machine based on an adaptive genetic algorithm. Compared with the prior art, its significant advantages are: 1. Drugs are dispensed through a dynamic weight scoring mechanism based on an adaptive genetic algorithm, taking into account a variety of priority factors, such as the expiration date of the drug, the transmission distance, etc. This multi-factor priority processing method can ensure that the drug dispensing process is more accurate and reasonable, reduce drug waste and improve drug dispensing efficiency. 2. The drug layer of the automatic drug dispensing machine is divided into a regular layer and a spare layer based on the drug placement strategy, so that the automatic drug dispensing machine can be reasonably distributed according to the actual drug dispensing situation. When the regular layer fails to dispense drugs or is out of stock, the spare layer can respond quickly, thereby reducing drug dispensing delays caused by drug shortages. 3. A maximum heap with an LRU cache mechanism is used to determine the target drug and dispense the drug, significantly improving the drug dispensing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is a structural schematic diagram of an automatic medicine dispensing machine in the prior art;
[0042] Figure 2 It is a schematic diagram of the medicine bin structure of an automatic medicine dispensing machine in the prior art;
[0043] Figure 3 It is a flow chart of a highly reliable medicine dispensing method of an automatic medicine dispensing machine based on an adaptive genetic algorithm of the present invention;
[0044] Figure 4 The adaptive genetic algorithm workflow diagram of the automatic medicine dispensing machine of the present invention;
[0045] Figure 5 It is a workflow diagram of the LRU cache mechanism of the present invention;
[0046] Figure 6 It is a schematic diagram of dispensing medicine in the experiment of the present invention. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0049] The present embodiment provides a highly reliable drug dispensing method for an automatic drug dispensing machine based on an adaptive genetic algorithm. Compared with existing drug dispensing methods on the market, the present invention takes into account multiple priority factors, such as the shelf life of the drug, the transmission distance, etc., and dispenses the drug through a dynamic weight scoring mechanism based on an adaptive genetic algorithm and multi-factor decision-making, which can ensure that the drug dispensing process is more accurate and reasonable, reduce drug waste and improve drug dispensing efficiency.
[0050] This embodiment can be applied to Figure 1 The automatic medicine dispensing machine shown in the figure mainly includes a medicine bin, a medicine layer belt, a lifting device, etc. It should be noted that the medicine bin, the medicine layer belt, etc. are the basic structures of the automatic medicine dispensing machine. Figure 1 The automatic medicine dispensing machine is shown in FIG. 1 , but the automatic medicine dispensing machine used in the present invention is not limited to only Figure 1 The automatic medicine dispensing machine shown in .
[0051] The medicine bin in the automatic medicine dispenser is an important component. It is mainly responsible for storing medicines, and under the action of the medicine bin motor, the medicines fall onto the medicine layer belt to complete the distribution of the medicines. The medicine layer belt is mainly responsible for transporting the medicines distributed by the medicine bin to the lifting device, and then the lifting device transports the medicines of each layer to the long belt. The medicine dispenser includes multiple medicine layers, and one medicine layer includes multiple medicine bins. The medicine layers are numbered sequentially from bottom to top. For example, from bottom to top, they are medicine layer 1, medicine layer 2, medicine layer 3... and so on.
[0052] As Figure 2 shown, each medicine layer contains multiple medicine bins, and two medicine layers share one medicine layer belt, which is located below the medicine bin. Each medicine bin is numbered in the following way: (Ai, Bi,..., Oi, Pi), where Ai represents the first medicine bin of the i-th medicine layer, Bi represents the second medicine bin of the i-th medicine layer, Oi represents the fifteenth medicine bin of the i-th medicine layer, and Pi represents the sixteenth medicine bin of the i-th medicine layer. It should be noted that the number of medicine bins contained in each medicine layer is not limited to sixteen and can be set according to the actual situation.
[0053] As Figure 3 shown, a highly reliable medicine dispensing method for an automatic medicine dispenser based on an adaptive genetic algorithm provided in this embodiment includes the following steps:
[0054] Step 1: Determine the strategy for placing medicines. The medicine dispenser has n layers. The first m layers are used as regular layers for regular storage of medicines. When placing medicines, each type of medicine is assigned to a specific medicine layer, and the same medicine is assigned to the same medicine bin. When replenishing medicines later, the same medicines are replenished to their designated medicine layers and medicine bins. The top n - m layers are spare layers (m < n), and the spare layer medicines contain as many types of all medicines in the regular layer as possible.
[0055] Suppose the medicine dispenser has a total of 10 layers. The first 8 layers are used for regular storage of medicines. When placing medicines, each type of medicine is assigned to a specific medicine layer, and the same medicine is assigned to the same medicine bin to reduce medicine mixing and medicine dispensing time. When replenishing medicines later, the same medicines are replenished to their designated medicine layers and medicine bins. The top two layers are used as spare layers to cover the medicines in the regular layer as comprehensively as possible for situations where medicine dispensing fails or there is a shortage of medicines. If medicine dispensing fails in the regular layer (such as mechanical failures, medicine blockages, out-of-stock of medicines, etc.) or in special situations such as emergency medicines or sudden large demands, then the spare layer is enabled.
[0056] After completing the placement of medicines, initialize the automatic medicine dispenser and collect information on all medicines, including the factory information of the medicines (including medicine name, production date, unique identification serial number, etc.), storage location, distance from the medicine outlet, inventory quantity, and other data.
[0057] Step 2: Initialize the drug score. The score is calculated based on factors such as production date and delivery distance. The calculation formula is as follows:
[0058]
[0059] Among them, scoring represents the score of the drug, expiration represents the remaining effective days of the drug, and distance represents the transmission distance of the drug from the drug outlet; w1 and w2 are adjustable weight coefficients.
[0060] The system dynamically adjusts the weight of the scoring mechanism based on the adaptive genetic algorithm according to the actual drug delivery situation. Figure 4 As shown, the specific operations are as follows:
[0061] Step 2.1: Define the fitness function. You can choose average drug delivery time, drug expiration rate and other indicators as indicators of the fitness function. A high fitness value means that the weighted combination brings a better drug delivery effect. Given a population size N, the probability of selection P xi , basic crossover probability P b , mutation probability P m and the total number of iterations T.
[0062] Step 2.2: Initialize N individuals, each of which contains the initial values of date weight and distance weight. N individuals constitute the initial population, and set the current iteration number t=1.
[0063] Step 2.3: Calculate the fitness of each individual in the population.
[0064] Step 2.4: If the current number of iterations t is greater than the total number of iterations T, take the output of the individual with the largest fitness in the population, obtain the optimal date weight and distance weight, and end; otherwise, proceed to the next step.
[0065] Step 2.5: According to the selection probability P xi Each time, one individual is randomly selected from the population and its chromosomes are replicated, and this is done N times in total. The N replicated chromosomes are then combined to form a population S1.
[0066] Step 2.6: According to the crossover probability P c Randomly select e individuals from population S1 and pair them up. Calculate the fitness difference ratio based on the fitness of the two parents in all pairs. Determine the crossover operation to be used based on the fitness difference ratio. Replace the original individuals with the new individuals generated by the crossover operation to obtain population S2. b Update the crossover probability by the ratio of fitness difference.
[0067] In order to balance the retention of excellent weight genes and the exploration of new weight solutions during the optimization process, an adaptive crossover method can be introduced to improve the genetic algorithm. Assume that there are two parent individuals P1 and P2, and f1 and f2 represent the fitness of the two parents respectively. According to the fitness difference ratio R of all parents, when R is larger, it means that the fitness difference between the two parents is larger; otherwise, it means that the fitness is similar.
[0068]
[0069] Where R is the fitness difference ratio, R∈[0,1], f1 and f2 are the fitness of the two parents in the pairing, and max is the maximum value operation.
[0070] Dynamically adjust the crossover probability P according to the fitness difference ratio R c When the fitness difference ratio R is large, the crossover probability is reduced, and more parent genes with high fitness are retained. When the fitness difference ratio R is small, the crossover probability is high, and more crossover operations are performed to enhance population diversity.
[0071] P c =P b ×(1-R)
[0072] In order to increase the number of crossovers in the early stage, the initial crossover probability is set to 0.8 for crossover operation. Different crossover operations can be selected according to the size of the fitness difference ratio R. When the fitness difference ratio R>0.5, the parent with higher fitness among the two parents is copied as a new individual, and the parent with higher fitness among the two parents is mutated to obtain another new individual. When the fitness difference ratio R<0.3, a multi-point crossover operation is performed to increase the probability of new weight combinations. When the fitness difference ratio 0.3≤R≤0.5, a weighted average crossover operation is performed, and the weighted average of the two parent genes is taken according to a certain ratio to produce a smooth solution for the offspring weights.
[0073] Step 2.7: According to the mutation probability P m The number of mutations determined is m, which is determined by the mutation rate and the population size, m = [N*P m ], randomly determine m chromosomes from population S2, perform mutation operations on them respectively, and replace the original chromosomes with the generated new chromosomes to obtain population S3;
[0074] Step 2.8: Use population S3 as the new generation population, set the current number of iterations t = t + 1, and re-execute step 2.3.
[0075] The present invention introduces adaptive crossover based on fitness into the genetic algorithm to balance the retention of genes with higher fitness weights and the exploration of new weight solutions. If there are other influencing factors that need to be considered, corresponding scores and weights can also be added.
[0076] The adaptive genetic algorithm is used to adjust the date weight and distance weight regularly. After the weight adjustment, the date weight and distance weight are used to weight the remaining effective days and the transmission distance respectively to calculate the score of each drug in the conventional layer.
[0077] Step 3: Use a maximum heap with an LRU cache mechanism to store drug information of each drug in the conventional layer, wherein the drug information includes factory information, rating, and location in the conventional layer.
[0078] Construct a drug scoring structure. In order to avoid recalculating the scores of all drugs every time the drugs are dispensed, a maximum heap with an LRU cache mechanism is used to store the scores of each drug, so as to ensure that the drug with the highest score can be quickly selected when the drugs are dispensed. Traverse all drugs, calculate the score of each drug according to the scoring formula, and store it in the maximum heap. The heap elements contain drug scores and drug information.
[0079] like Figure 5 As shown, the maximum heap of the data structure is defined to store the drug information of each drug in the conventional layer; the LRU cache mechanism is implemented using a bidirectional linked list to store the drug information taken from the maximum heap but not issued. The head of the bidirectional linked list stores the drug information with the most recent entry time, and the tail of the bidirectional linked list stores the drug information with the longest entry time. The entry time is understood as the time stored in the LRU cache mechanism. The head of the linked list is the drug that has not been successfully issued recently, and the tail is the drug that has not been used for the longest time; the hash table is used to quickly locate the location of the drug by drug name.
[0080] For example Figure 5 As shown in (a), there are currently drugs 1, 2, 3, and 4. According to the entry time LRU cache mechanism, drugs 2, 1, 3, and 4 are stored from the head node to the tail node, and the corresponding drug warehouse locations. When dispensing drug 3, it is first necessary to check whether the information of drug 3 is saved in the linked list, such as Figure 5 As shown in (b), if drug 3 exists in the linked list, the corresponding medicine warehouse location is obtained for drug delivery, and drug 3 is updated to the head of the linked list, that is, the entry time of drug 3 is updated to the current latest time.
[0081] Step 4. When a drug dispensing request is received, the drug with the highest score among the corresponding drugs is determined from the largest heap with an LRU cache mechanism based on the prescription information, and the automatic dispensing machine is controlled to dispense the drugs based on the position of the drugs in the regular layer. If the automatic dispensing machine fails to dispense the drugs, the corresponding drugs are obtained from the backup layer for dispensing; if the automatic dispensing machine successfully dispenses the drugs, the next drug is dispensed until all drugs are dispensed.
[0082] When dispensing medicine, the medicine bin where the target medicine is located is opened to transfer the selected medicine from the corresponding medicine bin layer to the medicine layer belt. The medicine is sent to the lifting device through the medicine layer belt, and the lifting device receives the medicine and sends it to the long belt for transportation.
[0083] When medicine needs to be dispensed, the system receives and parses prescription information through the hospital information system, obtains the type and quantity of medicines, and generates a medicine dispensing task list. Since the same medicine is stored in the same medicine warehouse, there may be other medicines of the same kind under the target medicine to be dispensed. Therefore, it is possible that the medicine to be dispensed cannot be dispensed at once. At this time, the cache will record the medicine to be dispensed. The next time the medicine needs to be dispensed, the medicine warehouse that last dispensed the medicine can be directly queried to continue dispensing the medicine. When the target medicine is successfully dispensed, it will be deleted from the cache. The steps to implement drug dispensing through a maximum heap with an LRU cache mechanism are as follows:
[0084] Check whether the corresponding drug information is recorded in the LRU cache mechanism according to the prescription information;
[0085] If the corresponding drug information is recorded in the LRU cache mechanism, the automatic drug dispensing machine is controlled to dispense the drug according to the location of the drug information record. If the automatic drug dispensing machine successfully dispenses the drug, it is determined whether the dispensed drug is the drug with the corresponding drug information recorded in the LRU cache mechanism. If so, the corresponding drug information in the LRU cache mechanism is deleted; otherwise, the corresponding drug information in the LRU cache mechanism is not deleted; if the automatic drug dispensing machine fails to dispense the drug, the corresponding drug information in the LRU cache mechanism is not deleted;
[0086] If the corresponding drug information is not recorded in the LRU cache mechanism, the drug information with the highest score in the corresponding drugs is taken out from the largest heap according to the prescription information. If drug information with the same score exists, the drug information closest to the drug dispensing point is taken, and the automatic dispensing machine is controlled to dispense the drugs according to the location of the drug information record; if the automatic dispensing machine dispenses the drugs successfully, it is determined whether the dispensed drugs are the drugs corresponding to the drug information taken from the largest heap this time. If so, the dispensing of the drugs is completed; otherwise, the drug information taken from the largest heap this time is recorded in the LRU cache mechanism; if the automatic dispensing machine fails to dispense the drugs, the drug information taken from the largest heap this time is recorded in the LRU cache mechanism, and the staff is reminded to promptly investigate the cause of the failure. If the medicine warehouse has already dispensed the drugs but the delivery fails, the corresponding drug information in the LRU cache mechanism needs to be deleted, or the drugs need to be put back into the medicine warehouse.
[0087] Since the medicine in the medicine bin can be pushed out and fall into the medicine layer belt by means of a motor and a medicine discharging belt, or can be taken out by means of a mechanical arm clamping and placed into the medicine layer belt. However, no matter which method is used, there is a medicine discharging point, such as the end of the medicine discharging belt close to the medicine layer belt in the motor and medicine discharging belt method, such as the clamping point fixed by the mechanical arm in the mechanical arm clamping method. Therefore, when there are multiple medicines with the highest scores, the medicine closest to the medicine discharging point is taken to improve the efficiency of dispensing medicine.
[0088] After the automatic medicine dispensing machine successfully dispenses medicine, it is still necessary to further determine whether the dispensed medicine is in the LRU cache mechanism or is taken from the largest heap this time. The reason is that the medicine with the highest score is not necessarily the medicine closest to the medicine dispensing point. Therefore, this embodiment introduces the LRU cache mechanism. If the medicine fails to be dispensed successfully, the medicine information is stored in the LRU cache mechanism, and the medicine warehouse position corresponding to this medicine is preferentially dispensed next time. If the cache is full, delete the medicine information stored at the end of the linked list to eliminate the medicine that has not been used for the longest time.
[0089] For example Figure 5 As shown in (c), the current linked list stores drug 1, drug 2 and drug 4, and the linked list is full. At this time, drug 3 needs to be stored in the linked list, so drug 1 at the end of the linked list is deleted, and drug 3 is inserted into the linked list and updated to the head of the linked list.
[0090] In this embodiment, when dispensing medicine, the target medicine is searched from the cache first. If the target medicine exists in the cache, the medicine is continuously dispensed from the medicine bin position recorded in the cache. If the target medicine does not exist in the cache, the medicine with the highest score is found through the maximum heap, and the medicine is selected and dispensed from it, thereby effectively improving the efficiency of dispensing medicine.
[0091] The system uses a dynamic scoring mechanism based on an adaptive genetic algorithm, and uses a maximum heap with an LRU cache mechanism to determine the target drugs and dispatch them. At the same time, the adaptive genetic algorithm dynamically adjusts the weight factors that affect drug dispatch after the dispatch is completed. In order to avoid frequent calculation updates, the weight update frequency is set to re-optimize every 10 dispatches. The adaptive genetic algorithm can optimize the calculation of drug dispatch priority, allowing the system to automatically adapt to drug demand and inventory changes in a dynamic environment, rather than simply defining static weight factors, thereby improving drug dispatch efficiency.
[0092] The LRU cache mechanism stores the warehouse information of the drug with the highest score. When there are other drugs below the drug with the highest score, the drug may not be issued in time. The LRU cache mechanism records the unissued drug, and can quickly locate the warehouse where the drug is located when the drug is issued next time, reducing redundant queries. The LRU cache mechanism will give priority to retaining the information of the target drug that has been issued recently and remove the information of the drug that has been issued least recently.
[0093] The system is equipped with sensors to monitor the working status of each module in real time, to detect whether the drugs are successfully delivered to the drug layer belt and whether the drug quantity meets the requirements. If an abnormal situation is detected, such as transmission failure, drug blockage, etc., the system automatically starts the emergency plan, switches to the standby layer to deliver drugs, and triggers the alarm system to notify maintenance personnel to check and repair.
[0094] When dispensing medicine, the DC motor controls the opening of the medicine bin baffle to transfer the medicine to the conveyor belt. After dispensing the medicine, the inventory information is updated in time. When the medicine is not successfully dispensed, the system automatically retries to dispense the medicine. If it fails multiple times, it switches to the backup layer. The system automatically searches for the corresponding partition of the backup layer according to the type of medicine required, and dispenses the medicine from the backup layer to ensure the continuity and reliability of the dispensing operation. The medicines in the backup layer are managed according to the demand partitions, and there is no need to strictly follow the dynamic scoring mechanism.
[0095] If the medicines on the reserve layer are also insufficient, the system will send out a medicine shortage alarm signal to prompt the staff to manually replenish them. After the medicines are transported to the lifting device via the conveyor belt, the lifting device will send the medicines to the long belt for transportation.
[0096] Step 5: After dispensing the medicine, the system updates the medicine inventory information and the medicine information stored in the largest pile. If the number of medicines decreases to a certain threshold, a warning is issued to remind the staff to replenish the medicines.
[0097] The present invention utilizes a dynamic scoring mechanism based on an adaptive genetic algorithm and a maximum heap with an LRU cache mechanism to quickly find a more optimal solution, so that the drug dispensing process has a higher response speed. At the same time, an adaptive genetic algorithm is used to dynamically adjust the weights of influencing factors such as production date and conveyor belt distance to adapt to different drug dispensing scenarios and improve the flexibility of the drug dispensing machine system.
[0098] The present invention sets a conventional layer for daily drug delivery, and a standby layer for dealing with drug delivery failure or drug shortage. The system dynamically calculates drug scores based on factors such as drug production date, conveyor belt distance, and demand through a dynamic scoring mechanism based on an adaptive genetic algorithm, and dynamically manages drug priorities using a heap structure with an LRU cache mechanism to achieve efficient and preferential delivery of the best target drugs. The present invention has the characteristics of high efficiency, flexibility, and strong adaptability, and effectively solves the problems of low drug delivery efficiency and drug waste in the prior art.
[0099] based on Figure 6 Taking the drug placement strategy shown as an example, an experiment was conducted. For example, to distribute "Drug 3", the drug distribution method of the present invention first loads the drug matrix of the drug distribution machine, which includes the drug name, inventory, expiration date and transmission distance, and dynamically optimizes the weights of the expiration date and transmission distance through a genetic algorithm. Then the system will give priority to screening the target drugs in the conventional layer. If the conventional layer fails to distribute the drugs, the spare layer will be queried, and the drugs with the best comprehensive score will be selected for distribution based on the drug score. After one round of iterations, it is determined that the target drug to be distributed is "Drug 3" in the No. 6 medicine warehouse on the 1st floor, and the drug distribution result is output at this time. The present invention effectively reduces drug waste, improves drug distribution efficiency and system reliability through dynamic weight adjustment, reasonable priority sorting and spare layer mechanism.
[0100] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0101] The above-mentioned embodiments only express several implementation modes of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the attached claims.
Claims
1. A highly reliable medicine dispensing method for an automatic medicine dispensing machine based on an adaptive genetic algorithm, characterized in that: The highly reliable medicine dispensing method of the automatic medicine dispensing machine based on the adaptive genetic algorithm comprises: Determine the conveying distance of the medicines in the regular layer when dispensing the medicines according to the medicine placement strategy, wherein the medicine placement strategy includes setting one or more layers of the automatic medicine dispensing machine as standby layers and the remaining layers as regular layers; Adaptive genetic algorithm is used to adjust date weight and distance weight regularly; Get the remaining effective days of the drug, use the date weight and distance weight to weight the remaining effective days and the transmission distance respectively, and calculate the score of each drug in the conventional layer; Using a maximum heap with an LRU cache mechanism to store drug information of each drug in the conventional layer, the drug information includes factory information, ratings, and positions in the conventional layer; According to the prescription information, the drug with the highest score among the corresponding drugs is determined from the largest heap with an LRU cache mechanism, and the automatic dispensing machine is controlled to dispense the drugs according to the position of the drugs in the regular layer. If the automatic dispensing machine fails to dispense the drugs, the corresponding drugs are obtained from the backup layer for dispensing; if the automatic dispensing machine successfully dispenses the drugs, the next drug is dispensed until all drugs are dispensed.
2. The highly reliable medicine dispensing method for an automatic medicine dispensing machine based on an adaptive genetic algorithm according to claim 1, characterized in that: The scoring formula for the drug is as follows: In the formula, scoring represents the score of the drug, w1 represents the date weight, expiration represents the remaining effective days of the drug, w2 represents the distance weight, and distance represents the transmission distance.
3. The highly reliable medicine dispensing method for an automatic medicine dispensing machine based on an adaptive genetic algorithm according to claim 1, characterized in that: The method of using an adaptive genetic algorithm to adjust the date weight and the distance weight includes: (1) Given a population size N, the basic crossover probability P b , mutation probability P m and the total number of iterations T; (2) Initialize N individuals, each of which contains the initial values of date weight and distance weight. N individuals constitute the initial population, and set the current iteration number t = 1; (3) Calculate the fitness of each individual in the population; (4) If the current number of iterations t is greater than the total number of iterations T, the output of the individual with the largest fitness in the population is taken to obtain the optimal date weight and distance weight, and the process ends; otherwise, the next step is executed; (5) According to the selection probability, one individual is randomly selected from the population each time and replicated, and a total of N selections and replications are performed. Then, the N replicated individuals form a population S1; (6) According to the crossover probability, randomly select e individuals from population S1 and pair them up. Calculate the fitness difference ratio based on the fitness of the two parents in all pairs. Determine the crossover operation to be used based on the fitness difference ratio. Replace the original individuals with the new individuals generated by the crossover operation to obtain population S2. b Update the crossover probability with the fitness difference ratio; (7) According to the mutation probability P m Randomly select m individuals from population S2 for mutation operation, and replace the original individuals with the generated new individuals to obtain population S3; (8) Take population S3 as the new generation population, set the current number of iterations t = t + 1, and re-execute step (3).
4. The highly reliable medicine dispensing method for an automatic medicine dispensing machine based on an adaptive genetic algorithm according to claim 3, characterized in that: The fitness difference ratio is calculated based on the fitness of the two parents in all pairings, including: Where R is the fitness difference ratio, R∈[0,1], f1 and f2 are the fitness of the two parents in the pairing, and max is the maximum value operation.
5. The highly reliable medicine dispensing method for an automatic medicine dispensing machine based on an adaptive genetic algorithm according to claim 3, characterized in that: The crossover operation adopted is determined according to the fitness difference ratio, including: When the fitness difference ratio R>0.5, the parent with higher fitness among the two parents is copied as a new individual, and the parent with higher fitness among the two parents is mutated to obtain another new individual. When the fitness difference ratio R<0.3, a multi-point crossover operation is performed. When the fitness difference ratio is 0.3≤R≤0.5, a weighted average crossover operation is performed.
6. The highly reliable medicine dispensing method for an automatic medicine dispensing machine based on an adaptive genetic algorithm according to claim 3, characterized in that: According to the basic crossover probability P b The crossover probability is updated based on the fitness difference ratio, including: P c =P b ×(1-R) Where P c represents the crossover probability, and R is the fitness difference ratio.
7. The highly reliable medicine dispensing method for an automatic medicine dispensing machine based on an adaptive genetic algorithm according to claim 1, characterized in that: The method of using a maximum heap with an LRU cache mechanism to store drug information of each drug in a conventional layer includes: Define a max heap of data structures to store drug information for each drug in the general layer; The LRU cache mechanism is implemented using a bidirectional linked list to store drug information taken from the largest heap but not issued. The head of the bidirectional linked list stores the drug information with the most recent entry time, and the tail of the bidirectional linked list stores the drug information with the longest entry time.
8. The highly reliable medicine dispensing method for an automatic medicine dispensing machine based on an adaptive genetic algorithm according to claim 7, characterized in that: The method of determining the drug with the highest score among the corresponding drugs from the maximum heap with the LRU cache mechanism according to the prescription information, and controlling the automatic drug dispensing machine to dispense the drugs according to the position of the drugs in the conventional layer, includes: Check whether the corresponding drug information is recorded in the LRU cache mechanism according to the prescription information; If the corresponding drug information is recorded in the LRU cache mechanism, the automatic drug dispensing machine is controlled to dispense the drug according to the location of the drug information record. If the automatic drug dispensing machine successfully dispenses the drug, it is determined whether the dispensed drug is the drug with the corresponding drug information recorded in the LRU cache mechanism. If so, the corresponding drug information in the LRU cache mechanism is deleted; otherwise, the corresponding drug information in the LRU cache mechanism is not deleted; if the automatic drug dispensing machine fails to dispense the drug, the corresponding drug information in the LRU cache mechanism is not deleted; If the corresponding drug information is not recorded in the LRU cache mechanism, the drug information with the highest score in the corresponding drugs is taken out from the maximum heap according to the prescription information. If drug information with the same score exists, the drug information closest to the drug dispensing point is taken, and the automatic dispensing machine is controlled to dispense the drugs according to the location of the drug information record; if the automatic dispensing machine successfully dispenses the drugs, it is determined whether the dispensed drugs correspond to the drug information taken from the maximum heap this time. If so, the dispensing of the drugs is completed; otherwise, the drug information taken from the maximum heap this time is recorded in the LRU cache mechanism; if the automatic dispensing machine fails to dispense the drugs, the drug information taken from the maximum heap this time is recorded in the LRU cache mechanism.