diff --git a/README.md b/README.md index 5261690..20a3065 100644 --- a/README.md +++ b/README.md @@ -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`: @@ -14,42 +15,46 @@ Add the following dependency to your `pom.xml`: org.moeaframework pisa-plugin - 2.0.0 + 3.0.0-SNAPSHOT ``` -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 -------- | ----------------------------- @@ -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 ``` @@ -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 . diff --git a/legacy.md b/legacy.md index be2ab91..41fc1b9 100644 --- a/legacy.md +++ b/legacy.md @@ -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. diff --git a/pom.xml b/pom.xml index 166041c..154dfdf 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.moeaframework pisa-plugin - 2.0.0 + 3.0.0-SNAPSHOT jar PISA Plugin for the MOEA Framework @@ -39,7 +39,7 @@ org.moeaframework moeaframework - 4.4 + 5.0-SNAPSHOT provided diff --git a/src/main/java/org/moeaframework/algorithm/pisa/PISAAlgorithm.java b/src/main/java/org/moeaframework/algorithm/pisa/PISAAlgorithm.java index 6469689..96865a2 100644 --- a/src/main/java/org/moeaframework/algorithm/pisa/PISAAlgorithm.java +++ b/src/main/java/org/moeaframework/algorithm/pisa/PISAAlgorithm.java @@ -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; /** @@ -65,6 +65,11 @@ * @see PISA Homepage */ 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. @@ -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) { @@ -202,9 +208,14 @@ public PISAAlgorithm(String name, Problem problem, Variation variation, TypedPro state = new State(new File(filePrefix + "sta")); solutions = new HashMap(); } + + @Override + public String getName() { + return name; + } @Override - protected void initialize() { + public void initialize() { super.initialize(); if (variation == null) { diff --git a/src/main/java/org/moeaframework/algorithm/pisa/PISAAlgorithms.java b/src/main/java/org/moeaframework/algorithm/pisa/PISAAlgorithms.java index 2ee396f..575beac 100644 --- a/src/main/java/org/moeaframework/algorithm/pisa/PISAAlgorithms.java +++ b/src/main/java/org/moeaframework/algorithm/pisa/PISAAlgorithms.java @@ -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. diff --git a/src/main/java/org/moeaframework/algorithm/pisa/installer/PISAInstaller.java b/src/main/java/org/moeaframework/algorithm/pisa/installer/PISAInstaller.java index 8d5cfef..2e62a13 100644 --- a/src/main/java/org/moeaframework/algorithm/pisa/installer/PISAInstaller.java +++ b/src/main/java/org/moeaframework/algorithm/pisa/installer/PISAInstaller.java @@ -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 { @@ -55,7 +55,7 @@ public default Map getDefaultParameters(String algorithm) throws File defaultParameterFile = getDefaultParameterFile(algorithm); Map defaultParameters = new LinkedHashMap(); - 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) { diff --git a/src/test/java/org/moeaframework/algorithm/pisa/PISAAlgorithmsStaticConfigurationTest.java b/src/test/java/org/moeaframework/algorithm/pisa/PISAAlgorithmsStaticConfigurationTest.java index 8d7002e..552f0f1 100644 --- a/src/test/java/org/moeaframework/algorithm/pisa/PISAAlgorithmsStaticConfigurationTest.java +++ b/src/test/java/org/moeaframework/algorithm/pisa/PISAAlgorithmsStaticConfigurationTest.java @@ -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. diff --git a/src/test/java/org/moeaframework/algorithm/pisa/PISAAlgorithmsTest.java b/src/test/java/org/moeaframework/algorithm/pisa/PISAAlgorithmsTest.java index 93494c5..1e7ad9c 100644 --- a/src/test/java/org/moeaframework/algorithm/pisa/PISAAlgorithmsTest.java +++ b/src/test/java/org/moeaframework/algorithm/pisa/PISAAlgorithmsTest.java @@ -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. diff --git a/troubleshooting.md b/troubleshooting.md index 6c8fa98..3474e9c 100644 --- a/troubleshooting.md +++ b/troubleshooting.md @@ -1,14 +1,17 @@ # Troubleshooting -**Assertion failed: fp != NULL, file \, line \** +### Assertion failed: fp != NULL, file \, line \ + 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= ``` + to `moeaframework.properties` and set `` to some temporary folder where the PISA communication files will be stored. Then configure your anti-virus software to ignore the contents of ``.