3.1. Basic ACO
ACO is a type of swarm intelligence heuristic algorithm that simulates the behaviors and communication of ants to solve complex optimization problems [
20]. In general, five phases are included in a basic ACO algorithm.
(1) Initializing pheromones. Usually, the pheromone on each node is initialized as the same value.
(2) Constructing solutions. Each artificial ant selects route nodes (solution’s elements) successively and pseudo-randomly according to the transition probability to form a route (a solution). The transition probability is determined by the pheromones on all nodes and the heuristic information. Commonly, the more pheromone deposited on a node, the higher the probability that the node is selected by an ant.
(3) Updating solutions. If a better solution is constructed, the best-so-far solution will be recorded as the better one.
(4) Updating the pheromones on all nodes after new solutions are constructed by ants. This contains two kinds of pheromone updating strategies. One is pheromone reinforcement, which is used to increase the pheromone on each solution’s nodes. The better the solution is, the larger the pheromone increment is. The other one is pheromone evaporation, which makes the pheromone on all nodes decrease at a predefined rate and is helpful for ants to “forget” the bad solutions in the previous iteration. By the combination of these two strategies and multiple repeated iterations, the pheromones on the optimal route’s nodes increase, thus, the ants tend to converge to the optimal path (the optimal solution).
(5) Judging the algorithm’s convergence. The convergent condition is usually defined as a maximum iteration number or maximum iteration time. If the convergent condition is not met, step 2 and step 3 will be executed again, otherwise, the algorithm stops.
3.2. Improvement Strategies
Based on the basic ACO algorithm, this paper proposes multiple ant colony optimization (MACO) to solve the problem of indoor spatial optimal allocation. Compared to basic ACO, MACO is improved from three aspects. First, three kinds of heuristic information that are influential to the transition probability calculation are proposed to navigate each ant’s route selection to areas in the solution space where the global optimal solution is located. Second, a two-colony optimization rule is proposed to prevent the ants’ route selection from being trapped in the local optimal solution. Third, a local search strategy is imported to improve the best solution’s quality in each iteration and also the algorithm’s overall performance.
3.2.1. Heuristic Information
When implementing indoor spatial allocation, if a fully random strategy is adopted, a large number of solutions with low quality will be generated, which makes it challenging to find the optimal solution within a reasonable time. Therefore, in this MACO, three types of connectivity costs in the problem’s optimization model (the minimum connectivity cost of allocated rooms and exits, the minimum connectivity cost among rooms that are assigned to the same department, and the minimum connectivity costs between rooms that belong to different departments) can be treated as the heuristic information for assigning rooms to each department.
While evaluating the heuristic information, the mathematic symbols are listed as follows (
Table 2).
Explicitly, heuristic information can be calculated based on the following three circumstances.
If or if and , then , which is the reciprocal of the minimum weighted connectivity cost between the allocated room and the building exits.
If and , then , which is the reciprocal of the minimum weighted connectivity cost between the allocated room and the allocated rooms whose department type is not .
If , then , which is the reciprocal of the minimum weighted connectivity cost between the allocated room and the allocated rooms whose department number is .
3.2.2. Two-Colony Optimization Strategy
Because of the usage of these three types of heuristic information, the order of allocating departments has a strong impact on the final allocation solution. In order to ensure more opportunities for generating solutions with a better order of allocating departments, a two-colony optimization rule has been imported to MACO. These two ant colonies are of the same size, .
In the phase of solution generation, the first ant colony is used to pseudo-randomly determine the optimal order of allocating departments according to the transition probability based on the pheromone. The first-colony pheromone matrix is
, in which
is the number of the department and
is the allocation order. If the allocation order of department
is
and the former
departments’ allocating order set is
, the transition probability that the allocating order of department
is set as
is:
in which
is the adjustment parameter of pheromone
.
Based on the order obtained by the first colony, the second ant colony assigns rooms to each department to form solutions (a sample of the solution is shown in
Figure 2) according to its transition probability. The probability is highly related to the heuristic information mentioned in
Section 3.2.1 and the second-colony’s pheromones. The second-colony pheromone matrix is
, in which
is the number of departments and
is the number of rooms. The transition probability that a room
is assigned to department
can be expressed as Formula (8):
in which
,
are the adjustment parameters of pheromone
and heuristic information
respectively. The meanings of and
can be found in
Table 2.
In the phase of pheromone updating, the two colonies use the same elite ant strategy via two pheromone matrixes,
and
(Formulas (9)–(11)):
Here, the pheromone and of node in and during the iteration are represented by the same symbol . is the pheromone decay parameter, is the pheromone increment on all nodes of the current best solution in iteration , is the pheromone increment of the best-so-far solution , is the best objective function value in iteration , and is the best function value of the best-so-far solution. is a predefined constant, which is used to ensure that the pheromone increments, and , are not too large to lead to a local optimal solution or too small to result in slow convergence relative to the pheromone and .
3.2.3. Local Search
In this MACO, if all ants finish constructing solutions, a greedy local search strategy, swap exchange, is used to further improve the solution quality. This strategy swaps two rooms that were originally assigned to different departments to generate a new solution (shown in
Figure 3). Because a local search is a time consuming operation, it is only applied to the best solution in the current iteration
.
The procedure of the local search can be expressed as follows.
Calculate the accumulated connectivity cost between each room that is assigned to department and the other rooms.
Select the number of rooms and all unallocated rooms to form an allocable room set .
Randomly swap two rooms , and calculate the new solution’s objective function value. Find the swap operation with the largest improvement value, execute this swap to obtain a new solution , and let .
3.3. Overall Procedure
The overall procedure can be explicitly described as follows.
Input: (1) Indoor connective map, which includes allocable rooms, building exits, room areas, and connectivity costs; (2) allocation demand data, such as department types and each department’s spatial area requirements; and (3) ACO parameters, such as population size , adjustment parameters of the pheromone and heuristic information , pheromone update constant and decay parameter , and the maximum iteration number .
Step 1: Initialize the data, such as the pheromone matrix and and the iteration number .
Step 2: Execute Steps 2.1–2.3 by each ant to construct solutions.
Step 2.0: Set ant counter .
Step 2.1: The ant in the first ant colony determines the departments’ allocating order. Execute steps 2.1.1–2.1.5.
Step 2.1.1: Set departments’ counter , departments’ allocating order .
Step 2.1.2: If , go to step 2.1.3, otherwise, go to step 2.2.
Step 2.1.3: Calculate the transition probability by Formula (7) according to pheromone matrix .
Step 2.1.3: Calculate the distribution of transition probabilities, .
Step 2.1.4: Generate a random number , select the value () as the allocating order of department , .
Step 2.1.5: , . Go to step 2.1.2.
Step 2.2: Based on the order obtained in Step 2.1, the ant in the second colony assign rooms to each department to obtain a solution. Execute steps 2.2.1–2.2.10.
Step 2.2.1: Set departments’ counter , the allocable rooms set , and the allocation solution as a zero matrix .
Step 2.2.2: If , go to step 2.2.3, otherwise, go to step 2.3.
Step 2.2.3: Determine the department that will be allocated in the current calculation, .
Step 2.2.4: Calculate the heuristic information according to
Section 3.2.1.
Step 2.2.5: Calculate the transition probability by Formula (8) according to the pheromone matrix and the heuristic information obtained in step 2.2.4.
Step 2.2.6: Calculate the distribution of transition probabilities, .
Step 2.2.7: Generate a random number , and select the value () as the room that was allocated to department , .
Step 2.2.8: Update the set of allocable rooms, .
Step 2.2.9: If , go to step 2.2.10, otherwise, go to step 2.2.4.
Step 2.2.10: . Go to step 2.2.2.
Step 2.3: Update the current-best solution.
Step 2.3.1: Calculate the objective function value according to Formulas (1)–(4).
Step 2.3.2: If , go to step 2.3.3, otherwise, go to step 2.4.
Step 2.3.3: Update the current-best objective function value , the current best allocating order of departments , and the current-best room allocation solution .
Step 2.4: , if , go to step 2.1, otherwise, go to step 3.
Step 3: Apply local search to the best solution in the current iteration to further improve the quality of the current-best solution.
Step 4: Update the best-so-far solution.
Step 4.1: If , go to step 4,2, otherwise, go to step 5.
Step 4.2: Update the best-so-far objective function value , the best-so-far allocating order of departments , and the best-so-far room allocation solution .
Step 5: Update the pheromone Matrix and by Formulas (9)–(11).
Step 6: Set g = g + 1. Evaluate the convergence. If , repeat steps 2–5; otherwise, stop.
Output: The best-so-far solution .