Resource allocation method, device, electronic device and storage medium
By iteratively generating and adjusting resource allocation plans, the problem of high time complexity in inventory allocation caused by traditional mathematical optimization methods is solved, and efficient resource allocation and revenue maximization are achieved.
Patent Information
- Application Number
- CN202111076729.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-14
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-09-14
AI Technical Summary
When traditional mathematical optimization methods are used to optimize the distribution of e-commerce inventory to multiple warehouses, they have high time complexity and take a long time, resulting in low efficiency.
By iteratively generating and adjusting resource allocation plans, calculating and deleting elements that do not meet the conditions based on the revenue function, optimizing resource allocation, ensuring that the number of elements is maintained at an appropriate level in each iteration, and reducing time complexity.
It achieves an optimized resource allocation plan in a relatively short period of time, improves the efficiency of inventory allocation and resource returns, and reduces computational complexity.
Smart Images

Figure CN113780831B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to a resource allocation method, device, electronic device and storage medium. Background Art
[0002] When e-commerce companies make inventory plans, they often need to split the total inventory into multiple warehouses. In order to maximize profits, it is necessary to comprehensively consider the storage cost, transportation cost, and revenue of each warehouse, and reasonably determine the inventory quantity of the total inventory allocated to each warehouse. Related technologies use traditional mathematical optimization methods to continuously optimize the inventory quantity of the total inventory allocated to each warehouse, but the time complexity of traditional mathematical optimization methods will increase exponentially and take a long time. Summary of the invention
[0003] In order to solve the above problems, an embodiment of the present invention provides a resource allocation method, device, electronic device and storage medium to at least solve the problem that the related technology uses traditional mathematical optimization methods to optimize the total inventory allocation to the inventory quantity of each warehouse, which takes too long.
[0004] The technical solution of the present invention is achieved in this way:
[0005] In a first aspect, an embodiment of the present invention provides a resource allocation method, the method comprising:
[0006] When the first set satisfies the set iteration condition, at least two second elements are generated based on at least two first elements in the first set, and the at least two second elements are added to the first set; wherein each element in the first set corresponds to a distribution situation of the representation resource in at least two containers;
[0007] Calculating a parameter value of a first parameter corresponding to each element in the first set based on a set function; the first parameter represents the corresponding resource benefit;
[0008] Deleting elements whose corresponding parameter values do not satisfy the set conditions from the first set;
[0009] If the first set does not satisfy the set iteration condition, the first set is output.
[0010] In the above solution, generating at least two second elements based on at least two first elements in the first set includes:
[0011] Two first elements are randomly selected from the first set; the first elements include at least two resource values; each resource value of the at least two resource values represents the amount of resources allocated to the corresponding container;
[0012] At least one resource value in the two selected first elements is replaced with each other to generate two second elements in the at least two second elements.
[0013] In the above solution, generating at least two second elements based on at least two first elements in the first set includes:
[0014] A first element is randomly selected from the first set; the first element includes at least two resource values; each resource value of the at least two resource values represents the amount of resources allocated to the corresponding container;
[0015] A resource value in the selected first element is modified to generate one of the at least two second elements.
[0016] In the above solution, deleting the elements whose corresponding parameter values do not satisfy the set conditions from the first set includes:
[0017] Randomly select two elements from the first set;
[0018] Calculate the value of the first parameter of the selected two elements;
[0019] The element with the smaller corresponding parameter value among the two selected elements is deleted from the first set.
[0020] In the above solution, when the first set does not satisfy the set iteration condition, after outputting the first set, the method further includes:
[0021] Determine the element with the largest corresponding parameter value in the first set;
[0022] The resources are allocated based on the element with the largest corresponding parameter value.
[0023] In the above solution, when generating at least two second elements based on at least two first elements in the first set, the method further includes:
[0024] In the case where the sum of all resource values in the second element is greater than the total quantity of the resources, all resource values in the second element are reduced according to a set ratio; the second element includes at least two resource values; each resource value of the at least two resource values represents the quantity of resources allocated to the corresponding container;
[0025] In a case where the sum of all resource values in the second element is less than the total number of the resources, determining a difference between the sum of all resource values in the second element and the total number of the resources, and adjusting the resource values in the second element based on the difference;
[0026] In the case where the first resource value in the second element is greater than the allocatable resource quantity of the corresponding container, the first resource value is modified to the allocatable resource quantity of the corresponding container.
[0027] In the above solution, adjusting the resource value in the second element based on the difference includes:
[0028] The resource value in the second element is adjusted based on a set sequence and the difference; the set sequence represents the ranking of the resource benefits corresponding to each container in the at least two containers.
[0029] In a second aspect, an embodiment of the present invention provides a resource allocation device, the device comprising:
[0030] A generation module, used for generating at least two second elements based on at least two first elements in the first set when the first set satisfies a set iteration condition, and adding the at least two second elements to the first set; wherein each element in the first set corresponds to a distribution of a representation resource in at least two containers;
[0031] A calculation module, configured to calculate a parameter value of a first parameter corresponding to each element in the first set based on a set function; the first parameter represents a corresponding resource benefit;
[0032] A deleting module, used to delete elements whose corresponding parameter values do not meet the set conditions from the first set;
[0033] The output module is used to output the first set when the first set does not meet the set iteration condition.
[0034] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor and a memory, wherein the processor and the memory are interconnected, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the steps of the resource allocation method provided in the first aspect of the embodiment of the present invention.
[0035] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, including: the computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of the resource allocation method provided in the first aspect of the embodiment of the present invention are implemented.
[0036] In the embodiment of the present invention, when the first set meets the set iteration conditions, at least two second elements are generated based on at least two first elements in the first set, and the at least two second elements are added to the first set. Then, the parameter value of the first parameter corresponding to each element in the first set is calculated based on the set function, and the elements whose corresponding parameter values do not meet the set conditions are deleted from the first set. In the case that the first set does not meet the set iteration conditions, the first set is output. Each element in the first set corresponds to a distribution of resources in at least two containers, and the first parameter represents the corresponding resource benefits. In each iteration process of the first set, the embodiment of the present invention calculates the parameter value of the first parameter corresponding to each element in the first set by setting a function, deletes the elements that do not meet the set conditions, so that the overall elements of the first set maintain a high resource benefit, and the number of elements in the first set will not increase significantly during each iteration. The time complexity is lower than that of the related technology, and the optimized first set can be obtained in a shorter time. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a schematic diagram of an implementation flow of a resource allocation method provided by an embodiment of the present invention;
[0038] Figure 2 This is a schematic diagram of inventory splitting provided by an embodiment of the present invention;
[0039] Figure 3 It is a schematic diagram of an implementation flow of another resource allocation method provided by an embodiment of the present invention;
[0040] Figure 4 It is a schematic diagram of an implementation flow of another resource allocation method provided by an embodiment of the present invention;
[0041] Figure 5 It is a schematic diagram of an implementation flow of another resource allocation method provided by an embodiment of the present invention;
[0042] Figure 6 It is a schematic diagram of an implementation flow of another resource allocation method provided by an embodiment of the present invention;
[0043] Figure 7 It is a schematic diagram of an inventory allocation process provided by an application embodiment of the present invention;
[0044] Figure 8 is a schematic diagram of a resource allocation device provided by an embodiment of the present invention;
[0045] Fig. 9 It is a schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0046] 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 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.
[0047] When the total inventory is split into multiple warehouses, the related technology first initializes multiple inventory splitting plans, which represent the inventory amount allocated to each warehouse. The related technology continuously optimizes the inventory splitting plan through traditional mathematical optimization methods, such as optimizing the inventory splitting plan through autoregressive models, recursive algorithms, or backtracking algorithms. Traditional mathematical optimization methods require a lot of computing resources, and the time complexity increases exponentially, so the optimization process of the inventory splitting plan takes a long time.
[0048] In view of the shortcomings of the above-mentioned related technologies, an embodiment of the present invention provides a resource allocation method, which can at least obtain an optimized resource allocation solution with lower time complexity. In order to illustrate the technical solution of the present invention, a specific embodiment is used for description below.
[0049] Figure 1 1 is a schematic diagram of an implementation flow of a resource allocation method provided by an embodiment of the present invention. The execution subject of the resource allocation method is an electronic device, and the electronic device includes a desktop computer, a notebook computer, and a server. Figure 1 , resource allocation methods include:
[0050] S101, when the first set satisfies the set iteration condition, at least two second elements are generated based on at least two first elements in the first set, and the at least two second elements are added to the first set; wherein each element in the first set corresponds to a distribution situation of the representation resource in at least two containers.
[0051] Here, the first element and the second element both refer to resource allocation plans. In the inventory allocation scenario, resources refer to the goods in the warehouse, and containers refer to the warehouse. Each resource allocation plan represents the inventory amount allocated to each warehouse from the total inventory.
[0052] Determining the resource allocation scheme is an optimization problem. The embodiment of the present invention adopts an iterative idea to optimize the resource allocation scheme. The iteration condition set here may refer to the number of iterations. It is determined whether the current number of iterations of the first set is less than the set number. If it is less than the set number, the first set meets the set iteration condition.
[0053] For example, the maximum number of iterations is set to 10 times, and if the current number of iterations of the first set is less than 10 times, the operation of the embodiment of the present invention is performed.
[0054] When the first set meets the set iteration condition, at least two second elements are generated based on at least two first elements in the first set. Here, the second element is essentially the same as the first element, and both refer to a distribution of resources in at least two containers.
[0055] refer to Figure 2 , Figure 2 This is a schematic diagram of inventory splitting provided by an embodiment of the present invention. The total inventory is split into 5 warehouses, where a single warehouse refers to a separate warehouse, and the percentage refers to the proportion of the inventory allocated to the single warehouse to the total inventory.
[0056] Before iterating, at least two first elements in the first set need to be generated. Here, the at least two first elements can be generated in a random manner.
[0057] refer to Figure 3 In one embodiment, generating at least two second elements based on at least two first elements in the first set includes:
[0058] S301, randomly selecting two first elements in the first set; the first elements include at least two resource values; each resource value of the at least two resource values represents the amount of resources allocated to the corresponding container.
[0059] The first set includes at least two first elements, and two first elements are randomly selected from the first elements. Each element in the first set includes at least two resource values, the resource values correspond to containers, and the resource values represent the quantity of resources allocated to the corresponding container.
[0060] For example, the resource value contained in the first element is:
[0061] 10% 20% 15% 40% 5% 10%
[0062] The five percentage values represent the proportion of the resources allocated to the five containers to the total resources.
[0063] S302: Replace at least one resource value in two selected first elements with each other to generate two second elements in the at least two second elements.
[0064] For example, the two first elements selected are:
[0065]
[0066] Select at least one resource value from the two first elements, for example, select the last 3 percentage values, replace the last 3 percentage values of the two first elements with each other, and get two second elements:
[0067]
[0068] refer to Figure 4 In another embodiment, generating at least two second elements based on at least two first elements in the first set includes:
[0069] S401, randomly selecting a first element in the first set; the first element includes at least two resource values; each resource value of the at least two resource values represents the amount of resources allocated to the corresponding container.
[0070] An embodiment of the present invention provides another method for generating a second element, randomly selecting a first element in a first set, each element in the first set includes at least two resource values, the resource values correspond to containers, and the resource values represent the quantity of resources allocated to the corresponding container.
[0071] S402: Modify a resource value in the selected first element to generate one of the at least two second elements.
[0072] For example, the first element selected is:
[0073] 10% 20% 15% 40% 5% 10%
[0074] A resource value is randomly selected from the resource value, such as 15%, and the selected resource value is modified. For example, a ratio can be randomly generated within the maximum value range to replace the original ratio. For example, 15% is randomly modified to 16%. The generated second element is as follows:
[0075] 10% 20% 16% 40% 5% 10%
[0076] In one embodiment, when generating at least two second elements based on at least two first elements in the first set, the method further includes:
[0077] When the sum of all resource values in the second element is greater than the total quantity of the resources, all resource values in the second element are reduced according to a set ratio; the second element includes at least two resource values; each resource value of the at least two resource values represents the quantity of resources allocated to the corresponding container.
[0078] When the sum of all resource values in the second element is greater than the total number of resources, that is, In the case of , all resource values in the second element are reduced according to the following formula:
[0079]
[0080] Where n is the number of containers, x i Indicates the percentage of resources allocated to the i-th container, Indicates the percentage of the jth element in container i.
[0081] All resource values in the second element are reduced in the same proportion, and the sum of all the reduced resource values is made to be the total number of resources, that is, the sum of the percentages is 100%.
[0082] When the sum of all resource values in the second element is less than the total number of the resources, the difference between the sum of all resource values in the second element and the total number of the resources is determined, and the resource values in the second element are adjusted based on the difference.
[0083] If the sum of all resource values in the second element is less than the total number of resources, In the case of inventory splitting, the sum of the percentages corresponding to each container is less than 100%. In the inventory splitting scenario, the sum of the inventory allocated to all warehouses is less than the total inventory. In this case, the difference between the sum of all resource values in the second element and the total quantity of resources is calculated, and the resource value in the second element is adjusted based on the difference, that is, the remaining inventory is used to continue to fill each warehouse.
[0084] In one embodiment, adjusting the resource value in the second element based on the difference includes:
[0085] The resource value in the second element is adjusted based on a set sequence and the difference; the set sequence represents the ranking of the resource benefits corresponding to each container in the at least two containers.
[0086] Here, setting the order refers to the sorting of resource benefits corresponding to each container in at least two containers. In the actual inventory splitting scenario, the resource benefits correspond to the commodity benefits of the warehouse, and the commodity benefits = sales - cost, and the cost includes transportation cost and storage cost.
[0087] The difference is used to adjust the resource value corresponding to the container with the largest resource benefit first, until the maximum allocatable resource quantity of the container is reached. According to the above principle, the resource values corresponding to each container in the second element are adjusted in turn to maximize the overall benefit.
[0088] In the case where the first resource value in the second element is greater than the allocatable resource quantity of the corresponding container, the first resource value is modified to the allocatable resource quantity of the corresponding container.
[0089] If the first resource value in the second element is greater than the allocatable resource quantity of the corresponding container, that is, the inventory allocated to the warehouse is greater than the disposable capacity of the warehouse, the inventory allocated to the warehouse is set to the maximum disposable capacity of the warehouse.
[0090] S102, calculating a parameter value of a first parameter corresponding to each element in the first set based on a set function; the first parameter represents the corresponding resource benefit.
[0091] Each element represents a distribution of resources in at least two containers. In the actual inventory splitting scenario, each element is an inventory splitting plan, and the commodity revenue under each inventory splitting plan is calculated.
[0092] Assume that the total inventory (total number of resources) is g, the number of warehouses (total number of containers) is n, and the transportation cost of all inventory in the i-th warehouse is expressed as f i ; The storage cost of all inventory in the i-th warehouse is expressed as s i , where 1≤i≤n; the expected revenue of all inventory in the i-th warehouse is expressed as p i , the available storage capacity of the i-th warehouse is represented by a i . As shown in the following table:
[0093] Shipping costs Storage costs Expected revenue Available storage capacity <![CDATA[f i ]]> <![CDATA[s i ]]> <![CDATA[p i ]]> <![CDATA[a i ]]>
[0094] Let x={x1,x2,…,x n}, 1≤i≤n represents an element, that is, a splitting scheme, where x i Represents the percentage of inventory allocated to the i-th warehouse.
[0095] Setting the profit function Cost Function The function is set to f(x) = f1(x) - f2(x). The larger the value of the function is, the greater the benefit is.
[0096] f(x)=f1(x)-f2(x),
[0097]
[0098]
[0099] Where 0≤x i g≤a i , 1≤i≤n.
[0100] The value calculated by the above setting function is the parameter value of the first parameter.
[0101] S103: Delete elements whose corresponding parameter values do not satisfy the set conditions from the first set.
[0102] In one case, elements whose parameter values are less than the set value may be deleted from the first set.
[0103] In another case, reference Figure 5 In one embodiment, deleting the elements whose corresponding parameter values do not satisfy the set condition from the first set includes:
[0104] S501: Randomly select two elements from the first set.
[0105] S502, calculating parameter values of the first parameters of the two selected elements.
[0106] S503: Delete the element with the smaller corresponding parameter value among the two selected elements from the first set.
[0107] Randomly select two elements in the first set, then calculate the parameter value of the first parameter of the two selected elements, and delete the element with the smaller parameter value from the first set.
[0108] The above steps can be repeated multiple times until the number of elements in the first set reaches the set number. At the end of each iteration, the number of elements in the first set is maintained at the set number, so that the number of elements in the first set input in each iteration is the same. Deleting elements with smaller parameter values can maintain a higher yield for the overall elements of the first set, so that the number of elements in each iteration is maintained at an appropriate level.
[0109] S104: When the first set does not satisfy the set iteration condition, output the first set.
[0110] Step S104 is a parallel step with step S101. When the first set does not meet the set iteration condition, for example, when the number of iterations of the first set is greater than or equal to the set number, the first set is output. At this time, resources can be allocated according to the first set.
[0111] refer to Figure 6 In one embodiment, when the first set does not satisfy the set iteration condition, after outputting the first set, the method further includes:
[0112] S601, determining the element with the largest corresponding parameter value in the first set.
[0113] S602: Allocate the resources based on the element with the largest corresponding parameter value.
[0114] The element with the largest corresponding parameter value in the first set is used as the final resource allocation scheme, and resources are allocated according to the element with the largest corresponding parameter value to maximize resource benefits.
[0115] In the embodiment of the present invention, when the first set meets the set iteration conditions, at least two second elements are generated based on at least two first elements in the first set, and the at least two second elements are added to the first set. Then, the parameter value of the first parameter corresponding to each element in the first set is calculated based on the set function, and the elements whose corresponding parameter values do not meet the set conditions are deleted from the first set. In the case that the first set does not meet the set iteration conditions, the first set is output. Each element in the first set corresponds to a distribution of resources in at least two containers, and the first parameter represents the corresponding resource benefits. In each iteration process of the first set, the embodiment of the present invention calculates the parameter value of the first parameter corresponding to each element in the first set by setting a function, deletes the elements that do not meet the set conditions, so that the overall elements of the first set maintain a high resource benefit, and the number of elements in the first set will not increase significantly during each iteration. The time complexity is lower than that of the related technology, and the optimized first set can be obtained in a shorter time.
[0116] refer to Figure 7 , Figure 7 : is a schematic diagram of an inventory allocation process provided by an application embodiment of the present invention, and the inventory allocation process includes:
[0117] First, obtain the transportation cost, storage cost, expected revenue and allocatable capacity of each warehouse for the goods to be split.
[0118] Construct a suitable setting function based on the above data.
[0119] For example, assuming that the total inventory (total number of resources) is g, the number of warehouses (total number of containers) is n, and the transportation cost of all inventory in the i-th warehouse is expressed as f i ; The storage cost of all inventory in the i-th warehouse is expressed as s i , where 1≤i≤n; the expected revenue of all inventory in the i-th warehouse is expressed as p i , the available storage capacity of the i-th warehouse is represented by a i .
[0120] Let x={x1,x2,…,x n}, 1≤i≤n represents an element, that is, a splitting scheme, where x i Represents the percentage of inventory allocated to the i-th warehouse.
[0121] Setting the profit function Cost Function The function is set to f(x) = f1(x) - f2(x). The larger the value of the function is, the greater the benefit is.
[0122] f(x)=f1(x)-f2(x),
[0123]
[0124]
[0125] Where 0≤x i g≤a i , 1≤i≤n.
[0126] Then, a first set to be iterated is generated according to the inventory to be split and the available storage capacity of each warehouse.
[0127] Assume that X represents the first set, X = {x 1 ,x 2 ,x j ,…,x m}, 1≤j≤m; where x j represents the jth individual in the first set, that is, the jth splitting scheme in the first set; Represents the proportion of warehouse i in the j-th split plan.
[0128] Start iteration and increase the current iteration count by 1.
[0129] Determine whether the current number of iterations is less than the set number.
[0130] When the current number of iterations is less than the set number, a crossover mutation operation is performed on the current first set to generate new elements, which are then added to the first set. Figure 3 Example, mutation operation reference Figure 4 Example.
[0131] Using the environment selection mechanism, select the better elements in the first set to participate in the next iteration. Environment selection mechanism reference Figure 5 Example.
[0132] When the current number of iterations is greater than the set number of iterations, the element with the largest parameter value of the first parameter in the first set is selected as the inventory splitting solution.
[0133] The application embodiment of the present invention iteratively updates the elements in the first set, eliminates inferior elements, retains better elements, and obtains a better splitting solution, and can obtain the best first set at a lower time complexity. The application embodiment of the present invention can provide users with the best inventory splitting solution to maximize profits.
[0134] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0135] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0136] It should be noted that the technical solutions described in the embodiments of the present invention can be arbitrarily combined without conflict.
[0137] In addition, in the embodiments of the present invention, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0138] refer to Figure 8 , Figure 8 is a schematic diagram of a resource allocation device provided by an embodiment of the present invention, such as Figure 8 As shown, the device includes: a generating module, a calculating module, a deleting module and an outputting module.
[0139] A generation module, used for generating at least two second elements based on at least two first elements in the first set when the first set satisfies a set iteration condition, and adding the at least two second elements to the first set; wherein each element in the first set corresponds to a distribution of a representation resource in at least two containers;
[0140] A calculation module, configured to calculate a parameter value of a first parameter corresponding to each element in the first set based on a set function; the first parameter represents a corresponding resource benefit;
[0141] A deleting module, used to delete elements whose corresponding parameter values do not meet the set conditions from the first set;
[0142] The output module is used to output the first set when the first set does not meet the set iteration condition.
[0143] In one embodiment, when generating at least two second elements based on at least two first elements in the first set, the generating module is configured to:
[0144] Two first elements are randomly selected from the first set; the first elements include at least two resource values; each resource value of the at least two resource values represents the amount of resources allocated to the corresponding container; at least one resource value in the two selected first elements is replaced with each other to generate two second elements in the at least two second elements.
[0145] In one embodiment, when generating at least two second elements based on at least two first elements in the first set, the generating module is configured to:
[0146] A first element is randomly selected from the first set; the first element includes at least two resource values; each of the at least two resource values represents the amount of resources allocated to the corresponding container; and a resource value in the selected first element is modified to generate one of the at least two second elements.
[0147] In one embodiment, when deleting elements whose corresponding parameter values do not satisfy the set condition from the first set, the deleting module is used to:
[0148] Randomly select two elements from the first set;
[0149] Calculate the value of the first parameter of the selected two elements;
[0150] The element with the smaller corresponding parameter value among the two selected elements is deleted from the first set.
[0151] In one embodiment, the device further comprises:
[0152] A determination module, used to determine the element with the largest corresponding parameter value in the first set;
[0153] The allocation module is used to allocate the resources based on the element with the largest corresponding parameter value.
[0154] In one embodiment, when generating at least two second elements based on at least two first elements in the first set, the generating module is further configured to:
[0155] In the case where the sum of all resource values in the second element is greater than the total quantity of the resources, all resource values in the second element are reduced according to a set ratio; the second element includes at least two resource values; each resource value of the at least two resource values represents the quantity of resources allocated to the corresponding container;
[0156] In a case where the sum of all resource values in the second element is less than the total number of the resources, determining a difference between the sum of all resource values in the second element and the total number of the resources, and adjusting the resource values in the second element based on the difference;
[0157] In the case where the first resource value in the second element is greater than the allocatable resource quantity of the corresponding container, the first resource value is modified to the allocatable resource quantity of the corresponding container.
[0158] In one embodiment, when adjusting the resource value in the second element based on the difference, the generating module is configured to:
[0159] The resource value in the second element is adjusted based on a set sequence and the difference; the set sequence represents the ranking of the resource benefits corresponding to each container in the at least two containers.
[0160] In actual application, the generation module, calculation module, deletion module and output module can be implemented by a processor in an electronic device, such as a central processing unit (CPU), a digital signal processor (DSP), a microcontroller unit (MCU) or a programmable gate array (FPGA).
[0161] It should be noted that: the resource allocation device provided in the above embodiment only uses the division of the above modules as an example when performing resource allocation. In actual applications, the above processing allocation can be completed by different modules as needed, that is, the internal structure of the device is divided into different modules to complete all or part of the processing described above. In addition, the resource allocation device provided in the above embodiment and the resource allocation method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0162] Based on the hardware implementation of the above program modules and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides an electronic device. Fig. 9 Schematic diagram of the hardware structure of the electronic device of the present application embodiment. Fig. 9 As shown, the electronic equipment includes:
[0163] Communication interface, which can exchange information with other devices such as network equipment;
[0164] The processor is connected to the communication interface to realize information exchange with other devices, and is used to execute the method provided by one or more technical solutions of the electronic device side when running the computer program. The computer program is stored in the memory.
[0165] Of course, in actual applications, the various components in the electronic device are coupled together through the bus system. It is understandable that the bus system is used to achieve connection and communication between these components. In addition to the data bus, the bus system also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Fig. 9 In the specification, various buses are labeled as bus systems.
[0166] The memory in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.
[0167] It can be understood that the memory can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memories described in the embodiments of the present application are intended to include, but are not limited to, these and any other suitable types of memories.
[0168] The method disclosed in the above embodiment of the present application can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in a memory, and the processor reads the program in the memory and completes the steps of the above method in combination with its hardware.
[0169] Optionally, when the processor executes the program, the corresponding processes implemented by the electronic device in each method of the embodiments of the present application are implemented, which will not be described in detail here for the sake of brevity.
[0170] In an exemplary embodiment, the present application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, for example, including a first memory storing a computer program, and the computer program can be executed by a processor of an electronic device to complete the steps of the aforementioned method. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.
[0171] In the several embodiments provided in the present application, it should be understood that the disclosed devices, electronic devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0172] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.
[0173] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0174] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium, which, when executed, executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, disks or optical disks.
[0175] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0176] It should be noted that the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.
[0177] In addition, in the examples of the present application, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0178] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A resource allocation method, characterized in that: The method comprises: In the case where the first set satisfies the set iteration condition, at least two second elements are generated based on at least two first elements in the first set, and the at least two second elements are added to the first set; the first element and the second element represent a resource allocation scheme; wherein each element in the first set represents a distribution of resources in at least two containers; the resources represent commodities in the containers, and the containers represent warehouses for storing the resources; Calculating a parameter value of a first parameter corresponding to each element in the first set based on a setting function; the first parameter represents the corresponding resource income; the setting function is a function constructed based on the transportation cost, storage cost, expected income of the resource to each container and the allocatable capacity corresponding to each container; the resource income represents the commodity income of the corresponding warehouse; Deleting elements whose corresponding parameter values do not satisfy a set condition from the first set until the number of elements in the first set reaches a set number; the set condition indicates that the element is an element with a larger parameter value among any two elements in the first set; If the first set does not satisfy the set iteration condition, output the first set; The generating at least two second elements based on at least two first elements in the first set comprises: Two first elements are randomly selected from the first set; the first elements include at least two resource values; each resource value of the at least two resource values represents the amount of resources allocated to the corresponding container; Replace at least one resource value in the two selected first elements with each other to generate two second elements in the at least two second elements; or, The generating at least two second elements based on at least two first elements in the first set comprises: A first element is randomly selected from the first set; the first element includes at least two resource values; each resource value of the at least two resource values represents the amount of resources allocated to the corresponding container; Modify a resource value in the selected first element to generate one of the at least two second elements; When generating at least two second elements based on at least two first elements in the first set, the method further includes: In the case where the sum of all resource values in the second element is greater than the total quantity of the resources, all resource values in the second element are reduced according to a set ratio; the second element includes at least two resource values; each resource value of the at least two resource values represents the quantity of resources allocated to the corresponding container; In a case where the sum of all resource values in the second element is less than the total number of the resources, determining a difference between the sum of all resource values in the second element and the total number of the resources, and adjusting the resource values in the second element based on the difference; In the case where the first resource value in the second element is greater than the allocatable resource quantity of the corresponding container, the first resource value is modified to the allocatable resource quantity of the corresponding container.
2. The method according to claim 1, characterized in that The deleting the elements whose corresponding parameter values do not satisfy the set condition from the first set includes: Randomly select two elements from the first set; Calculate the value of the first parameter of the selected two elements; The element with the smaller corresponding parameter value among the two selected elements is deleted from the first set.
3. The method according to claim 1, characterized in that In the case that the first set does not satisfy the set iteration condition, after outputting the first set, the method further includes: Determine the element with the largest corresponding parameter value in the first set; The resources are allocated based on the element with the largest corresponding parameter value.
4. The method according to claim 1, characterized in that: The adjusting the resource value in the second element based on the difference includes: The resource value in the second element is adjusted based on a set sequence and the difference; the set sequence represents the ranking of the resource benefits corresponding to each container in the at least two containers.
5. A resource allocation device, characterized in that: A generating module, configured to generate at least two second elements based on at least two first elements in the first set when the first set satisfies a set iteration condition, and add the at least two second elements to the first set; The first element and the second element represent a resource allocation scheme; wherein each element in the first set represents a distribution of resources in at least two containers; the resources represent commodities in the containers, and the containers represent warehouses for storing the resources; A calculation module, configured to calculate a parameter value of a first parameter corresponding to each element in the first set based on a setting function; the first parameter represents the corresponding resource benefit; the setting function is a function constructed based on the transportation cost, storage cost, expected benefit of the resource to each container and the allocatable capacity corresponding to each container; the resource benefit represents the commodity benefit of the corresponding warehouse; A deletion module, used to delete elements whose corresponding parameter values do not meet a set condition from the first set until the number of elements in the first set reaches a set number; the set condition indicates that the element is the element with the larger parameter value among any two elements in the first set; an output module, configured to output the first set if the first set does not satisfy the set iteration condition; The generating module is further configured to randomly select two first elements from the first set; the first elements include at least two resource values; each resource value of the at least two resource values represents the amount of resources allocated to the corresponding container; at least one resource value of the selected two first elements is replaced with each other to generate two second elements of the at least two second elements; The generating module is further configured to randomly select a first element in the first set; the first element includes at least two resource values; each resource value of the at least two resource values represents the amount of resources allocated to the corresponding container; modify a resource value of the selected first element to generate one of the at least two second elements; The generation module is also used to reduce all resource values in the second element according to a set ratio when the sum of all resource values in the second element is greater than the total number of resources; the second element includes at least two resource values; each resource value of the at least two resource values represents the number of resources allocated to the corresponding container; when the sum of all resource values in the second element is less than the total number of resources, determine the difference between the sum of all resource values in the second element and the total number of resources, and adjust the resource value in the second element based on the difference; when the first resource value in the second element is greater than the allocatable number of resources of the corresponding container, modify the first resource value to the allocatable number of resources of the corresponding container.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the resource allocation method according to any one of claims 1 to 4 is implemented.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the resource allocation method according to any one of claims 1 to 4.
