Professional Documents
Culture Documents
MOEAFramework 2.1 ManualFixed
MOEAFramework 2.1 ManualFixed
User Manual
Version 2.1
ii
Copyright 2011-2014 David Hadka. All Rights Reserved.
iii
iv
Permission is granted to copy, distribute and/or modify the program code
contained in this document under the terms of the GNU Lesser General
Public License, Version 3 or any later version published by the Free Software
Foundation. Attach the following notice to any program code copied or
modified from this document:
v
vi
Preface
vii
viii
Citing the MOEA Framework
ix
x
Contributing to this Document
xi
xii
Contents
1 Introduction 1
1.1 Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Other Java Frameworks . . . . . . . . . . . . . . . . . . . . . 3
1.2.1 Watchmaker Framework . . . . . . . . . . . . . . . . . 3
1.2.2 ECJ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.3 jMetal . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.4 Opt4J . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.5 Others . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Reporting Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
xiii
xiv CONTENTS
4 Diagnostic Tool 33
4.1 Running the Diagnostic Tool . . . . . . . . . . . . . . . . . . . 33
4.2 Layout of the GUI . . . . . . . . . . . . . . . . . . . . . . . . 34
4.3 Quantile Plots vs Individual Traces . . . . . . . . . . . . . . . 36
4.4 Viewing Approximation Set Dynamics . . . . . . . . . . . . . 37
4.5 Statistical Results . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.6 Improving Performance and Memory Efficiency . . . . . . . . 40
4.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Credits 161
Introduction
The MOEA Framework is a free and open source Java library for developing
and experimenting with multiobjective evolutionary algorithms (MOEAs)
and other general-purpose optimization algorithms. A number of algo-
rithms are provided out-of-the-box, including NSGA-II, -MOEA, GDE3 and
MOEA/D. In addition, the MOEA Framework provides the tools necessary
to rapidly design, develop, execute and statistically test optimization algo-
rithms.
This user manual is divided into the following three parts:
1
2 CHAPTER 1. INTRODUCTION
Throughout this manual, you will find paragraphs marked with a red ex-
clamation as shown on the left-hand side of this page. This symbol indicates
important advice to help troubleshoot common problems.
Additionally, paragraphs marked with the lightbulb, as shown to the left,
provide helpful suggestions and other advice. For example, here is perhaps
the best advice we can provide: throughout this manual, we will refer you
to the API documentation to find additional information about a feature.
The API documentation is available at http://moeaframework.org/
javadoc/index.html. This documentation covers every aspect and every
feature of the MOEA Framework in detail, and it is the best place to look
to find out how something works.
Over 1100 test cases to ensure validity. Every release of the MOEA
Framework undergoes extensive testing and quality control checks. And, if
any bugs are discovered that survive this testing, we will promptly fix the
issues and release patches.
Homepage: http://watchmaker.uncommons.org
License: Apache License, Version 2.0
Advantages:
Very clean API
Fully documented source code
Flexible decision variable representation
Large collection of interesting example problems (Mona
Lisa, Sudoku, Biomorphs)
Disadvantages:
Single objective only
Much of the implementation burden is placed on the
developer
Infrequently updated (the last release, 0.7.1, was in Jan-
uary 2010)
1.2.2 ECJ
ECJ is a research-oriented Java library developed at the George Mason Uni-
versitys Evolutionary Computation Laboratory. Now in existence for nearly
fourteen years, ECJ is a mature and stable framework. It features a range of
evolutionary paradigms, including both single and multiobjective optimiza-
tion, master/slave and island-model parallelization, coevolution, parsimony
pressure techniques, with extensive support for genetic programming.
Homepage: http://cs.gmu.edu/eclab/projects/
ecj/
License: Academic Free License, Version 3.0
Advantages:
Quickly setup and execute simple EAs without touching
any source code
One of the most sophisticated open source libraries, par-
ticular in its support for various GP tree encodings
1.2. OTHER JAVA FRAMEWORKS 5
1.2.3 jMetal
jMetal is a framework focused on the development, experimentation and
study of metaheuristics. As such, it includes the largest collection of meta-
heuristics of any framework discussed here. If fact, the MOEA Framework
incorporates the jMetal library for this very reason. The jMetal authors have
more recently started developing C++ and C# versions of the jMetal library.
Homepage: http://jmetal.sourceforge.net
License: GNU Lesser General Public License, Version 3 or later
Advantages:
Focused on multiobjective optimization
Implementations of 15 state-of-the-art MOEAs
Provides an extensive user manual
Disadvantages:
Not currently setup as a library; several places have
hard-coded paths to resources located on the original
developers computer
Appears to lack any kind of automated testing or quality
assurance
Source code is not fully documented
1.2.4 Opt4J
6 CHAPTER 1. INTRODUCTION
Homepage: http://opt4j.sourceforge.net/
License: GNU Lesser General Public License, Version 3 or later
Advantages:
Focused on multiobjective optimization
Uses aspect-oriented programming (AOP) via Google
Guice to manage dependencies and wire all the compo-
nents together
Well documented source code
Frequently updated
Disadvantages:
Only a limited number of MOEAs provided
1.2.5 Others
For completeness, we also acknowledge JGAP and JCLEC, two stable and
maintained Java libraries for evolutionary computation. These two libraries,
like the Watchmaker Framework, are specialized for single-objective opti-
mization. They do provide basic support for multiobjective optimization,
but not to the extent of JMetal, Opt4J, and the MOEA Framework. If you
are dealing with only single-objective optimization problems, we encourage
you to explore these libraries that specialize in single-objective optimization.
html. In the bug report, describe the problem encountered and, if known,
the version of the MOEA Framework used.
9
Chapter 2
Installation Instructions
This chapter details the steps necessary to download and install the MOEA
Framework on your computer.
11
12 CHAPTER 2. INSTALLATION INSTRUCTIONS
Source Code The source code distribution contains all source code, unit
tests, documentation and data files. This distribution gives users full control
over the MOEA Framework, as any component can be modified as needed.
As such, this download is recommended for developers wishing to contribute
to or study the inner workings of the MOEA Framework.
Windows users must use an unzip utility like 7-Zip to extract the file
contents. 7-Zip is a free, open source program which can be downloaded
from http://www.7-zip.org/.
make your life easier. This manual will often provide instructions specific to
these optional software packages.
Oracle - http://www.oracle.com/technetwork/java/javase/
OpenJDK - http://openjdk.java.net/
For Ubuntu 8.04 (or later), Fedora 9 (or later), Red Hat Enterprise
Linux 5, openSUSE 11.1, Debian GNU/Linux 5.0 and OpenSolaris
IBM - http://www.ibm.com/developerworks/java/jdk/
Apple - http://support.apple.com/kb/DL1572
Figure 2.1: How the NetBeans properties window should appear in the
MOEA Framework is properly configured.
java -Djava.ext.dirs=lib
org.moeaframework.analysis.diagnostics.LaunchDiagnosticTool
lib/ contains the compiled libraries required to use the MOEA Frame-
work. This includes the MOEA Framework compiled libraries and all
required third-party libraries.
licenses/ contains the complete text of all open source software licenses
for the MOEA Framework and third-party libraries. In order to comply
with the licenses, this folder should always be distributed alongside the
compiled libraries in the lib folder.
pf/ contains the Pareto front files for the test problems provided by de-
fault in the MOEA Framework.
LICENSE lists the open source software licenses in use by the MOEA
Framework, contributor code and third-party libraries.
18 CHAPTER 2. INSTALLATION INSTRUCTIONS
NEWS details all important changes made in the current release and prior
releases. This includes critical bug fixes, changes, enhancements and
new features.
lib/ contains all required third-party libraries used by the MOEA Frame-
work.
manual/ contains the LaTeX files and figures for generating this user
manual.
META-INF/ contains important files which are packaged with the com-
piled binaries. Such files include the service provider declarations, li-
censing information, etc.
pf/ contains the Pareto front files for the test problems provided by de-
fault in the MOEA Framework.
src/ contains all source code in use by the core MOEA Framework li-
brary.
test/ contains all JUnit unit tests used to ensure the correctness of the
MOEA Framework source code.
build.xml contains the Apache Ant build scripts for compiling and/or
building the MOEA Framework library.
2.9. CONCLUSION 19
LICENSE lists the open source software licenses in use by the MOEA
Framework, contributor code and third-party libraries.
NEWS details all important changes made in the current release and prior
releases. This includes critical bug fixes, changes, enhancements and
new features.
TODO lists all planned changes for the MOEA Framework source code.
This file is a starting point for individuals wishing to contribute modi-
fications to the MOEA Framework.
2.9 Conclusion
This chapter described each of the MOEA Framework distributions. At this
point, you should have a working MOEA Framework distribution which you
can use to run the examples in subsequent chapters.
20 CHAPTER 2. INSTALLATION INSTRUCTIONS
Chapter 3
Executor, Instrumenter,
Analyzer
The Executor, Instrumenter and Analyzer classes provide most of the func-
tionality provided by the MOEA Framework. This chapter walks through
several introductory examples using these classes.
3.1 Executor
The Executor class is responsible for constructing and executing runs of an
algorithm. A single run requires three pieces of information: 1) the problem;
2) the algorithm used to solve the problem; and 3) the number of objec-
tive function evaluations allocated to solve the problem. The following code
snippet demonstrates how these three pieces of information are passed to the
Executor.
Line 1 creates a new Executor instance. Lines 2, 3 and 4 set the problem,
algorithm and maximum number of objective function evaluations, respec-
tively. In this example, we are solving the two-objective UF1 test problem
21
22 CHAPTER 3. EXECUTOR, INSTRUMENTER, ANALYZER
using the NSGA-II algorithm. Lastly, line 5 runs this experiment and returns
the resulting approximation set.
Note how, on lines 2 and 3, the problem and algorithm are specified using
strings. There exist a number of pre-defined problems and algorithms which
are available in the MOEA Framework. Furthermore, the MOEA Framework
can be easily extended to provide additional problems and algorithms which
can be instantiated in a similar manner.
Once the run is complete, we can access the result. Line 1 above shows
that the approximation set, which is a NondominatedPopulation, gets
assigned to a variable named result. This approximation set contains all
Pareto optimal solutions produced by the algorithm during the run. For
example, the code snippet below prints out the two objectives to the console.
Line 1 loops over each solution in the result. A solution stores the decision
variables, objectives, constraints and any relevant attributes. Lines 2 and 3
demonstrate how the objective values can be retrieved from a solution.
Putting all this together and adding the necessary boilerplate Java code,
the complete code snippet is shown below.
1 import java.util.Arrays;
2 import org.moeaframework.Executor;
3 import org.moeaframework.core.NondominatedPopulation;
4 import org.moeaframework.core.Solution;
5
6 public class Example1 {
7
8 public static void main(String[] args) {
9 NondominatedPopulation result = new Executor()
10 .withProblem("UF1")
11 .withAlgorithm("NSGAII")
12 .withMaxEvaluations(10000)
13 .run();
14
Since line 6 defines the class name to be Example1, this code snippet
must be saved to the file Example1.java. Compiling and running this
file will produce output similar to:
0.44231379762506046 0.359116256460771
0.49221581122496827 0.329972177772519
0.8024234727753593 0.11620643510507386
0.7754123383456428 0.14631335018878214
0.4417794310706653 0.3725544250337767
0.11855110357018901 0.6715178312971422
...
the polynomial mutation (PM) rate and distribution index. Changing the
parameter settings from their defaults is possible using the setProperty
methods. Each parameter is identified by a key and is assigned a numeric
value. For example, all of NSGA-IIs parameters are set in the following code
snippet:
Each algorithm defines its own parameters. Refer to the API documen-
tation for the exact parameter keys. Any parameters not explicitly defined
using the withProperty methods will be set to their default values.
The Executor also provides many advanced features. One such feature is
the ability to distribute objective function evaluations across multiple pro-
cessing cores or computers. Distributing evaluations can significantly speed
up a run through parallelization. The simplest way to enable paralleliza-
tion is through the distributeOnAllCores method. This will distribute
objective function evaluations across all cores on your local computer. Note
that not all algorithms can support parallelization. In such cases, the MOEA
Framework will still run the algorithm, but it will not be parallelized. The
code snippet below extends our example with distributed evaluations.
11 .run();
3.2 Instrumenter
In addition to supporting a multitude of algorithms and test problems, the
MOEA Framework also contains a comprehensive suite of tools for analyzing
the performance of algorithms. The MOEA Framework supports both run-
time dynamics and end-of-run analysis. Run-time dynamics capture the
behavior of an algorithm throughout the duration of a run, recording how
its solution quality and other elements change. End-of-run analysis, on the
other hand, focuses on the result of a complete run and comparing the relative
performance of various algorithms. Run-time dynamics will be introduced in
this section using the Instrumenter; end-of-run analysis will be discussed in
the following section using the Analyzer.
The Instrumenter gets its name from its ability to add instrumentation,
which are pieces of code that record information, to an algorithm. A range
of data can be collected using the Instrumenter, including:
1. Elapsed time
4. Performance metrics
5. Restart frequency
First, line 1 creates the new Instumenter instance. Next, line 2 specifies
the problem. This allows the instrumenter to access the known reference
set for this problem, which is necessary for evaluating performance metrics.
Third, line 3 sets the frequency at which the data is recorded. In this exam-
ple, data is recorded every 100 evaluations. Lastly, line 4 indicates that all
available data should be collected.
Next, we create and configure the Executor instance with the following
code snippet:
This code snippet is similar to the previous examples of the Executor, but
includes the addition of line 5. Line 5 tells the executor that all algorithms
it executes will be instrumented with our Instrumenter instance. Once the
instrumenter is set and the algorithm is configured, we can run the algorithm
on line 6.
When the run completes, we can access the data collected by the instru-
menter. The data is stored in an Accumulator object. The Accumulator for
the run we just executed can be retrieved with the following line:
2 System.out.println(accumulator.get("NFE", i) + "\t" +
3 accumulator.get("GenerationalDistance", i));
4 }
In this code snippet, we are printing out two columns of data: the num-
ber of objective function evaluations (NFE) and the generational distance
performance indicator. Including all the boilerplate Java code, the complete
example is provided below.
1 import java.io.IOException;
2 import java.io.File;
3 import org.moeaframework.core.NondominatedPopulation;
4 import org.moeaframework.Instrumenter;
5 import org.moeaframework.Executor;
6 import org.moeaframework.analysis.collector.Accumulator;
7
Since line 8 defines the class name to be Example2, this code snippet
28 CHAPTER 3. EXECUTOR, INSTRUMENTER, ANALYZER
100 0.6270289757162074
200 0.5843583367503041
300 0.459146246330144
400 0.36799025371209954
500 0.3202295846482732
600 0.2646381449859231
...
If you have set the -Xmx option to include all available memory on your
computer and you still receive an OutOfMemoryException, then you need
to decrease the collection frequency or restrict what data is collected.
Third, the Instrumenter only collects data which is pro-
vided by the algorithm. For instance, an Instrumenter with
3.3. ANALYZER 29
3.3 Analyzer
The Analyzer provides end-of-run analysis. This analysis focuses on the
resulting Pareto approximation set and how it compares against a known
reference set. The Analyzer is particularly useful for statistically comparing
the results produced by two or more algorithms, or possibly the same algo-
rithm with different parameter settings. To start using the Analyzer, we first
create and configure a new instance, as shown below.
8 analyzer.addAll("GDE3",
9 executor.withAlgorithm("GDE3").runSeeds(50));
30 CHAPTER 3. EXECUTOR, INSTRUMENTER, ANALYZER
Lines 1-3 create the Executor, similar to the previous examples except we
do not yet specify the algorithm. Lines 5-6 run NSGA-II. Note how we first
set the algorithm to NSGA-II, run it for 50 seeds, and add the results from
the 50 seeds to the analyzer. Similarly, on lines 8-9 we run GDE3 and add
its results to the analyzer. Note how lines 5 and 8 pass a string as the first
argument to addAll. This gives a name to the samples collected, which can
be any string and not necessarily the algorithm name as is the case in this
example.
Lastly, we can display the results of the analysis with the following line.
1 analyzer.printAnalysis();
Putting all of this together and adding the necessary boilerplate Java
code results in:
1 import java.io.IOException;
2 import org.moeaframework.Analyzer;
3 import org.moeaframework.Executor;
4
17 analyzer.addAll("NSGAII",
18 executor.withAlgorithm("NSGAII").runSeeds(50));
19
20 analyzer.addAll("GDE3",
21 executor.withAlgorithm("GDE3").runSeeds(50));
22
23 analyzer.printAnalysis();
24 }
3.3. ANALYZER 31
25
26 }
GDE3:
Hypervolume:
Min: 0.4358713988821755
Median: 0.50408587891491
Max: 0.5334024567416756
Count: 50
Indifferent: []
...
NSGAII:
Hypervolume:
Min: 0.3853879478063566
Median: 0.49033837779756184
Max: 0.5355927774923894
Count: 50
Indifferent: []
...
Observe how the results are organized by the indenting. It starts with
the sample names, GDE3 and NSGAII in this example. The first indentation
level shows the different metrics, such as Hypervolume. The second indenta-
tion level shows the various statistics for the metric, such as the minimum,
median and maximum values.
The indifferent field show the statistical significance of the results. The
Analyzer applies the Mann-Whitney and Kruskal-Wallis tests for statistical
significance. If the medians are significantly different, then the indifferent
columns shows empty brackets (i.e., []). However, if the medians are in-
different, then the samples which are indifferent will be shown within the
brackets. For example, if GDE3s indifferent field was [NSGAII], then that
indicates there is no statistical difference in performance between GDE3 and
NSGA-II.
Statistical significance is important when comparing multiple algorithms,
particularly when the results will be reported in scientific papers. Running
an algorithm will likely produce different results each time it is run. This is
because many algorithms are stochastic (meaning that they include sources of
32 CHAPTER 3. EXECUTOR, INSTRUMENTER, ANALYZER
3.4 Conclusion
This chapter introduced three of the high-level classes: the Executor, In-
strumenter and Analyzer. The examples provided show the basics of using
these classes, but their functionality is not limited to what was demonstrated.
Readers should explore the API documentation for these classes to discover
their more sophisticated functionality.
Chapter 4
Diagnostic Tool
java -Djava.ext.dirs=lib
org.moeaframework.analysis.diagnostics.LaunchDiagnosticTool
33
34 CHAPTER 4. DIAGNOSTIC TOOL
1. The configuration panel. This panel lets you select the algorithm, prob-
lem, number of repetitions (seeds), and maximum number of function
evaluations (NFE).
2. The execution panel. Clicking run will execute the algorithm as config-
ured in the configuration panel. Two progress bars display the individ-
ual run progress and the total progress for all seeds. Any in-progress
runs can be canceled.
4.2. LAYOUT OF THE GUI 35
Figure 4.2: Screenshot of the diagnostic tool displaying two side-by-side met-
rics. You can select as many metrics to display by holding down the Alt key
and clicking a row in the displayed metrics table.
3. The displayed results table. This table displays the completed runs.
The entries which are selected/highlighted are displayed in the charts.
You can click an individual line to show the data for just that entry,
click while holding the Alt key to select multiple entries, or click the
Select All button to select all entries.
4. The displayed metrics table. Similar to the displayed results table, the
selected metrics are displayed in the charts. You can select one metric
or multiple metrics by holding the Alt key while clicking.
5. The actual charts. A chart will be generated for each selected metric.
Thus, if two metrics are selected, then two charts will be displayed
side-by-side. See Figure 4.2 for an example.
Figure 4.3: Screenshot of the diagnostic tool displaying the individual traces
rather than the quantile view. The individual traces provide access to the
raw data, but the quantile view is often easier to interpret.
By default, the charts displayed in the diagnostic tool show the statistical
25%, 50% and 75% quantiles. The 50% quantile is the thick colored line, and
the 25% and 75% quantiles are depicted by the colored area. This quantile
view allows you to quickly distinguish the performance between multiple
algorithms, particularly when there is significant overlap between two or
more algorithms.
You can alternatively view the raw, individual traces by selecting Show
Individual Traces in the View menu. Each colored line represents one seed.
Figure 4.3 provides an example of plots showing individual traces. You can
always switch back to the quantile view using the View menu.
4.4. VIEWING APPROXIMATION SET DYNAMICS 37
Figure 4.4: Screenshot of the approximation set viewer. This allows you to
view the approximation set at any point in the algorithms execution.
1. The approximation set plot. This plot can only show two dimensions.
If available, the reference set for the problem will be shown as black
points. All other points are the solutions produced by the algorithm.
Different seeds are displayed in different colors.
2. The evolution slider. Dragging the slider to the left or right will show
the approximation set from earlier or later in the evolution.
3. The display controls. These controls let you adjust how the data is
displayed. Each of the radio buttons switches between different scaling
options. The most common option is Use Reference Set Bounds, which
scales the plot so that the reference set fills most of the displayed region.
4. The displayed seeds table. By default, the approximation sets for all
seeds are displayed and are distinguished by color. You can also downs-
elect to display one or a selected group of seeds by selecting entries in
this table. Multiple entries can be selected by holding the Alt key while
clicking.
You can manually zoom to any portion in these plots (both in the ap-
proximation set viewer and the plots in the main diagnostic tool window) by
positioning the cursor at the top-left corner of the zoom region, pressing and
holding down the left-mouse button, dragging the cursor to the bottom-right
corner of the zoom region, and releasing the left-mouse button. You can reset
the zoom by pressing and holding the left-mouse button, dragging the cursor
to the top-left portion of the plot, and releasing the left-mouse button.
this is the hypervolume for the GDE3 algorithm. The third line says Aggre-
gate: 0.4894457739242269, and indicates that the aggregate hypervolume
produced by GDE3 was 0.489.
Displayed for each metric are the min, median and max values for the
specific metric. It is important to note that these values are calculated from
the end-of-run result. No intermediate results are used in the statistical tests.
The aggregate value is the metric value resulting when the result from all
seeds are combined into one. The count is the number of seeds.
The indifferent entries are of particular importance and will be explained
in detail. When comparing two data sets using statistical tools, it is not
sufficient to simply compare their average or median values. This is because
such results can be skewed by randomness. For example, suppose we are
calculating the median values of ten seeds. If one algorithm gets lucky
and happens to use more above-average seeds, the estimated median will
40 CHAPTER 4. DIAGNOSTIC TOOL
4.7 Conclusion
This chapter provided an introduction to the MOEA Diagnostic Tool, which
is a GUI that allows users to experiment running various MOEAs on different
problems. Readers are encouraged to experiment with this GUI when first
using the MOEA Framework as it should provide insight into how MOEAs
operate. As an exercise, try running all of the available MOEAs on the
DTLZ2 2 problem. Do the performance metrics (e.g., generational distance)
converge to roughly the same value? Does one MOEA converge to this value
faster than the others? Repeat this experiment with different problems and
see if you get the same result.
Chapter 5
The real value of the MOEA Framework comes not from the algorithms and
tools it provides, but the problems that it solves. As such, being able to
introduce new problems into the MOEA Framework is an integral aspect of
its use.
Throughout this chapter, we will show how a simple multiobjective prob-
lem, the Kursawe problem, can be defined in Java, C/C++, and in scripting
languages. The formal definition for the Kursawe problem is provided below.
41
42 CHAPTER 5. DEFINING NEW PROBLEMS
5.1 Java
Defining new problems in Java is the most direct and straightforward way
to introduce new problems into the MOEA Framework. All problems in the
MOEA Framework implement the Problem interface. The Problem inter-
face defines the methods for characterizing a problem, defining the problems
representation, and evaluating solutions to the problem. In practice, you
should never need to implement the Problem interface directly, but can ex-
tend the more convenient AbstractProblem class. AbstractProblem
provides default implementations for many of the methods required by the
Problem interface. The code example below shows the Kursawe problem
defined by extending the AbstractProblem class.
1 import org.moeaframework.core.Solution;
2 import org.moeaframework.core.variable.EncodingUtils;
3 import org.moeaframework.core.variable.RealVariable;
4 import org.moeaframework.problem.AbstractProblem;
5
6 public class Kursawe extends AbstractProblem {
7
8 public Kursawe() {
9 super(3, 2);
10 }
11
12 @Override
13 public Solution newSolution() {
14 Solution solution = new Solution(numberOfVariables,
15 numberOfObjectives);
16
1 new Executor()
2 .withProblemClass(Kursawe.class)
3 .withAlgorithm("NSGAII")
4 .withMaxEvaluations(10000)
5 .run();
1 new Executor()
2 .withProblemClass(ProblemWithArgument.class,
3 new File("inputFile.txt"))
4 .withAlgorithm("NSGAII")
5 .withMaxEvaluations(10000)
6 .run();
5.2 C/C++
It is often the case that the problem / model / computer simulation you
are working with is written in a different programming language, such as
C/C++. With a little work, it is possible to connect that C/C++ problem to
the MOEA Framework and optimize its inputs / parameters. In the following
5.2. C/C++ 45
1 #include <math.h>
2
3 int nvars = 3;
4 int nobjs = 2;
5
Note how the evaluate method takes two arguments, vars and objs
, which coincide with the inputs (the decision variables) and the outputs
(the objective values). Now we need to define how the evaluate method
connects to the MOEA Framework. This connection is established using the
following code.
1 #include <stdlib.h>
2 #include "moeaframework.h"
3
12 evaluate(vars, objs);
13 MOEA_Write(objs, NULL);
14 }
15
16 MOEA_Finalize();
17 return EXIT_SUCCESS;
18 }
1 #include <stdlib.h>
2 #include <math.h>
3 #include "moeaframework.h"
4
5 int nvars = 3;
6 int nobjs = 2;
7
8 void evaluate(double* vars, double* objs) {
9 int i;
10 objs[0] = 0.0;
5.2. C/C++ 47
11 objs[1] = 0.0;
12
You can save this C code to kursawe.c and compile it into an exe-
cutable. If using the GNU C Compiler (gcc), you can compile this code with
the following command on Linux or Windows. Note that you will need both
moeaframework.h and moeaframework.c in the same directory as
kursawe.c.
At this point, we now switch back to Java and define the prob-
lem class by extending the ExternalProblem class. We extend the
ExternalProblem class instead of the AbstractProblem class since
ExternalProblem understands how to communicate with the executable
48 CHAPTER 5. DEFINING NEW PROBLEMS
we just compiled. The code snippet below shows the complete Java class for
this example.
1 import org.moeaframework.core.Solution;
2 import org.moeaframework.core.variable.RealVariable;
3 import org.moeaframework.problem.ExternalProblem;
4
23 @Override
24 public Solution newSolution() {
25 Solution solution = new Solution(getNumberOfVariables(),
26 getNumberOfObjectives(), getNumberOfConstraints());
27
28 for (int i = 0; i < numberOfVariables; i++) {
29 solution.setVariable(i, new RealVariable(-5.0, 5.0));
30 }
31
32 return solution;
33 }
34
35 }
Note how we still need to define the number of variables, objectives, and
constraints in addition to defining the newSolution method. However,
we no longer include the evaluate method. Instead, we reference the
executable we previously created on line 8. The MOEA Framework will
5.3. SCRIPTING LANGUAGE 49
1 new Executor()
2 .withProblemClass(ExternalKursawe.class)
3 .withAlgorithm("NSGAII")
4 .withMaxEvaluations(10000)
5 .run();
Once the enter key is pressed, the program will output the two objectives
to the console:
-13.504159423733775 6.966377092192072
1 importPackage(java.lang);
2 importPackage(Packages.org.moeaframework.core);
3 importPackage(Packages.org.moeaframework.core.variable);
50 CHAPTER 5. DEFINING NEW PROBLEMS
4
5 function getName() {
6 return "Kursawe";
7 }
8
9 function getNumberOfVariables() {
10 return 3;
11 }
12
13 function getNumberOfObjectives() {
14 return 2;
15 }
16
17 function getNumberOfConstraints() {
18 return 0;
19 }
20
21 function evaluate(solution) {
22 x = EncodingUtils.getReal(solution);
23 f1 = 0.0;
24 f2 = 0.0;
25
26 for (i = 0; i < getNumberOfVariables() - 1; i++) {
27 f1 += -10.0 * Math.exp(-0.2 * Math.sqrt(
28 Math.pow(x[i], 2.0) + Math.pow(x[i+1], 2.0)));
29 }
30
31 for (i = 0; i < getNumberOfVariables(); i++) {
32 f2 += Math.pow(Math.abs(x[i]), 0.8) +
33 5.0 * Math.sin(Math.pow(x[i], 3.0));
34 }
35
36 solution.setObjective(0, f1);
37 solution.setObjective(1, f2);
38 }
39
40 function newSolution() {
41 solution = new Solution(getNumberOfVariables(),
42 getNumberOfObjectives());
43
44 for (i = 0; i < getNumberOfVariables(); i++) {
45 solution.setVariable(i, new RealVariable(-5.0, 5.0));
46 }
47
48 return solution;
5.4. CONCLUSION 51
49 }
50
51 function close() {
52
53 }
Note how all methods defined by the Problem interface appear in this
code. Also note how we can invoke Java methods and constructors through
the scripting language. The specifics of how to implement functions and
invoke existing methods are specific to the scripting language chosen. Refer
to the documentation for the scripting language for details.
Save this script to an appropriate file with the correct file extension for
the scripting language. Since the script in this example is written in the
Rhino Javascript language, we save the file to kursawe.js. Solving this
Javascript version of the Kursawe problem is nearly identical to all previous
examples, as shown below.
1 new Executor()
2 .withProblemClass(ScriptedProblem.class,
3 new File("kursawe.js"))
4 .withAlgorithm("NSGAII")
5 .withMaxEvaluations(10000)
6 .run();
The only difference is on lines 2-3, where we specify the problem class as
ScriptedProblem.class and pass as an argument the file kursawe.
js. The ScriptedProblem class loads the file, determines the appropriate
scripting engine, and uses that scripting engine to evaluate solutions to the
problem.
5.4 Conclusion
This chapter introduced the various means for introducing new problems
to the MOEA Framework. This includes implementing problems in Java,
C/C++, and in one of the many supported scripting languages. Care must
be taken when choosing which language to use, as each method has differ-
ent advantages and drawbacks. One key consideration is the speed of each
method. The table below shows the wall-clock time for the three methods
52 CHAPTER 5. DEFINING NEW PROBLEMS
TM
discussed in this chapter. These times were produced on an Intel
Core
c 2
Duo @ 2.13 GHz.
Representing Decision
Variables
53
54 CHAPTER 6. REPRESENTING DECISION VARIABLES
Inside the evaluate method, we can extract the decision variable val-
ues from the solution using the EncodingUtils.getReal(...) method.
Continuing the previous code example, we extract the values of the three de-
cision variables below.
The EncodingUtils class handles all the type checking and cast-
ing needed to ensure variables are read properly. Attempting to read or
write a decision variable that is not the correct type will result in an
IllegalArgumentException. If you see this exception, check all your
decision variables to ensure they are the types you expect.
6.2. INTEGERS 55
6.2 Integers
Integer-valued decision variables can be constructed in a similar way as
floating-point values. For instance, below we construct the solution using
calls to EncodingUtils.newInt(lowerBound, upperBound). As
we saw with floating-point values, we must specify the lower and upper
bounds of the decision variables.
Similarly, the values stored in the decision variables can be read using the
EncodingUtils.getInt(...) method, as demonstrated below.
The boolean decision variable works well when the problem has a single
choice. If the problem involves more than one choice, it is more convenient
and efficient to use bit strings (an array of booleans) instead. Bit strings are
introduced in the following section.
When evaluating the solution, the bit string can be read into an array of
boolean values, as demonstrated below.
6.5 Permutations
Permutation decision variables appear in many combinatorial and job
scheduling problems. In the famous traveling salesman problem (TSP), a
salesman must travel to every city with the condition that they visit each city
exactly once. The order in which the salesman visits each city is conveniently
represented as a permutation. For example, the permutation 0,3,1,2 states
that the salesman visits the first city first (0 represents the first city), travels
to the fourth city (3), then travels to the second city (1), and finally arrives
at the third city (2).
The code example below demonstrates the creation of a permutation of
25 elements.
The permutation is read out into an array of int values. If the permu-
tation is over N elements, the array length will be N and the values stored
will range from 0 to N 1. Each distinct value will appear only once in the
array (by definition of a permutation).
8 rules.add(new Cos());
9 rules.add(new Exp());
10 rules.add(new Log());
11 rules.add(new Get(Number.class, "x"));
12 rules.setReturnType(Number.class);
6.7 Grammars
Grammars are very similar to programs, but differ slightly in their definition
and how the derived programs are generated. Whereas the program required
us to define a set of program elements (the rules) used for constructing the
program, the grammar defines these rules using a context free grammar.
The text below shows an example grammar. The format of this grammar is
Backus-Naur form.
You should note that this grammar defines the same functions and ter-
minals as the example in the previous section. This also demonstrates an
important difference between programs and grammars in the MOEA Frame-
work. The grammar explicitly defines where each problem element can ap-
pear. This is in contrast to programs, whose structure is determined by the
type system. As a result, grammars require more setup time but offer more
control over programs. We will now demonstrate the use of grammars in the
MOEA Framework.
First, we must parse the context free grammar. In the example below,
the grammar is read from a file. It is also possible to pass a string containing
the grammar using a StringReader in place of the FileReader.
Finally, we can evaluate a solution by first extracting the codon and de-
riving the program. Unlike programs that can be evaluated directly, the
grammar produces a string (the derivation). While it is common for gram-
mars to produce program code, this is not a requirement. This is the second
major difference between grammars and programs in the MOEA Framework
the behavior of programs is defined explicitly, whereas the behavior of
grammars depend on how the grammar is interpreted. In this case, we are
producing program code and will need a scripting language to evaluate the
program. Using Javas Scripting API and having defined the grammar so
that it produces a valid Groovy program, we can evaluate the derivation
using the Groovy scripting language. In the code below, we instantiate a
ScriptEngine for Groovy, initialize the variable x, and evaluate the pro-
gram.
22 }
23 }
In order to compile and run this example, the Groovy scripting lan-
guage must be installed. To install Groovy, download the binary release
from http://groovy.codehaus.org/, extract the embeddable\
groovy-all-2.0.1.jar file into the lib folder in your MOEA Frame-
work installation, and add this jar file onto the Java classpath when launching
this example.
6.8.1 Initialization
The start of all evolutionary algorithms is the construction of an initial popu-
lation. This population is important since, in general, all future solutions are
derived from members of this initial population. Ensuring this initial popu-
lation provides a diverse and representative set of individuals is paramount.
The floating-point, integer, binary, permutation and grammar variables
are all initialized uniformly at random. This ensures the values, bit strings,
etc. are distributed uniformly throughout the search space.
Programs require a slightly more complicated initialization to ensure the
initial population contains a diverse sampling of potential programs. The
MOEA Framework provides the ramped half-and-half initialization method,
which is one of the most popular initialization techniques for programs. We
refer readers to the genetic programming literature for a detailed description
of ramped half-and-half initialization.
Variation operators are classified into two forms: crossover and mutation.
Crossover involves combining two or more parents to create an offspring.
Mutation involves a single parent. Mutations generally produce only small
changes, but this is not mandatory.
Table 6.1 lists the supported variation operators in the MOEA Frame-
work. The table highlights the decision variable representation and type of
each variation operator.
The abbreviation column lists the keyword used in the MOEA Frame-
work for referencing each operator. The example code below shows how we
can specify the operator used by an algorithm and also any parameters for
the operator. In this example, we are using parent-centric crossover (PCX)
and setting two of its parameters, pcx.eta and pcx.zeta. Refer to the
OperatorFactory class documentation for a complete list of the operators
and their parameters.
6.9. CONCLUSION 65
6.9 Conclusion
This chapter introduced the various decision variable representations sup-
ported by the MOEA Framework. Look at these different representations
as the building blocks for your problem. If you can construct your problem
using these building blocks, the problem will seamlessly integrate with the
MOEA Framework.
We close this chapter by commenting that the MOEA Framework is not
limited to these representations. New representations are periodically in-
66 CHAPTER 6. REPRESENTING DECISION VARIABLES
troduced in the literature. This fact influenced the design of the MOEA
Framework to allow new representations and variation operators. Interested
readers should stay turned for future updates to this user manual that will
discuss such extensions in detail.
Chapter 7
N
X N
X
Maximize d(i) P (i) such that d(i) W (i) C
i=1 i=1
The summation on the left (which we are maximizing) calculates the total
profit we gain from the items placed in the knapsack. The summation on
the right side is a constraint that ensures the items placed in the knapsack
do not exceed the weight capacity of the knapsack.
The multiobjective knapsack problem that we will be solving in this sec-
tion is very similar, except that we now have 2 knapsacks to hold the items.
Additionally, the profit and weights vary depending on which knapsack is
67
68 CHAPTER 7. EXAMPLE: KNAPSACK PROBLEM
holding each item. For example, an item will have a profit of $25 and a
weight of 5 pounds in the first knapsack, but will have a profit of $15 and
a weight of 8 pounds in the second knapsack. (It may seem unusual that
the weight changes, but that is how the problem is defined in the litera-
ture.) Thus, profit is now defined by P (i, j) and weight by W (i, j), where
the j = 1, 2 term is the knapsack index. Lastly, each knapsack defines its
own capacity, C1 and C2 . Combining all of this, the multiobjective knapsack
problem is formally defined as:
weight: +77
profit: +59
item 4:
weight: +74
profit: +83
item 5:
weight: +29
profit: +82
=
knapsack 2:
capacity: +190
item 1:
weight: +55
profit: +20
item 2:
weight: +10
profit: +19
item 3:
weight: +97
profit: +20
item 4:
weight: +73
profit: +66
item 5:
weight: +69
profit: +48
decision to include each item using a bit string with 5 bits. Each bit in the
string corresponds to an item, and is set to 1 if the item is included and 0 if
the item is excluded. For instance, the bit string 00110 would place items
3 and 4 inside the knapsacks, excluding the rest.
1 import java.io.File;
2 import java.io.FileReader;
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.io.InputStreamReader;
6 import java.io.Reader;
7 import java.util.regex.Matcher;
8 import java.util.regex.Pattern;
9
10 import org.moeaframework.core.Problem;
11 import org.moeaframework.core.Solution;
12 import org.moeaframework.core.variable.BinaryVariable;
13 import org.moeaframework.core.variable.EncodingUtils;
14 import org.moeaframework.util.Vector;
15 import org.moeaframework.util.io.CommentedLineReader;
16
17 /**
18 * Multiobjective 0/1 knapsack problem.
19 */
20 public class Knapsack implements Problem {
21
22 /**
23 * The number of sacks.
24 */
25 private int nsacks;
26
27 /**
28 * The number of items.
29 */
30 private int nitems;
31
32 /**
33 * Entry {@code profit[i][j]} is the profit from including
7.3. IMPLEMENTING THE PROBLEM 71
79 * instance
80 * @throws IOException if an I/O error occurred
81 * /
82 public Knapsack(Reader reader) throws IOException {
83 super();
84
85 load(reader);
86 }
87
88 /**
89 * Loads the knapsack problem instance from the specified
90 * reader.
91 *
92 * @param reader the file containing the knapsack problem
93 * instance
94 * @throws IOException if an I/O error occurred
95 * /
96 private void load(Reader reader) throws IOException {
97 Pattern specificationLine = Pattern.compile("knapsack
problem specification \\((\\d+) knapsacks, (\\d+) items
\\)");
98 Pattern capacityLine = Pattern.compile(" capacity: \\+(\\d+)
");
99 Pattern weightLine = Pattern.compile(" weight: \\+(\\d+)");
100 Pattern profitLine = Pattern.compile(" profit: \\+(\\d+)");
101
166
167 @Override
168 public void evaluate(Solution solution) {
169 boolean[] d = EncodingUtils.getBinary(
170 solution.getVariable(0));
171 double[] f = new double[nsacks];
172 double[] g = new double[nsacks];
173
198 @Override
199 public String getName() {
200 return "Knapsack";
201 }
202
203 @Override
204 public int getNumberOfConstraints() {
205 return nsacks;
206 }
207
208 @Override
209 public int getNumberOfObjectives() {
210 return nsacks;
7.3. IMPLEMENTING THE PROBLEM 75
211 }
212
213 @Override
214 public int getNumberOfVariables() {
215 return 1;
216 }
217
218 @Override
219 public Solution newSolution() {
220 Solution solution = new Solution(1, nsacks, nsacks);
221 solution.setVariable(0, EncodingUtils.newBinary(nitems));
222 return solution;
223 }
224
225 @Override
226 public void close() {
227 //do nothing
228 }
229
230 }
violated and we set the constraint to a non-zero value (line 189). To reiterate,
constraints that are satisfied have a value of zero; violated constraints have
non-zero values (both positive and negative).
Lastly, we set the objective values on line 194 and the constraint values on
line 195. Note on line 194 how we negate the objective values. This is because
we are trying to maximize the objectives (the profits). See Section 10.3 for
additional details on maximizing objectives.
1 import java.io.File;
2 import java.io.IOException;
3 import java.io.InputStream;
4 import org.moeaframework.Executor;
5 import org.moeaframework.core.NondominatedPopulation;
6 import org.moeaframework.core.Solution;
7 import org.moeaframework.util.Vector;
8
9 /**
10 * Example of binary optimization using the {@link Knapsack}
11 * problem
12 */
13 public class KnapsackExample {
14
15 /**
16 * Starts the example running the knapsack problem.
17 *
18 * @param args the command line arguments
19 * @throws IOException if an I/O error occurred
20 */
21 public static void main(String[] args) throws IOException {
22 // solve using NSGA-II
23 NondominatedPopulation result = new Executor()
24 .withProblemClass(Knapsack.class,
25 new File("knapsack.5.2"))
26 .withAlgorithm("NSGAII")
27 .withMaxEvaluations(50000)
7.5. CONCLUSION 77
28 .distributeOnAllCores()
29 .run();
30
31 // print the results
32 for (int i = 0; i < result.size(); i++) {
33 Solution solution = result.get(i);
34 double[] objectives = solution.getObjectives();
35
48 }
Here, we are using the Executor to configure and solve the Knapsack
problem. Please refer to Chapter 3 for more details. You can now run this
example code. If all goes well, you will see output similar to:
Solution 1:
Sack 1 Profit: 259.0
Sack 2 Profit: 133.0
Binary String: 01011
In this case, only one Pareto optimal solution was found. You can see
the profits for each knapsack as well as identify which items were selected in
this solution from the binary string being displayed.
7.5 Conclusion
This chapter walked you through a complete example of defining a new prob-
lem and solving it using the MOEA Framework. You should now have a gen-
eral understanding of using the MOEA Framework. We recommend walking
78 CHAPTER 7. EXAMPLE: KNAPSACK PROBLEM
through the other examples in the examples folder provided in the source
code distribution.
Part II
79
Chapter 8
Comparative Studies
81
82 CHAPTER 8. COMPARATIVE STUDIES
is important. Several such test suites have been developed in the literature
and are provided by the MOEA Framework. These include the ZDT, DTLZ,
WFG and CEC 2009 test problem suites.
Once the experimental design is set, you can begin running the experi-
ments and collecting data. The MOEA Framework provides all of the tools
for these analyses. For large-scale comparative studies, one should consider
the available computing resources. The MOEA Framework can run in nearly
any computing environment, from desktop computers to massive supercom-
puters. Regardless of the computing environment, the following sections walk
through all the steps needed to perform a complete comparative study.
java CommandName
--argument1 value1
--argument2 value2
All arguments have long and short versions. The long version is preceded
by two dashes, such as --input. The short version is a single dash followed
by a single character, such as -i. See the --help documentation for the
long and short versions for all arguments.
The end of this chapter includes a complete Unix script for executing all
commands discussed throughout this chapter.
The parameter names must match the parameters listed in the doc-
umentation for the algorithm. For this example, this file is located at
NSGAII_Params.
java org.moeaframework.analysis.sensitivity.SampleGenerator
--method latin
8.5. EVALUATION 85
--numberOfSamples 1000
--parameterFile NSGAII_Params
--output NSGAII_Latin
8.5 Evaluation
Evaluation is the time-consuming step, as each parameter sample must be
executed by the algorithm. The evaluation process reads each line from the
parameter file, configures the algorithm with those parameters, executes the
algorithm and saves the results to a result file. This result file contains the
approximation sets produced by each run of the algorithm. Entries in the
result file align with the corresponding parameter sample. For example, since
we generated 1000 parameter samples in the prior step, the result file will
contain 1000 approximation sets when evaluation completes.
Furthermore, to improve the statistical quality of the results, it is a com-
mon practice to repeat the evaluation of each parameter sample multiple
times using different pseudo-random number generator seeds. Stochastic
search algorithms like MOEAs require randomness in several key areas, in-
cluding 1) generating the initial search population; 2) selecting the parent
individuals from the search population; 3) determining which decision vari-
ables to modify and the extent of the modification; and 4) determining which
offspring survive to the next generation. In some cases, these sources of ran-
domness can significantly impact the algorithms behavior. Replicating the
evaluations using multiple random seeds increases the statistical robustness
of the results.
The following command runs a single seed. Note the naming convention
used for the output files. The overall filename format used in these examples
for result files is {algorithm} {problem} {seed} with the .set exten-
sion to indicate result files containing approximation sets. It is not necessary
to follow this convention, but doing so is extremely helpful for organizing the
files.
java org.moeaframework.analysis.sensitivity.Evaluator
86 CHAPTER 8. COMPARATIVE STUDIES
--parameterFile NSGAII_Params
--input NSGAII_Latin
--seed 15
--problem DTLZ2_2
--algorithm NSGAII
--output NSGAII_DTLZ2_2_15.set
This command will be invoked once for each seed, changing the --seed
value and the --output filename each time. Using at least 50 seeds is
recommended unless the computational demands are prohibitive.
java org.moeaframework.analysis.sensitivity.ResultFileInfo
--problem DTLZ2_2
NSGAII_DTLZ2_2_*.set
Since our example used 1000 parameter samples, each result file should
contain 1000 approximation sets.
NSGAII_DTLZ2_2_0.set 1000
NSGAII_DTLZ2_2_1.set 1000
NSGAII_DTLZ2_2_2.set 952
NSGAII_DTLZ2_2_3.set 1000
...
java org.moeaframework.analysis.sensitivity.ResultFileMerger
--problem DTLZ2_2
--output DTLZ2_2.reference
NSGAII_DTLZ2_2_*.set GDE3_DTLZ2_2_*.set
When using the true Pareto optimal set when calculating performance
metrics (discussed in the following section), the results are said to be absolute.
Using the best known approximation produces relative performance metrics.
java org.moeaframework.analysis.sensitivity.ResultFileEvaluator
--reference DTLZ2_2.reference
--input NSGAII_DTLZ2_2_15.set
--problem DTLZ2_2
88 CHAPTER 8. COMPARATIVE STUDIES
--output NSGAII_DTLZ2_2_15.metrics
Note the use of our filename convention with the .metrics extension
to indicate a file containing performance metric results. Each row in this
file contains the performance metrics for a single approximation set. The
performance metrics on each line appear in the order:
java org.moeaframework.analysis.sensitivity.SimpleStatistics
--mode average
--output NSGAII_DTLZ2_2.average
NSGAII_DTLZ2_2_*.metrics
8.10 Analysis
Finally, we can begin analyzing the data. The first analytical step is to
generate descriptive statistics for the data. Three common statistics are the
best achieved result, probability of attainment, and efficiency. The following
command is used to calculate these statistics.
java org.moeaframework.analysis.sensitivity.Analysis
--parameterFile NSGAII_Params
8.10. ANALYSIS 89
--parameters NSGAII_Latin
--metric 1
--threshold 0.75
--efficiency
NSGAII_DTLZ2_2.average
Note that the --metric argument specifies which of the six performance
metrics are used when calculating the results. In this example, --metric
1 selects the generational distance metric. The output of this command will
appear similar to:
NSGAII_DTLZ2_2.average:
Best: 0.98
Attainment: 0.53
Efficiency: 0.38
8.10.1 Best
The best attained value measures the absolute best performance observed
across all parameters. The value is normalized so that 1.0 indicates the best
possible result and 0.0 indicates the worst possible result. In the example
output, a best achieved value of 0.98 indicates at least one parameter setting
produced a near-optimal generational distance (within 2% of the optimum).
8.10.2 Attainment
While an optimization algorithm may produce near-optimal results, it will
be useless unless it can consistently produce good results. The probability of
attainment measures the reliability of an algorithm. Recall that we used
the --threshold 0.75 argument when invoking the command above.
The probability of attainment measures the percentage of parameter samples
which meet or exceed this threshold. The threshold can be varied from 0.0
to 1.0. In the example output, a probability of attainment of 0.53 indicates
only half of the parameter samples reached or exceeded the 75% threshold.
90 CHAPTER 8. COMPARATIVE STUDIES
8.10.3 Efficiency
Another important consideration is the computational resources required by
an optimization algorithm. An algorithm which can quickly produce near-
optimal results is preferred over an algorithm that runs for an eternity. Ef-
ficiency is a measure of the number of function evaluations (NFE) required
to reach the threshold with high likelihood. Efficiency values are normalized
so that 1.0 represents the most efficient algorithm and 0.0 indicates the least
efficient.
In this example, NSGA-II reports an efficiency of 0.38. Recall that we
set the upper bound for maxEvaluations to 1000000 in the parameter
description file for NSGA-II. This implies that it requires at least (1.00.38)
1000000 = 620000 NFE to reach the 75% threshold with high likelihood.
Since the efficiency calculation may be time consuming, you must
specify the --efficiency flag in order to calculate efficiency. There
is a fourth statistic called controllability, which is enabled by the
--controllability flag, but its use is outside the scope of this man-
ual.
java org.moeaframework.analysis.sensitivity.ResultFileMerger
--problem DTLZ2_2
--output NSGAII_DTLZ2_2.set
NSGAII_DTLZ2_2_*.combined
java org.moeaframework.analysis.sensitivity.ResultFileMerger
--problem DTLZ2_2
8.12. SOBOL ANALYSIS 91
--output GDE3_DTLZ2_2.set
GDE3_DTLZ2_2_*.combined
java org.moeaframework.analysis.sensitivity.SetContribution
--reference DTLZ2_2.reference
NSGAII_DTLZ2_2.combined GDE3_DTLZ2_2.combined
NSGAII_DTLZ2_2.combined 0.71
GDE3_DTLZ2_2.combined 0.29
Note that it is possible for the percentages to sum to more than 1 if the
contributions of each optimization algorithm overlap.
The impact of the problem is largely outside our control. Harder problems
are simply harder to solve. But, its impact can be mitigated by selecting an
appropriate optimization algorithm and carefully configuring its parameters.
92 CHAPTER 8. COMPARATIVE STUDIES
java org.moeaframework.analysis.sensitivity.SobolAnalysis
--parameterFile NSGAII_Params
--input NSGAII_DTLZ2_2.average
--metric 0
8.13. EXAMPLE SCRIPT FILE (UNIX/LINUX) 93
The output from this command will appear similar to the following.
First-Order Effects
populationSize 0.15 [0.04]
maxEvaluations 0.45 [0.03]
...
Total-Order Effects
populationSize 0.49 [0.06]
maxEvaluations 0.83 [0.05]
...
Second-Order Effects
populationSize * maxEvaluations 0.21 [0.04]
...
run. You may also modify the parameter sampling method (METHOD), the
problem being tested (PROBLEM), and the list of algorithms being compared
(ALGORITHMS).
1 NSAMPLES=1000
2 NSEEDS=50
3 METHOD=Saltelli
4 PROBLEM=UF1
5 ALGORITHMS=( NSGAII GDE3 )
6
7 SEEDS=$(seq 1 ${NSEEDS})
8 JAVA_ARGS="-Djava.ext.dirs=lib -Xmx512m"
9 set -e
10
11 # Clear old data
12 echo -n "Clearing old data (if any)..."
13 rm *_${PROBLEM}_*.set
14 rm *_${PROBLEM}_*.metrics
15 echo "done."
16
17 # Generate the parameter samples
18 echo -n "Generating parameter samples..."
19 for ALGORITHM in ${ALGORITHMS[@]}
20 do
21 java ${JAVA_ARGS}
org.moeaframework.analysis.sensitivity.SampleGenerator -m
${METHOD} -n ${NSAMPLES} -p ${ALGORITHM}_Params -o
${ALGORITHM}_${METHOD}
22 done
23 echo "done."
24
25 # Evaluate all algorithms for all seeds
26 for ALGORITHM in ${ALGORITHMS[@]}
27 do
28 echo "Evaluating ${ALGORITHM}:"
29 for SEED in ${SEEDS}
30 do
31 echo -n " Processing seed ${SEED}..."
32 java ${JAVA_ARGS}
org.moeaframework.analysis.sensitivity.Evaluator -p
${ALGORITHM}_Params -i ${ALGORITHM}_${METHOD} -b
${PROBLEM} -a ${ALGORITHM} -s ${SEED} -o
${ALGORITHM}_${PROBLEM}_${SEED}.set
33 echo "done."
34 done
8.13. EXAMPLE SCRIPT FILE (UNIX/LINUX) 95
35 done
36
67 echo "done."
68 done
69
70 # Perform the analysis
71 echo ""
72 echo "Analysis:"
73 for ALGORITHM in ${ALGORITHMS[@]}
74 do
75 java ${JAVA_ARGS}
org.moeaframework.analysis.sensitivity.Analysis -p
${ALGORITHM}_Params -i ${ALGORITHM}_${METHOD} -m 1
${ALGORITHM}_${PROBLEM}.average
76 done
77
Note that the above script sets a walltime of 96 hours. You should adjust
this value according to the walltime limit on your particular PBS queue. Jobs
will be terminated by the PBS system if their wall-clock time exceeds this
time limit. After all jobs terminate, use ResultFileInfo to check if the
results are complete. If any results are incomplete, simply rerun the script
above. The Evaluator automatically resumes processing where it left off.
In summary, the execution of a comparative study using PBS will gener-
ally follow these steps:
3. Submit the evaluation jobs to PBS and wait for them to finish
8.15 Conclusion
This chapter introduced techniques for performing comparative studies be-
tween two or more optimization algorithms. Using these techniques is
strongly encouraged since they ensure results are rigorous and statistically
sound. The final section in this chapter, Section 8.16, includes troubleshoot-
ing steps if you encounter issues while using any of the tools discussed in this
chapter.
8.16 Troubleshooting
The Evaluator or Analysis command throws an error saying maxEvaluations
not defined.
This error occurs when the output file contains more entries than
the input file, which indicates an inconsistency between the two
files. The output file should never have more entries than the
input file. You must delete the output file and restart evaluation
from the beginning.
This error occurs when the reference set file is missing, could not
be accessed, or is corrupted. The error message should include
additional details describing the cause of the error. Typically,
you will need to change the --reference argument to point to
a valid reference set file.
100 CHAPTER 8. COMPARATIVE STUDIES
Optimization Algorithms
9.1.1 -MOEA
-MOEA is a steady-state MOEA that uses -dominance archiving to record
a diverse set of Pareto optimal solutions. Full details of this algorithm are
available in the following technical report:
Use the string "eMOEA" when creating instances of this algorithm with the
Executor. The following parameters are available:
103
Table 9.1: List of available optimization algorithms.
CHAPTER 9. OPTIMIZATION ALGORITHMS
Parameter Description
populationSize The size of the population
epsilon The values used by the -dominance archive,
which can either be a single value or a comma-
separated array
sbx.rate The crossover rate for simulated binary crossover
sbx.distributionIndex The distribution index for simulated binary
crossover
pm.rate The mutation rate for polynomial mutation
pm.distributionIndex The distribution index for polynomial mutation
9.1.2 NSGA-II
NSGA-II is one of the most widely used MOEAs and was introduced in the
following paper:
Deb, K. et al. A Fast Elitist Multi-Objective Genetic Algo-
rithm: NSGA-II. IEEE Transactions on Evolutionary Compu-
tation, 6:182-197, 2000.
Use the string "NSGAII" when creating instances of this algorithm with
the Executor. The following parameters are available:
Parameter Description
populationSize The size of the population
sbx.rate The crossover rate for simulated binary crossover
sbx.distributionIndex The distribution index for simulated binary
crossover
pm.rate The mutation rate for polynomial mutation
pm.distributionIndex The distribution index for polynomial mutation
9.1.3 -NSGA-II
-NSGA-II is an extension of NSGA-II that uses an -dominance archive and
randomized restart to enhance search and find a diverse set of Pareto optimal
solutions. Full details of this algorithm are given in the following paper:
Kollat, J. B., and Reed, P. M. Comparison of Multi-Objective
Evolutionary Algorithms for Long-Term Monitoring Design.
Advances in Water Resources, 29(6):792-807, 2006.
106 CHAPTER 9. OPTIMIZATION ALGORITHMS
Use the string "eNSGAII" when creating instances of this algorithm with
the Executor. The following parameters are available:
Parameter Description
populationSize The size of the population
epsilon The values used by the -dominance archive,
which can either be a single value or a comma-
separated array
sbx.rate The crossover rate for simulated binary crossover
sbx.distributionIndex The distribution index for simulated binary
crossover
pm.rate The mutation rate for polynomial mutation
pm.distributionIndex The distribution index for polynomial mutation
injectionRate Controls the percentage of the population after a
restart this is injected, or copied, from the -
dominance archive
9.1.4 MOEA/D
MOEA/D is a relatively new optimization algorithm based on the concept
of decomposing the problem into many single-objective formulations. Two
versions of MOEA/D exist in the literature. The first, based on the paper
cited below, is the original incarnation:
Li, H. and Zhang, Q. Multiobjective Optimization problems
with Complicated Pareto Sets, MOEA/D and NSGA-II. IEEE
Transactions on Evolutionary Computation, 13(2):284-302, 2009.
An extension to the original MOEA/D algorithm introduced a utility func-
tion that aimed to reduce the amount of wasted effort by the algorithm.
Full details of this extension are available in the following paper:
Zhang, Q., et al. The Performance of a New Version of
MOEA/D on CEC09 Unconstrained MOP Test Instances. IEEE
Congress on Evolutionary Computation, 2009.
Use the string "MOEAD" when creating instances of this algorithm with the
Executor. The parameters listed below are available. Note that if the
updateUtility parameter is NOT defined, then the original MOEA/D
implementation is used. If updateUtility is set, then the utility-based
9.1. NATIVE ALGORITHMS 107
extension is enabled.
Parameter Description
populationSize The size of the population
de.crossoverRate The crossover rate for differential evolution
de.stepSize Control the size of each step taken by differential
evolution
pm.rate The mutation rate for polynomial mutation
pm.distributionIndex The distribution index for polynomial mutation
neighborhoodSize The size of the neighborhood used for mating,
given as a percentage of the population size
delta The probability of mating with an individual from
the neighborhood versus the entire population
eta The maximum number of spots in the population
that an offspring can replace, given as a percentage
of the population size
updateUtility The frequency, in generations, at which utility val-
ues are updated
9.1.5 GDE3
GDE3 is the extension of differential evolution for multiobjective problems.
It was originally introduced in the following technical report:
Use the string "GDE3" when creating instances of this algorithm with the
Executor. The following parameters are available:
Parameter Description
populationSize The size of the population
de.crossoverRate The crossover rate for differential evolution
de.stepSize Control the size of each step taken by differential evo-
lution
108 CHAPTER 9. OPTIMIZATION ALGORITHMS
Parameter Description
populationSize This parameter only has a use when parallelizing evalua-
tions; it controls the number of solutions that are gener-
ated and evaluated in parallel
epsilon The values used by the -dominance archive, which can
either be a single value or a comma-separated array (this
parameter is optional)
Parameter Description
sbx.rate The crossover rate for simulated binary crossover
sbx.distributionIndex The distribution index for simulated binary
crossover
pm.rate The mutation rate for polynomial mutation
pm.distributionIndex The distribution index for polynomial mutation
For binary encodings, the additional parameters are:
9.2. JMETAL ALGORITHMS 109
Parameter Description
1x.rate The crossover rate for single-point crossover
bf.rate The mutation rate for bit flip mutation
For permutation encodings, the additional parameters are:
Parameter Description
pmx.rate The crossover rate for PMX crossover
swap.rate The mutation rate for the swap operator
9.2.1 AbYSS
AbYSS is a hybrid scatter search algorithm that uses genetic algorithm op-
erators. It was originally introduced in the following paper:
Use the string "AbYSS" when creating instances of this algorithm with
the Executor. Only real-valued decision variables are supported. The
following parameters are available:
Parameter Description
populationSize The size of the population
archiveSize The size of the archive
refSet1Size The size of the first reference set
refSet2Size The size of the second reference set
improvementRounds The number of iterations that the local search op-
erator is applied
9.2.2 CellDE
CellDE is a hybrid cellular genetic algorithm (meaning mating only occurs
among neighbors) combined with differential evolution. CellDE was intro-
duced in the following study:
Use the string "CellDE" when creating instances of this algorithm with the
Executor. CellDE defines its own parameters for its real-valued operators
as listed below:
Parameter Description
populationSize The size of the population
archiveSize The size of the archive
feedBack Controls the number of solutions from the archive that
are fed back into the population
de.crossoverRate The crossover rate for differential evolution
de.stepSize Control the size of each step taken by differential evo-
lution
9.2.3 DENSEA
DENSEA is the duplicate elimination non-domination sorting evolutionary
algorithm discussed in the following paper:
D. Greiner, et al. Enhancing the multiobjective optimum de-
sign of structural trusses with evolutionary algorithms using
DENSEA. 44th AIAA (American Institute of Aeronautics and
Astronautics) Aerospace Sciences Meeting and Exhibit, AIAA-
2006-1474, 2006.
Use the string "DENSEA" when creating instances of this algorithm with
the Executor. DENSEA supports real-valued, binary, and permutation
encodings. The following parameters are available:
Parameter Description
populationSize The size of the population
9.2.4 FastPGA
FastPGA is a genetic algorithm that uses adaptive population sizing to solve
time-consumping problems more efficiencly. It was introduced in the follow-
ing paper:
Eskandari, H., et al. FastPGA: A Dynamic Population Siz-
ing Approach for Solving Expensive Multiobjective Optimiza-
tion Problems. Evolutionary Multi-Criterion Optimization,
Springer, 141-155, 2007.
9.2. JMETAL ALGORITHMS 111
Use the string "FastPGA" when creating instances of this algorithm with
the Executor. FastPGA supports real-valued, binary, and permutation
encodings. The following parameters are available:
Parameter Description
maxPopSize The maximum size of the population
initialPopulationSize The initial size of the population
a Constant controlling the population size
b Multiplier controlling the population size
c Constant controlling the number of offspring
d Multiplier controlling the number of offspring
termination If 0, the algorithm terminates early if all solutions
like on the Pareto optimal front
9.2.5 IBEA
IBEA is a indicator-based MOEA that uses the hypervolume performance
indicator as a means to rank solutions. IBEA was introduced in the following
paper:
Zitzler, E. and Kunzli, S. Indicator-based selection in multiob-
jective search. In Parallel Problem Solving from Nature (PPSN
VIII), Lecture Notes in Computer Science, pages 832842, Berlin
/ Heidelberg, Springer, 2004.
Use the string "IBEA" when creating instances of this algorithm with the
Executor. IBEA supports real-valued, binary, and permutation encodings.
The following parameters are available:
Parameter Description
populationSize The size of the population
archiveSize The size of the archive
9.2.6 MOCell
MOCell is the multiobjective version of a cellular genetic algorithm. It was
originally introduced at the following workshop:
Nebro, A. J., et al. A Cellular Genetic Algorithm for Multi-
objective Optimization. Proceedings of the Workshop on Na-
112 CHAPTER 9. OPTIMIZATION ALGORITHMS
Use the string "MOCell" when creating instances of this algorithm with
the Executor. MOCell supports real-valued, binary, and permutation
encodings. The following parameters are available:
Parameter Description
populationSize The size of the population
archiveSize The size of the archive
feedBack Controls the number of solutions from the archive that
are fed back into the population
9.2.7 MOCHC
Use the string "MOCHC" when creating instances of this algorithm with the
Executor. MOCHC defines its own parameters for its search operators as
listed below:
9.2. JMETAL ALGORITHMS 113
Parameter Description
initialConvergenceCount The threshold (as a percent of the number of
bits in the encoding) used to determine similar-
ity between solutions
preservedPopulation The percentage of the population that does not
undergo cataclysmic mutation
convergenceValue The convergence threshold that determines
when cataclysmic mutation is applied
populationSize The size of the population
hux.rate The crossover rate for the highly disruptive re-
combination operator
bf.rate The mutation rate for bit-flip mutation
9.2.8 OMOPSO
OMOPSO is a multiobjective particle swarm optimization algorithm that
includes an -dominance archive to discover a diverse set of Pareto optimal
solutions. OMOPSO was originally introduced at the following conference:
Use the string "OMOPSO" when creating instances of this algorithm with the
Executor. OMOPSO defines its own parameters for its search operators
as listed below:
Parameter Description
populationSize The size of the population
archiveSize The size of the archive
mutationProbability The mutation probability for uniform and non-
uniform mutation
perturbationIndex Controls the shape of the distribution for uniform
and non-uniform mutation
epsilon The values used by the -dominance archive
114 CHAPTER 9. OPTIMIZATION ALGORITHMS
9.2.9 PAES
PAES is a multiobjective version of evolution strategy. PAES tends to under-
perform when compared to other MOEAs, but it is often used as a baseline
algorithm for comparisons. PAES was introduced in the following conference
proceedings:
Use the string "PAES" when creating instances of this algorithm with the
Executor. PAES supports real-valued, binary, and permutation encodings.
The following parameters are available:
Parameter Description
archiveSize The size of the archive
bisections The number of bisections in the adaptive grid archive
9.2.10 PESA-II
PESA-II is another multiobjective evolutionary algorithm that tends to un-
derperform other MOEAs but is often used as a baseline algorithm. PESA-II
was introduced in the following paper:
Use the string "PESA2" when creating instances of this algorithm with
the Executor. PESA-II supports real-valued, binary, and permutation
encodings. The following parameters are available:
Parameter Description
populationSize The size of the population
archiveSize The size of the archive
bisections The number of bisections in the adaptive grid archive
9.2. JMETAL ALGORITHMS 115
9.2.11 SMPSO
SMPSO is a multiobjective particle swarm optimization algorithm that was
originally presented at the following conference:
Use the string "SMPSO" when creating instances of this algorithm with the
Executor. SMPSO defines its own parameters for its operators as listed
below:
Parameter Description
populationSize The size of the population
archiveSize The size of the archive
pm.rate The mutation rate for polynomial mutation
pm.distributionIndex The distribution index for polynomial mutation
9.2.12 SMSEMOA
SMSEMOA is an indicator-based MOEA that uses the volume of the domi-
nated hypervolume to rank individuals. SMSEMOA is discussed in detail in
the following paper:
Use the string "SMSEMOA" when creating instances of this algorithm with
the Executor. SMSEMOA supports real-valued, binary, and permutation
encodings. The following parameters are available:
Parameter Description
populationSize The size of the population
offset -
116 CHAPTER 9. OPTIMIZATION ALGORITHMS
9.2.13 SPEA2
SPEA2 is an older but popular benchmark MOEA that uses the so-called
strength-based method for ranking solutions. SPEA2 was introduced in
the following conference proceedings:
Zitzler, E., et al. SPEA2: Improving the Strength Pareto Evo-
lutionary Algorithm For Multiobjective Optimization. CIMNE,
Barcelona, Spain, 2002.
Use the string "SPEA2" when creating instances of this algorithm with
the Executor. SPEA2 supports real-valued, binary, and permutation
encodings. The following parameters are available:
Parameter Description
populationSize The size of the population
archiveSize The size of the archive
This design offers several benefits. First, it clearly demarcates the respon-
sibilities of algorithm experts from those of application engineers. The algo-
rithm experts focus on designing and improving the behavior of optimization
9.3. PISA ALGORITHMS 117
For this reason, the MOEA Framework provides the support necessary
to integrate with the PISA library. The PISAAlgorithm class acts as a
variator, which knows how to communicate with a PISA selector using the
file-based communication protocol.
118 CHAPTER 9. OPTIMIZATION ALGORITHMS
org.moeaframework.algorithm.pisa.algorithms=HypE
org.moeaframework.algorithm.pisa.HypE.command = ./pisa/hype_win/
hype.exe
org.moeaframework.algorithm.pisa.HypE.parameters = seed,
tournament, mating, bound, nrOfSamples
org.moeaframework.algorithm.pisa.HypE.parameter.tournament = 5
org.moeaframework.algorithm.pisa.HypE.parameter.mating = 1
org.moeaframework.algorithm.pisa.HypE.parameter.bound = 2000
org.moeaframework.algorithm.pisa.HypE.parameter.nrOfSamples = -1
9.3. PISA ALGORITHMS 119
Once completed, you should be able to run the diagnostic tool and confirm
that HypE appears in the list of available algorithms. Additionally, HypE
may be referenced throughout the MOEA Framework wherever the algorithm
is specified as a string, such as:
1 new Executor()
2 .withProblem("Kursawe")
3 .withAlgorithm("HypE")
4 .withMaxEvaluations(10000)
5 .withProperty("bound", 1000)
6 .withProperty("tournament", 2)
7 .run();
9.3.2 Troubleshooting
Im attempting to run the PISA algorithm, but nothing is happening. The
task manager shows the PISA executable is running, but shows 0% CPU
usage.
java.io.tmpdir = C:/temp/
PISA runs fine for a while, but eventually crashes with the message Asser-
tion failed: fp != null.
120 CHAPTER 9. OPTIMIZATION ALGORITHMS
java.io.tmpdir = C:/temp/
9.4 Conclusion
This chapter provided an overview of the optimization algorithms that are
known to work with and extensively tested within the MOEA Framework.
By following the parameterization guidance provided in this chapter and the
information in Table 9.1, you can apply any of these algorithms to solve your
optimization problems.
Chapter 10
Advanced Topics
org.moeaframework.core.indicator.hypervolume_delta = 0.01
http://ls11-www.cs.uni-dortmund.de/rudolph/
hypervolume/start
http://iridia.ulb.ac.be/manuel/hypervolume/
121
122 CHAPTER 10. ADVANCED TOPICS
http://www.wfg.csse.uwa.edu.au/hypervolume/1
Variable Description
{0} Number of objectives
{1} Approximation set size
{2} File containing the approximation set
{3} File containing the reference point
{4} The reference point, separated by spaces
If all else fails, the hypervolume calculation can be disabled. When dis-
abled, the hypervolume will be reported as NaN. To disable all hypervolume
calculations, add the following line to global.properties:
org.moeaframework.core.indicator.hypervolume_enabled = false
23 writer.append(new ResultEntry(algorithm.getResult(),
properties));
124 CHAPTER 10. ADVANCED TOPICS
24 }
25 } finally {
26 //close the result file writer
27 if (writer != null) {
28 writer.close();
29 }
30 }
31 } finally {
32 //close the problem to free any resources
33 if (problem != null) {
34 problem.close();
35 }
36 }
If the file you are saving already exists, the ResultFileWriter ap-
pends any new data to the end of the file. If you do not want to append to
any existing data, delete any old file first.
java org.moeaframework.analysis.sensitivity.ExtractData
--problem UF1
--input result.set
NFE ElapsedTime
#NFE ElapsedTime
100 125
200 156
300 172
10.3. DEALING WITH MAXIMIZED OBJECTIVES 125
400 187
500 203
...
java org.moeaframework.analysis.sensitivity.ExtractData
--problem UF1
--input result.set
--reference ./pf/UF1.dat
NFE ElapsedTime +hypervolume +epsilon +coverage
The added performance indicators will appear alongside the other prop-
erties:
Additional command line options allow you to format the output, such
as removing the column header line or specifying the column separator char-
acter.
1 solution.setObjective(0, obj1);
2 solution.setObjective(1, -obj2); //negate the original objective
value
java org.moeaframework.analysis.sensitivity.Negater
--direction 0,1
output.set
10.4 Checkpointing
The MOEA Framework provides checkpointing functionality. As an algo-
rithm is running, checkpoint files will be periodically saved. The checkpoint
file stores the current state of the algorithm. If the run is interrupted, such as
10.5. REFERENCING THE PROBLEM 127
during a power outage, the run can be resumed at the last saved checkpoint.
The setCheckpointFile sets the file location for the checkpoint file, and
checkpointEveryIteration or setCheckpointFrequency control
how frequently the checkpoint file is saved.
Resuming a run from a checkpoint occurs automatically. If the checkpoint
file does not exist, a run starts from the beginning. However, if the checkpoint
file exists, then the run is automatically resumed at that checkpoint. For this
reason, care must be taken when using checkpoints as they can be a source
of confusion for new users. For instance, using the same checkpoint file from
an unrelated run can cause unexpected behavior or an error. For this reason,
checkpoints are recommended only when solving time-consuming problems.
The code snippet below demonstrates the use of checkpointing.
10.5.1 By Class
The Executor, Instrumenter and Analyzer classes introduced in
Chapter 3 all accept direct references to the problem class using the
withProblemClass method. For example, following the previous example
128 CHAPTER 10. ADVANCED TOPICS
with the Kursawe problem, we can optimize this problem with the following
code:
1 new Executor()
2 .withProblemClass(Kursawe.class)
3 .withAlgorithm("NSGAII")
4 .withMaxEvaluations(10000)
5 .run();
1 new Executor()
2 .withProblemClass(ProblemWithArgument.class, new File("
inputFile.txt"))
3 .withAlgorithm("NSGAII")
4 .withMaxEvaluations(10000)
5 .run();
10.5.3 By Name
The MOEA Framework also provides the option to reference problems
by name. There are two advantages to using this approach. First,
this approach allows the use of short, meaningful names. For example,
rather than specifying the fully-qualified class name for the Schaffer prob-
lem, org.moeaframework.problem.misc.Schaffer, one can use the
name Schaffer instead. Second, a reference set for named problems can
optionally be defined. This reference set will be automatically used wherever
a reference set is required. Without this, a reference set must be manually
specified by the user or programmer each time it is required.
The disadvantage to this approach is that some additional configuration
is necessary to provide the mapping from the problem name to the prob-
lem class. As such, this approach is recommended for third-party library
developers who are developing new problems to be used with the MOEA
Framework. The remainder of this section describes two such methods for
referencing problems by name.
The problem name can be used to run problems anywhere the MOEA
Framework accepts a string representation of the problem. This includes but
is not limited to
1 import org.moeaframework.core.NondominatedPopulation;
2 import org.moeaframework.core.Problem;
3 import org.moeaframework.core.spi.ProblemProvider;
4
5 public class ExampleProblemProvider extends ProblemProvider {
6
7 public Problem getProblem(String name) {
8 if (name.equalsIgnoreCase("kursawe")) {
9 return new Kursawe();
10 } else {
11 return null;
12 }
13 }
14
15 public NondominatedPopulation getReferenceSet(String name) {
16 return null;
17 }
18
19 }
Lastly, a special configuration file used by the SPI must be created. The
file is located at META-INF/services/org.moeaframework.core.
spi.ProblemProvider. Each line of this file must contain the fully-
qualified class name for each of the ProblemProviders being introduced.
10.5. REFERENCING THE PROBLEM 131
When bundling the compiled class files into a JAR, be sure that this config-
uration file is also copied into the JAR.
Once packaged as a JAR, the provider is ready to be used. Place the JAR
on the classpath used by the MOEA Framework. Once on the classpath, the
Java SPI mechanism used by the MOEA Framework will be able to scan and
load all providers contained in all available JAR files.
org.moeaframework.problem.problems = Kursawe
org.moeaframework.problem.Kursawe.class = Kursawe
org.moeaframework.problem.Kursawe.referenceSet = kursawe.ref
132 CHAPTER 10. ADVANCED TOPICS
Part III
133
Chapter 11
Developer Guide
135
136 CHAPTER 11. DEVELOPER GUIDE
Every source code file should begin with a comment containing a copy-
right and license notice.
Bad:
1 import java.util.*;
Good:
1 import java.util.List;
2 import java.util.ArrayList;
Bad:
Good:
Bad:
1 try {
2 Thread.sleep(1000);
3 } catch (InterruptedException e) {}
Good:
1 try {
2 Thread.sleep(1000);
3 } catch (InterruptedException e) {
4 //sleep was interrupted, continue processing
5 }
1 @Override
2 public int hashCode() {
3 return new HashCodeBuilder()
4 .append(algorithm)
5 .append(problem)
6 .toHashCode();
7 }
8
9 @Override
10 public boolean equals(Object obj) {
11 if (obj == this) {
12 return true;
13 } else if ((obj == null) || (obj.getClass() !=
getClass())) {
14 return false;
15 } else {
16 ResultKey rhs = (ResultKey)obj;
11.4. CODE STYLE 139
17
18 return new EqualsBuilder()
19 .append(algorithm, rhs.algorithm)
20 .append(problem, rhs.problem)
21 .isEquals();
22 }
23 }
Bad:
Good:
Bad:
1 if ("yes" == inputTextField.getText()) {
2 ...
3 }
140 CHAPTER 11. DEVELOPER GUIDE
Good:
1 if ("yes".equals(inputTextField.getText()) {
2 ...
3 }
Write only one statement per line. Avoid multiple variable declarations
on one line. Also, initialize variables at their declaration whenever
possible.
Bad:
Good:
Bad:
11.5. LICENSING 141
Good:
11.5 Licensing
The MOEA Framework is licensed under the GNU Lesser General Public
License, version 3 or later. In order to ensure contributions can be legally
released as part of the MOEA Framework, all contributions must be licensed
under the GNU Lesser General Public License, version 3.
Modifications which are not licensed under the GNU Lesser General Pub-
lic License, version 3, can still be bundled with the MOEA Framework library
or distributed as a third-party extension. In fact, the GNU Lesser General
Public License specifically grants users of the MOEA Framework the right
to bundle the library with an application released under any license of their
choosing.
http://www.freecode.com/projects/moea-framework - An-
nounces new releases and other news to the open source community.
http://www.openhatch.org/+projects/MOEA%20Framework
- Provides information for individuals wishing to contribute to the
MOEA Framework.
12.1 Errors
Errors halt the execution of the program and produce an error message to
the standard error stream (i.e., the console). Most errors can be corrected
by the user.
145
146 CHAPTER 12. ERRORS AND WARNING MESSAGES
This Java error occurs when the initial heap size (allocated memory) is
too small to instantiate the Java virtual machine (VM). This error is
likely caused by the -Xmx command line option requesting less memory
than is necessary to start the VM. Increasing the -Xmx value may re-
solve this issue. Also ensure the -Xmx argument is properly formatted.
For instance, use -Xmx128m and NOT -Xmx128.
This Java error occurs when there is insufficient heap size (allocated
memory) to instantiate the Java virtual machine (VM). This error is
likely caused by the -Xmx command line option requesting more mem-
ory than is available on the host system. This error may also occur if
other running processes consume large quantities of memory. Lowering
the -Xmx value may resolve this issue.
PISA modules communicate using the file system. Some anti-virus soft-
ware scans the contents of files before read and after write operations.
This may cause one of the PISA communication files to become inac-
cessible and cause this error. To test if this is the cause, try disabling
your anti-virus and re-run the program.
12.1. ERRORS 147
java.io.tmpdir=<folder>
Several of the command line utilities read entries in an input file and
write the corresponding outputs to a separate output file. If the last
modified date on the input file is newer than the date on the output
file, this exception is thrown. This suggests that the input file has
been modified unexpectedly, and attempting to resume with a partially
evaluated output file may result in incorrect results. To resolve:
Thrown when the user attempts to use an algorithm that does not
support the given problems decision variable encoding. For instance,
GDE3 only supports real-valued encodings, and will throw this excep-
tion if binary or permutation encoded problems are provided.
1. The binary variable length differs from that specified in the prob-
lem definition.
2. The string encoding in the file contains invalid characters.
In either case, the binary variable stored in the result file could not be
read.
invalid permutation
PISA supports the ability to reuse a selector after a run has completed.
The MOEA Framework currently does not support this feature. This
exception is thrown if the PISA selector attempts to reset.
no digest file
Thrown when attempting to validate a data file using a digest file, but
no such digest file exists. Processing of the data file should cease imme-
diately for sensitive applications where data integrity is essential. If the
digest file simply hasnt yet been produced but the file contents are ver-
ified, the FileProtection command line utility can optionally generate
digest files.
Thrown when attempting to validate a date file using a digest file, but
the digest file is corrupted or does not contain a valid digest. Processing
of the data file should cease immediately for sensitive applications where
data integrity is essential.
152 CHAPTER 12. ERRORS AND WARNING MESSAGES
Thrown when attempting to validate a data file using a digest file, but
the actual digest of the data file does not match the expected digest
contained in the digest file. This indicates that the data file or the digest
file are corrupted. Processing of the data file should cease immediately
for sensitive applications where data integrity is essential.
Attempted to use the Java Scripting APIs, but no engine for the spec-
ified file extension could be found. To resolve:
1. Check that the extension is valid. If not, supply the file extension
for the scripting language required.
2. Ensure the scripting language engine is listed on the classpath.
The engine, if packaged in a JAR, can be specified with
java -classpath "$CLASSPATH:/path/to/
engine.jar"
Also ensure you are using the correct classpath separator. Linux
users will use the colon (:) as the above example demonstrates.
Windows and Cygwin users should use the semi-colon (;).
12.1. ERRORS 153
Attempted to use the Java Scripting APIs, but no engine with the
specified name was found.
1. Check that the name is valid. If not, supply the correct name for
the scripting language engine as required.
2. Ensure the scripting language engine is listed on the classpath.
The engine, if packaged in a JAR, can be specified with
java -classpath "$CLASSPATH:/path/to/
engine.jar"
Also ensure you are using the correct classpath separator. Linux
users will use the colon (:) as the above example demonstrates.
Windows and Cygwin users should use the semi-colon (;).
Thrown when using a scripting language engine which does not im-
plement the Invocable interface. The scripting language does not
support methods or functions, and thus can not be used as intended.
Attempted to use one of the n-ary statistical tests which require at least
two groups. Either add a second group to compare against, or remove
the statistical test.
Attempted to read a data file, but the row was missing one or more
entries. The exact meaning depends on the specific data file, but gen-
erally this error means the file is incomplete, improperly formatted or
corrupted. See the documentation on the various file types to determine
if this error can be corrected.
Attempted to read a data file, but an entry was not formatted correctly.
See the documentation on the various file types to determine if this error
can be corrected.
Attempted to set the decision variable values using an array, but the
number of elements in the array does not match the required number
of elements. For EncodingUtils.setReal and EncodingUtils
.setInt, ensure the number of real-valued/integer-valued decision
variables being set matches the array length. For EncodingUtils.
setBinary, ensure the number of bits expressed in the binary variable
matches the array length.
12.1. ERRORS 155
-x name=value
-x name1=value1;name2=value2;name3=value3
an unclean version of the file exists from a previous run, requires manual
intervention
156 CHAPTER 12. ERRORS AND WARNING MESSAGES
These two exceptions are thrown when using the Normalizer with a
degenerate population. A degenerate population either has fewer than
two solutions or the range of any objective is below computer precision.
In this scenario, the population can not be normalized.
invalid variable specification value, not properly formatted invalid real spec-
ification value, expected R(lb,ub) invalid binary specification value,
expected B(length) invalid permutation specification value, expected
P(length) invalid variable specification value, unknown type
--variables "R(0;1),B(5),P(10),R(-1;1)"
Also, always surround the argument with quotes as shown in this ex-
ample.
must specify either the problem, the variables, or the lower and upper bounds
arguments
12.2. WARNINGS 157
12.2 Warnings
Warnings are messages printed to the standard error stream (i.e., the con-
sole) that indicate an abnormal or unsafe condition. While warnings do not
indicate an error occurred, they do indicate caution is required by the user.
Also ensure you are using the correct classpath separator. Linux users
will use the colon (:) as the above example demonstrates. Windows
and Cygwin users should use the semi-colon (;).
Emitted by the Negater command line utility when one of the files
it is processing contains an invalid number of values in a row. The file
is expected to contain the same number of values in a row as values
passed to the -d,--direction command line argument. The file
will not be modified if this issue is detected.
Emitted by the Negater command line utility when one of the files
it is processing encounters a value it is unable to parse. The columns
being negated must be numeric values. The file will not be modified if
this issue is detected.
argument is null or
<class> not assignable from <class>
within the tree are non-null. The warning <class> not assignable
from <class> indicates the required type of an argument did not
match the return type of the argument. If this warning appears when
using Sequence, For or While nodes, ensure you specify the return
type of these nodes using the appropriate constructor.
unable to parse solution, ignoring remaining entries in the file or
insufficient number of entries in row, ignoring remaining rows in the file
Occurs when MetricFileReader or ResultFileReader en-
counter invalid data in an input file. They automatically discard any
remaining entries in the file, assuming they are corrupt. This is pri-
marily intended to allow the software to automatically recover from a
previous, interrupted execution. These warnings are provided to inform
the user that invalid entries are being discarded.
Unable to find the file file
This warning is shown when running an example that must load a data
file but the data file could not be found. Ensure that the examples
directory is located on your classpath:
java -classpath "$CLASSPATH:examples" ...
Also ensure you are using the correct classpath separator. Linux users
will use the colon (:) as the above example demonstrates. Windows
and Cygwin users should use the semi-colon (;).
incorrect number of names, using defaults
Occurs when using the --names argument provided by
ARFFConverter and AerovisConverter to provide custom
names for the decision variables and/or objectives, but the number of
names provided is not correct. When providing names for only the
objectives, the number of names must match the number of objectives.
When providing names for both variables and objectives, the number
of names must match the number of variables and objectives in the
data file. Otherwise, this warning is displayed and the program uses
default names.
population is empty, can not generate ARFF file
The ARFFConverter outputs an ARFF file using the last entry in a
result file. If the last entry is empty, then no ARFF file is generated.
Credits
David Hadka, the lead developer of the MOEA Framework and primary
author of this user manual.
Icons from the Nuvola theme, released under the GNU Lesser Gen-
eral Public License, version 2.1, and available at http://www.
icon-king.com/projects/nuvola/.
Icons from the FAMFAMFAM Silk icon set, released under the Cre-
ative Commons Attribution 3.0 license and available at http://www.
famfamfam.com/.
161
162 CREDITS
GNU Free Documentation
License
Copyright 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
http://fsf.org/
0. PREAMBLE
The purpose of this License is to make a manual, textbook, or other functional
and useful document free in the sense of freedom: to assure everyone the
effective freedom to copy and redistribute it, with or without modifying it,
either commercially or noncommercially. Secondarily, this License preserves
for the author and publisher a way to get credit for their work, while not
being considered responsible for modifications made by others.
This License is a kind of copyleft, which means that derivative works
of the document must themselves be free in the same sense. It complements
the GNU General Public License, which is a copyleft license designed for free
software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free program
should come with manuals providing the same freedoms that the software
does. But this License is not limited to software manuals; it can be used
for any textual work, regardless of subject matter or whether it is published
as a printed book. We recommend this License principally for works whose
163
164 GNU FREE DOCUMENTATION LICENSE
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either commer-
cially or noncommercially, provided that this License, the copyright notices,
and the license notice saying this License applies to the Document are re-
produced in all copies, and that you add no other conditions whatsoever to
those of this License. You may not use technical measures to obstruct or
control the reading or further copying of the copies you make or distribute.
However, you may accept compensation in exchange for copies. If you dis-
tribute a large enough number of copies you must also follow the conditions
in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printed
covers) of the Document, numbering more than 100, and the Documents
license notice requires Cover Texts, you must enclose the copies in covers
that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on
the front cover, and Back-Cover Texts on the back cover. Both covers must
also clearly and legibly identify you as the publisher of these copies. The front
cover must present the full title with all words of the title equally prominent
and visible. You may add other material on the covers in addition. Copying
with changes limited to the covers, as long as they preserve the title of the
Document and satisfy these conditions, can be treated as verbatim copying
in other respects.
If the required texts for either cover are too voluminous to fit legibly,
you should put the first ones listed (as many as fit reasonably) on the actual
cover, and continue the rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document number-
ing more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using public
has access to download using public-standard network protocols a complete
Transparent copy of the Document, free of added material. If you use the
latter option, you must take reasonably prudent steps, when you begin dis-
167
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under the
conditions of sections 2 and 3 above, provided that you release the Modified
Version under precisely this License, with the Modified Version filling the
role of the Document, thus licensing distribution and modification of the
Modified Version to whoever possesses a copy of it. In addition, you must
do these things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct from that
of the Document, and from those of previous versions (which should, if
there were any, be listed in the History section of the Document). You
may use the same title as a previous version if the original publisher of
that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified Version,
together with at least five of the principal authors of the Document (all
of its principal authors, if it has fewer than five), unless they release
you from this requirement.
C. State on the Title page the name of the publisher of the Modified
Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications adjacent to
the other copyright notices.
F. Include, immediately after the copyright notices, a license notice giving
the public permission to use the Modified Version under the terms of
this License, in the form shown in the Addendum below.
168 GNU FREE DOCUMENTATION LICENSE
G. Preserve in that license notice the full lists of Invariant Sections and
required Cover Texts given in the Documents license notice.
I. Preserve the section Entitled History, Preserve its Title, and add to
it an item stating at least the title, year, new authors, and publisher of
the Modified Version as given on the Title Page. If there is no section
Entitled History in the Document, create one stating the title, year,
authors, and publisher of the Document as given on its Title Page, then
add an item describing the Modified Version as stated in the previous
sentence.
J. Preserve the network location, if any, given in the Document for public
access to a Transparent copy of the Document, and likewise the network
locations given in the Document for previous versions it was based on.
These may be placed in the History section. You may omit a network
location for a work that was published at least four years before the
Document itself, or if the original publisher of the version it refers to
gives permission.
Document, you may at your option designate some or all of these sections
as invariant. To do this, add their titles to the list of Invariant Sections in
the Modified Versions license notice. These titles must be distinct from any
other section titles.
You may add a section Entitled Endorsements, provided it contains
nothing but endorsements of your Modified Version by various partiesfor
example, statements of peer review or that the text has been approved by
an organization as the authoritative definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover
Texts in the Modified Version. Only one passage of Front-Cover Text and
one of Back-Cover Text may be added by (or through arrangements made
by) any one entity. If the Document already includes a cover text for the
same cover, previously added by you or by arrangement made by the same
entity you are acting on behalf of, you may not add another; but you may
replace the old one, on explicit permission from the previous publisher that
added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or imply
endorsement of any Modified Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified versions,
provided that you include in the combination all of the Invariant Sections
of all of the original documents, unmodified, and list them all as Invariant
Sections of your combined work in its license notice, and that you preserve
all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and mul-
tiple identical Invariant Sections may be replaced with a single copy. If there
are multiple Invariant Sections with the same name but different contents,
make the title of each such section unique by adding at the end of it, in
parentheses, the name of the original author or publisher of that section if
known, or else a unique number. Make the same adjustment to the section
titles in the list of Invariant Sections in the license notice of the combined
work.
170 GNU FREE DOCUMENTATION LICENSE
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this License
in the various documents with a single copy that is included in the collection,
provided that you follow the rules of this License for verbatim copying of each
of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this License
into the extracted document, and follow this License in all other respects
regarding verbatim copying of that document.
8. TRANSLATION
Translation is considered a kind of modification, so you may distribute trans-
lations of the Document under the terms of section 4. Replacing Invariant
Sections with translations requires special permission from their copyright
holders, but you may include translations of some or all Invariant Sections in
addition to the original versions of these Invariant Sections. You may include
a translation of this License, and all the license notices in the Document, and
any Warranty Disclaimers, provided that you also include the original En-
glish version of this License and the original versions of those notices and
disclaimers. In case of a disagreement between the translation and the origi-
nal version of this License or a notice or disclaimer, the original version will
prevail.
If a section in the Document is Entitled Acknowledgements, Dedica-
tions, or History, the requirement (section 4) to Preserve its Title (section
1) will typically require changing the actual title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except
as expressly provided under this License. Any attempt otherwise to copy,
modify, sublicense, or distribute it is void, and will automatically terminate
your rights under this License.
However, if you cease all violation of this License, then your license from
a particular copyright holder is reinstated (a) provisionally, unless and until
the copyright holder explicitly and finally terminates your license, and (b)
permanently, if the copyright holder fails to notify you of the violation by
some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated
permanently if the copyright holder notifies you of the violation by some
reasonable means, this is the first time you have received notice of violation
of this License (for any work) from that copyright holder, and you cure the
violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under this
License. If your rights have been terminated and not permanently reinstated,
receipt of a copy of some or all of the same material does not give you any
172 GNU FREE DOCUMENTATION LICENSE
11. RELICENSING
Massive Multiauthor Collaboration Site (or MMC Site) means any
World Wide Web server that publishes copyrightable works and also pro-
vides prominent facilities for anybody to edit those works. A public wiki
that anybody can edit is an example of such a server. A Massive Multi-
author Collaboration (or MMC) contained in the site means any set of
copyrightable works thus published on the MMC site.
CC-BY-SA means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit corpo-
ration with a principal place of business in San Francisco, California, as well
as future copyleft versions of that license published by that same organiza-
tion.
Incorporate means to publish or republish a Document, in whole or in
part, as part of another Document.
173
with the Invariant Sections being LIST THEIR TITLES, with the
Front-Cover Texts being LIST, and with the Back-Cover Texts
being LIST.
If you have Invariant Sections without Cover Texts, or some other com-
bination of the three, merge those two alternatives to suit the situation.
If your document contains nontrivial examples of program code, we rec-
ommend releasing these examples in parallel under your choice of free soft-
ware license, such as the GNU General Public License, to permit their use
in free software.