Modeling of the process of territorial communities formation using swarm intelligence algorithms

The process of TC formation is considered, using algorithms of swarm intelligence. The main aim of TC formation is reducing the budget and saving the public funds. The approved methodology and the process of formation of capable communities are studied when in the human settlements that form the society is the administrative building, the health care institution, the general education school of the third degree, the kindergarten, the institutions of social protection, housing and communal services, taking into account the financial security and daily migration of residents in the zone of accessibility of the administrative center. The minimum distance from the center of the community to other settlements is taken for the purpose of forming territorial communities. A mathematical model of such problem is developed, using specific limitations that arise from the formulation of the problem itself. To build effective algorithms for formation of territorial communities, the concept of independence of communities, as well as the contiguity of individual councils is introduced. Stochastic algorithms of ant colony and migrating birds have been adapted to solve the established multicriteria optimization problem. The proposed approach is investigated.


Introduction
Recently in Ukraine there has been a tendency towards decentralization of power and the unification of several settlements, thus forming a capable territorial community (TC). It is about her ability to independently provide the appropriate level of various services, given the infrastructure, resources and geographic location.
On February 5, 2015, the Parliament approved the Law of Ukraine «On the Voluntary Association of Territorial Communities» [1], and the Government, to ensure its implementation, approved the Methodology for the formation of capable territorial (Resolution of the Cabinet of Ministers of Ukraine No. 214 of 08.04.2015) [2]. It is these acts that determine how communities should be united in order for them to become capable.
By distributing resources among communities and approving a long-term plan for the formation of a capable territorial community, the working groups should be guided by the approved methodology for the formation of capable TC. Thus, taking into account the financial security, the community will be able to provide the proper level of services, in particular, in the sphere of education, culture, health, social protection, housing and communal services independently or through local self-government bodies [2].
However, in real practice it is rather difficult to form a capable community due to the presence of many key factors in the community formation: -impossibility to provide secondary medical care and specialized education at the proper level; -the need for premises for the placement of institutions; -a complex geographical position, which must take into account the daily migration of residents in the zone of accessibility of the administrative center. Therefore, today the main problems of the reform are: -the correct allocation of resources to minimize government funding; -organization of perspective plans of association in all regions of Ukraine with the definition of a potential community center, taking into account the availabili ty of services in the relevant areas in the territory of a capable TC and with the condition of having a secondary school and an outpatient clinic in the access area.
Violation of the methodology of formation can lead to unpredictable turnover of finances in community, as well as to the appearance of «white spots» -these are cases when the zone of availability of potential centers does not cover the entire territory of the region. The distance from the center of the community to its remote settlement should be such that in emergency cases it can be carried out by fire brigade, ambulance, police patrol in no more than 30 minutes. Assistance will be provided after a longer period of time, dramatically losing effectiveness [2]. All this determines the relevance of the research topic.

the object of research and its technological audit
The object of research is the method of forming capable communities. One of the most problematic places in this methodology is the presence of many key factors in the formation of the community: -impossibility to provide secondary medical care and specialized education at the proper level; -the need for premises for the placement of institutions; -a complex geographical position, which must take into account the daily migration of residents in the zone of accessibility of the administrative center. The reason for this is the lack of clearly expressed steps for the successful formation of the community, taking into account the specifics of the design area. Violation of the formation methodology can lead to unpredictable turnover of finance in community, as well as to the emergence of «white spots» -these are cases when the zone of availability of potential centers does not cover the entire territory of the region.
To identify the features of community formation, a technological audit was conducted, which aims to determine the following process parameters: -carrying out analysis of certain areas, the state of HSs of which can be combined into communities; ISSN 2226-3780 -identification of the features of the methodology of forming capable communities; -creating a mathematical model on the basis of the investigated method; -implementation of the design of algorithms and software implementation of adapted algorithms of ant colony and migrating bird for solving the problem; -analysis and investigation of the results.

the aim and objectives of research
The aim of research is development of a system by which to simulate the formation of capable territorial communities. As algorithms to achieve the aim of research should be used algorithms of swarm intelligence.
To achieve this aim, it is necessary to perform the following tasks: 1. To analyze the methods of forming communities for further algorithmization.
2. To make algorithmization of the mathematical model and software implementation of optimization methods based on the adapted algorithms: Ant Colony Optimization (ACO) and Migrating Bird Optimization (MBO).
3. To develop a system in the form of a website for visualizing the results of the work of algorithms and interactive mapping of the map as the main tool for modeling. 4. To implement a system of dynamically changing modeling criteria.

research of existing solutions of the problem
Modeling of capable TCs is a complex process. To select optimal solutions using the community modeling technique, multicriteria optimization problem should be solved [3].
Local optimization methods are used to solve complex problems in the calculation of optimization problems. Methods of local optimization, or as they are also called methods of local search, can be used for problems, are formulated as finding an isolation, maximal by a certain criterion, among the existing possible solutions. The idea of local optimization methods is to re-sort possible solutions by performing local changes, until the result is reduced to the optimal one, or a certain time limit or number of attempts is exhausted [4].
The optimization model of TC formation will be a large number of conditions, which will require the development of a mathematical model with a certain number of constraints. Perfection of classical algorithms for solving multicriteria optimization problems (MOP) with a large volume of incoming data will not lead to optimal solutions when it comes to solving a dynamic problem. Computer systems based on the use of classical methods, regardless of the initial data and the principle of finding, have the following disadvantages: -search for a solution is performed by one agent that makes it impossible to distribute the calculations, thus solving only the static problem; -weak or inefficient ability to parallelize the algorithm execution for most classical methods; -ability of most methods to find solutions that are close to the optimal allowable time for only a small number of nodes.
The disadvantages of computer systems are considered making their application in practice ineffective for solving large-scale problems.
There is a whole class of optimization methods. Conditionally, all optimization methods can be divided into methods that use the concept of derivative, gradient methods and stochastic methods (for example, methods of the Monte Carlo group) [4,5].
Very promising is the application of the behavior of «natural agents» -social animals that are able to solve complex problems on a daily basis, which, in fact, are close to problems with combinatorial optimization, including MOP. Such methods are called «methods of social behavior», these methods refer to the methods of swarm intelligence [6], or as they are called intellectual me thods of optimization. Swarm intelligence is the result of the collective behavior of agents of decentralized (from the term «swarm» there is only the concept of a family, collective, without taking into account the center of such collective), self-organizing (capable of independently solving the tasks) systems. Most problems of combinatorial optimization are successfully solved in nature by ant colony and migrating birds. There is no single center, that is, insects act independently, self-organized, coordinated with the team. The algorithms of these self-organizing beings are promising to explore and implement in practice. In recent years, the scientific direction under the name «Natural Computing», which combines mathematical methods, based on the principles of natural decision-making mechanisms [7], is being intensively developed.
Thus, all the actions of insects are reduced to elementary instinctive reactions to the environment and other insects. So, the stigmergy mechanism is achieved. It is indirect interaction between agents based on marks. Thus, the collective of insects is able to effectively find the optimal route [8].
Thanks to the «pheromone evaporation» procedure, it is possible to avoid identical solutions of the problem in many iterations. In addition, in the optimization process, the pheromone is applied to the traversed edges in accordance with the length of the route to preserve the accumulated experience about optimal solutions [9-12].

methods or research
ACO algorithm execution begins with the placement of ants at the tops of the graph, then the movement of the ants begins -the direction is determined by the probability method, based on the formula: where P i -the probability of road transition i; l i -length of the i-th transition; f i -number of pheromones at the i-th transition; α -value that determines the «greed» of the algorithm; β -value that determines the «herdability» of the algorithm and α+β = 1.
The main idea of the MBO method is movement of the particles in the space of possible solutions. Let the problem of finding the minimum (maximum) of a function of the form f(X) be solved, where X -a vector of variables that can take values from a certain region D.

ISSN 2226-3780
Then each particle at each time is characterized by the value of the parameters X from the region D (coordinates of the point in space solutions) and the value of the function f(X), which should be optimized. In this case, the share «remembers» the best point in the space of decisions, in which it was and strives to return to it. As a link between particles, the so-called shared memory is used, (each share knows the coordinates of the best point of all in which there was any share of the swarm). In addition, the motion of the particle is affected by inertia and random deviations.
The classical algorithm uses only 3 coefficients: C 1 , C 2 and ω. The following formulas are used: where V ij -the speed of the i-th particle at the j-th iteration of the algorithm; P ij -the coordinates of the best point in the solution space, in which i-th particle was from 1 to the j-th iteration of the algorithm; X ij -position coordinates of the i-th particle at the j-th iteration; G -coordinates of the best point, found by the swarm at the time of the j-th iteration; r 1 and r 2 -random numbers uniformly distributed in the interval [0, 1); C 1 and C 2 -determine the importance for the agent of his best position and the best position among the whole swarm; ω -characterizes the inertial properties of the particles. The coordinates of the best point are the best position found by the flock and characterizes the collective memory of the flock [6][7][8].
Thus, the change in the speed of each fraction (its acceleration) is defined as the sum of two vectors, the first is directed to its own best position, and the second to the best position found by the whole swarm.
Experiments have shown that the coefficients C 1 and C 2 can be chosen differently. The best is the probability scheme, or all the coefficients are chosen randomly from the range [0, 1], or C 1 is randomly selected, and the value of C 2 is then 1-C 1 [4,6].
6. research results 6.1. Construction of a mathematical model for the formation of capable territorial communities. With the purpose of efficient formation of capable TC, it is expedient to study models of stochastic algorithms. For this, it is necessary to develop a mathematical model of such problem and adapt it for solving with the ACO and MBO algorithms. The mathematical model is represented in the form of a multicriteria problem. Having such model and developing methods for its solution, it is possible to justify the TC formation. The whole area in which modeling is conducted can be depicted as a graph where the constituent of territorial communities (TC) is human settlements (HS). HSs are interconnected by paved roads, the length d of which is known. That is, let's obtain a weighted graph whose vertices are HSs and the edges of the road between HSs. HSs (the tops of the graph) are characterized by the parameters that are necessary for the formation of the community: -type (village, urban-type settlement, small city, city); -number of schools, number of hospitals, etc.; -quality of roads leading to HS; -distance to the nearest center; -existence of a council. The arcs define paved roads, some arcs of the graph can be oriented, that is, HSs in which there is no village council can belong to HSs in which there is a village council. The number of councils in the region that can be modeled can be denoted. It is possible to say that each TC consists of a lot of councils, in addition, each R i council consists of a number of HSs, that is: where TG i -territorial community; The methodology states that for the successful TC formation, infrastructure should be developed in it, in particular, there should be a general educational institution of I-III degree, a hospital, a kindergarten, a law enforcement institution and a fire station on the territory. These criteria determine the ability of community. The remote settlement of the community should be easily accessible to the fire brigade, ambulance or police patrol.
Taking into account the adopted method of formation [2], it is possible to consider the limitations on the formation of a capable TC.
On the territory of a capable community there must be at least one general education school of the third degree, one hospital, one kindergarten, one law enforcement institution and at least one fire station. Let's write this restriction as follows: ISSN 2226-3780 If the council is not independent, then it is called dependent (a number of dependent councils denote  R ). The independent council itself can form TC, and the dependent one does not. A subset of dependent boards forms an independent board, subject to (6).
The adjacency of councils is one of the criteria. The contiguity of the councils is understood to mean the presence of adjacent vertices in the graph, where the vertices are HSs that refer to various councils. Let's write the adjunction function of the councils as follows: if councils and adjacent, if councils and non nadjacent.

  
Thus, if the TC consists of more than one council, then for any council that is part of the same TC, there should be a council for this TC adjacent to it. Let's write this as follows: 2. In addition, according to the Floyd-Warshall algorithm, based on the weighted graph of distances between HSs, the matrix of the shortest distances d ij between the HSs within the region is constructed. The administrative center of the TC is HS, the distance from which to all other HSs within the TC is minimal and is ≤25 km. Let's write this as follows: where d k -total distance; x j -initial HS; x k -destination point; k -the number of HSs in the TC. HSs that satisfy condition (9) form a set N p (HSs, which can be community centers). If the set N p = ∅, then the TC from the considered state HSs can't be formed. Therefore, from the TC it is necessary to exclude some HS and restart the algorithm. Let's assume that the set N p is not empty. Then, from this set, the potential center of the TC will be HS for which the following condition reaches a minimum: Such TC center corresponds to the total distance to all other HSs within one TC d i TG . At this step a settlement is selected, the total distance from which to the points proposed for entry is minimal. The next step is investigation of the possibility of assigning potential HSs to the community center through restriction (6). Therefore, the criterion for the formation of k communities in a certain region is the minimization of the function: The mathematical model of the problem consists in the formation in the given region of capable territorial communities, minimizing the function (11) under the constraints (6)- (10). The solution of the obtained MOP consists in choosing the optimal solution for an admissible set of solutions. A point x x x n = ( ) 1 ,..., that satisfies the constraints is called an admissible solution of the optimization problem. The set of all admissible solutions is called an admissible set of a given problem, which must be found.
In describing the mathematical model, other important factors that influence the determination of the ability of community are not taken into account: the population (including school, preschool age), the amount of income and the total area of TC is formed.
The above criteria have a high dynamic factor, they are constantly changing, so their use can significantly affect the quality of decision making on the basis of static criteria. The sphere of education, culture, health, social protection, housing and communal services and developed infrastructure are related to static criteria. Therefore, they are of decisive importance in the process of forming a long-term plan for unification.
The statement of the problem is very similar to the statement of the graph partition problem. This problem relates to the so-called class of NP-complete problems.
To visualize the formation of capable TC, a model has been developed that encompasses all stages of the process and takes into account the requirements determined by the method of formation of capable TC. According to the approved methodology, the formation process consists of the following steps (the process activity diagram is shown in Fig. 1): -initiating the creation of working groups. At this stage, the chairman of the council -the initiator is preparing an order «On initiating a voluntary association of territorial communities», the regional state administration creates a working group that develops a forward-looking plan. The working group includes: representatives of the State Administration, local selfgovernment bodies, bodies of self-organization of the population and the public; -identification of the boundaries of the area where the modeling will be conducted, settlements, or the list of territorial communities that can be part of a capable territorial community and the identification of potential centers of the united communities; -determination of the basic powers of local governments of territorial communities for maintenance of its development (criteria of ability); -determination of the accessibility zones of the potential administrative center of a capable territorial community that is optimal to provide administrative and other services to community residents and the formation of a plurality of TCs, provided that the HSs is included in the united community and the potential specific center may remain the center; -determination of the infrastructural capacity of a potential unified community. The availability of secondary schools and hospitals is mandatory and the definition of centers and boundaries of TC. Determination of the list of territorial communities whose territories are not covered by the zones of accessibility of potential administrative centers; -in order to take into account the interests of the communities themselves, when developing the plan, consultations are held with the self-government bodies and public hearings; -creation of perspective plans, which consist of: a) graphical part that reflects the limits of capable TC, the potential administrative centers of such communities and all human settlements; b) passport of a capable territorial community with a description of each such community; c) consultation protocol with community representatives.
ISSN 2226-3780 6.2. application of the ant colony algorithm for the formation of capable territorial communities. The ant colony method is able to solve MOP, taking as initial data only the initial node P(0). The matrix of values (pheromones) C and the matrix of availability (distances) D in full are optional for this method, that is, the data may be partially unknown at the beginning of the calculation or heuristic [9].
The ant colony algorithm is based on the use of several agents and has specific properties characteristic of ants that are used for orientation in the physical space, in particular pheromone, which the ants notice the traveled distance. Labels in the case of hardware-software implementation of the algorithm are digital (chemical in real ants). The value of the mark refers to the connection of the HS i to the HS j , denoted as M ij , and the totality of the mark values is the matrix M (marks). This set of values of marks is also called the memory of the ant colony, which is the accumulator of the experience accumulated by the ants in the process of solving MOP. To solve the problem posed by the ant algorithm, the following input parameters are key: -number of agents (ants) -denoted by k; -expediency of using auxiliary means of amplifying the found quasi-optimal routes by increasing the value of the mark (additional «pheromone application») in order to accelerate the MOP solution; -parameters of the processes of «pheromone overlapping» and «pheromone evaporation»; Establishment of a working group by the Regional State Administration The definition of the proposed community center, which is located in the «center» of the community and has the best infrastructure The association plan is approved by the working group Holding public hearings to improve the integration plan Change in association plans to avoid «white spots» in the region Creation of passports of capable TC, creation of a protocol The plan of the association is approved by the community of the region Otherwise Otherwise Step 1: Association initiation Step 2. Identification of potential communities in the modeling region Step 3. Identification of the community center Step 4. Creation of passports for promising TC, creation of a protocol -criterion for stopping calculations: the number of iterations of the route search cycle by ants or calculation time; -coefficients that determine the ratio of the length of the edges -β and the value of pheromone (mark values) -α. Since ants solve the problems of finding the best ways with the help of chemical regulation (pheromones), another ant, having felt a trace on the ground, is sent along it, thanks to the stigmergy mechanism -indirect interaction between agents based on marks.
Solving the task, the environment for the movement of ants is an oriented graph, the peaks of which are HSs, among which communities should be formed. Each edge has a weight, which is denoted as the distance between two HSs connected by it. The graph is bi-directional, so an ant can travel on the edge in any direction. Before the beginning of the algorithm, all agents are placed at the vertices of the graph.
At the beginning of the algorithm, the initial values of all the marks M ij located at the junctions between the HSs, which together form the matrix M, are given. The initial value for initialization is a small positive number, that is, at the initial stage the probabilities of transition to the next node will be equal but not zero. In fact, the memory of the ant colony in the beginning is nullified (without the experience of the colony).
For the proposed task of forming capable communities, the matrix of pheromones M (edges of the graph) should be filled in, taking into account the probability of transition from the i-th HS to the j-th HS due to the presence in the j-th HS of the necessary administrative facilities (schools, gardens, fire stations, etc.). Each administrative building has its own priority, which is set dynamically and can change during the algorithm execution. Based on the priority of each administrative building in the j-th HS and the number of criteria affecting the definition of ability, the initial value of the mark from the range [0, 1] is calculated using the following equation: where M ij -intensity of the pheromone on the edge from i to j; CR -number of criteria for which modeling is carried out; q -number of criteria in HS with the index j; PR -priority of the criteria by the index c for HS with the index j.
In addition, the probability of including an edge in the route of a separate ant is proportional to the amount of pheromone on that edge, and the amount of pheromone that is delayed is proportional to the length of the route. The shorter the route the more pheromone will be delayed on its edges, hence a larger number of ants will include its constituents in the synthesis of its own routes.
While the algorithm is running, the ant maintains a list of HSs that have already been visited. Thus, the ant-agent must pass through HSs that are within the reach of the community center [9,12].
The movement of the ant-agents is based on one fairly simple probability equation (1). If the ant-agent has not yet completed the journey, that is, has visited an insufficient amount of HSs to form a capable TC, then a probabilistic sample is used to determine the next state of HS for the transition, based on the value of the inverse mapping function of the significance of the passed HSs.
The nodes, the ant-agent visited, are listed in the list of forbidden visits, which is also called the taboo list. Since the agent travels only for HSs that have not yet been visited (according to the taboo list), the probability is calculated only for connections that lead to unreachable available HSs. The procedure for finding the next node occurs until all the HSs are passed among which an able community can be formed [12,13].
After all ants-agents have completed their journey for each agent, it investigates the distance traveled and whether all settlements are within 25 km according to the restrictions (9). The next step is to select the center of the proposed community, determining the minimum size from all proposed HSs with the help of (11).
The next step is increase in the number of ants by the amount of pheromone on the edges between HSs. After the completion of the route, the cost of the route can be calculated. It is equal to the sum of the lengths of all the connections through which the ants-agents passed. The change in the amount of pheromone per ∆M t ij k ( ), which occurs at each connection, makes up the route for the k -th ants-agent is calculated by the following equation: where Q -a constant proportional to the expected length of the path; C t k ( ) -total route length at the time point t for the k -th ants. The result of equation (13) is the acquisition of an experiment for the memory of the ant colony, and the connection between the HSs making up the route with the smaller total distance will receive larger pheromone values than the connections that are components of the routes that have a long length. The obtained result ∆M t ij k ( ) is used in equation (14) to increase the intensity of pheromone on each edge between the incident traced by the ant-agent route. An increase in the mark value (pheromone imposition) occurs at the end of each iterations of the route search cycle by ants-agents, following the procedure of «pheromone evaporation» (15).

M t M t P ij ij
where P -a constant that determines the evaporation intensity within [0, 1]. Equation (14) is applied to the entire route, and the pheromone value on each edge increases in proportion to the length of the traversed route. Therefore, it is necessary to wait until the ant-agent completes the journey and only then update the meaning of pheromone according to the experience obtained by the agents, otherwise the true length of the traversed path will remain unknown [9,14].
Modeling this approach using only positive feedback leads to premature convergence -most ants move along a locally optimal path, which leads to suboptimal decisions [12,13].

ISSN 2226-3780
To avoid this, one can model a negative feedback in the form of pheromone evaporation (15). If the pheromone evaporates quickly, it results in the loss of the accumulated experience, stored in the memory of the ant colony and information about the optimal solutions. On the other hand, a long evaporation time can lead to a stable local optimal solution without the possibility of finding more optimal solutions.
Finding the optimal MOP solutions for the formation of capable communities, the algorithm requires a certain number of iterations, which is noted at the beginning of the modeling. During each iterations of the cycle, the ants-agents, starting their way from some initial HS P(0), travel through the network visiting other HSs, passing through a connection between HSs selected according to equation (1). Each iteration of the search cycle for ants-agents ends with the return of all agents to the initial HS and the collection of results, after which the «taboo» list is cleared for each k -th agent and the length of the traversed route is deleted along with the recorded resulting route. The cycle is executed by one or more of the following conditions: a certain number of iterations are executed; the best solutions have a very small change factor compared to previous solutions; a certain time limit for MOP calculation has been exhausted [14,15]. After the path is completed and the ant-agent returns to the original node, a procedure is performed to determine if there is an opportunity to form a community based on the received data. If it is true, then by means of constraints (6)-(10) HSs and the proposed TC center are determined. Then the procedure «pheromone evaporation» on all edges is avoided, avoiding identical solutions. In addition, the pheromone is applied to the traversed edges in accordance with the length of the route to preserve the accumulated experience about the optimal solutions.
Further, the analysis of all established communities by ants-agents is carried out, and the choice of optimal ones is carried out. After the completion of the cycle of formation of the best communities, the analysis of all proposed solutions for determining the best is carried out. The best solution can change if run the algorithm several times. In addition, the flexibility of the parameters α and β makes it possible to control the quality of the proposed decoupling and greed of the algorithm [15]. For α = 1 and β = 0, only administrative buildings will be taken into account in the results. For α = 0 and β = 1, the result will be based on the distance between the HSs. Fig. 2 is a block diagram of ACO algorithm execution for the formation of capable communities. According to the described algorithm for solving the problem of TC formation, at the beginning of the algorithm, the coefficients of the ACO algorithm, HS and the criteria for modeling are entered. The next step is initialization of the agents.
In the process of work, each ant offers its best solution for each HS in the area (graph) of the model. The choice of points is carried out with the help of formula (1). Upon completion of the work, the data are collected and the procedure for updating the value of pheromone and its evaporation is collected in accordance with the description of the solution of TC formation problem by the ACO algorithm. At the end, optimal solutions are selected.  fig. 2. Block diagram of ACO (Ant Colony Optimization) software execution 6.3. Application of the migrating bird algorithm for the formation of capable territorial communities. The MBO method is based on the fact that individual members of the flock can benefit from the previous experience of all other members of the flock when searching for optimal solutions. This advantage of the algorithm becomes decisive always when the necessary objects are located in the path in a random or unknown way. That is, there is a social division of information among representatives of one species, which is beneficial to all members of the pack. The method is based on the grouping of agents due to the specific topology of the links in the flock. It is used to solve optimization problems in a multicriteria formulation. In this case, the optimization problem can be formed and solved as a vector optimization problem, which consists in minimizing the vector criterion [5,6].
The problem of global optimization is formulated as the problem of minimizing the objective function (11) in the search space D: where D -search area for the optimal solution; d -the number of vertices in the graph; x -the argument of the optimized function; X* -global solution. Технологічний аудиТ Та резерви виробницТва -№ 5/2(37), 2017

ISSN 2226-3780
The number of agents used in the MBO algorithm directly affects the quality of the carried out optimization. Too small a number of them may not allow to localize the global optimum or the rate of convergence to it will be very low. Increasing the number of used agents increases the probability of finding the optimal solution, but can lead to an excessively high number of calculations of the objective function [8].
To solve MOP on the formation of capable communities, it is sufficient to specify the size of the swarm, which would be equal to the HS amount in the given area for which optimization is performed.
In this method, a flock of birds is a collection of decision points that move in space in search of a global optimum. When moving, particles try to improve solutions they found earlier and exchange information with their neighbors. Let's denote the set of positions of the flock agents as follows: where t -the number of birds in the flock. The position of the i-th particle is the set of its coordinates (visited by the HS) (17) in the search environment (in the graph At the initial stage of the algorithm, random initialization of agents from the flock is carried out. If there is no specific information about the function, which is optimized, it is simpler to select the initial positions of the agents by the formula: where b ij -j-th coordinate of the i-th agent; rand(b jmin , b jmax )a random number with a uniform distribution. A set of vectors of agents is also associated with a flock of birds: At the initial stage, all speeds are assumed to be equal to zero. During the movement of birds in the area of decisions, the presence in each of the visited HSs necessary for the creation of the community facilities (schools, kindergartens, etc.) is checked. In addition, the distance and its length are remembered. When the agent during the movement has passed some set of HSs, among which can select the center by the constraints (6), the community center is defined beyond the constraints (9) and (10) to create the optimal unification plan. If possible, then beyond the constraint (7), each agent offers its own set of independent councils. This sequence of steps should be done for each agent in the flocks to analyze the proposed solutions and compare them. After all the agents in the flock have offered their solutions, the algorithm tries to find the best solution for function (11) (fitness) in order to create a capable community [7]. To this end, among all the proposed solutions, it is necessary to find a solution for which the following formula gives the greatest value: where R i -the optimality of the solution for the i-th agent; CR j j c = ∑ 1 -the total number of criteria in the visited HS; d idistance traveled by the i-th agent. After that, this solution becomes the best until a better correlation is found on the next iterations of the algorithm. The next step is to update the agent's speed and position, using formulas (2) and (3). If the agent goes beyond the search space during the optimization process, the agent's speed is reset to zero, and the agent returns to the nearest graph boundary. The inertial coefficient ω determines the influence of the preliminary speed of the particle on its new value. Numerical experiments show that with an increase in the dimensionality of the solved optimization problem, it is possible to achieve better results by applying a narrower interval of variation of the inertial coefficient, increasing its lower limit in order to avoid rapid loss of speeds by agents.
A premature convergence of the algorithm may occur, when most agents in a flock practically stop changing their optimally-local solutions, and the global solution is still found. This situation can arise when small values of inertial, cognitive or social coefficients are used.
Another feature of the application of the algorithm is that the values of the coefficients for equation (2) are selected in the following ranges: To ensure the convergence of this optimization method, to maintain a balance between local and global search, the numerical values of the coefficients C 1 and C 2 are usually chosen to be the same. There are also various ways to dynamically select the parameters of a flock, but such adaptation requires additional initial iterations of the algorithm, which can lead to an increase in the number of calculations of the objective function necessary to find the optimal solution. An additional parameter of the algorithm is the maximum permissible value of the module of the speed parameter of the agents in the flock v max . Usually it is chosen small, for example. If the permissible speed exceeds the range , the agent returns to the HS.
In the process of the algorithm, the flock has a memory of the best solutions that are found by individual agents and the entire flock as a whole. During initialization, the initial positions of agents are considered to be the best. At each subsequent iterations of the algorithm after applying formulas (2) After all calculations, when the optimality change factor of the solution is very small, the analysis of all formed communities is carried out. In addition, the flexibility of the parameters C 1 and C 2 allow to control the quality of proposed solutions or, as a solution, preference is given to the general decoupling of the flock, or local to each agent [4,[6][7][8]. At the beginning of the algorithm all birds-agents are initialized with a random speed vector and position in the graph. Further it is determined, among the HSs of some agent is all the criteria, and it is possible to form a community. Better value of the ratio of criteria to the common path becomes best for the flock. On the basis of formula (1), the speed vector of the agents is updated based on the flock position.
6.4. logical structure of software implementation. In the developed system of formation of capable TС, all stages of the community formation process should be covered, and requirements that determine its capacity should be taken into account. Fig. 4 shows the logical structure of the formation system of capable TС.
The presented structure is an architectural solution with the help of which it is possible to design and implement a software product. The implementation of the system can consist of the following stages: -analysis of the approved methodology of community formation for the purpose, definition of expected results of development and creation of the subject area; -obtaining data presented in the form of cartographic information, since the map is the main modeling tool; -application of the map to collect information about HSs, division of the regions of Ukraine, road network research and terrain modeling; -use of existing Google systems to obtain data on the distance between HSs and the coordinates of HSs, and their limits; -entering data on HSs, among which will be modeling in the database and determining approved, key criteria for determining the ability and entering information about them in the database; -determination of the main search coefficients for optimal solutions for the ACO  To determine the ability of the community, it is necessary to add the criteria for modeling. In addition, the program supports the dynamic modification of parameters that will be used to determine the ability of the community. To do this, it is possible to add new modeling criteria to study the obtained results with the various included parameters. The criterion takes precedence, and also the type. Priority will be used in modeling. The available priorities are listed in Table 1.
Also, the criterion can have one of the following types: -institutions that are maintained at the expense of the budget of local self-government bodies; -premises for placement of state bodies, institutions exercising powers.
To solve the problem of forming capable communities, one should submit each variable of applied algorithms in the form that was used in the software implementation of each of the selected algorithms. Let's consider the steps that need to be taken to apply the algorithm of ant colonies: -using the GoogleMaps DistanceMatrix service, it is necessary to obtain a matrix of distances between all the HSs; -introduce coefficients α and β to use algorithm features; -enter the distance for the criterion «HS accessibility zone to the center»; -transfer the list of HESs for which modeling is performed; -transfer an array of criteria for which modeling is performed; -determine the number of iterations for the algorithm. The work of the algorithm is based on a cycle, the condition of an exit from which is the excess of the number of possible iterations. At the beginning of the algorithm, the matrix of marks (pheromones) is filled, the probability of transition from one HS to another is determined on the basis of the presence of the necessary criteria for the TC formation in the HS. Also, all ants-agents are placed in each HS. The next step is ant movement modeling. For each ant, the next destination is determined based on formula (1) for using the introduced coefficients α and β, reading the pheromone value and the distance between the HSs. After the next city is chosen, all necessary criteria for community formation are checked. If there are enough criteria, then the ant found a local solution, and the ant completes the path to the next iteration of the cycle. When all ants have found local solutions, the procedure for pheromone evaporation for the mark matrix is carried out. Based on the distance traveled by each ant, the pheromone values are updated. To avoid cycling and modeling feedback, the procedure of pheromone evaporation is carried out one more time.
The next step is collection of all the data in ants that have successfully found local solutions. Among the selected HS, the TC center is selected based on the Floyd-Warshall algorithm. All data is stored in an associative array, the key of which is the agent number in the swarm. After the completion of the algorithm, all the collected data is analyzed and data is sampled based on the quality of the proposed solution by each ant during the algorithm operation time.
To use the MBO algorithm, it is necessary to follow the following steps: -enter the coefficients C 1 and C 2 to use the algorithm features; -determine the number of iterations for the algorithm. Other steps are similar to using ACO. At the beginning of the algorithm, it is necessary to randomly select the speed factor and position of each agent. The next step is modeling of the movement of particles in space, for this purpose, according to formulas (2) and (3), the particle displacement vector is determined, taking into account the inertia constant, which usually has a value of 1. To determine the maximum permissible speed parameter, the agent with the largest value current solution. Using formula (2), using the coefficients C 1 and C 2 , a new speed is determined, and for (3) -the position of each individual particle. The next step is sorting of the whole array of particles to get the best agent that went the very way, and on the basis of the visited HS, which could form a TC. Its position becomes the best G for the flock.
To analyze the best solutions, the array of particles is sorted by the formula (21) and the best solution is chosen. Further for the analysis of this solution, the TC center is chosen according to the Floyd-Warshall algorithm. This decision is entered into an associative array of solutions for further analysis.  Based on the updated speed, the Fisher-Yates algorithm randomly sorts the traversed path (array of visited HSs) for each agent. And the algorithm is repeated for all agents. After sorting, the traversed path is obtained by each agent, changed according to the speed vector of the flock. After the algorithm is completed, the associative array is sorted for each HS by the quality of the community center choice for it and the best solution is formed.
Interaction between modules includes all classes of the system. But for the modeling process, only those classes that are directly involved in modeling are the main ones. Dynamics of interaction between objects in time in the process of community formation is shown in Fig. 5.
The resulting sequence diagram shows the activity of objects in the modeling process.
6.5. research results of the proposed approach for tC formation. In the process of developing this page, the possibility of choosing HS was realized, among which communities should be formed. To do this, it is necessary to select the HS by clicking on the corresponding check boxes in the right column of the table. After that, click on the «Model» button. The window shown in Fig. 6 is opened. By pressing the «Go to modeling» button the user will be moved to the «Map» page.
By opening the «Selection Criteria» page, the user will see all the added criteria that are contained in 3 categories. The table contains all information about the criteria. By clicking the appropria te checkboxes in the «Use?» field, it is possible to disable the criteria, in which case only selected criteria will be used to identify capable communities. This page is shown in Fig. 7, a. To add a new criterion, click the «Add Criteria» button below the main table. Clicking on the button opens the window shown in Fig. 7, b, where it is necessary to enter the necessary information about the criteria. The choice of priority and type of criteria is implemented using drop-down lists.
Go to the «Map» page is possible by selecting the HS on the «Locations» page and clicking «Model», or by clicking on the «Map» link. Almost the whole area of the «Map» page is occupied by a graphical representation of the map, which is displayed thanks to the GoogleMaps service and JavaScript code. The interface for interacting with the map is shown in Fig. 8.
«Show settlements» -loads HSs that is found in the specified radius. The result of the button is shown in Fig. 9, a. «Model» -allows to start the modeling process. The corresponding window shown in Fig. 9, b.
«Preliminary results» -allows to view the results of preliminary modeling. «Clear Results» -clears all markers on the map and all results.
To start the modeling, enter the coefficients of the ACO and MBO algorithm and press the «Start modeling» button.
After modeling, the page on the right shows a pullout panel with modeling results. This panel is shown in Fig. 10, a. In the results panel, it is possible to switch between modeling results suggested by the ACO and MBO algorithms. The results are shown in a table with two columns. In the first -HSs, which are part of the proposed community, and in the second -the center. ISSN 2226-3780 The «Show Graph» button displays the best solution in the form of oriented sub-graphs. The graph display interface is implemented using the window shown in Fig. 10, b.
When working with modeling results, it is possible to review the existing results on the map. To do this, click on the line with the company. For each community, randomly selected color for visualization on the map. The center of the community is affected by a circle of larger size than the circles for HS that entered the TC. By clicking on the circle of the center of the community, it is possible to view information about the corresponding TC. In particular, what criteria were used for modeling and the distance to HS that entered the established community. A map with modeling results is shown in Fig. 11, a. The TC information window is shown in Fig. 11, b.
For comparison and analysis of modeling results, it is possible to add existing communities. In addition, the program is supported by obtaining information about two elected communities. They can be selected by clicking on the corresponding line. If select a sufficient number of communities for comparison, a «Compare» button appears, clicking on which it is possible to get information about the compared TCs (Fig. 12).
6.6. software testing. To test the developed software product, it is advisable to select a certain region of Ukraine, and model the merger plans.
An example of testing the system may be the problem of modeling capable TC for a separate part of the Chernivtsi region.
The administrative-territorial structure of the Chernivtsi region is as follows: 11 districts, 2 cities of regional significance, 2 cities of regional significance, 398 villages, and 8 urban-type settlements.
Part of the Storozhynets district will be used to model territorial communities and to study the results of program implementation.
The The indicated criteria data for an example are given in Table 2. Table 3 shows information about the distance between individual HSs, all values are in meters. Having carried out a number of experiments using different parameter values, it is necessary to find a combination of algorithm coefficients, in which algorithms will give the optimal value or the algorithm closest to it in most cases. The solution may not be optimal and even one of the worst, but because of the randomness in the choice of solutions, algorithms can produce a fairly accurate result.
For the ant algorithm there are a number of parameters that affect the efficiency of its operation: -coefficient of accounting for the pheromone value in the transition between the nodes α; -coefficient of taking into account the length of the edges in the transition between the nodes β; -parameter of the pheromone evaporation intensity P; -pheromone renewal coefficient at transition Q. At the same time, the following parameters are the main parameters for the migrating bird algorithm: -coefficient of cognitive behavior C 1 ; -coefficient of social behavior C 2 ; -agent inertia parameter ω.
To determine whether the set of values of the coefficients affects the result of the operation of the algorithms, it is necessary to use variations in the parameter values. In the developed system, the coefficients for which can enter a value before executing the program are α, β, C 1 and C 2 and the values of the parameters P, Q, and ω dynamically change during program execution.
During testing, the effect of changing parameters on the quality of the proposed solution will be investigated, and the values of the basic coefficients will vary with some step. To assess the quality of applied algorithms, the total length from the center L to each HS that is part of the community will be used, since the criterion «Accessibility zone» determines the prospect of the unification plan before its direction. In addition, it is advisable to investigate the total amount of incomes of the established community Q for assessing the possibility of budget development and providing a financial subvention to the community. This evaluation of the criterion is important for budgeting the established community and for implementing budget monitoring: Using the values of the coefficients α = 0.5, β = 0.5, C 1 = 0.5, C 2 = 0.5, the next results are obtained (Tables 4, 5). Using the values of the coefficients α = 0, β = 1, C 1 = 0, C 2 = 1, the results given in Table 1 are obtained (Tables 6, 7). Introducing the values of the coefficients α = 0.2, β = = 0.8, C 1 = 0.2, C 2 = 0.8, the results given in Tables 8, 9 are obtained. Technology audiT and producTion reserves -№ 5/2(37), 2017 ISSN 2226-3780 Testing the effect of the coefficients, the following values are introduced: α = 0.7, β = 0.3, C 1 = 0.7, C 2 = 0.3, the results given in Tables 10, 11 are obtained. Carrying out testing with the values α = 1.0, β = 0, C 1 = 1.0, C 2 = 0, the results given in Tables 12, 13 are obtained.  Table 14 shows the results for combinations of coefficients of algorithms of ant colonies and migrating birds. The conducted testing is based on the analysis of data obtained in a stochastic manner, thanks to the peculiarities of the ACO and MBO algorithms for finding the optimal partition of the area. To compare the obtained data, it is necessary to investigate the capable communities that would be proposed by the working group. Guided by the method of TC formation, for the considered example, the reference solution can be the result given in Table 15. The optimal solution is based on minimizing the distance between the HS and TC center. Fig. 13 graphically displays the results of experiments.
Investigating the effect of parameters on the quality of obtaining an optimal partition of the area, it is possible to conclude that the change in the values of the coefficients significantly affects the quality of the proposed solution. The methodology states that the formation of capable TCs in a given area should occur by sharing powers between HSs that can provide all necessary services, while choosing community centers of HSs that have the smallest total distance to each HS in the community, this shows the specifics of the task of TC formation.
The ant colony algorithm demonstrated that, with an increase in its coefficient β, optimal solutions are based on the distance between individual HSs among which communities can be formed. When β = 1, the algorithm showed «greed» to allow for the distance between HS. At large values of α, the obtained solution depends significantly on the pheromone on the path. At α = 1, the choice of the HS is not based on the distance value for TC formation. The most optimal solution is obtained using the values α = 0.5, β = 0.5.
The migrating bird algorithm shows that reducing the coefficient of influence C 2 algorithm relied on the local decisions of the agent, reducing the total distance to the HS in the community. Reducing the coefficient of local optimum C 1 , the formation of communities relied on a common solution that the flock found, which gives an ISSN 2226-3780 increase in the TC area through the involvement of new HS in the communities. The most optimal solution is obtained using the values C 1 = 1, C 2 = 0, that it demonstrates the best choice of TC centers.
The obtained results should be investigated in practice for specific regions of Ukraine. The final result may not be the best, it only demonstrates the application of methods for solving the problem. Specificity of the task of TC formation involves the account of all HSs, among which it is necessary to simulate TC, choosing the center of those HSs, which can be reached even from the most remote HSs. It is advisable to restart the algorithms until a better outcome of the previous one is found.
It can be seen that regardless of the choice of the community center, absolutely all TCs have criteria for recognizing the ability, the set of which is determined at the beginning of testing. As for the aggregate amount of the TC budget, this parameter is dynamically changing during the testing process. Analysis of solutions demonstrates a similar distribution of resources, which makes it possible to build an effective management system aimed at the development of all established TCs.
The conducted researches are based on the data received by the stochastic method due to the specific operation of the swarm intelligence algorithms. The implementation of their analysis and the determination of the best solution can be the basis for justifying the opportunities of the established communities. The proposed methods show the effectiveness of the example of the formation of capable TC for part Storozhynets district of the Chernivtsi region (Ukraine). 6.7. Prospective directions for improving software implementation. During the development of the program, two algorithms of swarm optimization are adapted to solve the task of TCs formation. But the drawback is that not all the characteristics that can influence the decision-making have been taken into account. In the future, for the best work of the algorithm, it would be possible to include the following limitations in the optimization task: -total TC area is formed; -population in the community; -timetable for the movement of vehicles (trains, buses, etc.). As for the applied algorithms for the solution, it is possible to improve the ACO algorithm by adding the applications of elite ants, their number and the frequency of the launch. «Elite» ants-agents move around the graph as well as ordinary agents. The purpose of their launching is increase in the value of the marks on the joins of the found set of best results, and, accordingly, exclusion of too long routes. But the number and frequency of launching elite ant agents is not yet fully explored, since with their frequent use, solutions that might be included in potentially optimal routes may remain unresolved.
As for the flock of birds, the promising direction is the hybridization of the algorithm with other methods of searching for the optimum, in particular, local search, the method of moving bacteria and genetic algorithms.

sWot analysis of research results
Strengths. The strength of research is the analysis of information technologies and algorithms that are used to form capable territorial communities in Ukraine. It is also important to adapt the algorithms of swarm intelligence to solve the problem of forming communities in a given area. The flexibility of changing the parameters that are used for modeling, in particular, the criteria that determine the ability of TC and the maximum distance of a hardsurfaced road, makes it possible to dynamically change the program's proposed merger plans. Due to this, the system can be configured for use with specific areas of Ukraine.
Weaknesses. The weak side is that each individual modeling area has its own set of criteria for determining the ability to adapt to. That is, it is advisable to run the algorithm several times to determine the best solution. Also, modeling is carried out on the basis of geoinformation maps, which should be sufficiently reliable and relevant to obtain a more accurate result of the division of the area in the formation of capable communities.
Opportunities. Opportunities for further research are the borrowing of the experience of the EU countries in the formation of territorial communities, the study of technologies and methods used to study this issue for the introduction of the method of adaptation to the various types of territorial distribution of a country.
Threats. The difficulty in implementing the findings of the study is that in Ukraine there are many changes at the community level, changing the needs of the population, carrying out many reforms of various types in connection with the integration of Ukraine into the European Union. All of the below listed aspects affect the feasibility of the proposed method of forming capable territorial communities, since there are different types of territorial arrangement.