Disclosure of Invention
In order to solve the technical problems in the prior art, the application provides a resource allocation method and device, which can realize maximum resource calling and improve the resource utilization rate.
In view of this, an aspect of the present embodiment provides an automatic resource configuration method, where the method includes:
acquiring initial data corresponding to a task to be processed, wherein the initial data comprises: the task type parameter and the resource limit parameter corresponding to the task type parameter;
acquiring a resource configuration combination set according to the task type parameters and the resource limit parameters, wherein the resource configuration combination set comprises all resource configuration combinations of each task combination;
and respectively calculating to obtain a resource configuration scheme meeting the constraint condition aiming at each resource configuration combination.
Optionally, before the obtaining of the task resource configuration combination set, the method further includes:
checking whether the type, value and length of the initial data are correct or not;
if yes, continuing to execute the step of obtaining the resource configuration combination set;
if not, generating an error report and finishing the subsequent operation steps.
Optionally, the obtaining a resource configuration combination set according to the task type parameter and the resource limit parameter includes:
arranging different types of tasks according to task type parameters in the initial data to obtain a task combination set;
and generating a resource configuration combination set according to the resource limit parameters in the initial data based on the task combination set.
Optionally, the calculating to obtain the resource allocation scheme meeting the constraint condition includes:
and calculating to obtain the resource allocation scheme meeting the constraint condition by using an interior point method, a simplex method or an ellipsoid algorithm.
Optionally, the method further includes:
and sequencing each resource allocation scheme according to the resource allocation parameters, and selecting the optimal schemes with expected quantity.
Another aspect of the embodiments of the present application provides an apparatus for automatically configuring a resource, where the apparatus includes:
the data acquisition unit is used for acquiring initial data corresponding to the task to be processed, and the initial data comprises: the task type parameter and the resource limit parameter corresponding to the task type parameter;
a combination obtaining unit, configured to obtain a resource configuration combination set according to the task type parameter and the resource limit parameter, where the resource configuration combination set includes all resource configuration combinations of each task combination;
and the scheme acquisition unit is used for respectively calculating and obtaining the resource configuration scheme meeting the constraint condition aiming at each resource configuration combination.
Optionally, the apparatus further includes a data verification unit;
the data checking unit is used for checking whether the type, value and length of the initial data are correct or not; if yes, continuing to execute the step of obtaining the resource configuration combination set; if not, generating an error report and finishing the subsequent operation steps.
Optionally, the combination obtaining unit includes: a task combination subunit and a resource allocation subunit;
the task combination subunit is configured to arrange different types of tasks according to task type parameters in the initial data to obtain a task combination set;
and the resource allocation subunit is configured to generate a resource allocation combination set according to the resource limit parameter in the initial data based on the task combination set.
Optionally, the scheme obtaining unit is configured to calculate to obtain the resource configuration scheme meeting the constraint condition by using an interior point method, a simplex method, or an ellipsoid algorithm.
Optionally, the apparatus further comprises: and the selecting unit is used for sequencing each resource configuration scheme according to the resource configuration parameters and selecting the optimal schemes with expected quantity.
The method has the following advantages:
the embodiment of the application provides a resource allocation method, which is characterized in that all possible task resource allocation combinations are generated, and a resource allocation scheme meeting constraint conditions is calculated under the constraint conditions aiming at each resource allocation combination. Specifically, initial data corresponding to a task to be processed is obtained first, where the initial data includes: the task type parameter and the resource limit parameter corresponding to the task type parameter; further, according to the task type parameters and the resource limit parameters, a resource configuration combination set is obtained, wherein the resource configuration combination set comprises all resource configuration combinations of each task combination; and respectively calculating to obtain a resource configuration scheme meeting the constraint condition aiming at each resource configuration combination. Because the generated resource configuration combination set comprises all the resource configuration combinations of each task combination, the optimal solution corresponding to each task combination can be selected under the constraint condition, and the optimal solution is the resource configuration scheme corresponding to the maximum value of the objective function. Based on the resource allocation scheme, the resources are allocated according to the corresponding task combination, so that the resources can be utilized to the maximum extent, and the utilization rate of the resources is improved.
Detailed Description
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be understood that the resource automatic configuration computing method provided in the embodiment of the present application may be applied to a device with computing capability, such as a terminal device or a server, and the method may be applied to a terminal independently, or may be applied to a network scenario where a terminal device (terminal for short) communicates with a server. The terminal equipment can be a mobile phone, a desktop computer, a portable computer and the like; the server may be understood as an application server or a Web server, and in actual deployment, the server may be an independent server or a cluster server.
In order to better understand the resource automatic configuration calculation method and device provided by the embodiment of the present application, a server is taken as an execution subject, and the following description is made with reference to the accompanying drawings.
Referring to fig. 1, fig. 1 is a schematic flowchart of a resource automatic configuration calculation method according to an embodiment of the present application. As shown in fig. 1, the method comprises the steps of:
step S101: and acquiring initial data corresponding to the task to be processed.
The server acquires initial data required by calculation; wherein the initial data may include:
a) n: the number of task types, namely the total number of the task types, is an integer;
b)Ni: the number of tasks, namely the number of each type of tasks, is an integer;
c)Ii: the task type parameters, namely the ith task, are used for representing the parameters of different types of resources, such as the A-type task and the B-type task; i takes the value of 1,2, …, N;
d)Ki: the utilization rate of the ith type task resource, and the numerical value is a floating point type;
e)maxKi: first, theThe utilization rate of the i-type task resources is limited, and the numerical value is a floating point type;
f)minKi: the lower limit of the utilization rate of the ith type task resource, and the numerical value is a floating point type;
g) Δ k: the resource utilization rate is a floating step length, and the numerical value is a floating point type;
h)Qi: the actual utilization rate of the ith type task resource, and the numerical value is a floating point type;
i) x1: total resources, numerical values are floating point;
j) x2: total amount of available resources, the numerical value is of floating point type;
k) x3: resource utilization rate, the numerical value is a floating point type;
it should be noted that, in practical applications, the initial parameters are not limited to the above parameters, and the corresponding initial data may be determined according to different requirements, which is not limited herein.
It is understood that the server may check after receiving the initial data to determine whether the data is correct. Specifically, whether the types corresponding to the initial data are matched, whether the data value is in a correct range, and whether the data length meets the processing requirements of the server are checked. If the initial data is checked to have errors, terminating the execution of the subsequent steps, generating an error log, and returning an error report for reference checking; if the initial data is verified to be normal without errors, the step S102 is continuously executed.
Step S102: and acquiring a task configuration combination set according to the task type parameter and the resource utilization rate limit parameter.
And according to the task type parameters, performing full arrangement on different tasks to generate a task combination set. Specifically, for N classes of tasks, there is a total
And (6) combining tasks.
For example, if there are N ═ 3 tasks, they are respectively: i is
1=A、I
2=B、I
3If the task combination set generated by the three types of task permutation and combination is C, the task combination set is common
The task combination comprises the following steps: A. b, C, AB, AC, BC, ABC.
Because the resource utilization rate corresponding to each type of task is a range value, the resource utilization rate limit parameter, namely the resource utilization rate upper limit maxK, corresponding to each type of resource is used as the limit valueiLower limit minKiAnd a floating step size deltak, a task configuration combination set can be obtained. Wherein, the task type parameter and the resource utilization rate limit parameter are in one-to-one correspondence; and the task configuration combination set comprises all task configuration combinations corresponding to each task combination.
For the above example, if the resource utilization upper limit maxK of the A-type task10.8, lower limit minK10.7, upper limit maxK for B-class task resource utilization20.7, lower limit minK20.5, upper limit maxK for C-class task resource utilization30.7, lower limit minK3And if the resource utilization floating step size Δ k is 0.7 and the resource utilization floating step size Δ k is 0.1, the task configuration combination corresponding to the class AB task combination includes:
based on the above table, it can be known that there are 2 types of resource utilization rate values for the class a task, 3 types of resource utilization rate values for the class B task, and 6 types of task configuration combinations corresponding to the class AB task combination, that is, 2 × 3. In view of this, for the A, B, C three types of tasks, the corresponding number of task configuration combinations is 2+3+1+2x3+2x1+3x1+2x3x1 equals 23.
Step S103: respectively calculating to obtain a task configuration scheme meeting constraint conditions aiming at each task configuration combination; the task configuration scheme is a scheme corresponding to the maximum value of the objective function.
Due to the interaction between different tasks, each type of task is available for different task combinationsIs subject to certain constraints. Assume that each type of task uses resources as YiAnd calculating the optimal solution of each task combination under the constraint condition, wherein the constraint condition is as follows:
the optimization target is the maximum resource utilization rate, and the mathematical expression of the optimization target is as follows:
based on the constraint conditions, an optimal solution can be calculated by adopting an interior point method, a simplex method or an ellipsoid algorithm, and the optimal solution can be understood as a task configuration scheme when the corresponding objective function obtains the maximum value for each task combination type.
According to the resource allocation method, all possible task resource allocation combinations are generated, and a resource allocation scheme meeting the constraint condition is obtained by calculation under the constraint condition aiming at each resource allocation combination. Because the generated resource configuration combination set comprises all the resource configuration combinations of each task combination, the optimal solution corresponding to each task combination can be selected under the constraint condition, and the optimal solution is the resource configuration scheme corresponding to the maximum value of the objective function. Based on the resource allocation scheme, the resources are allocated according to the corresponding task combination, so that the resources can be utilized to the maximum extent, and the utilization rate of the resources is improved.
It should be noted that the resource configuration method provided by the embodiment of the present application may be applied to various application scenarios, for example, when a computer processes multiple types of tasks, a resource allocation scenario is performed; and when different models are built on a new land, the occupied area of the different models is distributed, and the like.
Referring to fig. 2, fig. 2 is a schematic flowchart of another automatic resource configuration method according to an embodiment of the present application. The following description will specifically describe the new block business allocation as an example.
Step S201: and acquiring initial data corresponding to the task to be processed.
It can be understood that when the server deals with the problem of allocating the state of the land parcel, different states can be regarded as different types of tasks, and the land parcel which can be divided can be regarded as resources which can be called. Based on this, the initial data acquired by the server may include:
a) n: the number of task types, namely the total number of the business types, is an integer;
b)Ni: the number of tasks, namely the number of layers established in each state, is an integer;
c)Ii: task type parameters, i.e., names of i-th type of business, such as "high-level", "ocean-houses", "amalgamation", "gang", "single-family", etc.; i takes the value of 1,2, …, N;
d)Ki: the i-th type of state volume fraction, the numerical value is of floating point type;
e)maxKi: the upper limit of the i-th type operation volume rate, and the numerical value is a floating point type;
f)minKi: the lower limit of the i-th type state volume rate, the numerical value is a floating point type;
g) Δ k: the volume rate of the state floats the step length, the numerical value is the floating point type;
h)Qi: the numerical value of the i type of state is a floating point type per square meter of cargo value;
i) x1: the construction land area, the numerical value is floating point type;
j) x2: the building area is counted, and the numerical value is a floating point type;
k) x3: building density, the numerical value is floating point type;
step S202: checking whether the type, value and length of the initial data are correct or not; if yes, go on to step S203; if not, generating an error report and terminating the program.
Step S203: and according to the task type parameters in the initial data, performing full arrangement on different tasks to obtain a task combination set.
It is understood that the different statuses are arranged according to the received status type parameter to obtain the status combination set. The process of generating the business state combination is similar to the process of generating the task combination in step S102, and is not described herein again.
Step S204: and generating a resource configuration combination set according to the resource limit parameters in the initial data based on the task combination set.
It should be understood that, based on the above-mentioned obtained state combination set, the volume rate limit parameter in the initial data, i.e. the state volume rate upper limit maxKiLower limit minKiAnd a floating step size deltak, a combination set of state volume fractions can be obtained. For each of the state combinations, the process of generating the corresponding state volume ratio is similar to the process of generating the resource allocation combination in step S102, and is not repeated here.
Step S205: and respectively calculating to obtain a resource configuration scheme meeting the constraint condition aiming at each resource configuration combination.
It is understood that, when allocating a new region, the corresponding constraints may include: building density, capacity area, and proportion of the state of the trade. Specifically, the formula is expressed as follows:
the objective function mathematical expression may be expressed as:
and calculating the corresponding state capacity allocation scheme when the objective function obtains the maximum value by adopting an interior point method aiming at each state capacity rate combination according to the constraint conditions.
It can be understood that the server may adopt a single process to perform computation during the computation process, or may adopt multiple processes to perform parallel computation, thereby increasing the computation speed.
Step S206: and selecting a desired number of preferred resource allocation schemes according to the resource allocation parameters.
In the practical application of the method, the material is,can satisfy the condition of capacity area
When the number of the business form design distribution schemes is small, the solution which basically meets the condition of the design area can be selectively reserved. Specifically, the above-mentioned volumetric area condition can be expressed as:
correspondingly, if the number of the obtained business allocation plans is large, all the allocation plans can be sorted according to the business parameters, and the optimal plan with the expected number is selected.
Specifically, the method can be arbitrarily selected from: and (4) carrying out priority ranking on each capacity allocation scheme by using parameters such as total goods value, the number of the types of the states, high-state capacity allocation area, high-state land area, total capacity and the like, and selecting a scheme with expected quantity. In practical application, the sorting rule is set according to the requirement, and the preferred scheme meeting the requirement is selected, which is not limited herein.
According to the method, an industry state volume rate combination set is generated according to the acquired initial data of the to-be-built land parcel, and the industry state volume rate combination set comprises all industry state volume rate combinations corresponding to each industry state combination; further, for each of the combinations of the state capacity ratios, a state capacity allocation plan which corresponds to the maximum value of the objective function and satisfies the constraint condition is calculated. Because the state capacity rate combination centralizes all possible capacity value combinations of each state, the possible situation of each state capacity value is considered in the state capacity allocation scheme calculated by aiming at each state capacity rate combination, and compared with the manual adjustment of the state capacity parameters, the scheme can automatically calculate to obtain the state capacity allocation scheme meeting the constraint condition, and can enable the objective function to obtain the maximum value, thereby meeting the business requirements.
For the above-described method for automatically configuring resources, an embodiment of the present application further provides a corresponding device for automatically configuring resources, which is described below with reference to the accompanying drawings.
Referring to fig. 3, fig. 3 is a schematic structural diagram of an automatic resource configuration device according to an embodiment of the present application. In fig. 3, the resource automatic configuration apparatus 300 includes:
a data obtaining unit 301, configured to obtain initial data corresponding to a task to be processed, where the initial data includes: the task type parameter and the resource limit parameter corresponding to the task type parameter;
a combination obtaining unit 302, configured to obtain a resource configuration combination set according to the task type parameter and the resource limit parameter, where the resource configuration combination set includes all resource configuration combinations of each task combination;
a scheme obtaining unit 303, configured to calculate, respectively, a resource configuration scheme that meets the constraint condition for each resource configuration combination.
Based on fig. 3, referring to fig. 4, fig. 4 is a schematic structural diagram of another resource allocation apparatus provided in the embodiment of the present application. In fig. 4, the resource allocation apparatus 400 further includes:
a data checking unit 404, configured to check whether the type, value, and length of the initial data are correct; if yes, continuing to execute the step of obtaining the resource configuration combination set; if not, generating an error report and finishing the subsequent operation steps.
Optionally, the combination obtaining unit 302 in the resource configuration apparatus 400 includes: a task combining subunit 4021 and a resource configuring subunit 4022;
the task combining subunit 4021 is configured to arrange different types of tasks according to the task type parameters in the initial data to obtain a task combining set;
the resource allocation subunit 4022 is configured to generate a resource allocation combination set according to the resource limit parameter in the initial data based on the task combination set.
Optionally, the scheme obtaining unit 303 is configured to calculate to obtain the resource configuration scheme meeting the constraint condition by using an interior point method, a simplex method, or an ellipsoid algorithm.
Optionally, the apparatus 400 further includes: a selecting unit 405, configured to sort each resource allocation scheme according to the resource allocation parameter, and select a desired number of preferred schemes.
According to the automatic resource configuration device, all possible task resource configuration combinations are generated, and a resource configuration scheme meeting the constraint conditions is obtained by calculation under the constraint conditions for each resource configuration combination. Because the generated resource configuration combination set comprises all the resource configuration combinations of each task combination, the optimal solution corresponding to each task combination can be selected under the constraint condition, and the optimal solution is the resource configuration scheme corresponding to the maximum value of the objective function. Based on the resource allocation scheme, the resources are allocated according to the corresponding task combination, so that the resources can be utilized to the maximum extent, and the utilization rate of the resources is improved.
It should be understood that in the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" for describing an association relationship of associated objects, indicating that there may be three relationships, e.g., "a and/or B" may indicate: only A, only B and both A and B are present, wherein A and B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of single item(s) or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus embodiment, since it is substantially similar to the method embodiment, it is relatively simple to describe, and reference may be made to some descriptions of the method embodiment for relevant points. The above-described apparatus embodiments are merely illustrative, and the units and modules described as separate components may or may not be physically separate. In addition, some or all of the units and modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
It should be noted that, in the present specification, the embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. The system or the device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The foregoing is merely a preferred embodiment of the invention and is not intended to limit the invention in any manner. Although the present invention has been described with reference to the preferred embodiments, it is not intended to be limited thereto. Those skilled in the art can make numerous possible variations and modifications to the present teachings, or modify equivalent embodiments to equivalent variations, without departing from the scope of the present teachings, using the methods and techniques disclosed above. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention are still within the scope of the protection of the technical solution of the present invention, unless the contents of the technical solution of the present invention are departed.