Optimized fuzzy logic by Genetic algorithm for identifying the situation of social network users

Today, mobile social networks and smartphones are highly developed and widely used. Owing to the transfer of vast amounts of data, information, and communication between users, such networks have addressed privacy as a fundamental issue. Recently, there has been a growing interest in identifying the privacy requirements of each user to act independently and dynamically according to the situations and conditions. This paper seeks to meet the privacy requirements of users by identifying their situation. For this purpose, we define a number of significant parameters in compliance with the conditions of users. Also, after inferring the current exact situation of the user, the fuzzy logic is automatically utilized to specify the privacy settings based on the conditions. To increase the accuracy in the identification of user situation, this method employs the genetic algorithm for selecting the coefficients of optimal input parameters in the fuzzy system. In this way, the fuzzy system is able to make a more accurate identification of the user situation. Compared to a similar method, the proposed method shows a better accuracy in identifying the user situation and, as a result, better performance in correctly setting the privacy.


Introduction
Online social networks (OSNs) encompass various forms of interactive communication, including the microblogging services, multimedia sharing, business networks, etc. They allow users to create profiles, communicate with friends, and share daily activities and thoughts [1]. With the development of the internet and the extensive use of mobile devices, mobile social networks (MSNs) have taken a vital part in our daily lives [2]. However, the increased connectivity level through the smart mobile devices and interaction with social networks has increased the risk of privacy violation [3][4][5]. Privacy concerns negatively affect the users' interests in the participation in social networks [6]. Social networks enable users to share places, share location-based contents, track friends, share photos, and much more. When utilized by users, these services cause the disclosure of locations on social networks. Similar to sensitive information, the information regarding the user location should enable the access management and control [7,8].
* Correspondence: msafi@ce.sharif.edu 2 Faculty of Science and Engineering, I.C.K.I, Sharif University of Technology (SUT), Iran. Full list of author information is available at the end of the article Therefore, they allow users to share their interests and activities with others [9]. Any social network can be considered a great source of personal information. Naturally, the contents posted on mobile social networks are mainly related to the daily activities of users, events, and social interactions. This content combines with the context information such as the current place and time of the posts, revealing some information about the users' daily activities, habits and functions, and many aspects of their personal lives [10][11][12]. Social concerns involve the access to private information by others, such as family members, friends, and colleagues [13][14][15]. Users should have sufficient knowledge of their privacy and be fully aware of the risks of sharing their information on the internet. Therefore, they should be able to protect sensitive information from the relatives and neighbors [16].
In mobile social networks, users may not be willing or able to manually configure the privacy settings for any situation or context before the posting. Therefore, it is necessary to analyse the current situation of users and type of content they post and to select the appropriate privacy settings. Users are also unaware of which personal information is covertly collected and shared on social media [17]. Therefore, there is a vital necessity to dynamically set the user privacy. This means that it is difficult to manually manage the privacy and that the user needs vary according to each situation. Situation refers to "user activity (or simultaneous activities) performed in a specific location for a certain period of time" [18]. The awareness of the situation is a particular type of awareness of the context [19]. Situation is considered a set of context data that are rationally collected [20]. Fuzzy logic [21] is a technique that makes fuzzy decisions using the input parameters. The linguistic variables have some values that are linguistic rather than numerical [22]. They can represent inaccurate and qualitative human knowledge and are used to label fuzzy sets [23,24]. In this paper, we infer the location of user by fuzzy logic using a number of factors; a system that is based on fuzzy logic and adopts the if-then rule to infer the location [25,26]. Then, to achieve an accurate and optimal solution, we combine fuzzy logic and genetic algorithm. Genetic algorithms [27] fall into the group of random optimization algorithms and rely on the evolutionary ideas of natural selection and genetic processes [28,29]. This paper continues as follows. Section 2 includes the review of previous works. In Section 3, we describe the method proposed in this paper. Section 4 deals with the final result of the proposed work.

Methods/experimental
In this paper, we study the privacy requirements of each users in MSN and identifying their situation with fuzzy-genetic algorithm. We define a number of significant parameters in compliance with the conditions of users and inferring the current exact situation of the user, by fuzzy logic then this method employs the genetic algorithm to of optimal input parameters in the fuzzy system.
The problem model was implemented in a computer with Intel (R) Core (TM) i5-4210U CPU @ 1.70GHz 2.40 GHz, RAM 8.00 GB in the MATLAB R2017b programming software.

Related work
Considering the user privacy on social networks, Soares Teles et al. [17] concluded that user privacy is a dynamic context-dependent requirement and that each context information is related to deciding the willingness of users to share content on social networks. Based on the findings, they proposed the Selpri method using the fuzzy logic. It applies the privacy settings independently and dynamically to the posts on social networks according to the current situation of user. Also, according to each situation obtained based on fuzzy logic, it automatically determines the privacy settings relevant to the situation.
Imran-Daud et al. [30] provided a dynamic, transparent, and private control mechanism for the text messages posted on online social networks. The semantic analysis of the posted messages defines the concept of privacy, which is used to assess the degree of sensitivity of the content. For this purpose, the proposed system automatically used the semantic annotation mechanism to link the meaning to the information to be published using the databases and linguistic tools. As a result, their proposal, which can be available on social networks, allows the automatic, integrated content protection for the userpublished data and meets the privacy requirements and type of readers that have access to the data.
To help online social network users, Squicciarini et al. [31] proposed a technique to group the contacts within the social circle. Hence, they used the social circle to optimize the privacy setting process for the users who add new contacts or upload new data. One goal is to reduce the users' responsibility for managing social connections and automatically group user contacts into the social groups with shared features.
Hu et al. [32] proposed a method for protecting the data shared among multiple users on online social networks. This model creates the participatory management of access control. The model provided with manual control is employed by the user to perform various analysis tasks.
Shehab et al. [33] provided an access control structure for managing a third-party application. This framework relies on the user's access to a specific feature of the data shared with the application. They modeled the application as a finite-state mechanism and utilized the user profile feature as a condition for running the program.
Tschersich et al. [34] conducted a study on users and identified the privacy requirements of mobile social networks. They then developed a framework called PICOS, which involves the conditions such as resources to prevent access to the user's location and protect private websites. Fang and LeFevre [35] proposed a framework for the design of a social media privacy wizard. This design is obtained based on the viewpoints of real users who perceived the privacy settings (which friend can see which information) and based on a set of implicit rules. Thus, a machine learning model is usually developed with a limited number of users as input. This model briefly describes the preferences of specific users and then automatically configures the users' privacy settings. Toch et al. [36] developed a mobile social networking application called Locaccino. It is a location sharing software so that users could effectively control their privacy. The purpose of developing this software is to find friends and colleagues and set the confidential privacy policies for sharing the location. It allows the user to share location information with the contacts.
Sadeh et al. [37] developed the Peoplefinder application, enabling mobile and laptop users to share their location with others (such as friends, family, and colleagues). The primary purpose of this application is to well understand the people's attitudes and behaviors towards privacy.

Proposed method
The primary purpose of this paper is to identify the user situation using the fuzzy logic and to optimize the coefficients of fuzzy input functions using the genetic optimization algorithm. In this method, according to the extracted situation, the privacy settings are applied automatically, which will lead to the enhancement and protection of users' privacy.
In this paper, we define four types of input parameters as the factors affecting the privacy requirements of users. This will cause the situation of users to be identified. Then, the input parameters are implemented in MATLAB software to perform the situation analysis. These parameters are listed below: S={L, Ttime, Tweek, Cv} L denotes the current location of user (where). T is the time represented by Tweek, day of the week, and Ttime, time of the day (when). Also, Cv shows the content view. These parameters show the daily life situation of users. In this method, the situation of users will be identified using the definitions and fuzzy inference system.

Identification of situation
According to the needs of users, the influential factors for identifying the situation are defined as follows:   • If the user's location is close to home, it is weekend, the time of day is not dawn, and the content view is medium, then the user's situation is leisure time.
• If the user's location is away from home, it is one of the days of week from Monday to Friday, the time of day is afternoon, and the content view is medium, then the user's situation is at work.
• If the user's location is away from home, it is weekend, and the content view is very high, then the user's situation is on holiday.
The situation inference is made considering the context information and using the defined fuzzy rules as follows.
The defined points that are related to the location in a fuzzy set are the spatial information recorded by the user using the geographic coordinates. The user's location is expressed in a set with three states as follows: {user's location on the map, close to the selected location, away from the selected location}. The points recorded for each of the three states above are: 1) The desired location of user in the set is less than 100 km and up to 300 km, 2) The user is close to the selected location in the range of 799 km to 1200 km, and 3) A set from 800 km to more than 1200 km is defined away from the selected location.
The presented values of time include two series of time sets (time of week and time of day), and the fuzzy set intended for these two sets is defined as follows. The time of week is considered as a circle from 0 to 7 where each number represents one day of the week, and the time of day is defined from 00:00 to 24:00. For the Saturday and Sunday, we considered two sets: Weekend 1 and Weekend 2.
The content view defined in the fuzzy set in two states of zero to one includes the following five different states: {very low, low, medium, high, and very high}.
Users can express 120 rules of different situations using a fuzzy set of context information as follows: 3 (three states from different locations) × 4 (four states of time of day) × 2 (days of week, weekend) × 5 (five different states of content view) = 120.

Example of situation inference
An example of the defined rules is illustrated in this section: • If (location is different place) and (day of week is Monday to Friday), then (situation is holiday). The above rule can be inferred as follows: Location: The user records a point on a map and sets the linguistic variable to "place away from the recorded point". The inference is made as follows: 1) It checks the current location of user; 2) It checks the coordinates recorded in this situation; and 3) It then calculates the Euclidean distance between the points to determine the amount of input for the context information.
• Time: The user selects one of the days of week from the section of the week days, and the inference machine acts as follows: 1) Check the current time from the mobile clock, 2) Transfer the data to the conventional information used in the fuzzy sets in case of the converted time, and 3) Input values for the context information. The result of analyzing the location and time is that the inferred situation of the user is on holiday.

Fuzzy model optimization using genetic algorithm
Here, optimization means choosing the best and discarding the rest. In the following, the genetic algorithm is employed to optimize the coefficients of fuzzy functions in order to improve the performance. The genetic-fuzzy algorithm is implemented according to the following steps: i. The first step involves defining the problem where the number of decision variables and the interval for changing the variables are defined.
ii. In the second step, the initial population consisting of 200 chromosomes is generated.
iii. The third step involves calculating the value of the fitness function for each chromosome according to Equation (1): (1) To change the chromosomes, as seen in Equation (1), Cost is considered the initial cost in this section, with the initial value defined as 1000, and i here is the input data, which is subtracted from the input data to the power 2.
iv. The fourth step is the random selection of chromosomes using the roulette wheel method. In this method, the roulette wheel selects the number of good chromosomes with the best fit among the chromosomes in each population to create a new generation and passed on to the next generation. Also, the roulette wheel discards the chromosomes that have the worst fit.
v. Crossover operator: It applies by pc probability. A single-point crossover is utilized in this step. It is defined according to Equations (2) and (3): pc=0.9; % Crossover Percentage (2) nc=2*round (pc*nPop/2); % Number of Offspring (also Parents) vi. Mutation operator: This operator is applied by pm probability to each gene. This operator randomly selects a gene from a chromosome and then modifies the content of the gene according to Equations (4) and (5).
pm=0.3; % Mutation Percentage (4) nm=round(pm*nPop); % Number of Mutants (5) vii. This final step checks the termination condition. If there is no significant change after generating several consecutive generations by changing the mutation probability, go to the final step and introduce the generated chromosomes into the fuzzy system, resulting in an optimal model. Otherwise, return to step iii and perform the initial steps from the beginning.
The following relation shows the accuracy of the work: Accuracy=(1-Cost)*100 (6) As shown in Fig. 3, the flowchart is a combined genetic-fuzzy method that briefly shows all the steps above.

Results and discussion
In this section, we evaluate the performance of our scheme via extensive experiments. We give the detailed experimental results and discussion.

Experimental settings
To evaluate the proposed model and genetic optimization algorithm and to assess the efficiency and accuracy, the problem model was implemented in a computer with Intel (R) Core (TM) i5-4210U CPU @ 1.70GHz 2.40 GHz, RAM 8.00 GB in the MATLAB R2017b programming software.
We used the MATLAB software to optimization this model to generate the simulation. Optimized genetic-fuzzy method has been compare with with the Selpri[17] method.

Implementation of genetic optimization algorithm
The following table shows the number of parameters used in the genetic evolutionary algorithm.

Parameter Value
Population size 200 Crossover 0.9 Mutation 0.3 Maximum number of iterations 200 Table. 1 Parameters of Genetic algorithm Fig. 4 shows the change of the objective function relative to the number of iterations based on the genetic optimization algorithm. As can be seen, Fig.  4 shows the best cost per 100 iterations for each input, and as the number of iterations increases, the cost follows a decreasing trend until reaching a fixed value.  As can be seen, Fig. 6 shows the degree of accuracy of the work, which considers the best accuracy for each input per 100 iterations according to the previously described equation.    8 shows the surface diagram, which is seen in linear form, related to the optimized fuzzy input parameters obtained using the genetic-fuzzy algorithm, and the results of the optimization are shown in the output. As can be seen in Figure 8.a, the closer we get to the farthest points, the more negative the situation, which indicates that it is away from home.    The proposed method tried to change the results by changing the input parameters and defining new rules and more outputs than similar methods. Then, the proposed method improved using the optimization, increasing the accuracy and reducing the error percentage. Table. 2 compares the proposed optimized genetic-fuzzy method with the Selpri method, which shows how performance improves. The accuracy ratio of genetic-fuzzy method was 99.9880 compared to the Selpri method equal to 94.6.

Conclusions
The increasing use of social networks and the entry of personal information into social networks further highlight the need for protecting the privacy of people on such networks. In this paper, considering the needs of social network users, a mechanism was provided to identify the user situation, which allows the application of privacy settings in an automatic manner. For this purpose, we first recognized the privacy requirements of users in online social networks and then identified the factors affecting the needs. These factors were utilized as the input parameters of fuzzy functions. Optimizing the coefficients of fuzzy functions using the geneticfuzzy algorithm enabled identifying the user's situation with high accuracy. As such, the accuracy of the work increased to about 99.9880, outperforming the previously proposed methods.      Shows the degree of accuracy of the work, which considers the best accuracy for each input per 100 iterations.  Shows the surface diagram, which is seen in linear form, related to the optimized fuzzy input parameters obtained using the genetic-fuzzy algorithm. Fig. 9 Three-dimensional diagram of location versus input and output parameters in optimized state. Shows the three-dimensional diagram of the location surface versus days of week, time of day, content view, and situation in the optimized state.   To show how this parameter affected on the result after optimization.