Skip to content

Commit

Permalink
Update for v5
Browse files Browse the repository at this point in the history
  • Loading branch information
dhadka committed Dec 20, 2024
1 parent 2b4d8ca commit a2e9ac0
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 71 deletions.
69 changes: 24 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# PISA-Plugin

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
algorithms, please cite:
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 algorithms, please cite:

> 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).

## Installation

Add the following dependency to your `pom.xml`:
Expand All @@ -14,42 +15,46 @@ Add the following dependency to your `pom.xml`:
<dependency>
<groupId>org.moeaframework</groupId>
<artifactId>pisa-plugin</artifactId>
<version>2.0.0</version>
<version>3.0.0-SNAPSHOT</version>
</dependency>
```

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


## Supported Versions

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

MOEA Framework Version | Compatible PISA-Plugin Version
---------------------- | ------------------------------
**`>= 4.0`** | **`2.0.0`**
**`>= 5.0`** | **`3.0.0`**
`>= 4.0` | `2.0.0`
`>= 3.8` | `1.0.3`
`3.7` | `1.0.2`
`<= 3.6` | Not available


## Usage

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

```java
Problem problem = new DTLZ2(3);

Algorithm algorithm = AlgorithmFactory.getInstance().getAlgorithm("hype-pisa", problem);
algorithm.run(10000);

NondominatedPopulation result = new Executor()
.withProblem("DTLZ2_3")
.withAlgorithm("hype-pisa")
.withMaxEvaluations(10000)
.run();
NondominatedPopulation result = algorithm.getResult();
```

One key difference, however, is that PISA selectors are third-party executables. Precompiled binaries are
available for Windows and Linux.
One key difference, however, is that PISA selectors are third-party executables. Precompiled binaries are available
for Windows and Linux.

The following PISA selectors are supported. We recommend adding `-pisa` to the algorithm name to ensure
the PISA version is used.
The following PISA selectors are supported. We recommend adding `-pisa` to the algorithm name to ensure the PISA
version is used.

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

```bash

java -classpath "lib/*" org.moeaframework.algorithm.pisa.PISAAlgorithms install
```

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

### Building from Source

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

```bash

java -classpath "lib/*" org.moeaframework.algorithm.pisa.PISAAlgorithms install_source
```

Compiling will require the following dependencies: `make`, a C/C++ compiler such as `gcc`, `unrar`,
`unzip`, and `tar`.


## Limitations

Some algorithms are implemented in both PISA and the MOEA Framework. If such cases, you can request the PISA
version by appending `-PISA` to the name, such as `NSGA2-PISA`.

## License

Copyright 2009-2024 David Hadka and other contributors. All rights reserved.

The MOEA Framework is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

The MOEA Framework is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
Compiling will require the following dependencies: `make`, a C/C++ compiler such as `gcc`, `unrar`, `unzip`, and `tar`.

You should have received a copy of the GNU Lesser General Public License
along with the MOEA Framework. If not, see <http://www.gnu.org/licenses/>.
9 changes: 4 additions & 5 deletions legacy.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Legacy Configuration for PISA-Plugin

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

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

```
## The following defines the available PISA selector names.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.moeaframework</groupId>
<artifactId>pisa-plugin</artifactId>
<version>2.0.0</version>
<version>3.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>PISA Plugin for the MOEA Framework</name>
Expand Down Expand Up @@ -39,7 +39,7 @@
<dependency>
<groupId>org.moeaframework</groupId>
<artifactId>moeaframework</artifactId>
<version>4.4</version>
<version>5.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
23 changes: 17 additions & 6 deletions src/main/java/org/moeaframework/algorithm/pisa/PISAAlgorithm.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
import org.moeaframework.algorithm.AlgorithmException;
import org.moeaframework.algorithm.pisa.installer.PISAInstaller;
import org.moeaframework.core.FrameworkException;
import org.moeaframework.core.Initialization;
import org.moeaframework.core.NondominatedPopulation;
import org.moeaframework.core.PRNG;
import org.moeaframework.core.Problem;
import org.moeaframework.core.Solution;
import org.moeaframework.core.Variation;
import org.moeaframework.core.TypedProperties;
import org.moeaframework.core.initialization.Initialization;
import org.moeaframework.core.initialization.RandomInitialization;
import org.moeaframework.util.TypedProperties;
import org.moeaframework.core.operator.Variation;
import org.moeaframework.core.population.NondominatedPopulation;
import org.moeaframework.problem.Problem;
import org.moeaframework.util.io.RedirectStream;

/**
Expand All @@ -65,6 +65,11 @@
* @see <a href="http://sop.tik.ee.ethz.ch/pisa/">PISA Homepage</a>
*/
public class PISAAlgorithm extends AbstractAlgorithm {

/**
* The name of the PISA selector.
*/
private final String name;

/**
* The file prefix used when creating the PISA communication files.
Expand Down Expand Up @@ -117,6 +122,7 @@ public class PISAAlgorithm extends AbstractAlgorithm {
*/
public PISAAlgorithm(String name, Problem problem, Variation variation, TypedProperties properties) throws IOException {
super(problem);
this.name = name;
this.variation = variation;

if (problem.getNumberOfConstraints() > 0) {
Expand Down Expand Up @@ -202,9 +208,14 @@ public PISAAlgorithm(String name, Problem problem, Variation variation, TypedPro
state = new State(new File(filePrefix + "sta"));
solutions = new HashMap<Integer, Solution>();
}

@Override
public String getName() {
return name;
}

@Override
protected void initialize() {
public void initialize() {
super.initialize();

if (variation == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
import java.io.IOException;
import java.util.function.BiFunction;

import org.moeaframework.algorithm.Algorithm;
import org.moeaframework.algorithm.pisa.installer.PISAInstaller;
import org.moeaframework.algorithm.pisa.installer.SourceInstaller;
import org.moeaframework.core.Algorithm;
import org.moeaframework.core.Problem;
import org.moeaframework.core.Variation;
import org.moeaframework.core.TypedProperties;
import org.moeaframework.core.operator.Variation;
import org.moeaframework.core.spi.OperatorFactory;
import org.moeaframework.core.spi.ProviderNotFoundException;
import org.moeaframework.core.spi.RegisteredAlgorithmProvider;
import org.moeaframework.util.TypedProperties;
import org.moeaframework.problem.Problem;

/**
* Algorithm provider for PISA selectors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.commons.lang3.SystemUtils;
import org.moeaframework.algorithm.pisa.PISASettings;
import org.moeaframework.core.FrameworkException;
import org.moeaframework.util.io.CommentedLineReader;
import org.moeaframework.util.io.LineReader;

public interface PISAInstaller {

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

try (CommentedLineReader reader = new CommentedLineReader(new FileReader(defaultParameterFile))) {
try (LineReader reader = LineReader.wrap(new FileReader(defaultParameterFile)).skipComments()) {
String line = null;

while ((line = reader.readLine()) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.moeaframework.algorithm.Algorithm;
import org.moeaframework.algorithm.pisa.installer.PISAInstaller;
import org.moeaframework.core.Algorithm;
import org.moeaframework.core.Problem;
import org.moeaframework.core.Settings;
import org.moeaframework.core.TypedProperties;
import org.moeaframework.core.spi.ProblemFactory;
import org.moeaframework.core.spi.ProviderNotFoundException;
import org.moeaframework.util.TypedProperties;
import org.moeaframework.problem.Problem;

/**
* Tests the {@link PISAAlgorithms} class using the old, static configuration files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.moeaframework.core.Algorithm;
import org.moeaframework.algorithm.Algorithm;
import org.moeaframework.core.PRNG;
import org.moeaframework.core.Problem;
import org.moeaframework.core.TypedProperties;
import org.moeaframework.core.indicator.Indicators;
import org.moeaframework.core.spi.ProblemFactory;
import org.moeaframework.util.TypedProperties;
import org.moeaframework.problem.Problem;

/**
* Tests the {@link PISAAlgorithms} class using the new, parameter-based configurations.
Expand Down
5 changes: 4 additions & 1 deletion troubleshooting.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Troubleshooting

**Assertion failed: fp != NULL, file \<filename\>, line \<linenumber\>**
### Assertion failed: fp != NULL, file \<filename\>, line \<linenumber\>

PISA modules communicate using the file system. Some anti-virus software scans the contents of files before read and
after write operations. This may cause one of the PISA communication files to become inaccessible and cause this error.
To test if this is the cause, try disabling your anti-virus and re-run the program.

A more permanent and secure solution involves adding an exception to the anti-virus software to prevent active
monitoring of PISA communication files. For example, first add the line

```
java.io.tmpdir=<folder>
```

to `moeaframework.properties` and set `<folder>` to some temporary folder where the PISA communication files
will be stored. Then configure your anti-virus software to ignore the contents of `<folder>`.

0 comments on commit a2e9ac0

Please sign in to comment.