Advancing remote consultation through the integration of blockchain and ant colony algorithm

: To guide the more reasonable and fair allocation of medical resources, to solve the problem of fee prices negotiated by various subjects in the medical and health system and patient payment, and to solve the problem of how to ensure the privacy, accuracy, consistency and traceability of data in the process of collecting patient information in each hospital, according to the operation process of a remote consultation service, a decentralized remote intelligent consultation blockchain model is proposed. The model uses the improved ant colony algorithm under a smart contract and studies the practicality of the improved ant colony algorithm on the multi-node remote consultation service simulation platform. According to the experimental analysis results, the improved ant colony algorithm can automatically execute and effectively match the target population under the smart contract.


Introduction
Blockchain is a novel decentralized database technology that serves as the underlying technology of Bitcoin. It is characterized by non-changeability, complete record-keeping, universal maintenance and transparency to all users, making it a promising technology for various applications. Dwivedi et al. [1] have proposed a naive blockchain and watermarking-based social media framework to control the by the conclusions of this study in Section 7.

Related works
The application of blockchain in the intelligent medical technology field has been researched by scholars. Fan et al. [7] proposed an efficient and secure medical data sharing scheme based on medical blockchain and presented a trusted cloud medical data sharing example. Liu et al. [8] explored a privacy-protected sharing mode of electronic medical records. Zhang [9] proposed a blockchainbased electronic medical record-sharing model that leverages the distributed and tamper-proof properties of blockchain technology. The work of Griggs et al. [10] represents an attempt to integrate smart contracts with blockchain technology to achieve remote automatic monitoring of patients, thereby contributing to the reduction of electronic medical record costs. Similarly, Shae and Tsai [11] have designed a blockchain platform aimed at facilitating clinical trials and precision medicine, while also outlining the challenges encountered in utilizing blockchain technology. Meanwhile, Christidis and Devetsikiotis [12] have constructed a blockchain and smart contract model in the context of the IoT, which represents a novel approach to exploring the integration of blockchain and big data. Moosavi et al. [13] introduced the application of blockchain in supply chain management. Alshudukhi et al. [14] have introduced blockchain security managers, based on microservice technology, for federated cloud systems in an IoT environment. Liao et al. [15] proposed a novel remote medical service model by integrating remote real-time interactive functions with electronic medical records containing the patient's pertinent examination materials. Zhou et al. [16] analyzed the communication technologies used in telemedicine systems and restructured corresponding module functions in multimedia, providing an effective solution to enhance communication efficiency and bandwidth utilization. Moreover, Chen et al. [17] expounded on the potential benefits of telemedicine in enhancing medical and healthcare service capabilities. The preservation of patient data privacy, accuracy, consistency and traceability during the collection process is crucial to ensure efficient information exchange in telemedicine [5], which subsequently impacts the quality of remote consultation. To address this, Mao and Zhang [18] designed an intelligent remote medical system tailored for households and communities through the integration of IoT platforms, big data and cloud computing technologies. In the aspect of intelligent service transactions, Bachrach [19] proposed a framework based on deep compensation learning to find the maximum win-win situation for negotiating teams. In [20] and [21], different heuristic methods are also applied to automatic negotiation in various ways to find a win-win negotiation result.
Through the above research, it is found that there are few studies on the theoretical research and application results of applying blockchain to a remote consultation service model and the establishment of doctor-patient relationships between patients and experts. How blockchain technology provides a non-central service model in the field of telemedicine, how to establish a remote consultation service platform based on blockchain, and how to apply intelligent contracts and swarm intelligence algorithm in the process of establishing doctor-patient relationships still need to be solved urgently. To fill the aforementioned gaps, this paper proposes an improved ant colony algorithm for improving the doctorpatient relationships matching module in the remote intelligent consultation platform. In the matching mode of patients and experts, the traditional cumbersome online application management and consultation management are abandoned, and the improved ant colony algorithm is used to automatically match patients with experts.

Remote consultation and contract model
In the current era of swift progress in the service industry, the relative proportion of this sector in overall economic development is on the rise. As a result, the quality of medical services has emerged as a crucial element of competitive advantage for major hospitals. The advent of remote consultation services has facilitated multi-objective interaction by means of information sharing, thereby transcending the spatial constraints of medical services and enabling a larger segment of the population to avail themselves of top-notch medical care. In this section, we will introduce the traditional centralized model of remote consultation service and propose a conceptual model of smart contracts for remote consultation.

Traditional centralized model of remote consultation service
The remote consultation service center realizes the informatization of the remote consultation center system through modern information technology and IoT technology and puts forward the traditional model of remote consultation. However, the traditional model of remote consultation service is based on a centralized model, and there are some problems such as credit problems and lack of automation, intelligence and parallelism in transaction operation. The traditional model of remote consultation is shown in Figure 1. The conventional mode of remote consultation typically comprises four distinct stages: 1) Information processing-The remote consultation center disseminates the patient application information and expert database information. The platform allows patients and consultation experts to conduct bidirectional queries based on the information posted.
2) Consultation stage-The management center receives the consultation request and consultation data sent by the patient, preliminarily screens the eligible patients, synchronizes the information with the experts of the higher hospital and coordinates the consultation time. During the consensus period, experts consult patients remotely through multimedia to determine the treatment plan.
3) Payment stage-The final treatment plan is determined by the patient and attending doctor in conjunction with the treatment opinions of the consultation experts, and the patient receives treatment after paying the cost. 4) Service completion and feedback stage-The management center records the entire treatment process and data of the patients and classifies them to provide a reference for other similar cases.

Conceptual model of smart contract for remote consultation
Drawing on an analysis of the demand for remote intelligent consultation services, this study proposes a remote consultation service platform underpinned by a smart contract, wherein the functions of the remote consultation management center are decentralized, and the information processing and negotiation stage are incorporated into the smart contract. The conceptual model of remote consultation service smart contract is shown in Figure 2. The execution steps of the proposed model are as follows: 1) Participants in remote consultation formulate smart contracts according to relevant standards and requirements, including patients and doctors, both consultation experts in higher hospitals and attending doctors in lower hospitals.
2) The blockchain network receives the information generated after the execution of smart contracts and synchronizes the information to each block after the execution.
3) Upon completion of the consultation service process, the patient pays the fee as per the fee standard established by the contract. The remote consultation management center no longer serves as the coordination center in the entire process and only automatically records the logs of each link.

Encryption and verification algorithm for remote consultation service
In the context of remote intelligent consultation services, the blockchain network adopts an effective big data outlier detection algorithm based on distributed density for data encryption and digital signature to ensure the consistency, accuracy and non-repudiation of data transmission. The detailed steps involved are illustrated in Figure 3 [22].

Overview of smart contracts under blockchain
In contrast to traditional contract methods, modern smart contract technology can independently complete the transaction process without requiring the supervision or intervention of a third party. Once formulated, the smart contract cannot be revoked or modified and is automatically executed upon being placed into the blockchain. The immutability of the blockchain and the openness and transparency of the information facilitates multi-party transaction subjects to perform transactions without the need for a centralized trust mechanism. A smart contract is a digital form of computer protocol code that can run within a computer system and is triggered to execute automatically when specific conditions are met [23]. Its operating principle shown in Figure 4 can be summarized as follows: 1) Establishment of contracts: Multiple parties involved in the contract reach a mutual agreement based on their respective requirements, and the contract is digitized, expressed in computer code to convey its complete meaning and executed automatically based on the predetermined conditions. The involved parties sign the digital signature using their private keys to validate the contract.
2) Storage of contracts: The compiled electronic contract is transmitted to the blockchain, and each node of the blockchain synchronizes the contract information to verify the status of the contract and store it.
3) Implementation of the contract: Before the execution of the contract, the status of the predetermined trigger condition and the response rule is verified, and the transactions that meet the response condition are queued for verification. After the digital signature validation, the blockchain reaches a consensus, and the contract is executed.

Remote intelligent consultation transaction model under blockchain
Based on the conventional remote consultation service and in conjunction with the conceptual model of smart contracts for a remote consultation service, the integration of swarm intelligence algorithm and blockchain technology into the central link of the remote consultation service leads to the construction of a centerless intelligent trading platform. Consequently, a decentralized remote consultation service contract model under blockchain is proposed as shown in Figure 5. In the blockchain network, the public and private keys obtained by the superior and subordinate hospitals, remote consultation management centers and patients upon registration of accounts on the blockchain are employed for encryption and decryption, and the public key is utilized to address customers on the blockchain. The superior and subordinate hospitals as well as the remote consultation management center participate in the development of a contract. The multi-party contract is signed with the key to render the contract effective, thereby improving the contract's anti-interference capability during execution. The contract is compiled into a computer-recognized language and imported into the blockchain through a peer-to-peer network. Each block implements a consensus mechanism and stores the contract. Additionally, the patient customers and superior hospital experts are matched via the group intelligent algorithm integrated into the contract. All transaction processes are devoid of central institutions, and the parties involved in the transaction do not require mutual trust. The entire process is irreversible to ensure information consistency and transparency. The blockchain structure used for contract execution is as follows: In the data layer of the blockchain network, all blocks are encapsulated with their hash values, the hash value of the previous block and a consensus time record. The contract layer encapsulates each authenticated contract in a decentralized remote intelligent consultation model, which enables both parties to engage in flexible two-way selection and negotiate to formulate contracts. Preference value expresses the fit degree of time matching between patients and experts. In the context of remote consultation services, n represents the number of free times of patients, m represents the number of free times of experts in higher hospitals, I = {i|i = 1,2,..., n} represents the set of patients, J = {j|j = 1,2,..., m} represents the set of superior hospital experts, Sk = {(i,j)|i ∈ I, j ∈ J} represents a successful match between patients and experts, and S = {s1,s2,...,sk} represents the set of all successful matches between patients and experts. X = (x1,x2,...,xn) represents the idle time vector of each patient, Y = (y1,y2,...yn) represents the idle time vector of experts in the superior hospital, xi represents a certain idle time of the patient, yi represents the idle time of a certain expert, Xmin represents the minimum idle time of a certain patient, Xmax represents the maximum idle time of a certain patient, Ymin represents the minimum idle time of the expert, and the idle time format is yyyyy-mm-dd hh: mm: ss. wi and wj represent the weight values of the degree of mutual demand between patients and superior hospital experts, respectively. cij represents the number of patients matched with experts in a consultation, and Tij represents the time of consultation. A mathematical model is constructed based on these variables: The constraints of the proposed model are as follows: The preceding equations denote various aspects of the mathematical model, where Eq (1) and Eq (2) represent the time preference functions of the patient and the expert from the superior hospital, respectively. Equations (3) and (4) represent the satisfaction degree of the patient following the matching process with the expert from the superior hospital. Equation (5) denotes the overall preference value of the patient post-matching with the expert from the superior hospital. Equation (6) limits the value range of the weight values, wi and wj. Equations (7) and (8) indicate that the sum of the time weights of the patient and the expert from the superior hospital is equal to 1. Equation (9) stipulates the value range of the preference values, Ui and Uj.

Classical ant colony algorithm
Ant colony optimization (ACO) is a bionic stochastic search algorithm proposed to find an optimal path, based on the summary and analysis of the foraging behavior of ants in nature, with the characteristics of positive feedback, self-organization, parallel search, strong robustness and easy combination with other algorithms. In the process of searching for food, ants will always release a kind of pheromone on the path they pass through and can sense the pheromones released by other ants. As more ants pass through a certain path, the concentration of pheromone released by ants on the path will increase. In a unit of time, as more and more ants leave pheromones on shorter paths, and ants are more inclined to move to the path with the high pheromone concentration, the chance that later ants will choose that path increases, and eventually the colony will find the shortest path. The ant colony algorithm solves combinatorial optimization problems through search mechanism, updating mechanism and coordination mechanism.
1) Search mechanism Suppose there are n nodes and m ants, is the pheromone concentration between node i and node j at time t, and the initial pheromone concentration of each path is the same. The ant decides to visit the node according to the pheromone concentration, and the probability of ant k transferring from node i to node j is i j means the distance between nodes.
denotes the set of all superior hospital experts as the tabu list. α and β indicate the weight of pheromone concentration and heuristic information. The larger α and β are, the faster the algorithm converges, but the randomness of the search is weakened, and it is easy to fall into a local optimum.
2) Pheromone update Due to the positive feedback effect of the ant colony algorithm, after all ants complete a cycle, in order to prevent the pheromone content on the path from being too high, the pheromone concentration on the path needs to be updated. The pheromone concentration updating mechanism is as follows: where ρ represents the global volatilization factor of the pheromone, ρ ∈ (0,1). The greater ρ is, the stronger the positive feedback effect of pheromone and the faster the convergence speed, but the randomness of the algorithm search is weakened, and it is easy to fall into a local optimum.
( , ) k i j   represents the pheromone concentration released by the kth ant on the path between node i and node j. Q is the total pheromone released by ants in a cycle, and the size of Q has an influence on the convergence speed of the algorithm. The larger Q is, the stronger the positive feedback mechanism is and the faster the convergence speed of the algorithm is, but the randomness of the search is weakened, and it is easy to fall into a local optimum. k L is the path length of the kth ant.

Bacterial foraging ant colony optimization (BFACO)
In this paper, to solve the problem that the algorithm can easily fall into a local optimum, and the search speed is always slow, we improved the classical ACO algorithm.
1) Improvement of the search mechanism The heuristic information of the search mechanism is dynamically introduced to improve the efficiency of the ant colony algorithm in effectively matching patients and experts. A patient is selected randomly as the initial point for the search process aimed at identifying a suitable match. Supposing that ant k selects patient i as the starting point for its search, the heuristic information that impacts patients and experts is represented by a new η (i,j): zi and zj represent the satisfaction degree of the patient following the matching process with the expert from the superior hospital from Eqs (3) and (4).
2) Improvement of pheromone update Another pheromone increment is introduced into the pheromone updating formula of classical ant colony algorithm, which avoid the problem that ant colony algorithm falls into local optimization prematurely. The diffusion rate of pheromone is controlled by the coefficient of pheromone change, denoted as ρ, where ρ∈(0,1). The change values of pheromone released by ants k during the process of searching pairing on the successful pairing (i,j) are represented by ∆ τ (i,j). The number of current successful pairings is denoted as c, while C∈ [0,n] represents the pheromone left by a successful pairing (i,j), and ∆ τ* (i,j) is the pheromone increment introduced and decide by Eq (5). when a matching pheromone is too large, the next matching pheromone in the current position is fine-tuned, to avoid falling into local optimum. which changes according to the following formula:

3) Combination of improved ACO and bacterial foraging optimization (BFO)
In an ant colony algorithm, the search for the optimal value is achieved through pheromone feedback, resulting in strong parallel searchability and robustness. However, the convergence speed and the ability to search for the global optimal solution require improvement, as reported in [24]. BFO, on the other hand, is a bionic algorithm that emulates the behavior of E. coli parasites in the intestine, which search for food using chemotaxis, reproduction and elimination and dispersal of bacteria [25]. BFO aims to find the optimal solution using these principles.
To address the issues of slow convergence speed and the risk of falling into local optima inherent in the ant colony algorithm, this paper proposes a novel approach that combines the strengths of two distinct algorithms. Specifically, the reproduction and chemotaxis operations of the bacterial foraging algorithm are integrated into the basic ant colony algorithm to enhance its performance.
Integration of chemotaxis of bacteria-Let θi (j,r,l) denote the current location of bacterial individual i, where j represents the number of times that bacteria perform chemotaxis, r denotes the number of times that bacteria replicate, and l signifies the number of times that bacteria migrate. Moreover, C (i) represents the step size of each displacement of bacteria, while ∆ (i) indicates the direction of chemotaxis. The update of the location of bacteria i is governed by the following formula: Integration of bacterial reproduction.
In the above formula, J i health represents a robust function of bacteria, while J (i,j,r,l) represents the fitness of bacteria. Here, r denotes the number of reproductions performed by bacteria, l denotes the number of elimination and dispersals undertaken by bacteria, and j signifies the number of chemotaxis operations carried out by bacteria. NC indicates the number of chemotaxis operations performed by bacteria. Furthermore, the bacterial population is pruned by eliminating half of the individuals with low robustness, while the remaining half of the individuals undergo reproduction operations to ensure that the total number of individuals remains unchanged.
After the ant colony traverses all the nodes, each ant corresponds to a crawling trajectory, which is then mapped to the position of each bacterium. The robustness of the bacteria is inversely proportional to the sum of the trajectory length traversed by each ant. By discarding the ants with longer trajectories (corresponding to bacteria with lower robustness), the individuals with shorter trajectories are selected and replicated to expedite the convergence process.
The following steps describe the execution of the improved algorithm and pseudo-code is presented in Algorithm 1: Step 1 Initialize the pheromone value τ (i,j) to 0 and the iteration number NC to 0, and randomly distribute m ants on n nodes. The ants calculate the probability of matching node j with the starting point i based on Eq (10) and select the endpoint accordingly. The trajectory is recorded in the tabu list Jk (i), and the process is repeated until all initial nodes are traversed. An ant individual corresponds to a bacterial individual.
Step 2 By the proposed methodology, it is imperative to designate eligible patients and experts as Ski and Skj, respectively. Additionally, the path length of each ant is assigned a label of Lk, signifying the starting point of each bacterium.
Step 4 Subsequently, the bacterial chemotaxis action is carried out, and a comparison of the Lk value before and after the execution is conducted. If the Lk value decreases, the location is updated, and the resultant data is stored.
Step 5 The subsequent step involves computing the pheromone concentration remaining on the trajectory as per Eq (15) to Eq (16). Save the current matching initial node i and the endpoint j, and remove the matching node j in Jk (i). Subsequently, the cycle is resumed by returning to Step 2 until all nodes have been matched.
Step 6 In the final step of the proposed methodology, if the number of iterations does not exceed the predetermined upper limit, the process proceeds to Step 3. However, if the maximum limit is reached, the process is halted, and the best matching node is outputted.
The flowchart of the BFACO algorithm is presented in Figure 6. Calculate the heuristic information   Calculate the matching probability of ant k by Eq (10), select the end node j; 9: Add j to J k (i); 10: Calculate the path length L k from i to j; 11: END 12: Perform bacterial reproduction: Sort bacteria (ant) in descending order of L k , kill m/2 bacterial (ant) with Larger L k and reproduce bacterial (ant) with smaller L k . 13: Perform bacterial chemotaxis; 14: If the path length is improved 15: Update L k ; 16: Pheromone update by Eq (12), Eq (13), Eq (15) and Eq (16); 17: Update J k (i) using current matching node j; 18: END 19: NC+1; 20: END 21: Return J k (i) with the best matching node;

Process of smart contract algorithm for remote consultation based on improved ant colony algorithm
Based on the decentralized remote consultation contract model of blockchain and the swarm intelligence algorithm, this paper proposes a multi-party smart contract algorithm for remote consultation. The algorithm can be executed under the condition that patients and experts conform to the terms and obligations stipulated in the consultation service. Figure 7 illustrates the implementation process of the algorithm.
1) Information dissemination: The Management Center engages in the dissemination of information by publishing expert information that has been subjected to an audit on the remote consultation platform.
2) Consultation application: The proposed consultation application entails the submission of pertinent medical information by patients, which subsequently awaits platform review. To elaborate, patients will provide relevant health data via the application interface, after which the platform will conduct a thorough assessment of the submitted information.
3) Consultation matching: The process of consultation matching involves the utilization of an improved ant colony algorithm to match patients and experts who have passed the information audit on the platform. Specifically, the algorithm is applied to match the relevant medical expertise of the available experts with the specific health needs of the patients, based on the information provided by both parties. 4) Contract establishment: Upon the successful matching of a patient with an expert, a contract is automatically established. As part of this process, the patient is required to prepay the consultation fee to the designated contract address. Subsequently, the consultation expert is obliged to fulfill the contractual requirements by delivering the service as stipulated. Finally, the two parties are expected to utilize the digital signature key to ensure the authenticity and security of the transaction. 5) Implementation and preservation of the contract: The implementation and preservation of the contract entail the completion of consensus and testing of each block, which automatically triggers the execution of the contract. Upon completion of the consultation service, the cost of the service is cleared as per the terms of the contract.

Remote consultation management Center releases medical information Patients submit personal and relevant medical information
Agree to a consultation match?

Finish
Yes According to the matching information, the contract is generated, and the matching parties digitally sign The contract is stored in the blockchain for automatic execution

Experiments and analysis of improved ant colony algorithm
This paper aims to verify the performance and effectiveness of the BFACO through an optimization simulation that examines two aspects of the problem: the Traveling Salesman Problem (TSP) and function optimization.

Solution and result analysis of TSP
The TSP is a widely recognized and classical combinatorial optimization problem [26]. The problem involves determining the shortest path for a traveler who visits n cities and returns to the origin, subject to the condition that each city can only be visited once. The model of the TSP problem can be simply described: Given an undirected graph G = (V,E), in which each edge is e∈E, and there is a non-negative weight d(i,j) representing the distance between nodes, find the loop that traverses all nodes in the graph G and has the minimum total weight. In this study, to solve the discrete problem, the position P of each bacterial (ant) individual corresponds to a path sequence. Path coding is employed to encode the problem [27], that is, each bacterial (ant) individual represents a path sequence, the dimensions are consistent with the number of cities, and the numerical value of each dimension represents the city number of the position. Let N = {1,2,...,n} represent the set of all site numbers, and the code of each bacterial (ant) individual is a random arrangement of elements in set N, P = (p1,p2,... pn).
To evaluate the efficacy of the bacterial foraging ant colony algorithm in addressing the TSP, this study employed the TSPLIB standard library to simulate seven classical datasets (Eli51, Eli76, Rat99, Berlin52, St70, D657 and Nrw1379) using Matlab 2016b. The optimization outcomes obtained through Chaos Ant Colony Optimization (CACO) [28], Simulated Annealing Ant Colony Optimization (SAACO) [29] and Levy flight Ant Colony Optimization (Levy-ACO) [30] were compared and analyzed alongside those obtained through the ACO and BFACO.
During the testing phase, we established the maximum iteration number NCmax as 200, while setting the ant colony size m as 1.5n. The algorithm parameters were selected based on the guidance provided in [31]. Specifically, we set the pheromone importance factor α to 1, the heuristic function importance factor β to 5, the global pheromone evaporation factor ρ to 0.5 and the total pheromone release Q to 100. Pheromone importance factor, α 1 Heuristic function importance factor, β 5 Pheromone global volatilization factor, ρ 0.5 Total pheromone release, Q 100 1) Algorithm optimization ability The algorithm's optimization ability was evaluated based on two metrics: the test optimal value and the average value. To conduct this evaluation, we solved the TSP for seven classical datasets, including Eli51, Eli76, Berlin52, St70, Rat99, D657 and Nrw1379, using the ACO, CACO, SAACO, Levy-ACO and BFACO algorithms. This process was repeated for 20 consecutive runs. The optimal solution is known and was obtained from the TSPLIB standard database. Meanwhile, the test optimal solution is the shortest path length out of the 20 obtained solutions, while the average value is the average path length across all 20 solutions. The results are presented in Tables 2 and 3.
The results of the optimization simulation are presented in Tables 2 and 3, which demonstrate the algorithm's optimization ability in terms of test optimal value and average value. The tables show the outcomes of solving Eli51, Eli76, Berlin52, St70, Rat99, D657 and Nrw1379 with ACO, CACO, SAACO, Levy-ACO and BFACO over 20 consecutive runs. The known optimal value provided in the TSPLIB standard database serves as the benchmark for the optimal solution. The test optimal solution represents the shortest path length among 20 solutions, while the average value represents the average path length of the 20 solutions. Tables 2 and 3 reveal that under the same basic parameter settings, BFACO consistently outperforms ACO and the three improved ant colony algorithms in terms of optimal solution, worst solution and average value. For instance, in Eli51, BFACO yields a test optimal solution and average value that are 4.9 and 5.8 less than ACO, respectively. Similarly, in Eli76, BFACO produces a test optimal solution and average values that are 1.9 and 4.1 less than ACO, respectively. In Rat99, BFACO yields a test optimal solution and average value that are 8.687 and 15.4 less than ACO, respectively. For St70, BFACO achieves a test optimal solution and average value that are 10.4 and 16.7 less than ACO, respectively. For Berlin52, BFACO achieves a test optimal solution and average value that are 117.6 and 104.3 less than ACO, respectively. However, for large-scale problems such as D657 and Nrw1379, the gap between the test optimal solution and the known optimal solution is considerable. Specifically, in D657, the test optimal solution and average value obtained by BFACO are 1023.9 and 1114.5 less than ACO, respectively. In Nrw1379, BFACO yields a test optimal solution and average value that are 2019.5 and 2405.4 less than ACO, respectively. This finding suggests that the bacterial foraging ant colony algorithm exhibits a weaker optimization ability for large-scale problems.
In summary, the bacterial foraging ant colony algorithm surpasses ACO and three improved ant colony algorithms in terms of optimization ability, as evidenced by the better optimal solution, worst solution and average value. Additionally, the algorithm can escape local optima, making it more effective. However, for large-scale problems, the optimization performance of the bacterial foraging ant colony algorithm is relatively poor.  2) Algorithm reliability and convergence speed In terms of evaluating the reliability and convergence speed of the algorithm, success rate and mean convergence generations are used as indicators. The success rate represents the ratio of the number of times the algorithm reaches the critical value to the total number of runs based on a preset critical value. Tables 4 and 5 present the comparison results of the reliability and convergence rate obtained by ACO, CACO, SAACO, Levy-ACO and BFACO for 20 consecutive solutions to Eli51, Eli76, Rat99, Berlin52, St70, D657 and Nrw1379. As shown in Table 4, BFACO demonstrates superior reliability, with a 100% success rate for solving the seven test data sets. This performance is significantly better than that of ACO and also superior to those of CACO, SAACO and Levy-ACO. Moreover, as shown in Table 5, the mean convergence generations of the BFACO algorithm are smaller than those of ACO and also smaller than those of CACO, SAACO and Levy-ACO in terms of convergence rate. Therefore, it can be concluded that the bacterial foraging ant colony algorithm outperforms the basic ant colony algorithm, chaotic ant colony algorithm, simulated annealing ant colony algorithm and Levy flight ant colony algorithm in terms of reliability and convergence speed.

3) Algorithm stability
The stability of an algorithm is typically evaluated by its standard deviation, which measures the degree of variation of each solution. To assess the stability of ACO, CACO, SAACO, Levy-ACO and BFACO, Table 6 presents the standard deviation comparison results obtained from solving Eli51, Eli76, Rat99, Berlin52, St70, D657 and Nrw1379 after 20 consecutive runs. Table 6 presents the standard deviation comparison results calculated by ACO, CACO, SAACO, Levy-ACO and BFACO after 20 consecutive solutions to Eli51, Eli76, Rat99, Berlin52, St70, D657 and Nrw1379. The analysis reveals that the standard deviation of BFACO for solving the seven test data sets is smaller than that of ACO, and it is also superior to those of CACO, SAACO and Levy-ACO. These results demonstrate that the bacterial foraging ant colony algorithm exhibits superior stability compared to the basic ant colony algorithm, chaotic ant colony algorithm, simulated annealing ant colony algorithm and Levy flight ant colony algorithm.

Test and result analysis of function optimization problem
To evaluate the effectiveness of the bacterial foraging ant colony algorithm in solving function optimization problems, two commonly used test functions, the Rastrigin function and the Schaffer function, were selected and solved [32]. The expressions of these test functions are presented below. 2 2 1 10 cos (2 ) Equation (19) represents the Rastrigin function, where xi is bounded within the range of [−5.12,5.12]. Equation (20) represents the Schaffer function, where x1 and x2 are bounded within the range of [−10,10].
The algorithm parameters are configured as follows: NCmax, the maximum iteration number, is set to 100; m, the ant colony scale, is set to 100; α, the pheromone importance factor, is set to 1; β, the heuristic function importance factor, is set to 5; ρ, the global pheromone volatilization factor, is set to 0.5; and Q, the total pheromone release, is set to 100.
To optimize the Rastrigin function and Schaffer function, the basic ant colony algorithm and bacterial foraging ant colony algorithm were utilized for 20 iterations. The outcomes of these iterations are presented in Table 7.  Table 7, it is apparent that the optimal solution and average solution values obtained by the bacterial foraging ant colony algorithm for both the Rastrigin function and the Schaffer function are less than those obtained by the basic ant colony algorithm. Furthermore, the standard deviation computed by the bacterial foraging ant colony algorithm is smaller than that of the basic ant colony algorithm. These results indicate that the bacterial foraging ant colony algorithm exhibits better optimization ability and stability than the basic ant colony algorithm for function optimization problems. Figure 8 illustrates the comparison of optimization convergence between the basic ant colony algorithm and bacterial foraging ant colony algorithm for the Rastrigin function, while Figure 9 presents the optimization convergence comparison between the basic ant colony algorithm and the bacterial foraging ant colony algorithm for the Schaffer function.  Based on Figures 8 and 9, it is apparent that the Bacterial Foraging Ant Colony Algorithm exhibits superior optimization ability and convergence efficiency compared to the basic ant colony algorithm when addressing function optimization problems.

Application of improved ant colony algorithm
In this study, the feasibility of the enhanced ant colony algorithm is investigated using a multinode remote consultation service simulation platform. The Solidity programming language is employed to develop the computer protocol code, and the resulting smart contracts are tested on the Ethereum platform to assess their efficacy.
In the context of the Ethernet virtual machine, the value assigned to the number of ants Nm is 20, with a density parameter of ρ = 0.8 and an iterative upper limit of 200. Tables 9 and 10 present statistical information concerning 10 patients seeking remote consultation services (Y1,Y2,...,Y10) and 10 expert consultants affiliated with superior hospitals (X1,X2,...,X10). The relevant indicator information includes the blockchain-based addresses of patients and consultation experts in the higher hospital, the cost of consultation (Bp/eth), the duration of consultation (Bt/h) and the number of consultations (Bq/person). Bp and Bt are parameters of particular interest to patients, and their corresponding weights have been assigned as wi = (0.50,0.50). On the other hand, Bp, Bt and Bq are three indicators of concern to consultation experts, with respective weights of wj = (0.6,0.15,0.25). The simulation parameters table and the statistical results about the willingness of patients to be matched with consultation experts are presented in the following Table 8:   The utilization of the enhanced ant colony algorithm enabled matching on the virtual machine, yielding the results and overall preference values presented in Table 11. The data indicate a high level of satisfaction among both patients and experts upon completion of the matching process. Following this outcome, the algorithm initiates contract execution automatically. Through iterative tests on the simulation platform, the performances of the classical ant colony algorithm, improved ant colony algorithm, basic particle swarm optimization (PSO) [33] and parallel dynamic weigh niches artificial fish swarm (PDN-AFS) [34] algorithm are compared and analyzed, without altering the initial parameters.
Based on the comparison results presented in Figure 10, under the same parameters, the curve of the improved ant colony algorithm fluctuates smoothly with the increasing number of iterations, and it tends to be stable earlier than the other three algorithms. Therefore, the improved ant colony algorithm has better performance than the other three algorithms and is more stable.  Figure 11 shows the change curves of the global optimal mean of three objective functions, Eqs (3)-(5), under the comparative experiments of improved ant colony algorithm, classical ACO, PSO and PDN-AFS algorithm. As can be seen from Figure 11, the global optimal mean of the three objective functions of the improved ant colony algorithm has a decreasing trend compared with the calculation results of the classical ant colony algorithm. The classical ant colony algorithm and the PSO have unstable fluctuations compared with the improved ant colony algorithm in the process of finding the optimal solution from the change curve, and the iterative effect of the PDN-AFS algorithm in the early stage is not very ideal. Therefore, the improved ant colony algorithm obtains the better global optimal average value of three objective functions, and the iterative process is more stable, which can prove that the improved ant colony algorithm keeps finding effective global optimal solutions in the iterative process. Figure 11. Variation curves of the global optimal mean of the three objectives.
The smart contract algorithm introduced in this study was implemented in a peer-to-peer network, and the execution of contracts within a seven-day timeframe was analyzed. The results in Table 12 showed a contract scrap proportion of only 0.96% and a matching success rate of 99.02% in the contracts that were established. Furthermore, the efficiency of the service execution was substantially enhanced.

Conclusions
With the maturity of telemedicine service, more and more transactions will be carried out through the intelligent platform of network information. The integration of blockchain and artificial intelligence provides a new development direction for telemedicine services. In this paper, based on blockchain and swarm intelligence technology, an improved ACO algorithm based on bacterial foraging is used to combine the conditional attributes of the patient and the consultation experts in the superior hospital, so as to obtain a high degree of fit between the two parties and realize the automatic management of consultation services. According to the experimental results, the ACO algorithm based on bacterial foraging is effective in dealing with multi-objective matching problems.
However, the proposed model was limited by the fields of smart contracts and blockchain, and it is still in the initial stage of exploration. The performance and efficiency of the transaction matching algorithm can be further improved by integrating it with other heuristic algorithms. In addition, this paper only solves the common problems such as decentralization and intelligence of remote consultation, but in the distributed, dynamic and open big data environment with increasing transaction data of remote consultation, how to solve the problem of massive storage for blockchain is the focus of future research.

Use of AI tools declaration
The authors declare they have not used artificial intelligence (AI) tools in the creation of this article.