1 Introduction

Finding an optimal solution for an optimization problem is often a very challenging task [1], depending on the choice and the correct use of the correct algorithm. The choice of an algorithm may depend on the type of problem, the availability of algorithms, computational resources and time constraints. For large-scale, non-linear global optimization problems, there is often no agreed guideline for the choice of algorithm and, in many cases, there is no efficient algorithm. Several algorithms can be used to solve optimization problems. The conventional or classical algorithms are mostly deterministic.

Metaheuristics is another major field devoted to solving optimization problems. They are useful when finding the best solution is computationally very expensive. The key is to provide a way of finding a good-enough solution in a fixed amount of time. Metaheuristics, as the suffix says, are upper level heuristics. They are intelligent strategies to design or improve general heuristic procedures with high performance. In their original definition, metaheuristics are general purpose approximated optimization algorithms; they find a good solution for the problem in a reasonable time (not necessarily the optimal solution). They are iterative procedures that smartly guide a subordinate heuristic, combining different concepts to suitably explore and operate the search space.

Over time, these methods have also come to include any procedures that employ strategies for overcoming the trap of local optimality in complex solution spaces, especially those procedures that utilize one or more neighborhood structures as a mean for defining admissible transitions from one solution to another, or to transform solutions in a constructive process [2]. To get good solutions, any search algorithm must establish an adequate balance between two overlayed process characteristics:

Intensity is a mechanism that explores more throughly the portions of the search space that seem promising in order to make sure that the best solution in these areas is indeed found (space exploitation).

Diversity is a mechanism that forces the search into unexplored areas of the search space (space exploration). This balance is needed to quickly identify regions with good quality solutions and do not waste time in promising or visited regions. The metaheuristics are categorized in: Constructive heuristics: they start from an empty solution and continue adding components until a solution is built. (i.e.: GRASP [3], Ant Colony Optimization [4] and Intelligent Water Drops [5]). Trajectory methods: they start from an initial solution and then, iteratively, try to replace it with a better one from their neighborhood. (i.e.: Local Search [6], Tabu Search [7], Simulated Annealing [8]). Population-based methods: they iteratively evolve a population of solutions (i.e.: Genetic Algorithms [9, 10], Particle Swarm [11]).

Metaheuristic optimization algorithms are often inspired from nature. According to the source of inspiration of the metaheuristic algorithms they can be classified into different categories. The main category is the biology-inspired algorithms which generally use biological evolution and/or collective behavior of animals. Science is another source of inspiration for the metaheuristics.

These algorithms are usually inspired physic and chemistry. Moreover, art-inspired algorithms [12] have been successful for the global optimization. They generally inspired from artists behavior to create artistic stuffs (such as musicians and architectures). Socially inspired algorithms can be defined as another source of inspiration and the algorithm simulate the social trying to extract the “swarm intelligence”. In this paper, we use a social media inspired optimization algorithm: Twitter Optimization (TO) originally developed by Lv et al. on [13]. TO is able to solve combinatorial optimization problems by imitating human’s social actions on Twitter: following, tweeting and retweeting.

As the most intelligent biological system, human society is considered very worthy of investigation. By observing the daily routine of humans, we surprisingly discovered that we ourselves, as individuals in human society, were actually performing some unconscious optimization tasks on the Internet, or more specifically on Twitter. This is because when we use Twitter, we tend to publish the Tweet (a term similar to Twitter) that is considered more valuable. For example, if someone receives two Tweets, separately on the local climate and the presidential elections, he would be more willing to share this last message on Twitter because it is worth mentioning. Similar filtering behavior occurs in all Twitter users. Everyone receives the Tweets filtered by others and publishes the Tweets filtered by himself.

Tweets that can be widely disseminated among users have been filtered millions of times and would be considered the most valuable Tweets at that time. This explains why Twitter users can always catch up with the access point. Inspired by this phenomenon, the algorithm called Twitter Optimization (TO) was created.

To create an effective algorithm for the phenomenon mentioned above, TO introduces three metaphors on Twitter. First, each Tweet is considered as a solution vector x composed of D real value parameters. And to minimize the optimization mission of the objective function F, the smaller the value F(x), the more valuable the Tweet will be. Secondly, when a person publishes a Tweet, he will send the content to all his followers (a Twitter term represents a unidirectional relationship). This means that he produces a solution and shares it with the specific crowd connected to him.

Finally, each person must retweet (a Twitter term means to republish) the most valuable Tweet of the people who followed, implying that it is helping the best solution to spread more. The realization of the three metaphors makes TO look for the global optimum.

2 Social Media Optimization

The inspiration of this metaheuristic is taken from the interaction of people in social media, more specifically the behavior of people on Twitter. In order to define the behavior of the algorithm, it is imperative to detail the central elements that configure it. To do this, in the next section will delve into the formal definition of each of this elements.

Objective Function. Mathematical expression representing the problem to solve. In this case we apply the TO to solve the SCP.

Fitness. Represent the value of a solution or in this case a Tweet, evaluated in the objective function (F(x)). For example, if we are working with a minimization problem and evaluate two solution vectors: \(F(x_1)\) and \(F(x_2)\) with the objective function, you get the values 100 and 200 respectively, you could say that the vector \(x_1\) is better, because it has a lower value than \(x_2\).

Tweet. A tweet in case of this metaheuristic, corresponds to a feasible solution of the search space. A tweet represent vector of n columns. In binary case, possible values are 0 and 1 in each columns. Formally we define a new tweet as: \(x_{new}=\{x_1,x_2,\dots ,x_n\}, \forall i \in \{1,2,\dots ,n\} \ and \ x_i \in \{0,1\}\). Some metaheuristics work with binarization functions for the generation of solution vectors as shown in [14], however in TO, the formulas are presented in a general way but the decision variables (\(x_i\)), just can take the values \(\{1,0\}\).

Following. This behavior mimics human relations given in the context of tweeter. Initially the algorithm generates a direct graph between each of the people or tweeter users. Each user is allowed to follow only F users. Then, in each round, each user will update or optimize the following set through the operations of follow or unfollow. He will select the tweet with the best fitness received in this round and will follow his original author, if he does not follow it already. After this operation has been carried out correctly, the user who has the tweet with the worst fitness must be eliminated in such a way that F is preserved. The presented method makes the direct graph adjust as each round passes. This methodology ensures that p will be following the users that generate the best tweets, that is, the solutions closest to the global optimum.

Initialization of Algorithm. The process of tweeting involves generating a new solution and sharing it with the followers. During the initiation of the search algorithm, each user issues a tweet. The formal procedure is described in Eq. (1):

$$\begin{aligned} x^{k}_{i}=min_i + (max_i - min_i)*rand() \end{aligned}$$
(1)

where \(x^{k}\) is the current solution of user k and \(x^{k}_{i}\) is the value of \(x^{k}\) in i-th dimension. \(min_i\) and \(max_i\) represent lower and upper value of solution value in i-th dimension.

The random retweet consists of the initialization process where a person k randomly selects a person p from \( following_k \) and proceeds to retweet the p solution. Formally we can say \(y^{k}_{i}=x^{p}_{i}\), where \( y ^ k \) is the solution that the user k will share and \( x ^ p \) is the current solution found by the user p.

Tweeting and Retweeting. The process of retweeting corresponds to the imitation of the process of sharing with followers, content that the user recognizes as valuable. This behavior ensures that a good solution is shared by as many users as possible. The TO algorithm adds two disturbance operators which are discussed below. When the user k decides to retweet the user’s Tweet p, the user k randomly selects one of the following operations:

Comments:

$$\begin{aligned} {x^{p}_{i}}_{new} = x^{p}_{i} + {Character}^{k}*rand(-1,1) \end{aligned}$$
(2)

Participation:

$$\begin{aligned} {x^{p}_{i}}_{new} = x^{k}_{i} \end{aligned}$$
(3)

When user decides to comments the Eq. (2) is calculated, for each dimension i, there is the possibility that the new solution is better than the current one, given that case, the new solution should replace the current one.

When a user decides to participate, he will contribute his own share to the activity. Given the above, Eq. (3) is used to simulate this behavior.

Publishing New Tweet. This specific operation consists of discarding a current solution to generate a new one. Additionally, users called celebrity are chosen in each round if they are ranked within the best 1% of all users and classified as averageman otherwise.

For the celebrity a new behavior is introduced which takes into consideration if its solution has not been updated during the last W times, given this case generates a new solution. Where W corresponds to the number of followers of k in the current round.

The behavior for averagemen in each round, will consist in generating a new Tweet according to the Eq. (4). The celebrity will choose the Tweet with better fitness and will own it.

$$\begin{aligned} x^{k}_{i} = {x}_{{new}_{i}} + \delta * rand(-1,1) \end{aligned}$$
(4)

where \( x_ {new} \) is the best solution found so far, \(\delta \) is the scan radius. The Eq. (4) is able to generate solutions near the best available solution. TO will stop when the number of iterations is greater than the upper limit N.

Hottest Tweet. The Hottest tweet or global optimum is defined as a solution \(s^* \in S\) and it has a better fitness than all solutions of the search space, i.e., \(\forall s \in S, f(s^*) \le f(s)\).

A complete flow chart of the TO algorithm can be reviewed in the Fig. 1.

Fig. 1.
figure 1

Social media optimization workflow.

3 Set Covering Problem

SCP Formulation. The SCP is a well-known mathematical problem, which tries to cover a set of needs at the lowest possible cost. The SCP was included in the list of 21 \(\mathcal {N} \mathcal {P}\)-complet problems of Karp [15]. There are many practical uses for this problem, such as: airline crew scheduling [16, 17], location of emergency facilities [18], vehicle routing [19], network attack or defense [20], traffic assignment in satellite communication systems [21], the calculation of bounds in integer programs [22], assembly line balancing [23], political districting [24], among others. The SCP can be formulated as follows:

$$\begin{aligned} \text {Minimize} \quad Z = \sum _{j = 1}^{n} c_j x_j \end{aligned}$$
(5)

Subject to:

$$\begin{aligned} \sum _{j = 1}^{n} a_{ij} x_j \ge 1 \quad \forall i \in I \end{aligned}$$
(6)
$$\begin{aligned} x_j \in \{0,1\} \quad \forall j \in J \end{aligned}$$
(7)

Let \(A = (a_{ij})\) be a \(m \times n\) 0-1 matrix with \(I = \{ 1,\dots , m\}\) and \(J = \{ 1,\dots , n\}\) be the row and column sets respectively. We say that column j can be cover a row i if \(a_{ij} = 1\). Where \(c_j\) is a nonnegative value that represents the cost of selecting the column j and \(x_j\) is a decision variable, it can be 1 if column j is selected or 0 otherwise. The objective is to find a minimum cost subset \(S \subseteq J\), such that each row \(i \in I\) is covered by at least one column \(j \in S\).

Table 1. Solutions of SCP4.1 through T.O.

4 Experiments

In order to test the correct execution of the T.O. metaheuristics, 30 independent executions were made of each instance of the benchmark. The metaheuristic T.O. measured its effectiveness against the instances of the library or benchmark OR (Beasley, 1990). T.O. was programmed in language Python 3.6, making use of the libraries Numpy and Scipy. GIT was used as source code repository. As a persistence, text files and in memory Data Base were used and as processing, a virtual machine with a 2.0 GHz (64 bit) dual-core CPU, 12 GB of RAM, 80 GB of Hard Disk and Ubuntu 18.04 as operating system. In the table presented in this section, the RPD column reports the relative percentage deviation between the lowest experimentally obtained value (best fitness) and the global optimum for that instance (s *). The RPD is calculated by Eq. (8).

$$\begin{aligned} RPD = 100\frac{(Min - Optimum)}{Optimum} \end{aligned}$$
(8)

As we can see in Table 1, the values of RPD are maintained between 1% and 19% for all evaluated instances. The instance with the best result was SCP4.1, obtaining an RPD of 1.10%, with a minimum value of 461. The worst result was obtained in the instance SCP4.2, where the value of the RPD was 19.34%. The regular behavior of the algorithm without changes in its parameters was around 6%. In terms of RPD evaluation, the algorithm behaved consistently in all evaluated instances.

Fig. 2.
figure 2

Convergence to optimum, instance SCP41.

Table 2. Comparison of algorithms for SCP resolution

If we look at Fig. 2, a fast convergence of the algorithm towards the global optimum is verified, achieving an asymptotic behavior to y axis, managing to escape from local optima successfully. The behavior of the algorithm before the benchmark has demonstrated its functionality and effectiveness.

Additionally, a comparison of the results obtained when solving the SCP was made, with two known algorithms. Specifically, TO is compared with Harmony Search (HS) in the work done by Salas et al. in [25] and with Black Hole in the work done in [26]. As can be seen in Table 2, the TO algorithm was superior in 9/10 instances, achieving an outstanding result.

5 Conclusion

Basically the social capacity to relate between people, allows us to be able to imitate their behavior to obtain relevant topics in their interaction. As indicated in the introduction to this paper, people are more willing to share information they consider valuable or important, rather than of little value. This very natural behavior allows to be applied in algorithms that behave in a good way in the resolution of problems like the SCP.

Our experiment results show good results solving SCP benchmark functions. Some improvements can be implemented taking ideas from other metaheuristic techniques, that introduce certain operators that better aspects such as exploitation and exploration. This is considered as future work. Finally It can be concluded that TO has a potential in solving optimization problems.