Skip to content

Commit a2e9ac0

Browse files
committed
Update for v5
1 parent 2b4d8ca commit a2e9ac0

File tree

9 files changed

+63
-71
lines changed

9 files changed

+63
-71
lines changed

README.md

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# PISA-Plugin
22

3-
Enables using [PISA - A Platform and Programming Language Independent Interface for Search Algorithms](http://sop.tik.ee.ethz.ch/pisa) selectors within the MOEA Framework. If using any of the PISA
4-
algorithms, please cite:
3+
Enables using [PISA - A Platform and Programming Language Independent Interface for Search Algorithms](http://sop.tik.ee.ethz.ch/pisa)
4+
selectors within the MOEA Framework. If using any of the PISA algorithms, please cite:
55

66
> Bleuler, Stefan, Marco Laumanns, Lothar Thiele and Eckart Zitzler. “PISA: A Platform and Programming Language Independent Interface for Search Algorithms.” International Conference on Evolutionary Multi-Criterion Optimization (2003).
77
8+
89
## Installation
910

1011
Add the following dependency to your `pom.xml`:
@@ -14,42 +15,46 @@ Add the following dependency to your `pom.xml`:
1415
<dependency>
1516
<groupId>org.moeaframework</groupId>
1617
<artifactId>pisa-plugin</artifactId>
17-
<version>2.0.0</version>
18+
<version>3.0.0-SNAPSHOT</version>
1819
</dependency>
1920
```
2021

21-
Or download the JAR from the [Releases](https://github.com/MOEAFramework/PISA-Plugin/releases) into the MOEA Framework's `lib/` folder.
22+
Or download the JAR from the [Releases](https://github.com/MOEAFramework/PISA-Plugin/releases) into the MOEA
23+
Framework's `lib/` folder.
24+
2225

2326
## Supported Versions
2427

25-
The latest versions of the MOEA Framework and the PISA-Plugin are compatible. If using an older version of the
26-
MOEA Framework, use the table below to identify which version of this plugin to use.
28+
The latest versions of the MOEA Framework and the PISA-Plugin are compatible. If using an older version of the MOEA
29+
Framework, use the table below to identify which version of this plugin to use.
2730

2831
MOEA Framework Version | Compatible PISA-Plugin Version
2932
---------------------- | ------------------------------
30-
**`>= 4.0`** | **`2.0.0`**
33+
**`>= 5.0`** | **`3.0.0`**
34+
`>= 4.0` | `2.0.0`
3135
`>= 3.8` | `1.0.3`
3236
`3.7` | `1.0.2`
3337
`<= 3.6` | Not available
3438

39+
3540
## Usage
3641

3742
Once this plugin is added, you can reference PISA selectors as you would any other algorithm:
3843

3944
```java
45+
Problem problem = new DTLZ2(3);
46+
47+
Algorithm algorithm = AlgorithmFactory.getInstance().getAlgorithm("hype-pisa", problem);
48+
algorithm.run(10000);
4049

41-
NondominatedPopulation result = new Executor()
42-
.withProblem("DTLZ2_3")
43-
.withAlgorithm("hype-pisa")
44-
.withMaxEvaluations(10000)
45-
.run();
50+
NondominatedPopulation result = algorithm.getResult();
4651
```
4752

48-
One key difference, however, is that PISA selectors are third-party executables. Precompiled binaries are
49-
available for Windows and Linux.
53+
One key difference, however, is that PISA selectors are third-party executables. Precompiled binaries are available
54+
for Windows and Linux.
5055

51-
The following PISA selectors are supported. We recommend adding `-pisa` to the algorithm name to ensure
52-
the PISA version is used.
56+
The following PISA selectors are supported. We recommend adding `-pisa` to the algorithm name to ensure the PISA
57+
version is used.
5358

5459
Selector | MOEA Framework Algorithm Name
5560
-------- | -----------------------------
@@ -73,7 +78,6 @@ Selectors are automatically downloaded and installed from our [GitHub Mirror](ht
7378
To avoid this setup or to support running without an internet connection, you can preinstall all selectors by running:
7479

7580
```bash
76-
7781
java -classpath "lib/*" org.moeaframework.algorithm.pisa.PISAAlgorithms install
7882
```
7983

@@ -88,37 +92,12 @@ org.moeaframework.algorithm.pisa.allow_install = false
8892

8993
### Building from Source
9094

91-
Precompiled binaries are provided for Windows and Linux. Attempting to use on a different OS will try to
92-
compile from source code. This is experimental and is not supported on all systems. You may also compile
93-
all selectors by running:
95+
Precompiled binaries are provided for Windows and Linux. Attempting to use on a different OS will try to compile from
96+
source code. This is experimental and is not supported on all systems. You may also compile all selectors by running:
9497

9598
```bash
96-
9799
java -classpath "lib/*" org.moeaframework.algorithm.pisa.PISAAlgorithms install_source
98100
```
99101

100-
Compiling will require the following dependencies: `make`, a C/C++ compiler such as `gcc`, `unrar`,
101-
`unzip`, and `tar`.
102-
103-
104-
## Limitations
105-
106-
Some algorithms are implemented in both PISA and the MOEA Framework. If such cases, you can request the PISA
107-
version by appending `-PISA` to the name, such as `NSGA2-PISA`.
108-
109-
## License
110-
111-
Copyright 2009-2024 David Hadka and other contributors. All rights reserved.
112-
113-
The MOEA Framework is free software: you can redistribute it and/or modify
114-
it under the terms of the GNU Lesser General Public License as published by
115-
the Free Software Foundation, either version 3 of the License, or (at your
116-
option) any later version.
117-
118-
The MOEA Framework is distributed in the hope that it will be useful, but
119-
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
120-
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
121-
License for more details.
102+
Compiling will require the following dependencies: `make`, a C/C++ compiler such as `gcc`, `unrar`, `unzip`, and `tar`.
122103

123-
You should have received a copy of the GNU Lesser General Public License
124-
along with the MOEA Framework. If not, see <http://www.gnu.org/licenses/>.

legacy.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# Legacy Configuration for PISA-Plugin
22

3-
Starting with MOEA Framework 3.7 and the introduction of the PISA-Plugin extension, no configuration
4-
is required to use PISA selectors.
3+
Starting with MOEA Framework 3.7 and the introduction of the PISA-Plugin extension, no configuration is required to use
4+
PISA selectors.
55

6-
However, with prior versions, one needed to edit `moeaframework.properties` to configure each
7-
selector. This legacy configuration is still supported for backwards compatibility. Below is an
8-
example of the settings:
6+
However, with prior versions, one needed to edit `moeaframework.properties` to configure each selector. This legacy
7+
configuration is still supported for backwards compatibility. Below is an example of the settings:
98

109
```
1110
## The following defines the available PISA selector names.

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.moeaframework</groupId>
44
<artifactId>pisa-plugin</artifactId>
5-
<version>2.0.0</version>
5+
<version>3.0.0-SNAPSHOT</version>
66
<packaging>jar</packaging>
77

88
<name>PISA Plugin for the MOEA Framework</name>
@@ -39,7 +39,7 @@
3939
<dependency>
4040
<groupId>org.moeaframework</groupId>
4141
<artifactId>moeaframework</artifactId>
42-
<version>4.4</version>
42+
<version>5.0-SNAPSHOT</version>
4343
<scope>provided</scope>
4444
</dependency>
4545
<dependency>

src/main/java/org/moeaframework/algorithm/pisa/PISAAlgorithm.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@
3838
import org.moeaframework.algorithm.AlgorithmException;
3939
import org.moeaframework.algorithm.pisa.installer.PISAInstaller;
4040
import org.moeaframework.core.FrameworkException;
41-
import org.moeaframework.core.Initialization;
42-
import org.moeaframework.core.NondominatedPopulation;
4341
import org.moeaframework.core.PRNG;
44-
import org.moeaframework.core.Problem;
4542
import org.moeaframework.core.Solution;
46-
import org.moeaframework.core.Variation;
43+
import org.moeaframework.core.TypedProperties;
44+
import org.moeaframework.core.initialization.Initialization;
4745
import org.moeaframework.core.initialization.RandomInitialization;
48-
import org.moeaframework.util.TypedProperties;
46+
import org.moeaframework.core.operator.Variation;
47+
import org.moeaframework.core.population.NondominatedPopulation;
48+
import org.moeaframework.problem.Problem;
4949
import org.moeaframework.util.io.RedirectStream;
5050

5151
/**
@@ -65,6 +65,11 @@
6565
* @see <a href="http://sop.tik.ee.ethz.ch/pisa/">PISA Homepage</a>
6666
*/
6767
public class PISAAlgorithm extends AbstractAlgorithm {
68+
69+
/**
70+
* The name of the PISA selector.
71+
*/
72+
private final String name;
6873

6974
/**
7075
* The file prefix used when creating the PISA communication files.
@@ -117,6 +122,7 @@ public class PISAAlgorithm extends AbstractAlgorithm {
117122
*/
118123
public PISAAlgorithm(String name, Problem problem, Variation variation, TypedProperties properties) throws IOException {
119124
super(problem);
125+
this.name = name;
120126
this.variation = variation;
121127

122128
if (problem.getNumberOfConstraints() > 0) {
@@ -202,9 +208,14 @@ public PISAAlgorithm(String name, Problem problem, Variation variation, TypedPro
202208
state = new State(new File(filePrefix + "sta"));
203209
solutions = new HashMap<Integer, Solution>();
204210
}
211+
212+
@Override
213+
public String getName() {
214+
return name;
215+
}
205216

206217
@Override
207-
protected void initialize() {
218+
public void initialize() {
208219
super.initialize();
209220

210221
if (variation == null) {

src/main/java/org/moeaframework/algorithm/pisa/PISAAlgorithms.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
import java.io.IOException;
2121
import java.util.function.BiFunction;
2222

23+
import org.moeaframework.algorithm.Algorithm;
2324
import org.moeaframework.algorithm.pisa.installer.PISAInstaller;
2425
import org.moeaframework.algorithm.pisa.installer.SourceInstaller;
25-
import org.moeaframework.core.Algorithm;
26-
import org.moeaframework.core.Problem;
27-
import org.moeaframework.core.Variation;
26+
import org.moeaframework.core.TypedProperties;
27+
import org.moeaframework.core.operator.Variation;
2828
import org.moeaframework.core.spi.OperatorFactory;
2929
import org.moeaframework.core.spi.ProviderNotFoundException;
3030
import org.moeaframework.core.spi.RegisteredAlgorithmProvider;
31-
import org.moeaframework.util.TypedProperties;
31+
import org.moeaframework.problem.Problem;
3232

3333
/**
3434
* Algorithm provider for PISA selectors.

src/main/java/org/moeaframework/algorithm/pisa/installer/PISAInstaller.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.apache.commons.lang3.SystemUtils;
2929
import org.moeaframework.algorithm.pisa.PISASettings;
3030
import org.moeaframework.core.FrameworkException;
31-
import org.moeaframework.util.io.CommentedLineReader;
31+
import org.moeaframework.util.io.LineReader;
3232

3333
public interface PISAInstaller {
3434

@@ -55,7 +55,7 @@ public default Map<String, String> getDefaultParameters(String algorithm) throws
5555
File defaultParameterFile = getDefaultParameterFile(algorithm);
5656
Map<String, String> defaultParameters = new LinkedHashMap<String, String>();
5757

58-
try (CommentedLineReader reader = new CommentedLineReader(new FileReader(defaultParameterFile))) {
58+
try (LineReader reader = LineReader.wrap(new FileReader(defaultParameterFile)).skipComments()) {
5959
String line = null;
6060

6161
while ((line = reader.readLine()) != null) {

src/test/java/org/moeaframework/algorithm/pisa/PISAAlgorithmsStaticConfigurationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
import org.junit.Before;
2828
import org.junit.Ignore;
2929
import org.junit.Test;
30+
import org.moeaframework.algorithm.Algorithm;
3031
import org.moeaframework.algorithm.pisa.installer.PISAInstaller;
31-
import org.moeaframework.core.Algorithm;
32-
import org.moeaframework.core.Problem;
3332
import org.moeaframework.core.Settings;
33+
import org.moeaframework.core.TypedProperties;
3434
import org.moeaframework.core.spi.ProblemFactory;
3535
import org.moeaframework.core.spi.ProviderNotFoundException;
36-
import org.moeaframework.util.TypedProperties;
36+
import org.moeaframework.problem.Problem;
3737

3838
/**
3939
* Tests the {@link PISAAlgorithms} class using the old, static configuration files.

src/test/java/org/moeaframework/algorithm/pisa/PISAAlgorithmsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
import org.junit.Assert;
2424
import org.junit.Before;
2525
import org.junit.Test;
26-
import org.moeaframework.core.Algorithm;
26+
import org.moeaframework.algorithm.Algorithm;
2727
import org.moeaframework.core.PRNG;
28-
import org.moeaframework.core.Problem;
28+
import org.moeaframework.core.TypedProperties;
2929
import org.moeaframework.core.indicator.Indicators;
3030
import org.moeaframework.core.spi.ProblemFactory;
31-
import org.moeaframework.util.TypedProperties;
31+
import org.moeaframework.problem.Problem;
3232

3333
/**
3434
* Tests the {@link PISAAlgorithms} class using the new, parameter-based configurations.

troubleshooting.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# Troubleshooting
22

3-
**Assertion failed: fp != NULL, file \<filename\>, line \<linenumber\>**
3+
### Assertion failed: fp != NULL, file \<filename\>, line \<linenumber\>
4+
45
PISA modules communicate using the file system. Some anti-virus software scans the contents of files before read and
56
after write operations. This may cause one of the PISA communication files to become inaccessible and cause this error.
67
To test if this is the cause, try disabling your anti-virus and re-run the program.
78

89
A more permanent and secure solution involves adding an exception to the anti-virus software to prevent active
910
monitoring of PISA communication files. For example, first add the line
11+
1012
```
1113
java.io.tmpdir=<folder>
1214
```
15+
1316
to `moeaframework.properties` and set `<folder>` to some temporary folder where the PISA communication files
1417
will be stored. Then configure your anti-virus software to ignore the contents of `<folder>`.

0 commit comments

Comments
 (0)