Abstract
This paper introduces a new high-level domain-specific modelling language, LAnt, for the design of ant colony optimization algorithms. This language is used to represent the main elements required to define the structure of the algorithms and to capture the specific constraints associated to the problem to solve. It aims to support users with low experience in the development of solutions based on this paradigm. The proposal has been implemented as an Eclipse plug-in, including an editor and an integrated code generator.
Keywords
Introduction
Swarm intelligence [5] helps to solve problems by means of techniques inspired in the collective behaviour of many individuals that interact among them and with the environment without any individual controlling the group. “A collective decision capability that is as least good as or better that a single decision” [22]. In some cases, the natural selection has combined thousands of individual brains to conform higher entities. This is the case of species which live in colonies, flocks, schools or crows that denotes collectively intelligent behaviour when finding paths for food or fighting off predators. This natural behaviour has been applied in computer science to design computational techniques inspired in these collective environments. Many of them, such as Bee Colony [23], Particle Swarm [24], Grey Wolf [28] or Black hole Optimization [20] are devoted to solve optimization problems. It is specially relevant the case of Ant colony optimization (ACO) that has been the basis for the development of solutions for different engineering problems, such as scheduling [29], constraint satisfaction [35] or graph coloring [9]. Besides, this technique has been used in other computational research fields. This is the case of the machine learning [11], pattern recognition [8] or data mining [30]. Furthermore, ACO paradigm has significant presence in other orthogonal disciplines such as sociology [7], cognitive science [31], biology [34] and economy [40]. The development of these solutions, in most cases, comprises thousand of code lines. The more is the length of the solution, the more is the probability of occurrence a software failure. It is well known that the 50% of a project budget is spent on finding bugs. Therefore, it is important to include mechanisms in early stages of the software development cycle that allow to detect and reduce possible errors. The use of formal methods aids to increment the software robustness and software developed using them is usually free of errors. Several formal methodologies even generate executable code. However, it requires a deep mathematical background and makes developers reluctant to apply them. Model Driven Engineering (MDE) [25] technologies help to alleviate this problem, helping developers to model complex systems from a high level of abstraction. It reduces the appearance of failures as well as increases the productivity of the programmers. Moreover, the use of high level models aids to perform model analysis and apply verification techniques. MDE requires both the definition of domain specific languages (DSL) that capture the structure, behaviour, and requirements of a particular domain and transformations that (partially) automates the mappings between models.
In this paper we propose a model driven methodology to design ant colony optimization algorithms. First, we propose LAnt, a textual DSL aiming to provide an expressive syntaxis for the design of ACO algorithms. Second, we have implemented a model transformation to generate Java code from the design expressed using LAnt.
The rest of the paper is structured as follows. Section 2 presents a brief overview of the ACO algorithms. Next, Section 3 introduces the main concepts and definitions of MDE and DSLs. Section 4 describes in detail the proposed DSL to model ACO. Finally, in Section 5 we present the conclusions and some lines of future work.
Ant colony optimization
Swarm intelligence studies the collective behaviour of unsophisticated entities which interact among them through a shared environment. It is inspired by animal societies, in which each individual has only limited capabilities but the interaction among them can reproduce a complex global behaviour. Among the different systems applied by swarm intelligence we can find ant colonies. Ants deposit a chemical substances, known as pheromones, while moving between the nest and the food. Initially, each ant colony member moves randomly through the environment trying to find a food source. When an individual finds food, it returns to the nest depositing small amounts of trial pheromones. Usually, the individual uses the same path several times, to increase the the pheromone signals. In this way, other members of the colony will detect the chemical signals which increases probability of path being followed. Figure 1 illustrates ants behaviour.
Beckers et al. [1] performed an experiment that showed that a colony of ants has a high probability to choose the shortest path between the nest and food source. This behaviour has been modelled by the scientific community in order to exploit its simplicity for applying it to the resolution of different problems. The ACO algorithms are based on this phenomenon. These algorithms are used to solve minimum cost problems on graphs.
Dorigo and Stützle [16] give a formal characterization of a model to represent combinatorial optimization problems, in order to apply the ACO metaherustic to build solutions.
a search space S defined over a finite set of discrete decision variables x
i
, 1 ≤ i ≤ n. a set Ω of constraints among the variables. an objective function to be minimized
A variable x i takes values in a domain D i . A feasible solution s ∈ S is a complete assignment of values to variables such that all the problem constraints in Ω are satisfied. A feasible solution s f ∈ S is called a global minimum of P if and only if we have that f (s f ) ≤ f (s) , ∀ s ∈ S Ω .
The Algorithm 1 presents the main steps of the ACO metaheuristic. Next, we explain the different phases involved in the algorithm. In the
1: Initialization
2:
3: BuildingSolutions
4: daemonSearch (optional)
5: pheromoneUpdate
6:
Although different probabilistic decision rules have been designed for being used in the application of the ACO metaehuristic [3, 19] most ACO algorithms use a variation of the one defined in Ant System [15].
The formula calculates the probability that the ant k, that so far has constructed a partial solution , moves from component i to a feasible component j. The set of feasible components is denoted by . The parameters α and β control the influence of the trail pheromones and the heuristic information, respectively.
The pheromone level of the edges is updated when all the ants have built a solution. Initially, a constant is assigned to all of them and after each iteration, the pheromone level of each edge ij is updated according to the following formula.
Model driven engineering and domain specific languages
Model Driven Engineering (MDE) is a software development methodology based on the use of different abstract representations of systems known as models. MDE technologies combine modelling languages that allow to specify models and model transformations to increase the automation of code generation by means of transformations of high-level models to low-level ones.
The modelling languages can be classified, depending on their purpose, in two different groups. The General Purpose Domain Languages (GPML) are focused in a wide spectrum of fields, providing an elevated number of generic constructions and notations. Thus, it is intended that the users can be capable of designing and specifying any kind of system. The Unified Modelling Language (UML) [32] is the most extended GPML in both industry and research. Several software solutions and research techniques [6, 12] have been designed using this modelling language. However, these languages rarely capture particular domain concepts. On the contrary to GPMLs, Domain Specific Languages (DSL) are tailored to a specific domain. DSLs provide a high level abstraction, achieved through the use of domain concepts, which improves the readability, understand, and the communication between developers and domain knowledge experts. Some studies determine that DSLs can improve productivity, reliability, maintainability and portability [21, 39]. Several examples of DSLs can be found in the literature, among them, HTML [2], LATEX [26] and MATLAB [27] are some of the most representative.
The structure os a DSL is composed of four elements depicted in Fig. 2: an abstract syntax, a concrete syntax semantics, a description of the semantic and the pragmatics of the language. Abstract syntax represents the main concepts, abstractions, and their relations underlying the application domain. It its strongly associated with the domain knowledge. The abstract syntax of a language is often represented as a metamodel. A metamodel can be considered as a model of a class of models [33]. It describes the elements that conform the definition of a model and their relations. Concrete syntax: corresponds to the concrete representation of the language. It can be textual or graphical. This component affects to the user experience in terms of effectiveness. Semantic refers to the mathematical model that reflects the computational behaviour of syntactically valid models of a language. The static semantics defines structural properties, that is, well-formedness of models. The dynamic semantics describes the execution behaviour of the model. There exist different techniques to define formally the semantics of a language, the main ones are operational, translational, and denotational. Pragmatics: The pragmatics of a language concerns the meaning and interpretation of the language depending on the context. Tutorials, guidelines, examples composes the methodology of the language needed to use the language in a proper way.
Figure 3 illustrates the general scheme of the four-layer architecture used as reference in the MDE context. At the top level of abstraction (M3) we can found the meta-metamodel layer, which is used to define metamodels. The Meta-Object Facility (MOF) is a standard hosted by the Object Management Group (OMG). MOF can be seen as a DSL for defining metamodels.
At the next level down in the hierarchy (M2), the metamodels specify models to define the structure of a modelling language. In the layer below (M1) we have the models, that are instances of the metamodels and are designed according to the users requirements. Finally, in the last layer (M0) we find the real-world objects, which are modelled by the upper layers.
While MOF itself is also expressed as a model, it is often called a meta-metamodel.
Model driven ACO
The main goal of this paper is to provide a high level platform, based on MDE and DSLs, that makes possible the effective generation of ACO algorithms for solving different optimization problems in a fast and easy way. It supplies mechanisms to customize the different components associated with the development of an ACO algorithm.
This platform includes a DSL, LAnt, focused on facilitating the use of ACO paradigm to users without programming and modelling languages background. LAnt provides an abstraction layer which allows the application of the ACO paradigm by means of the selection of a reduced set of instructions that will allow to model the specific behaviour of the algorithm on the basis of the problem that the user needs to solve. As we said previously, the main components that must be defined when designing a DSL are the abstract syntax, the concrete syntax and the semantics. The abstract syntax has been designed using a meta-model, the standard choice when using MDE. Initially, we have decided to define a textual concrete syntax for the language, although we plan to provide graphical version. For the semantics of LAnt we have chosen code generation instead of interpretation.
For the complete comprehension of the modelled paradigm, in the next subsections we describe the abstract, concrete syntax, semantics and tool support of LAnt.
Abstract syntax
The meta-model diagram that describes the abstract syntax of LAnt, depicted in Fig. 4, captures the most representative components of ACO algorithms. The Annex of the paper includes the rest of meta-models. The ObjectiveFunction class represents the intended objective of the problem to be solved. It can correspond to either, the maximization or the minimization of an expression. The EndCondition denotes the condition for the algorithm termination. This condition can consider three different factors: a maximum number of Iterations to be performed by the algorithm, an upper bound in the amount of Time the algorithm will spend and a limit in the number of solutions that can be generated. The ACO meta-class orchestrates all the elements required for the design of the algorithm. The UpdatePheromone class represents the pheromone updating rule, which includes the mechanisms to carry out the pheromones evaporation and reinforcement of the trails. The ProbFunction class denotes a probabilistic rule which determines the movements of the ants based on the pheromone trails values and the heuristic information. Both functions can be defined in two different ways. On the one hand, the user can indicate an update rule from a predefined set, which is comprised by the expressions included in the well known algorithms Ant Colony System (ACS) [14], Max-Min Ant System (MMAS) [38] and Ant System (AS) [15]. This choice is represented by the PredefinedSet class. On the other hand, the user can provides a customized function, which is represented by the CustomExpression class. In this case, the EdgeFormat is required. It represents the information associated to the edges of the graphs to which the algorithm will be applied.
All the previous components are mandatory but, optionally, the user can include Constraints that must be satisfied by the solutions. They are grouped in PartialConstraints and SolConstraints. The former impose restrictions over partial solutions and the latter must be fulfilled by final solutions. In Fig. 11 is depicted the expansion of the meta-model that corresponds to the Constraints class. There are four types of restrictions. The ArithConstr denotes the constraints that compare arithmetical expressions by means of conditional operators (<, ≤ , > , ≥ , = , ≠). The SetConstrEdges and SetConstrNodes classes correspond to constraints over sets of edges and nodes respectively. These operations are listed in the SetConstrOp enumeration. Finally, the SetConstrNodeSingle represents conditions that involved a node and a set of nodes. The NodeSel represents a node of the graph that is being analyzed to be included in a partial solution, the NodeInit refers to the initial node of the graph and the NodeGoal corresponds to the node that must be reach by the solution of the problem.
Although we can find in the literature many DSLs that help to describe a graph, we do not need all the expressiveness that they provide and we have define a small DSL to describe them. The Graph metaclass depicted in Fig. 9 represents the search space of the algorithm. It is comprised by a set of Nodes and a set of Edges and presents an NodeInit and a NodeGoal. Although each edge has associated the pheromone level, other heuristic values can be assigned to them to be used in the search process of thesolutions.
Figure 10 depicts the abstract syntax of the expressions that can be included in the definition of the functions and constraints introduced previously. The Expression metaclass are split into two main groups. The first one corresponds to arithmetical expressions that are used to express formula. This category includes binary expressions (BinaryExp), unary expressions (UnaryExp), groups of expressions (GroupExp) and literal expressions (LiteralExp). The last class refers to both primitive data types, such as Real and Integer, and domain specific values represented by ACOVar and ACOConst. The second group, represented by the SetExp class, corresponds to expressions over either values of integer intervals (RangeInteger) or predefined sets of edges and nodes (SetNodes and SetEdges). These sets are grouped in the EdgesEnum and the SAllNod enumeration types that include the most representative sets of elements used in the ACO algorithms. SAllEdge and SAllNod represent the set of all edges and nodes that comprises the graph, respectively. SPartSolEdg corresponds to the set of edges included in partial solutions, SFinalSolEdg is the set of edges that form final solutions, SFeasEdg is the set of edges which are reachable during the construction of solutions and satisfy the problem constraints, SNeighEdg is the set of edges that connects with neighbor nodes and SBestSolEdg denotes the set of edges that corresponds to the best solution. Regarding the set of nodes, SPartSolNod is the set of nodes that are included in a partial solution and SFinalSolNod is the set of nodes that form final solution.
Concrete syntax
We have considered to design the concrete syntax of the DSL using a simple textual syntax based on Extended Backus-Naur Form (EBNF). This fact helps users of avoiding technical aspects of the design, allowing them to build the domain elements in a intuitive way.
The concrete syntax of the top level of LAnt is described at Fig. 12, the expressions and constraints are described at Figs.13 and 14 contains the concrete syntax to build an ACO algorithm that gives an approximation to a good solution.
For a better comprehension, we have included an example to illustrate the concrete syntax of all the components that comprise the proposed model. We will use the well known Travelling Salesman Problem [13]. This is an combinatorial optimization problem in which given a set of cities nd the distances between them, there must be found the shortest path that visits each city only once and returns to the origin city. The problem is represented by using a graph, where nodes represents cities and the edges, that have an associated a distance distance, denotes the connection between them.
Figure 5 depicts the definition of a graph by using LAnt. The graph is composed by 5 nodes (line 2) interconnected between them through edges with different distances (lines 5-8). In addition, the description indicates that the initial and the final nodes of the solutions must correspond to the node 1 (lines 3-4). Figure 6 describes the use of LAnt for the design of an ACO algorithm to solve the TSP problem. Although the pheromone update and probability rules can be selected from the predefined set of expressions, for the sake of illustration of the language, we have included the explicit definition of both of them. The objective function (line 2) indicates that the algorithm achieve to find the shortest path of the graph. Another mandatory element in the description of the algorithm is the end condition. In this case, the execution of the algorithm must stop 1000 units of time (line 3). The probability function and the update pheromone functions (lines 4-5) correspond to the expressions used in the AS proposal. The solution constraint SFinalSolNod equal SAllNod indicates that all the nodes must be included in the final solution and NodeGoal equal NodeInit represents that the tour must finish at the initial city (line 6). The partial constraint (line 7) requires that a city only can be visited once during the tour.
Semantics
Specifying the semantics of LAnt requires the generation of the Java code corresponding to the ACO algorithm that satisfies the definition of the main domain aspects of the problem and its associated constraints.
Tool support
The different components of the designed DSL has been developed using Eclipse Model Framework (EMF) [36], a modelling and code generation platform which supports developers with several tools and templates to construct applications on a structured data model. The abstract syntax has been modelled using Ecore [37], a diagram editor based on UML for designing domain models. The concrete syntax has been designed using Xtext [18], a powerful grammar language, which provides a high level description support to easily build the concrete syntax of models based on the domain aspects of a system.
The code generator has been performed using a statically-typed programming language, Xtend [17], which provides a flexible and expressive dialect of Java. Xtend improves Java in different aspects that support the creation of generation templates such as template expressions, extension methods and polymorphic method invocation, which are useful for the Java code translation.
As a result, we have obtained an Eclipse plugin of LAnt, that includes an editor, to easily model the ACO paradigm, that it is shown in Fig. 7 and a graph editor shown in Fig. 8.
Conclusions and future work
In this paper we have defined a high-level domain-specific modelling language, LAnt, for the design of ant colony optimization algorithms. This language allows to represent the main elements required to define the structure of the algorithms and to capture the specific constraints associated to the problem to solve. It aims to help users with low experience in the development of solutions based on this paradigm. The user can compose its own expressions based on problem domain values or select them from a predefined set, as well as define the solution constraint that must be satisfied to solve the problem. The proposal has been implemented as an Eclipse plug-in, including an editor and an integrated code generator.
As future lines of work, we consider to include a graphical editor for the graph generation, using a framework such as Eclipse GMF and Eugenia, that provides a set of mechanisms which favors the generation of a graphical editor, based on the abstract syntax of the language. Furthermore, we will include a more intuitive IDE, to easily configure LAnt and offer a more helpful solution. Finally, we plan to extend the set of predefined expressions to supply the users with an extensive set of default features.
