Particle swarm algorithm-based medicine feeding method of automatic medicine feeding machine

Through the method based on particle swarm algorithm, the storage location and drug delivery path of the automatic drug delivery machine are optimized, and the problems of expired drugs and inefficient drug delivery are solved, and efficient and precise management of drugs are achieved.

CN120183602AActive Publication Date: 2025-06-20HANGZHOU YIWAN INTELLIGENT EQUIPMENT CO LTD

Patent Information

Application Number
CN202510661772.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2025-06-20
Estimated Expiration
2045-05-22

AI Technical Summary

Technical Problem

The existing automatic drug delivery machine cannot reasonably arrange the storage location of drugs, resulting in expired and waste of drugs and inefficient drug delivery.

Method used

Using a method based on particle swarm algorithm, we optimize the storage location and drug delivery path by initializing particle swarms, adjusting particle positions, building objective functions, and updating particle speed and position, ensuring that drugs are given priority during the effective period, and improving the space utilization rate of the drug warehouse and drug delivery efficiency.

Benefits of technology

Effectively reduce the risk of drug expiration, improve the space utilization rate of drug warehouses, shorten the time for drug delivery, improve overall work efficiency, and dynamically adapt to drug changes and drug cabinet status.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120183602A_ABST
    Figure CN120183602A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of automatic medicine feeding machine control and computational intelligence and optimization algorithms, and discloses an automatic medicine feeding machine medicine feeding method based on a particle swarm optimization algorithm, which comprises the following steps: initializing particles of the particle swarm optimization algorithm according to the residual capacity of a medicine bin and a medicine storage rule, and according to the use frequency of the medicine bin and the frequently-used degree of medicines, calculating the medicine feeding efficiency of the medicine bin; adjusting the positions of the particles obtained by partial initialization; an objective function is constructed based on the number of remaining effective days of the medicine, the medicine bin space utilization rate and the medicine feeding efficiency, the fitness value of each particle is calculated according to the objective function, and the individual optimal position and the global optimal position are determined; updating the speed and the position of the particle; outputting a global optimal position as an optimal medicine applying scheme after an iteration ending condition is met; and the automatic medicine feeding machine completes the medicine feeding operation of the medicine to be fed according to the optimal medicine feeding scheme. The medicine storage position is optimized, the medicine feeding efficiency is improved, and medicine changes can be dynamically adapted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the fields of automatic medicine - feeding machine control, computational intelligence, and optimization algorithms, and particularly relates to a medicine - feeding method for an automatic medicine - feeding machine based on a particle swarm algorithm. Background Art

[0002] Currently, the traditional manual medicine - feeding method not only has low efficiency, is prone to errors, but also is difficult to reasonably arrange the storage positions of medicines in the medicine cabinet, resulting in problems such as expired and wasted medicines or overly long medicine - searching times. Although some existing automatic medicine - feeding machines have improved the medicine - feeding speed to a certain extent, they have deficiencies in considering the expiration time of medicines, the utilization of medicine cabinet space, and the optimization of the medicine - feeding path, and cannot meet the requirements of efficient and accurate medicine management in modern medical institutions. For example, in terms of the management of the expiration time of medicines, there is often a lack of a dynamic adjustment mechanism and it is unable to reasonably arrange the medicine - feeding order according to the remaining validity period of the medicines; in terms of the utilization of medicine cabinet space, the changes in the types and quantities of medicines are not fully considered, resulting in wasted or crowded medicine cabinet space; in terms of the planning of the medicine - feeding path, no effective optimization is carried out, which prolongs the medicine - feeding time and affects the overall work efficiency. Summary of the Invention

[0003] The purpose of the present invention is to provide a medicine - feeding method for an automatic medicine - feeding machine based on a particle swarm algorithm to solve the problems existing in the existing automatic medicine - feeding machines, such as the inability to reasonably arrange the storage positions of medicines, the easy occurrence of expired and wasted medicines, and the low medicine - feeding efficiency.

[0004] To achieve the above - mentioned purpose, the technical solutions adopted by the present invention are as follows:

[0005] A medicine - feeding method for an automatic medicine - feeding machine based on a particle swarm algorithm, the medicine - feeding method for an automatic medicine - feeding machine based on a particle swarm algorithm includes:

[0006] Obtain the information of the medicines to be fed and the inventory information of the medicine cabinet of the automatic medicine - feeding machine;

[0007] Initialize the particles of the particle swarm algorithm according to the remaining capacity of the medicine cabinet and the medicine storage rules, and adjust the positions of some of the initialized particles according to the usage frequency of the medicine cabinet and the commonness of the medicines;

[0008] Construct an objective function based on the remaining valid days of the medicines, the utilization rate of the medicine cabinet space, and the medicine - feeding efficiency, calculate the fitness value of each particle according to the objective function, and determine the individual optimal position and the global optimal position;

[0009] Update the speed and position of the particles, and after the position is updated, judge whether the new position conforms to the remaining capacity of the medicine cabinet and the medicine storage rules. If it conforms, accept the new position; otherwise, randomly generate a position according to the remaining capacity of the medicine cabinet and the medicine storage rules as the new position;

[0010] Determine whether the iteration end condition is reached. If not, recalculate the fitness value of each particle and continue the iteration; otherwise, output the global optimal position as the optimal drug application plan.

[0011] The automatic drug applicator completes the drug application operation for the drug to be applied according to the optimal drug application plan.

[0012] The following also provides several optional methods, which are not additional limitations to the above overall solution, but only further supplements or optimizations. Without technical or logical contradictions, each optional method can be combined with the above overall solution separately, or multiple optional methods can be combined with each other.

[0013] Preferably, the obtaining of the information of the drug to be applied and the drug warehouse inventory information of the automatic drug applicator includes:

[0014] Obtain the name, production date, expiration date, and specification of the drug to be applied by scanning the code, and calculate the remaining valid days = production date + expiration date - current date. The obtained drug application information includes name, production date, expiration date, specification, and remaining valid days.

[0015] The medicine cabinet of the automatic drug applicator adopts a multi-layer and multi-warehouse structure design. Each layer has multiple independent medicine warehouses. Only one type of drug can be stored in the same medicine warehouse. Each medicine warehouse is equipped with sensors for real-time monitoring of the inventory quantity and drug type in the medicine warehouse. The obtained medicine warehouse inventory information includes the remaining capacity of the medicine warehouse, inventory quantity, and drug type, where the remaining capacity of the medicine warehouse = actual capacity of the medicine warehouse - inventory quantity.

[0016] Preferably, the adjusting the positions of some particles obtained by partial initialization according to the usage frequency of the medicine warehouse and the common usage degree of the drug includes:

[0017] Count the number of times the drug is taken within a preset time period, and calculate the drug usage frequency. Set the drug with a drug usage frequency greater than the common threshold as a commonly used drug. If the current drug to be applied is a commonly used drug, take some particles obtained by partial initialization. For each taken particle, adjust the position of the particle to any one of the nearest target medicine warehouses to the drug outlet of the automatic drug applicator, where the target medicine warehouse is the medicine warehouse for storing the current drug to be applied; if the current drug to be applied is not a commonly used drug, count the historical usage times of all medicine warehouses for storing the current drug to be applied within a preset time period, and calculate the medicine warehouse usage frequency. Take some particles obtained by partial initialization. For each taken particle, adjust the position of the particle to any one of the top medicine warehouses with the highest medicine warehouse usage frequency.

[0018] Preferably, the constructing the objective function based on the remaining valid days of the drug, the space utilization rate of the medicine warehouse, and the drug application efficiency includes:

[0019]

[0020] In the formula, is the objective function, , and are the weights of the remaining effective days of the drug, the utilization rate of the medicine warehouse space, and the medicine loading efficiency respectively, and , represents the remaining effective days of the th drug to be loaded, is the convenience weight for accessing the rd medicine warehouse on the th layer, , represents the inventory quantity of the rd medicine warehouse on the th layer, represents the actual capacity of the rd medicine warehouse on the th layer, represents the single-time medicine loading time of the th drug to be loaded, represents the set maximum allowable medicine loading time;

[0021] Among them, the single-time medicine loading time is calculated as follows:

[0022]

[0023] In the formula, represents the single-time medicine loading time of the th drug to be loaded, represents the moving speed of the robotic arm of the automatic medicine loading machine, represents the moving distance of the robotic arm from the medicine loading position to the medicine warehouse position for the th drug to be loaded, represents the time required for the robotic arm to grasp and place the medicine.

[0024] Preferably, updating the velocity and position of the particle includes:

[0025]

[0026]

[0027]

[0028] In the formula, represents the velocity of the particle at the th iteration, is the inertia weight, represents the velocity of the particle at the -th iteration, and is a random number between [0, 1], and are learning factors, represents the personal best position of the particle , represents the global best position, represents the position of the particle at the -th iteration, represents the position of the particle at the -th iteration, represents the maximum value of the inertia weight, represents the minimum value of the inertia weight, is the attenuation coefficient, is the adaptive adjustment amplitude, is the difference in the fitness values of the particles corresponding to the global best position in the last two iterations, is the fitness value of the particle corresponding to the global best position among the initialized particles, is the maximum number of iterations, is the current iteration number.

[0029] Preferably, after the drug loading operation of the drug to be loaded is completed, regularly check the remaining effective days of the drug in the medicine warehouse. When the remaining effective days of the drug reach the warning value, mark the drug as a high-risk drug;

[0030] The automatic drug loading machine takes out the high-risk drug from the medicine warehouse as the drug to be loaded, updates the medicine warehouse inventory information at the same time, re-runs the particle swarm algorithm to complete the drug loading of the high-risk drug, and increases the weight of the remaining effective days of the drug in the particle swarm algorithm.

[0031] Preferably, if the drug loading operation fails, the automatic drug loading machine emits an alarm signal and re-runs the particle swarm algorithm to complete the drug loading of the current drug.

[0032] The medicine - loading method of an automatic medicine - loading machine based on the particle swarm algorithm provided by the present invention has the following significant advantages compared with the prior art: 1. Optimize the storage positions of medicines. By comprehensively considering multiple factors such as the expiration time of medicines, the utilization rate of the medicine bin space, and the medicine - loading efficiency through the particle swarm algorithm, the optimal storage positions for medicines can be found, reducing the risk of medicine expiration and improving the effective utilization of the medicine bin space. For example, place the medicines approaching expiration at more convenient positions for access to ensure they are preferentially used within the validity period; at the same time, according to the actual space situation of the medicine bin, reasonably allocate the storage positions of medicines to avoid space waste. 2. Improve the medicine - loading efficiency. During the algorithm iteration process, by dynamically adjusting the speed and position of particles, continuously optimize the medicine - loading path and sequence, effectively shortening the average medicine - loading time. Moreover, when initializing the particle swarm and calculating the objective function, fully consider the actual working parameters of the medicine - loading machine and the layout characteristics of the medicine cabinet, further improving the medicine - loading efficiency. 3. Dynamically adapt to medicine changes. Regularly check the remaining valid days of medicines and adjust the medicine - loading strategy according to the actual situation, being able to respond in a timely manner to changes in the validity period of medicines. When a malfunction occurs in the medicine cabinet or the medicine demand changes, it can also quickly re - plan the medicine - loading plan to ensure the continuity and stability of the medicine - loading process. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 is a schematic structural diagram of the automatic medicine - loading machine of the present invention;

[0034] Figure 2 is a flowchart of the medicine - loading method of an automatic medicine - loading machine based on the particle swarm algorithm of the present invention;

[0035] Figure 3 is a flowchart of the operation of the particle swarm algorithm of the present invention;

[0036] Figure 4 is a flowchart for the management of the expiration time of medicines of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0037] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0038] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present invention belongs. 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.

[0039] This embodiment provides a method for dispensing drugs by an automatic drug dispenser based on the particle swarm optimization algorithm. Compared with the existing drug dispensing methods on the market, the present invention takes into account various priority factors, such as the expiration date of drugs, transmission distance, etc. By optimizing the dynamic weights based on the particle swarm optimization algorithm and making multi-factor decisions for drug dispensing, it can ensure that the drug dispensing process is more accurate and reasonable, reduce drug waste and improve the drug dispensing efficiency.

[0040] The automatic drug dispenser in this embodiment mainly includes a control system, a warehouse management system, a drug dispensing belt, a camera, a medicine cabinet, a medicine warehouse, etc. It should be noted that the drug dispensing belt, medicine warehouse, etc. are the basic structures of the automatic drug dispenser. The medicine warehouse in the automatic drug dispenser is an important component, which is mainly responsible for storing drugs. The structure of the medicine warehouse is as Figure 1 shown. One medicine warehouse can only store one type of drug, and some medicine warehouses can be set with special environments, such as controlling temperature, humidity, etc. When dispensing drugs, a non-empty medicine warehouse can only further store the same type of drug. An empty medicine warehouse can be set to be stored by any drug, or it can be set to be stored only by a specified drug.

[0041] As Figure 2 shown, a method for dispensing drugs by an automatic drug dispenser based on the particle swarm optimization algorithm provided in this embodiment includes the following steps:

[0042] Step 1, Information initialization: Obtain the information of the drugs to be dispensed and the inventory information of the medicine warehouses in the automatic drug dispenser.

[0043] When a batch of drugs needs to be dispensed, the automatic drug dispenser starts to initiate the work process. First, the drugs are conveyed to the camera scanning area through the conveying device. The camera uses an industrial-grade camera with high precision and fast recognition, having high resolution and good light adaptability, and can accurately identify the drug barcode information under different lighting conditions. The camera is connected to the control system of the automatic drug dispenser through a high-speed data interface to ensure that the scanned drug information can be transmitted to the control system in a timely and accurate manner.

[0044] The camera scans the barcode of each drug one by one. During the scanning process, the control system will conduct a preliminary verification on the scanned information to ensure the integrity and accuracy of the information. Once the barcode is scanned, the camera will immediately transmit the detailed information such as the name, production date, expiration date, and specification of the drug to the database of the control system for storage and processing. For example, for a box of "Amoxicillin Capsules", after scanning, the production date is obtained as March 1, 2024, the expiration date is 24 months, and the specification is 0.5g * 24 capsules. Based on this information, the control system quickly calculates the remaining effective days of the drug. The calculation formula is: Remaining effective days = Expiration date deadline (Production date + Expiration date) - Current date.

[0045] Meanwhile, the control system will interact with the warehouse management system of the medicine cabinet to obtain detailed information about each layer of medicine bins in the medicine cabinet. The medicine cabinet adopts a multi-layer and multi-bin structure design. Each layer has multiple independent medicine bins, and each medicine bin is equipped with sensors for real-time monitoring of the inventory quantity and types of medicines in the bin. For example, the types of medicines are identified by cameras installed at the bin openings, and the operations of medicines entering and being taken out of the bin are monitored. The warehouse management system communicates with these sensors through network interfaces to read the current inventory quantity, the types of stored medicines, and the location information of each medicine bin. For example, if the medicine cabinet has 6 layers and each layer has 20 medicine bins, the control system can accurately know that the 15th medicine bin on the 3rd layer currently stores "Ganmaoling Granules" with an inventory quantity of 15 boxes. To facilitate subsequent control, this embodiment introduces the concepts of the actual capacity and the remaining capacity of the medicine bin. Since the packaging sizes of different medicines are different, the quantities stored in the medicine bins are also different. Therefore, this embodiment defines the actual capacity of the medicine bin as the quantity of the corresponding medicine stored in the bin, and the remaining capacity of the medicine bin = actual capacity of the medicine bin - inventory quantity.

[0046] All the obtained medicine information and medicine bin inventory information provide an accurate data basis for the subsequent operation of the particle swarm algorithm. At the same time, the medicine bin inventory information and medicine information will be displayed in an intuitive table form on the operation interface, facilitating the operator to view and monitor.

[0047] Step 2: Use the particle swarm algorithm to iteratively find the optimal medicine loading plan, as Figure 3 shown, and the specific operations are as follows:

[0048] In this embodiment, the particle swarm algorithm is independently run for each medicine to be loaded. During the operation of the particle swarm algorithm, the medicine loading plan for each medicine is abstracted as a particle. Each particle represents a possible way of placing the medicine, and the position information of the particle represents the specific medicine bin position selected when loading the medicine. To accurately represent the medicine bin position, the position of the particle is defined in the form of a two-dimensional vector. Assume that the medicine cabinet has layers, and each layer has medicine bins. Then the position of the particle can be represented by a two-dimensional vector , where , . When , it means that the medicine will be placed in the th layer and the th medicine bin; when , it means that the medicine will not be placed in the th layer and the th medicine bin.

[0049] The velocity vector of the particle has the same dimension as the position vector, and each component of the velocity vector It represents the direction and amplitude of the adjustment of the drug application position. The velocity vector determines the moving direction and speed of the particle in the search space, thus guiding the particle to continuously explore a better drug application plan.

[0050] Step 2.1: Initialize the particles of the particle swarm algorithm according to the remaining capacity of the medicine warehouse and the drug storage rules, and adjust the positions of some of the initialized particles according to the usage frequency of the medicine warehouse and the commonness of the drugs.

[0051] Randomly generate particles to form an initial particle swarm, where can be adjusted according to the actual situation, and generally takes a value between 50 and 100. When initializing the particle swarm, it is necessary to consider the remaining capacity of the medicine warehouse and the drug storage rules. Each medicine warehouse has a fixed storage upper limit, that is, when a certain medicine warehouse has reached the maximum capacity, even if the placement position calculated by the particle swarm algorithm is feasible, drugs cannot be stored continuously; each medicine warehouse can only store one kind of drug, and some drugs may have special storage requirements due to different characteristics. For example, temperature-sensitive drugs need to be stored in a specific medicine warehouse. For the initial position of each particle, it is randomly generated on the premise of meeting the medicine warehouse capacity limit and the drug classification storage rules. For example, if some special drugs need to be stored in a specific temperature environment, then these drugs cannot be randomly placed in a medicine warehouse that does not meet the conditions during initialization. It should be noted that the drug storage rules correspond to the drugs that actually need to be stored. When the drugs to be applied are known, the drug storage rules are also known. Therefore, when initializing the example position, determine the medicine warehouses where the drugs to be applied can be stored according to the drug storage rules, and then randomly select a medicine warehouse from the medicine warehouses that can store to complete the initialization.

[0052] At the same time, according to the actual usage frequency of the medicine warehouse and the commonness of the drugs, the initial positions of the particles are set specifically. The actual usage frequency of the medicine warehouse is obtained by counting the historical usage times of the medicine warehouse, for example, the number of times each medicine warehouse is used within a certain period of time; the commonness of the drugs is obtained by counting the number of times the drug is taken within a period of time, for example, the number of times of taking drugs in the past month. The specific operation is as follows: count the number of times of taking drugs of the drug within the preset time period, and calculate the drug usage frequency. Set the drugs with a drug usage frequency greater than the common threshold as common drugs. If the current drug to be applied is a common drug, take some of the initialized particles, and for each of the taken particles, adjust the position of the particle to the one closest to the drug outlet of the automatic drug applicator. Any one of the target medicine bins, where the target medicine bin is the medicine bin for storing the currently to-be-dosed medicine; if the currently to-be-dosed medicine is not a commonly used medicine, then count the historical usage times of all the medicine bins for storing the currently to-be-dosed medicine within a preset time period, calculate the medicine bin usage frequency, select some of the initially obtained particles, and for each selected particle, adjust the position of the particle to any one of the top medicine bins with the highest medicine bin usage frequency.

[0053] For example, for commonly used medicines, their initial positions are preferably set in the 3 medicine bins closest to the medicine outlet. For example, "Aspirin Enteric-coated Tablets" is a commonly used medicine. During initialization, the components of the position vector representing "Aspirin Enteric-coated Tablets" in some (for example, 0.1 pieces, adjusted according to actual needs) particles can be set to the positions corresponding to the 3 medicine bins closest to the medicine outlet, which can improve the efficiency of finding a better dosing plan subsequently.

[0054] The initial velocity of each particle is randomly taken within a certain range. The setting of the velocity range should comprehensively consider the size of the search space and the convergence speed of the algorithm. Generally speaking, the velocity range can be set to [-1, 1], which can not only ensure that the particles have sufficient exploration ability but also prevent the particles from moving blindly in the search space.

[0055] Step 2.2: Construct an objective function based on the remaining effective days of the medicine, the utilization rate of the medicine bin space, and the dosing efficiency, calculate the fitness value of each particle according to the objective function, and determine the individual optimal position and the global optimal position.

[0056] To optimize the dosing plan, a reasonable objective function needs to be set. The objective function comprehensively considers multiple factors such as the risk of medicine expiration, the utilization rate of the medicine bin space, and the dosing efficiency to ensure that the finally obtained dosing plan can achieve a better balance in all aspects. The specific objective function formula is:

[0057]

[0058] where, is the remaining effective days of the th medicine, is the convenience weight for taking the th medicine from the th medicine bin on the , The value of The lower it is, the objective function The larger the value of the drug expiration risk index, the greater the possibility of drug expiration, and the higher the weight in the objective function. Each drug warehouse has its storage space limit, For the th occupied space (i.e., inventory quantity) of the th warehouse on the th represents the remaining space utilization rate of the th warehouse on the , represents the single-dose loading time of the th drug to be loaded, represents the moving speed of the robotic arm of the automatic loading machine, represents the moving distance of the robotic arm from the loading position to the warehouse position for the th drug to be loaded, represents the time required for the robotic arm to grasp and place the drug, is the set maximum allowable loading time. . These three weight coefficients can be adjusted according to actual needs to balance the importance of various factors. For example, when the drug expiration risk is relatively high, the value of can be appropriately increased; when the warehouse space is tight, the value of can be increased; when the loading efficiency requirement is relatively high, the value of can be increased.

[0059] Step 2.2.1. For each particle in the particle swarm, calculate its fitness value according to the set objective function. The fitness value reflects the quality of the loading plan represented by the particle. The smaller the fitness value, the better the loading plan. When calculating the fitness value, first determine the specific warehouse where each drug is placed according to the position vector of the particle, then calculate the values of each parameter according to the formula of the objective function, and finally substitute each parameter into the objective function to calculate the fitness value.

[0060] For example, for each particle, its position vector represents the placement of drugs in different medicine compartments respectively. According to this placement scheme, the remaining effective days of the drugs, the remaining space utilization rate of the medicine compartments, and the medicine loading time are calculated, and then substituted into the objective function to calculate the fitness value of the particle. During the calculation process, it is necessary to ensure the accurate calculation of each parameter to ensure that the fitness value can truly reflect the advantages and disadvantages of the medicine loading scheme.

[0061] Step 2.2.2: Compare the current fitness value of each particle with its historical best fitness value. If the current fitness value is better, it means that the particle has found a better medicine loading scheme in this iteration. At this time, update the individual optimal position of the particle to the current position. For example, the historical best fitness value of particle A before the th iteration is 80, and the current fitness value calculated in the th iteration is 75. Since 75 < 80, the individual optimal position of particle A is updated to the current position.

[0062] Meanwhile, compare the fitness values of all particles to find the global optimal position . The fitness value corresponding to the global optimal position is the minimum fitness value found by all particles in the current iteration. After each iteration, the global optimal position is updated to ensure that it always represents the optimal medicine loading scheme found in the current particle swarm.

[0063] Step 2.3: During the iteration process of the particle swarm algorithm, the particles will update their velocities and positions according to their own historical experience and the optimal information of the group. The specific update formulas are as follows:

[0064]

[0065]

[0066] Among them, is the current iteration number, is the inertia weight, which plays an important role in balancing the global search and local search capabilities in the algorithm. At the beginning of the iteration, in order to allow the particles to explore in a larger search space and discover more possible optimal solutions, can be set to a larger value; as the iteration progresses, in order to allow the particles to converge more precisely to the optimal solution, gradually decreases. A non-linear adaptive adjustment strategy based on the fitness change rate can be used to adjust the value of , and this strategy introduces a non-linear exponential decay term and an adaptive term based on the fitness change. The specific formula is:

[0067]

[0068] Among them, is the maximum value of the initial inertia weight, generally taking a value of 0.9; is the minimum value of the inertia weight in the later stage of iteration, generally taking a value of 0.4; is the maximum number of iterations. The non-linear exponential decay term , is the decay coefficient, which controls the decline rate of the global search ability, is the adaptive adjustment amplitude, usually taking a value of 0.1, is the difference in the global best fitness in the last two iterations (the -th iteration and the -th iteration), is the initial global best fitness value. If is large (the algorithm is still significantly optimizing), then increase , delay the decay to continue exploration. If is small (the algorithm is close to convergence), then decrease to enhance the local search ability. and are learning factors, usually taking a value of 1.49445. They control the step sizes for the particle to learn towards the individual optimal position and the global optimal position respectively. and are random numbers between [0, 1]. The purpose of introducing random numbers is to increase the randomness and diversity of the algorithm and avoid the particles falling into the local optimal solution prematurely. is the individual optimal position of particle , that is, the medicine bin position corresponding to the optimal fitness value found by this particle during the historical iteration process; is the global best position of the entire particle swarm, that is, the medicine bin position corresponding to the solution with the smallest fitness value found by all particles during all iteration processes. The non-linear exponential decay term introduced in this embodiment, compared with linear adjustment, the exponential decay combined with the adaptive term can reduce redundant iterations and shorten the medicine loading planning time. And in this embodiment, through non-linear decay and dynamic feedback, it can avoid the algorithm from converging prematurely or diverging excessively.

[0069] When updating the position, it is necessary to ensure that the position vector meets the actual constraints of the medicine bin, that is, after the position is updated, judge whether the new position conforms to the remaining capacity of the medicine bin and the medicine storage rules. If it conforms, accept the new position; otherwise, randomly generate a position according to the remaining capacity of the medicine bin and the medicine storage rules as the new position.

[0070] For example, the medicine storage has a capacity limit. If a certain medicine storage has reached its maximum capacity, even if the calculated position component is 1, the medicine cannot be placed in that storage. At this time, it is necessary to adjust the position of the particle and randomly generate some position components of the particle again until all constraint conditions are met. At the same time, it is necessary to detect whether the medicine storage rules are satisfied to ensure the feasibility and rationality of the medicine loading plan.

[0071] Step 2.4: Determine whether the iteration end condition is reached. If not, recalculate the fitness value of each particle and continue the iteration, that is, return to Step 2.2.1 to execute again; otherwise, output the global optimal position as the optimal medicine loading plan.

[0072] Set the maximum number of iterations , the current number of iterations When the maximum number of iterations is reached , stop the iteration. The setting of the maximum number of iterations needs to be adjusted according to the complexity of the actual problem and the performance of the algorithm. Generally speaking, a suitable maximum number of iterations can be determined through multiple experiments.

[0073] In addition, another termination condition can be set, that is, the fitness value of the global best position changes less than the set threshold in consecutive several iterations . When this condition is met, it means that the algorithm has converged to a stable solution, and continuing the iteration may not get better results. At this time, stop the iteration. For example, set the threshold . If the fitness value of the global best position changes less than 0.01 in consecutive 10 iterations, it is considered that the algorithm has converged and stop the iteration.

[0074] When any of the above termination conditions is met, output the global optimal position as the optimal medicine loading plan. This optimal medicine loading plan represents the medicine placement plan that can minimize the objective function value under the current medicine information and medicine cabinet status, that is, the optimal plan obtained by comprehensively considering factors such as the risk of medicine expiration, the utilization rate of medicine storage space, and the medicine loading efficiency.

[0075] Step 4: According to the optimal medicine loading plan obtained by the particle swarm algorithm, the control system sends control instructions to the robotic arm of the automatic medicine loading machine to complete the medicine loading operation of the medicine to be loaded. The robotic arm uses a high-precision and high-speed industrial robotic arm, which has multiple degrees of freedom and precise positioning capabilities, and can accurately grasp and place medicines. The movement trajectory of the robotic arm is determined by pre-programming and real-time adjustment to ensure that the medicine can be quickly and accurately grabbed from the conveying device and placed into the corresponding medicine storage.

[0076] When placing drugs, strictly follow the principle of first-in, first-out. For the situation where there are already drugs in the same medicine bin, the new drugs are placed behind the existing drugs to ensure that the earlier stored drugs can be taken out first when dispensing drugs, reducing the risk of drug expiration.

[0077] During the drug loading process, sensors installed on the medicine bin and the robotic arm will continuously monitor the actual status of the medicine bin and the placement of drugs. The medicine bin sensor can detect information such as the capacity of the medicine bin and the storage location of drugs; the robotic arm sensor can detect information such as the grasping status of drugs and whether the placement location is accurate. These sensors will feed the real-time data back to the control system, and the control system will analyze and process the data. If it is found that the actual status is inconsistent with the expected drug loading plan, such as the medicine bin is full but there is still a plan to place drugs in this medicine bin, or the drug placement location is inaccurate, etc., the control system will judge that the drug loading operation has failed, immediately stop the drug loading operation, and send an alarm signal to notify the operator for handling. At the same time, the control system will restart the particle swarm optimization algorithm and recalculate the optimal drug loading plan according to the current actual situation to ensure the accuracy and reliability of the drug loading process.

[0078] After the drug loading operation is completed, the control system will update the inventory quantity and drug information of the medicine bin in real time. Add the detailed information of the newly placed drugs to the drug list of the medicine bin, and at the same time update the inventory quantity of the medicine bin. The updated information will be stored in the database and displayed in real time on the operation interface for the convenience of the operator to view and manage.

[0079] Step 5: Management of drug expiration time and adjustment of drug loading strategy. The process is as Figure 4 shown. The control system of the automatic drug loading machine will regularly check the remaining valid days of the drugs in the medicine cabinet. The inspection cycle can be set according to the actual situation, and generally can be set to be inspected once a week or once a month. During the inspection process, the control system will read information such as the production date, expiration date, and current date of each drug from the database, calculate the remaining valid days of each drug, and compare the results with the set warning value.

[0080] When it is found that the remaining valid days of some drugs reach the set warning value, for example, the remaining valid days are less than one-fourth of the total expiration date, the control system will immediately mark these drugs as high-risk drugs and take them out of the medicine cabinet, and restart the particle swarm optimization algorithm to adjust the drug loading strategy. The drugs marked as high-risk will not be marked as high-risk again when they are loaded again. When restarting the particle swarm optimization algorithm, the weight of the drug expiration risk factor in the objective function will be appropriately increased . For example, The value is increased from the original 0.4 to 0.6, so that the algorithm will pay more attention to reducing the expiration risk of drugs when searching for the optimal drug loading plan. At the same time, the algorithm will incorporate the space of the medicine cabinet after removing high-risk drugs into the calculation. When calculating the utilization rate of the medicine cabinet space, it will evaluate the utilization rate of different drug loading plans based on the remaining space after removing the drugs. When updating the example position, it will also ensure that the drug loading plan represented by the particle conforms to the actual constraints such as the medicine cabinet capacity limit according to the new state of the medicine cabinet space.

[0081] After re-running the particle swarm algorithm, a new drug loading plan will be generated. This new plan will prioritize the loading and dispensing of drugs nearing expiration, placing these drugs in more accessible locations to ensure they can be used preferentially within the expiration date. For example, placing drugs nearing expiration in the medicine cabinet near the drug outlet, or placing them in the same area as commonly used drugs so that they can be more easily discovered and used when dispensing drugs. The present invention optimizes the storage location of drugs, improves the drug loading efficiency, and can dynamically adapt to drug changes.

[0082] When implementing the new drug loading plan, the principle of first-in, first-out and the actual constraints of the medicine cabinet should also be followed. During the entire drug expiration time management process, the control system will monitor the status of drugs and the information of the medicine cabinet in real time to ensure that the expiration risk of drugs is effectively controlled and the efficiency and safety of drug management are improved.

[0083] The technical features of the above-described embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.

[0084] The above-described embodiments merely represent several implementation manners of the present invention. The description is relatively specific and detailed, but it should not be construed as a limitation on the scope of the invention. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can still be made, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the appended claims.

Claims

1. An automatic medicine - dosing method for a medicine - dosing machine based on the particle swarm optimization algorithm, characterized in that, The method for loading drugs by the automatic drug loading machine based on the particle swarm optimization algorithm includes: Obtaining the information of the drugs to be loaded and the inventory information of the medicine bins of the automatic drug loading machine; Initializing the particles of the particle swarm optimization algorithm according to the remaining capacity of the medicine bin and the drug storage rules, and adjusting the positions of some of the initialized particles according to the usage frequency of the medicine bin and the commonness of the drugs; Constructing an objective function based on the remaining effective days of the drugs, the space utilization rate of the medicine bin, and the drug loading efficiency, calculating the fitness value of each particle according to the objective function, and determining the individual optimal position and the global optimal position; Updating the velocity and position of the particles, and after the position is updated, judging whether the new position conforms to the remaining capacity of the medicine bin and the drug storage rules. If it conforms, accept the new position; otherwise, randomly generate a position as the new position according to the remaining capacity of the medicine bin and the drug storage rules; Judging whether the iteration end condition is reached. If not, recalculate the fitness value of each particle and continue the iteration; otherwise, output the global optimal position as the optimal drug loading plan; The automatic drug loading machine completes the drug loading operation of the drugs to be loaded according to the optimal drug loading plan.

2. The automatic medicine - dosing method for a medicine - dosing machine based on the particle swarm optimization algorithm according to claim 1, characterized in that, The obtaining of the information of the drugs to be loaded and the inventory information of the medicine bins of the automatic drug loading machine includes: Obtaining the name, production date, expiration date, and specification of the drugs to be loaded by scanning the code, and calculating the remaining effective days = production date + expiration date - current date, so as to obtain the drug loading information including name, production date, expiration date, specification, and remaining effective days; The medicine cabinet of the automatic drug loading machine adopts a multi-layer and multi-bin structure design. Each layer has multiple independent medicine bins. Only one type of drug can be stored in the same medicine bin. Each medicine bin is equipped with a sensor for real-time monitoring of the inventory quantity and drug type of the medicine bin, so as to obtain the medicine bin inventory information including the remaining capacity of the medicine bin, the inventory quantity, and the drug type, where the remaining capacity of the medicine bin = actual capacity of the medicine bin - inventory quantity.

3. The automatic medicine - dosing method for a medicine - dosing machine based on the particle swarm optimization algorithm according to claim 1, characterized in that, The adjusting of the positions of some of the initialized particles according to the usage frequency of the medicine bin and the commonness of the drugs includes: Count the number of times a drug is dispensed within a preset time period, calculate the drug usage frequency, and set drugs with a drug usage frequency greater than the common threshold as common drugs. If the drug to be loaded currently is a common drug, select some of the initially obtained particles. For each selected particle, adjust the position of the particle to any one of the nearest target drug compartments, where the target drug compartment is the drug compartment used to store the drug to be loaded currently; if the drug to be loaded currently is not a common drug, count the historical usage times of all drug compartments used to store the drug to be loaded currently within a preset time period, calculate the drug compartment usage frequency, select some of the initially obtained particles, and for each selected particle, adjust the position of the particle to any one of the top drug compartments with the highest drug compartment usage frequency.

4. The automatic medicine - dosing method for a medicine - dosing machine based on the particle swarm optimization algorithm according to claim 1, characterized in that, The constructing of an objective function based on the remaining effective days of the drugs, the space utilization rate of the medicine bin, and the drug loading efficiency includes: ; In the formula, is the objective function, , and are the weights of the remaining effective days of the drug, the utilization rate of the medicine warehouse space, and the medicine loading efficiency respectively, and , represents the remaining effective days of the th drug to be loaded with medicine, is the convenience weight for accessing the th layer and the th medicine warehouse, , represents the inventory quantity of the th layer and the th medicine warehouse, represents the actual capacity of the th layer and the th medicine warehouse, represents the single medicine loading time of the th drug to be loaded with medicine, represents the set maximum allowable medicine loading time; Among them, the single drug application time is calculated as follows: ; Wherein, represents the single dosing time of the th drug to be dosed, represents the moving speed of the robotic arm of the automatic dosing machine, represents the moving distance of the robotic arm from the dosing position to the medicine bin position for the th drug to be dosed, represents the time required for the robotic arm to grasp and place the drug.

5. The automatic medicine - dosing method for a medicine - dosing machine based on the particle swarm optimization algorithm according to claim 1, characterized in that, The updating of the velocity and position of the particles includes: ; ; ; In the formula, represents the velocity of the particle at the -th iteration, is the inertia weight, represents the velocity of the particle at the -th iteration, and are random numbers between [0, 1], and are learning factors, represents the individual optimal position of particle , represents the global optimal position, represents the position of the particle at the -th iteration, represents the position of the particle at the -th iteration, represents the maximum value of the inertia weight, represents the minimum value of the inertia weight, is the attenuation coefficient, is the adaptive adjustment amplitude, is the difference in the fitness values of the particles corresponding to the global optimal positions in the last two iterations, is the fitness value of the particle corresponding to the global optimal position among the initialized particles, is the maximum number of iterations, is the current number of iterations.

6. The automatic medicine - dosing method for a medicine - dosing machine based on the particle swarm optimization algorithm according to claim 4, characterized in that, After completing the drug loading operation of the drugs to be loaded, regularly check the remaining effective days of the drugs in the medicine bin. When the remaining effective days of the drugs reach the warning value, mark the drugs as high-risk drugs; The automatic drug loading machine takes out the high-risk drugs from the medicine bin as the drugs to be loaded, updates the medicine bin inventory information at the same time, re-runs the particle swarm optimization algorithm to complete the drug loading of the high-risk drugs, and increases the weight of the remaining effective days of the drugs in the particle swarm optimization algorithm.

7. The automatic medicine - dosing method for a medicine - dosing machine based on the particle swarm optimization algorithm according to claim 1, characterized in that, If the drug loading operation fails, the automatic drug loading machine emits an alarm signal and re-runs the particle swarm optimization algorithm to complete the drug loading of the current drug.

Citation Information

Patent Citations

  • Automatic pharmacy storage location optimizing method based on improved chaos particle swarm algorithm

    CN103559396A

  • Cargo distribution method for fish-bone type stereoscopic warehouse

    CN107944616A

  • Drug storage method and device for dual mechanical arms pharmacy control system

    CN110370292A

  • Intelligent pharmacy optimization method based on digital twinning

    CN111986772A

  • Global optimal solution searching method based on improved particle swarm optimization algorithm

    CN115983130A

Cited By

  • Smart factory warehouse management method and system based on big data

    CN120746449A