A Computational Framework For Combinatorial Optimization Problems
A Computational Framework For Combinatorial Optimization Problems
of the VII ALIO–EURO – Workshop on Applied Combinatorial Optimization, Porto, Portugal, May 4–6, 2011
∗
Fluminense Federal University, UFF
Niteroi, RJ, Brazil
{imcoelho, pmunhoz, mmsilva, satoru}@ic.uff.br
†
Federal University of Ouro Preto
Ouro Preto, MG, Brazil
{mathaddad, vncoelho}@gmail.com, [email protected]
ALIO-EURO 2011 – 51
Proc. of the VII ALIO–EURO – Workshop on Applied Combinatorial Optimization, Porto, Portugal, May 4–6, 2011
[4] point that local search is a common interest theme of scientific neighborhood N) is a solution s0 such that f (s0 ) 6 f (s), ∀s ∈ N(s0 )
community, at the same time that there isn’t a standard software for minimization problems, or f (s0 ) > f (s), ∀s ∈ N(s0 ) for maxi-
in this sense. So, the authors propose EasyLocal++, a compu- mization problems.
tational object-oriented framework for the design and analysis of
Many combinatorial optimization problems are classified as NP-
local search algorithms. According to the authors the architecture
Hard and it is common to use heuristic algorithms to find good
of EasyLocal++ allows code modularization and the combination
solutions for these problems. These methods have the capabil-
of basic techniques and neighborhood structures. Some successful
ity of finding good local optimums in short computational times.
applications of EasyLocal++ are showed and according to the au-
Classical local search heuristics stop on the first local optimum
thors EasyLocal++ provides flexibility enough for the implemen-
found. However, metaheuristics can go beyond the local optimum
tation of many scheduling problems.
and thus these methods are able to produce final solutions of better
ParadisEO [5] is a white-box object-oriented framework written quality.
in C++ and dedicated to the reusable design of parallel and dis-
tributed metaheuristics. This framework is based on a conceptual
separation of the solution methods from the problems they are in- 4. OPTFRAME
tended to solve. According to the authors, this separation gives the
users maximum code and design reuse. ParadisEO provides some OptFrame is a white-box object oriented framework in C++. In
modules that deals with population based metaheuristics, multiob- the following sections its implementation and design aspects are
jective optimization, single-solution based metaheuristics, and it presented and discussed.
also provides tools for the design of parallel and distributed meta-
heuristics. ParadisEO, as the OptFrame, is one of the rare frame-
works that provide parallel and distributed models. Their imple- 4.1. Representation and Memory
mentation is portable on distributed-memory machines as well as
on shared-memory multiprocessors, as it uses standard libraries The OptFrame framework is mainly based on two important struc-
such as MPI, PVM and PThreads. tures: the solution representation and the memory.
The Intelligent Optimization Toolkit (iOpt), proposed by [6] can be The Representation is the data structure used to represent a valid
seen as an IDE for the rapid construction of combinatorial prob- solution for a specific problem. For example, for the Traveling
lems. The iOpt takes as input problems modeled in one-way con- Salesman Problem (TSP) [8] a user may wish to represent the so-
straints and uses metaheuristics to solve them. The authors show lution as an array of integers. In this case, the representation in this
how to model the Vehicle Routing Problem with iOpt and good heuristic approach for TSP is vector < int > (in C++ language).
results are reported. Finally, the authors conclude that a better un-
On the other hand, the Memory is a set of auxiliary data structures
derstanding of the problem can be achieved by a fairer comparison
needed for a smarter version of the method.
between heuristic methods.
jMetal [7] is an object-oriented Java-based framework aimed at
facilitating the development of metaheuristics for solving multi- 4.2. Solution and Evaluation
objective optimization problems (MOPs). According to the au-
thors, this framework provides a rich set of classes which can be There are two important container classes2 in OptFrame: Solution
used as the building blocks of multi-objective metaheuristics; thus, and Evaluation. Solution carries a reference to a Representation of
taking advantage of code-reusing, the algorithms share the same the problem, while a Evaluation carries a reference to a Memory
base components, such as implementations of genetic operators structure. To develop a smarter version of the method, the infor-
and density estimators, so making the fair comparison of different mation in the Memory structure along with an earlier evaluation
metaheuristics for MOPs possible. can be used to reevaluate a Solution in a faster way, for example.
In general, frameworks are based on previous experience with the
implementation of many methods for different problems. In this 4.3. Evaluators
work we also review some important concepts of combinatorial
problems and metaheuristics, in order to propose an architecture The Evaluator concept is very important in OptFrame. It encapsu-
that is both problem and heuristic independent. The following sec- lates the function f : S → R (defined in Section 3) as an specific
tion shows the theoretical modeling of combinatorial problems be- case of its function f : S → E, where E = (R, R, M). The tuple E
hind OptFrame architecture. can be seen as the Evaluation class defined in Subsection 4.2.
The first value of the tuple E is the objective function value itself
3. METAHEURISTICS and the second one is an infeasibility measure value. By eval-
uating a solution this way you can implement heuristic methods
that are able to see unfeasible solutions, by giving a high penalty
We present now some important concepts of metaheuristics and value to the infeasibility measure value. When the infeasibility
combinatorial optimization problems. measure value is zero the solution is considered feasible. So, the
Let S be a set of discrete variables s (called solutions) and f : S → R evaluation function value over a solution consists in the sum of
an objective function that associates each solution s ∈ S to a real ob jective_ f unction_value + in f easibility_measure_value.
value f (s). We seek any s∗ ∈ S such that f (s∗ ) 6 f (s), ∀s ∈ S for The third value M of the tuple E is called memory defined in Sub-
minimization problems, or f (s∗ ) > f (s), ∀s ∈ S for maximization section 4.1. In this context the memory can record some steps of
problems. The solution s∗ is called a global optimum. the evaluation algorithm, so they won’t be repeated in future evalu-
A function N associates a solution s ∈ S to a set N(s) ⊆ S (called ations. This way, some future computational effort can be avoided.
neighborhood of s). This is also an important concept in the sub- 2 What we name here as a container class is in some ways related to with
ject of heuristic based algorithms. This way, a neighbor s0 of s
Proxy Pattern [9] since the idea is to carry a reference to an object (repre-
is such that s0 = s ⊕ m, where m is called a move operation. The sentation or memory) and to delete it when the container itself is destroyed.
cost of a move m is defined as fb = f (s0 ) − f (s), which means that But in this case a container is also used to provide some extra operations
s0 = s⊕m =⇒ f (s0 ) = f (s)+ fb. So, a local optimum (in terms of a over the carried object like printing, reference counting and cloning.
ALIO-EURO 2011 – 52
Proc. of the VII ALIO–EURO – Workshop on Applied Combinatorial Optimization, Porto, Portugal, May 4–6, 2011
There is also a more general definition for the evaluation method void exec(Population){ ... }
where the function f is defined by f : (S, E) → E. This way it void exec(Population, FitnessValues){ ... }
is possible to develop smarter versions of a Evaluator by using
informations of a previous evaluation E. where: Population is a list of Solutions and
FitnessValues is a list of Evaluations.
4.4. Moves The first one is the simplest version of the method while the second
is a more elaborated version. But if the user wish to implement
A move operation defines a neighborhood structure. In OptFrame only one of them it is possible to implement one and the other one
the Move class has two most important methods: canBeApplied only calls the first.
and apply.
The canBeApplied method of a Move object m returns true if the 4.7. Other structures
application of m to a solution s will produce a valid solution. Oth-
erwise it returns false. This is method is often used before the Some metaheuristics may require specific structures, but they can
apply method. also be defined in specific files, e.g., Perturbation for Iterated Local
The apply method of a Move m to a solution s transforms s into a Search; Mutation and Crossover operators for Genetic and Memetic
neighbor s0 and returns another Move m that can undo the changes Algorithms.
made by m. Since complete copies of solutions are expensive op-
erations it is possible to avoid them by developing efficient imple-
5. COMPUTATIONAL EXPERIMENTS AND
mentations of the reverse Move m.
CONCLUDING REMARKS
4.5. Neighborhood Structures This work presents OptFrame, a white-box object oriented frame-
work in C++ for the development of efficient heuristic based algo-
There are three types of neighborhood structure in OptFrame: NS, rithms. Our objective is to provide a simple interface for common
NSSeq and NSEnum. components of trajectory and population based metaheuristics.
NS is the simplest definition of a neighborhood structure. It only OptFrame’s architecture is intended to minimize the differences
requires the user to define a move(s) method, that returns a random among code and theoretical concepts of combinatorial optimiza-
move operation of the neighborhood type. Although not in focus tion. Thus, this paper describes a C++ modeling of the frame-
of this paper, it is possible to define neighborhood structures for work, but this model can also be applied to other programming
continuous problems optimization using this kind of structure. languages, since generic programming features are available.
NSSeq is a more elaborated version of NS. It also requires the user As a benchmark for the framework, we propose to implement a
to define a getIterator(s) method, that returns an object capable heuristic algorithm based on General Variable Neighborhood Search
of generating moves of the neighborhood structure in a sequential [14] for two different optimization problems.
way. The returned object must implement the NSIterator interface,
that itself implements the Iterator Pattern [9]. The first problem is the classical Traveling Salesman Problem, and
the second is the Eternity II Puzzle optimization problem (more
NSEnum is the most complete definition of a neighborhood struc- details on [15]). We also want to show the flexibility of the de-
ture in OptFrame. It provides an enumerable set of move opera- veloped interface by implementing the proposed heuristic in two
tions for a given combinatorial problem. Although it only requires different programming languages: C++ and Java3 .
the user to define the move(int) and size() methods, with these
methods it is possible to define default implementations for the To guarantee that the algorithms will follow the same paths (even
move(s) and getIterator(s) methods of NS and NSSeq. on different languages), we have implemented the Mersenne Twister
[16] random number generator, using the same seeds for both tests.
Table 1 shows the average time (in seconds) of 10 executions of the
4.6. Heuristic based methods proposed algorithm. “Java GCJ” is a compiled version of the Java
code (using the most optimized flags); “Java JRE” is an interpreted
Heuristic methods are mainly divided in two classes: trajectory version of the Java code; and “C++” is a compiled version of the
based and population based methods [10]. code using GCC compiler (with the most optimized flags).
In order to maximize the code reuse and to favor testing of Hybrid
Metaheuristics [11], all heuristic methods should be implemented
using the Heuristic class abstraction. With this abstraction we have Table 1: Computational experiments
already been able to implement the following methods: First Im-
Java GCJ (s) Java JRE (s) C++ (s)
provement, Best Improvement, Hill Climbing and other classical
Eternity II 121.60 33.08 8.35
heuristic strategies [12]; Iterated Local Search, Simulated Anneal-
TSP 115.52 33.45 7.32
ing, Tabu Search, Variable Neighborhood Search and other basic
versions of many famous trajectory based metaheuristics [13]; and,
finally, the basic versions of population based metaheuristics Ge-
netic Algorithm and Memetic Algorithm [13]. As expected, in both problems C++ got the lowest computational
times, while the compiled Java version got the highest times. The
So, there are four definitions of the method exec and the user must interpreted version of Java was faster than the compiled one, but
implement at least two of them. For trajectory based heuristics, the slower than C++ version.
user must implement:
This way, OptFrame showed to be a good tool for a fair comparison
void exec(Solution){ ... } between heuristic methods for different optimization problems and
void exec(Solution, Evaluation){ ... } even with different programming languages.
3 The Java version of OptFrame is called JOptFrame and it is also avail-
For population based heuristics: able on http://sourceforge.net/projects/joptframe/
ALIO-EURO 2011 – 53
Proc. of the VII ALIO–EURO – Workshop on Applied Combinatorial Optimization, Porto, Portugal, May 4–6, 2011
OptFrame is a free software licensed under LGPLv3. The develop- [6] R. Dorne, P. Mills, and C. Voudouris, “Solving vehicle rout-
ment version and newer stable version of OptFrame are available at ing using iOpt,” in Proceedings of MIC 2005 - The 6th Meta-
http://sourceforge.net/projects/optframe/. It heuristics International Conference, Viena, Áustria, 2005.
has been successfully applied to model many realistic optimiza- [7] J. J. Durillo, A. J. Nebro, F. Luna, B. Dorronsoro, and
tion problems. E. Alba, “jMetal: A java framework for developing multi-
Users are invited to visit our homepage and collaborate with the objective optimization metaheuristics,” Departamento de
project. Code reuse must be maximized, with clear abstractions Lenguajes y Ciencias de la Computación, University of
based on optimization concepts, but always keeping in mind that Málaga, E.T.S.I. Informática, Campus de Teatinos, Tech.
the target user should use only simple C++ on his/her code. Rep. ITI-2006-10, 2006.
[8] D. L. Applegate, R. E. Bixby, V. Chvatal, and W. J. Cook,
The Traveling Salesman Problem: A Computational Study.
6. ACKNOWLEDGMENTS
United Kingdom: Princeton University Press, 2006.
[9] E. Gamma, R. Helm, R. Johnson, and J. Vlissides, Design
The authors are grateful to CNPq (CT-INFO and UNIVERSAL),
Patterns: Elements of Reusable Object-Oriented Software.
CAPES (PROCAD and PRO-ENG), FAPERJ and FAPEMIG that
Addison-Wesley, 1995.
partially funded this research.
[10] C. Ribeiro and M. Resende, “Path-relinking intensification
methods for stochastic local search algorithms,” AT&T Labs
7. REFERENCES Research, Tech. Rep. NJ 07932, 2010.
[11] C. Blum and A. Roli, Hybrid Metaheuristics. Springer,
[1] A. Fink and S. Voß, “HotFrame: a heuristic optimiza- 2008.
tion framework,” in Optimization Software Class Libraries,
S. Voß and D. L. Woodruff, Eds. Boston: Kluwer Academic [12] P. Hansen and N. Mladenović, “First vs. best improvement:
Publishers, 2002, pp. 81–154. an empirical study,” Discrete Appl. Math., vol. 154, no. 5, pp.
802–817, 2006.
[2] M. Graccho and S. C. S. Porto, “TabOOBuilder: An object-
oriented framework for building tabu search applications.” in [13] F. W. Glover and G. A. Kochenberger, Handbook of Meta-
Proceedings of the Third Metaheuristics International Con- heuristics. Springer, 2003.
ference, Angra dos Reis, Rio de Janeiro, 1999, pp. 247–251. [14] Hansen, Mladenovic, and Perez, “Variable neighborhood
[3] A. Mendes, P. França, and P. Moscato, “NP-Opt: an opti- search: methods and applications,” 4OR: Quarterly journal
mization framework for np problems,” in Proceedings of the of the Belgian, French and Italian operations research soci-
IV SIMPOI/POMS 2001, Guarujá, São Paulo, 2001, pp. 11– eties, vol. 6, pp. 319–360, 2008.
14. [15] I. M. Coelho, B. N. Coelho, V. N. Coelho, M. N. Haddad,
[4] L. D. Gaspero and A. Schaerf, “EasyLocal++: an object- M. J. F. Souza, and L. S. Ochi, “A general variable neighbor-
oriented framework for the flexible design of local-search al- hood search approach for the resolution of the eternity ii puz-
gorithms,” Softw. Pract. Exper., vol. 8, no. 33, pp. 733–765, zle,” in International Conference on Metaheuristics and Na-
2003. ture Inspired Computing, Tunisia, Djerba Island, 2010, p. 3.
[5] S. Cahon, N. Melab, and E.-G. Talbi, “Paradiseo: A frame- [16] M. Matsumoto and T. Nishimura, “Mersenne twister: a 623-
work for the reusable design of parallel and distributed meta- dimensionally equidistributed uniform pseudo-random num-
heuristics,” Journal of Heuristics, vol. 10, no. 3, pp. 357– ber generator,” ACM Trans. Model. Comput. Simul., vol. 8,
380, 2004. pp. 3–30, January 1998.
ALIO-EURO 2011 – 54