Disclosure of Invention
The invention aims to solve the defects in the prior art, and provides a service resource matching algorithm based on an improved particle swarm algorithm, so that different subtasks can be distributed to different factories on a production line, the cooperation efficiency among the factories can be improved, and the cooperation cost among the factories can be reduced.
In order to achieve the purpose, the invention adopts the following technical scheme:
the invention relates to a business resource allocation method based on an improved particle swarm algorithm, which is characterized in that the method is applied to the production tasks of decomposing business resources into m subtasks and allocating each subtask to n factories for processing production, and an agent alliance is formed by the n factoriesWherein, the ith subtask is marked as T i ,i∈[1,m](ii) a J th plant is marked F j ,j∈[1,n](ii) a And using binary X ij Represents the ith subtask T i And jth plant F j Thereby obtaining a service resource allocation matrix X and a service logic scheduling allocation problem matrix V:
in the formula (1), the reaction mixture is,
is the element of the ith row and the jth column in the service resource allocation matrix X, and represents the ith subtask T
i And jth plant F
j The positional relationship that exists; if it is
Represents the ith subtask T
i Assigned to the i-th subtask F
j Processing and producing; otherwise, the ith subtask T is represented
i Not assigned to represent the ith subtask F
j Processing and producing;
in the formula (2), v (X) ij ) Is the element of the ith row and jth column in the business logic scheduling assignment problem matrix V, which represents the ith subtask T i And jth plant F j The relationship of the increments present;
the service resource allocation method is carried out according to the following steps:
step 1, initializing each parameter in a particle swarm algorithm, comprising the following steps: iteration times L and initializing L to be 1; maximum number of iterations L max Number of two learning factors c 1 And c 2 The inertial weight ω;
step 2, making the position matrix X of the L-th generation particles L Initializing matrix X at random; speed of L-th generation particleDegree matrix V L Distributing a problem matrix V for service logic scheduling and initializing the problem matrix V to be 0 so as to generate an L-th generation population;
step 3, the L-th generation service resource distribution matrix X L The distribution situation of the medium particles obtains a two-dimensional particle matrix S:
if the L-th generation service logic scheduling distribution problem matrix X
L Middle element
If the weight of (2) is 1, the corresponding element S in the ith row and the jth column in the two-dimensional particle matrix S shown in the formula (3)
ij The weight of (1) is 1, otherwise, the element s of the ith row and the jth column
ij The weight of (2) is 0;
in the formula (3), s ij Is to indicate the ith subtask T at the Lth generation i Assigned to the jth plant F j Generating a particle in a two-dimensional particle matrix S;
step 4, calculating the ith row and the jth column of particles S in the two-dimensional particle matrix S
ij Scheduling assignment problem matrix X in Lth generation service logic
L Degree of adaptability in
Maximum fitness of particles in the first L-1 generation
Degree of adaptability
Make a comparison if
Then the maximum fitness will be
Corresponding element
Is used as the Lth generation service logic scheduling distribution problem matrix X
L The best position of the ith row and the jth column of particles in the search space
Otherwise, the fitness is measured
Corresponding element
Is used as the L-th generation service logic scheduling distribution problem matrix X
L The best position of the ith row and the jth column of particles in the search space
Thereby obtaining the local optimal solution matrix of the particles in the two-dimensional particle matrix S at the L-th generation
Step 5, from local optimal solution matrix of L generation
The position of the optimal solution corresponding to the maximum fitness of the ith row is selected as a position matrix X
L The global optimal solution of the ith row is recorded as
Otherwise, returning to the step 4 for sequential execution; wherein,
representing a position matrix X
L The global optimal solution of the ith row;
step 6, solving a velocity matrix V of the particles in the L generation L ;
Step 6.1, calculating an inertia factor omega by using the formula (5):
ω=(ω ini -ω end )(L max -L)/L max +ω end (5)
in the formula (5), L max Is the maximum number of iterations, L is the current number of iterations, ω ini As an initial inertia weight, ω end The inertia weight value is the inertia weight value when iteration is carried out to the maximum evolution algebra;
step 6.2, updating the velocity matrix V of the L-th generation particles by the formula (6) L :
In the formula (6), c 1 ,c 2 Is a learning factor; rand is [0, 1 ]]A uniform random number within a range; when L is 1, V L-1 =0;
Step 7, calculating the L +1 th generation position matrix X according to the formula (7) L+1 :
X L+1 =X L +V L (7)
Step 8, calculating the fitness of the jth particle in the ith row of the L +1 generation in the two-dimensional particle matrix S
And the fitness of the corresponding particles in the L generation
Comparing, and taking the particle position corresponding to the larger fitness value as the optimal solution position of the jth particle in the ith row of the L +1 th generation in the two-dimensional particle matrix S
Step 9, repeating step 8 to calculate the fitness of the next particle of the L +1 th generation in the two-dimensional particle matrix S and comparing the fitness to obtain the L + of the two-dimensional particle matrix SOptimal solution matrix of 1 generation all particles
From the optimal solution matrix
The optimal solution corresponding to the maximum fitness is selected from the ith row of the position matrix X as the L +1 th generation
L+1 Global optimal solution for row i of
Step 10, assigning L +1 to L, and judging L<L
max If yes, returning to the step 4 for sequential execution, otherwise, indicating that L is finished
max The second iteration to obtain the L
max Surrogate location matrix X
Lmax Global optimal solution for row i of
Thereby obtaining a two-dimensional matrix
Global optimal solution for each row
Namely, it is
At the L th
max Position moment matrix
The upper position indicates the optimal plant to which the i-th sub-task is assigned.
The service resource allocation method based on the improved particle swarm optimization is also characterized in that the fitness of the particles in the step 4
The calculation is carried out according to the following steps:
step 4.1, dividing the evaluation indexes into accurate indexes and grade indexes;
4.2, converting the low-quality index in the accurate index into a high-quality index by using the formula (8), thereby obtaining a factory evaluation index matrix H shown as the formula (9);
in the formula (9), h
ij A j high-quality index representing the ith factory;
a j-th low-priority index representing an i-th plant;
4.3, carrying out normalization processing on the factory evaluation index matrix H to obtain an index homotaxial normalization matrix Z shown in a formula (10);
in the formula (10), Z ij Representing the jth index value of the ith plant in the index homotaxial normalization matrix;
step 4.4, according to the index homotaxial normalization matrix Z, respectively determining the optimal scheme Z by using the formula (11) and the formula (12) + And the worst case Z - :
In the formulae (11) and (12),
the maximum value of the ith column index in the index homotaxial normalization matrix Z is represented;
the minimum value of the ith column index in the index homotaxial normalization matrix Z is represented;
step 4.5, solving the current scheme and the optimal scheme Z by using the formula (13) and the formula (14)
+ Is a distance of
With the current scheme and the worst scheme
Is a distance of
Step 4.6, calculating the self-adaptability of the ith task distributed to j plant schemes by using the formula (15)
Compared with the prior art, the invention has the beneficial effects that:
1. according to the invention, under a typical differential batch manufacturing mode, the problem of cooperative scheduling production of enterprises is researched, and by adopting an improved particle swarm algorithm, the problems that evaluation indexes are not uniform in the production and transportation process, multiple indexes need to be considered during distribution, indexes of subtasks completed by a factory are unified, and the method has universality and adaptability. Obtaining the position and the speed of the particles; then, updating the positions and the speeds of the particles by utilizing a particle swarm algorithm, realizing multiple iterations and finally obtaining an optimal solution;
2. the invention provides a novel service resource allocation method based on a particle swarm algorithm. Firstly, complex business is decomposed into a plurality of flow segments, and then the optimal solution is worked out by dynamic planning of a particle swarm algorithm. The method can effectively solve the problem of current complex business resource allocation (instrument and service allocation), and has accuracy, rapidity and robustness. The method has strong universality when calculating the self-adaptability, can be widely applied and solves the problems of distribution and scheduling of various service resources.
3. The invention decomposes the complex task into a plurality of normalized subtask flows according to the business logic relationship, forms an Agent production union among the small factories to form a complete production chain, decomposes the complex production task into different subtasks with logic relationship when the user demand is generated, disperses the different subtasks to each small factory based on the particle swarm algorithm, and selects a proper path from the different subtasks. The algorithm has strong universality, can unify complex indexes in the production and transportation processes, has strong universality, and can be applied to the field of different business logic distribution.
Detailed Description
In this embodiment, a service resource allocation method for improving a particle swarm algorithm is to divide a service resource into m subtasks, allocate each subtask to n production tasks for processing and production in n factories, and form an agent union by the n factories, where the ith subtask is denoted as T i ,i∈[1,m](ii) a J th plant is marked F j ,j∈[1,n](ii) a And using binary X ij Represents the ith subtask T i And jth plant F j Thereby obtaining a service resource allocation matrix X and a service logic scheduling allocation problem matrix V:
in the formula (1), the acid-base catalyst,
is the element of the ith row and jth column in the service resource allocation matrix X, which represents the ith subtask T
i And jth plant F
j The positional relationship that exists; if it is
Represents the ith subtask T
i Assigned to the i-th subtask F
j Processing and producing; otherwise, the ith subtask T is represented
i Not assigned to represent the ith subtask F
j Processing and producing;
in the formula (2), v (X) ij ) Is the element of the ith row and jth column in the business logic scheduling assignment problem matrix V, which represents the ith subtask T i And the jth plant F j The relationship of the increments present;
the service resource allocation method is performed according to the following steps as shown in fig. 1:
step 1, initializing each parameter in a particle swarm algorithm, comprising the following steps: iteration times L and initializing L to 1; maximum number of iterations L max Number of two learning factors c 1 And c 2 The inertial weight ω, given by L max Has a value of 300, learning factor c 1 And c 2 Has a value of 2 and the inertial weight ω has a value of 1;
step 2, making the position matrix X of the L-th generation particles
L For matrix X and randomly initializing to generate L generation population, and distributing v (X) in problem matrix according to sum service logic scheduling
ij ) Obtaining the value of the service resource distribution matrix X
L Initial position and initial velocity of the ith row and jth column of the particle, if
If the value of (1) is less than the threshold, it represents the service resource allocation matrix X
L The ith row and the jth column of the medium-speed particle matrix have the existence of particles, otherwise, the No is not, so that the speed matrix V of the L-th generation particles
L Assigning problem matrix for service logic scheduling order service logic scheduling assignment problem matrix V
L V (X) in
ij ) Initialization to 0, where v (X)
ij ) The particle is represented in the service resource allocation matrix X
L The velocity increment of the ith row and the jth column of particles;
step 3, the L-th generation service resource distribution matrix X L Obtaining a two-dimensional particle matrix S according to the distribution condition of the medium particles:
if the Lth generation service logic scheduling distribution problem matrix X
L Middle element
If the weight of (2) is 1, the corresponding element S in the ith row and the jth column in the two-dimensional particle matrix S shown in the formula (3)
ij The weight of (1) is 1, otherwise, the element s of the ith row and the jth column
ij The weight of (2) is 0;
in the formula (3), s
ij Is to indicate the ith subtask T at the Lth generation
i Assigned to the jth plant F
j Generating a particle in a two-dimensional particle matrix S, each particle having memory, i.e. when the number of iterations is L-th generation
ij The fitness of L-1 generation particles containing L generation particles can be recorded
Step 4, calculating the ith row and the jth column of particles S in the two-dimensional particle matrix S
ij Scheduling assignment problem matrix X in Lth generation service logic
L Degree of adaptability in
Maximum fitness of particles in the first L-1 generation
Degree of adaptability
Make a comparison if
Then the maximum fitness will be
Corresponding element
Is used as the L-th generation service logic scheduling distribution problem matrix X
L The best position of the ith row and jth column of particles in the search space
Otherwise, the fitness is measured
Corresponding element
Is used as the Lth generation service logic scheduling distribution problem matrix X
L The best position of the ith row and jth column of particles in the search space
Thereby obtaining the local optimal solution matrix of the particles in the two-dimensional particle matrix S at the L-th generation
Fitness of the particles in step 4
The calculation was performed as follows as shown in fig. 2:
and 4.1, recording indexes in the production and transportation process of a factory, and establishing an evaluation index model. The evaluation indexes are divided into accurate indexes (objective indexes) and grade indexes (subjective indexes) according to the factory reference indexes in the actual ordering process, and the model is used for calculating and updating the self-adaptability of the factory. The method mainly comprises two parts, namely an accurate index and a grade index, wherein the accurate index comprises transportation cost, transportation time, production time, product price and the like; the grade index comprises a factory quality score, a service attitude and the like.
According to the consideration factors of the actual ordering process, the model uses the accurate indexes of transportation cost, transportation time, production time, product price, factory quality score and grade index of service attitude as shown in table 1.
TABLE 1 index Classification
Taking the selected indexes as the reference of the selected factory, defining the effective interval of each index as the following table 2, wherein the effective interval of the quality score and the service attitude of the factory is { A, B, C, D, E }, and the effective interval of the transportation cost, the transportation time, the production time and the product price is [0, ∞ ].
TABLE 2 evaluation index intervals for factories
The two indexes are assigned in respective intervals by using different assignment methods, and the first accurate index is assigned according to an actual value; the second class index is assigned according to the class, a being a value of 5, B being a value of 4, C being a value of 3, D being a value of 2, and E being a value of 1.
Step 4.2, performing chemotaxis treatment on the evaluation indexes, and converting low-quality indexes in the accurate indexes into high-quality indexes by using the formula (1), so as to obtain a factory evaluation index matrix H shown in the formula (2);
in the formula (2), h
ij A j high-quality index representing the ith factory;
a j-th low-priority index representing an i-th plant;
4.3, carrying out normalization processing on the indexes of each factory in the factory evaluation index matrix H by using the formula (3) to obtain an index homotaxial normalization matrix Z shown as the formula (4), wherein Z ij Representing the jth index value of the ith plant in the index homotaxial normalization matrix;
and 4.4, performing homotaxial normalization processing on the indexes, having universality, making decisions by taking various indexes as judgment conditions at the same time, and respectively determining an optimal scheme Z consisting of optimal evaluation indexes in current production and transportation evaluation by using a formula (5) and a formula (6) according to an index homotaxial normalization matrix Z + And the worst scheme Z consisting of the worst evaluation index - :
In the formulae (5) and (6),
the maximum value of the ith column index in the index homotaxial normalization matrix Z is represented;
the minimum value of the ith column index in the index homotaxial normalization matrix Z is represented;
step 4.5, solving the current scheme and the optimal scheme Z by using the formula (7) and the formula (8)
+ Is a distance of
With the current scheme and the worst scheme
Is a distance of
Step 4.6, calculating the self-adaptability of the ith task distributed to j plant schemes by using the formula (9)
According to
To the optimal solution Z
+ If Z is
ij For the optimal solution, the corresponding T
i 1 is ═ 1; if Z is
ij Is the worst scheme, then corresponding T
i 0. If it is
The closer to 1, Z
j The closer to the optimal solution; if it is
The closer to 0, Z
ij The closer to the worst case to derive the degree of adaptability of each plant.
Step 5, from local optimal solution matrix of L generation
The position of the optimal solution corresponding to the maximum fitness of the ith row is selected as a position matrix X
L The global optimal solution of the ith row is recorded as
Otherwise, returning to the step 4 for sequential execution; wherein,
representing a position matrix X
L The global optimal solution of the ith row;
step 6.1, the service resource allocation algorithm based on the improved particle swarm optimization is shown in fig. 1, and when the iteration times are L generations, an inertia factor ω is calculated by using a formula (10):
ω=(ω ini -ω end )(L max -L)/L max +ω end (10)
in the formula (10), L max Is the maximum number of iterations, ω ini Is an initial inertia weight, omega end The inertia weight when iterating to the maximum evolution algebra.
Step 6.2, updating the velocity matrix V of the L-th generation particles by the formula (11) L :
In the formula (11), c
1 ,c
2 Is a learning factor; rand () is [0, 1 ]]The uniform random number in the range, the formula of the update speed is composed of three parts, the first part is omega V
L-1 The 'inertia' reflects the 'habit' of the movement of the subtask particle swarm; the second part
Is 'cognitive', reflects memory of self historical experience (i.e. best-in-proximity to self); the third part
Is 'society', and the group historical experience reflecting the cooperative knowledge sharing among the subtask particles approaches to the global optimum.
Step 7, calculating the L +1 th generation position matrix X according to the formula (12) L+1 :
X L+1 =X L +V L (12)
Step 8, calculating the fitness of the jth particle in the ith row of the L +1 generation in the two-dimensional particle matrix S
And the fitness of the corresponding particles in the L generation
Comparing, and taking the particle position corresponding to the larger fitness value as the optimal solution position of the jth particle in the ith row of the L +1 th generation in the two-dimensional particle matrix S
Step (ii) of9. Repeating the step 8 to calculate the fitness of the next particle in the L +1 th generation in the two-dimensional particle matrix S and comparing the fitness to obtain the optimal solution matrix of all the particles in the L +1 th generation in the two-dimensional particle matrix S
From the optimal solution matrix
The optimal solution corresponding to the maximum fitness is selected from the ith row of the matrix as the L + 1-th generation position matrix X
L+1 Global optimal solution for ith row
Step 10, assigning L +1 to L, and judging L<L
max If yes, returning to the step 4 for sequential execution, otherwise, indicating that L is finished
max The second iteration to obtain the L
max Surrogate position matrix X
Lmax Global optimal solution for row i of
Thereby obtaining a two-dimensional matrix
Global optimal solution for each row
Namely that
At the L th
max Position moment matrix
The upper position indicates the optimal plant to which the i-th sub-task is assigned.