Skip to content

Commit

Permalink
Add example and update CI to only run on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
dhadka committed Jan 2, 2025
1 parent 5936f26 commit a0743ee
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 99 deletions.
41 changes: 17 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,35 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-latest', 'windows-latest' ]
os: [ 'ubuntu-latest' ]
java: [ '17', '18', '19', '20', '21' ]
steps:
- name: Setup build
uses: MOEAFramework/.github/actions/setup-build@main
with:
java-version: ${{ matrix.java }}
- name: Set up Matlab
if: runner.os == 'Linux'
uses: matlab-actions/setup-matlab@v1
- name: Setup Radar Waveform code (Linux only)
if: runner.os == 'Linux'
setup-matlab: true
- name: Setup Radar Waveform code
run: |
cd native/Radar/bin
wget https://perspectival-classi.000webhostapp.com/code/radar_many.zip \
|| wget https://github.com/MOEAFramework/Archive/raw/main/evanhughes/radar_many.zip
unzip radar_many.zip
cp web_code/testpris.p testpris.p
- name: Build native programs
run: make -C native
- name: Build and test with Maven
run: mvn package
- name: Test with latest MOEA Framework JAR (Linux only)
if: false && runner.os == 'Linux'
run: |
VERSION=$(curl https://api.github.com/repos/MOEAFramework/MOEAFramework/releases/latest | jq '.tag_name' | grep -oEi '[0-9]+\.[0-9]+(\.[0-9]+)?')
wget https://github.com/MOEAFramework/MOEAFramework/releases/download/v${VERSION}/MOEAFramework-${VERSION}.tar.gz
tar -xzf MOEAFramework-${VERSION}.tar.gz
MOEAFRAMEWORK_ROOT=$(realpath -s MOEAFramework-${VERSION})
ln -s $(realpath -s native/) ${MOEAFRAMEWORK_ROOT}/native
cp target/real-world-benchmarks-[0-9].[0-9].[0-9].jar ${MOEAFRAMEWORK_ROOT}/lib
rm native/shared/*
cp ${MOEAFRAMEWORK_ROOT}/examples/moeaframework.[ch] native/shared
make -C native
cd ${MOEAFRAMEWORK_ROOT}
java -cp "lib/*" org.moeaframework.analysis.tools.Solve -a NSGAII -b LRGV -n 1000 -f output.set
- name: Build and test with Maven
run: |
mvn package
- name: Test example
run: |
mvn compile exec:java -Dexec.mainClass="org.moeaframework.benchmarks.Example"
- name: Test solve
run: |
mvn compile exec:java -Dexec.mainClass="org.moeaframework.analysis.tools.Solve" \
-Dexec.args="--algorithm NSGAII --problem LRGV --numberOfEvaluations 10000 --output LRGV_Result.txt"
cat LRGV_Result.txt
- name: Validate README
run: |
mvn compile exec:java -Dexec.mainClass="org.moeaframework.util.cli.UpdateCodeSamples" -Dexec.args="README.md"
22 changes: 0 additions & 22 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,7 @@ on:
type: boolean

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Build Windows native files
run: make -C native
- uses: actions/upload-artifact@v4
with:
name: native-windows
path: native/
stage:
needs: build
runs-on: ubuntu-latest
steps:
- name: Setup release
Expand All @@ -61,24 +50,13 @@ jobs:
ossrh-username: ${{ secrets.OSSRH_USERNAME }}
ossrh-password: ${{ secrets.OSSRH_TOKEN }}
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Remove native/ folder
run: rm -rf native/
- name: Download Windows native files
uses: actions/download-artifact@v4
with:
name: native-windows
path: native/
- name: Zip Windows native files
run: zip -r native-windows.zip native
- name: Stage GitHub release
if: ${{ inputs.publish-github }}
uses: MOEAFramework/.github/actions/publish-github@main
with:
extra-files: native-windows.zip
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger integration tests
if: ${{ inputs.trigger-tests }}
uses: MOEAFramework/.github/actions/integration-test@main
with:
github-token: ${{ secrets.PAT }}

96 changes: 43 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Real World Benchmarks

This repository contains a collection of multi- and many-objective optimization problems
with real-world applications for benchmarking multiobjective evolutionary algorithms (MOEAs).
Please cite the following if using this code:
This repository contains a collection of multi- and many-objective optimization problems with real-world applications
for benchmarking multiobjective evolutionary algorithms (MOEAs). Please cite the following if using this code:

> Zatarain Salazar, J., Hadka, D., Reed, P., Seada, H., & Deb, K. (2024). Diagnostic benchmarking of many-objective evolutionary algorithms for real-world problems. Engineering Optimization, 1–22. https://doi.org/10.1080/0305215X.2024.2381818
Expand All @@ -13,74 +12,66 @@ Please cite the following if using this code:
These codes are intended for use with the MOEA Framework. Follow the steps below to setup these real-world
benchmark problems:

#### Prerequisites
### Requirements

These codes are intended to run on a Unix-like system (e.g., Ubuntu). In addition, please ensure the following
dependencies are installed:

Ensure your system has the following software installed:
1. Java 17+
2. Maven
3. GNU Make
4. GNU C/C++ compilers (`gcc` and `g++`)

#### Setup MOEA Framework
### Setup with Eclipse

First, clone this repository:

Download the latest MOEA Framework binaries or source code from http://moeaframework.org/ and
extract the archive to a folder on your computer. We will refer to this as folder as `${MOEAFRAMEWORK_ROOT}`
in the following steps.
```bash
git clone https://github.com/MOEAFramework/RealWorldBenchmarks.git
```

#### Install Real-World Benchmark Library
We recommend opening this project in an IDE, such as Eclipse or IntelliJ. Next, we must compile the benchmark
problems, as several are written in C / C++. Open a new terminal window and run the following from the
`RealWorldBenchmarks` folder:

Download the latest version of the real-world benchmarks JAR file from the
[releases page](https://github.com/MOEAFramework/MOEAFramework/releases) and place it in the
`${MOEAFRAMEWORK_ROOT}/lib` folder.
```bash
make -C native
```

#### Compile Benchmark Problems
Finally, locate and run `Example.java` (in `src/main/java`). In Eclipse, you would right-click on `Example.java` and
select `Run As > Java Application`. If everything is setup correctly, you will see output showing the Pareto front.

Several of the benchmark problems must be compiled before use. If using Windows, we include compiled
executables for each release version (see `native-windows.zip`). Otherwise, to compile the executables, run:
### From Command Line

1. Clone this repository - `git clone https://github.com/MOEAFramework/RealWorldBenchmarks.git`
2. Run `make -C native`
3. Copy or link the `native/` folder into your MOEA Framework directory using either:
* Option 1 - Copy the entire directory with `cp -R native/ ${MOEAFRAMEWORK_ROOT}/native`
* Option 2 - Create a symbolic link with `ln -s $(realpath -s native/) ${MOEAFRAMEWORK_ROOT}/native`
Alternatively, we can also build and run the example from the command line using Maven. First, we can package and test
this project with:

## Maven
```bash
mvn package
```

Alternatively, if you want to include these benchmark problems in a Maven project, add the following
dependency to your `pom.xml`. Please note that you will still need to compile the native executables
separately.
This will verify all benchmark problems are built and running correctly. Then, run the example with:

```xml
<dependency>
<groupId>org.moeaframework</groupId>
<artifactId>real-world-benchmarks</artifactId>
<version>1.1.0</version>
</dependency>
```bash
mvn compile exec:java -Dexec.mainClass="org.moeaframework.benchmarks.Example"
```

## Usage
## Example

To run one of these real-world benchmark problems, you can then either directly construct the problem:
The following example, from `Example.java`, demonstrates solving the General Aviation Aircraft (GAA) problem using the
NSGA-II algorithm, displaying the decision variables, objectives, and constraint values comprising the Pareto
approximation set:

```java
<!-- java:src/main/java/org/moeaframework/benchmarks/Example.java [9:15] -->

Problem problem = new GAA();
```java
GAA problem = new GAA();

NSGAII algorithm = new NSGAII(problem);
algorithm.run(10000);

NondominatedPopulation result = algorithm.getResult();
```

or reference it by name if using the `Executor`:

```java

NondominatedPopulation result = new Executor()
.withProblem("GAA")
.withAlgorithm("NSGAII")
.withMaxEvaluations(10000)
.run();
result.display();
```

## Available Benchmarks
Expand All @@ -97,8 +88,8 @@ The following benchmark problems are available:
| Lake Pollution Control Policy | `LakeProblem` | 100 | 4 | 1 | [9]-[11] |
| Electric Motor Product Family | `ElectricMotor` | 80 | 20 | 60 | [12] |

In addition, this repository contains twelve bi-objective water distribution system (WDS) design problems [13]
ranging from 8 to 567 decision variables:
In addition, this repository contains twelve bi-objective water distribution system (WDS) design problems [13] ranging
from `8` to `567` decision variables:

| Problem | Problem Name | Variables | Objectives | Constraints |
| -------------------------------- | ------------ | :-------: | :--------: | :---------: |
Expand All @@ -115,14 +106,13 @@ ranging from 8 to 567 decision variables:
| Belerma Irrigation Network (BIN) | `WDS(BIN)` | 454 | 2 | 1 |
| Exeter Network (EXN) | `WDS(EXN)` | 567 | 2 | 1 |

Additional information for specific problems can be found in the cited papers as well as
the README files and other documentation for each problem.
Additional information for specific problems can be found in the cited papers as well as the `README` files and other
documentation for each problem.

## License

Most of the software contained in this repository is copyright by the respective authors
who developed each benchmark problem. Please cite these original works if using any of the
benchmark problems.
Most of the software contained in this repository is copyright by the respective authors who developed each benchmark
problem. Please cite these original works if using any of the benchmark problems.

## References

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/org/moeaframework/benchmarks/Example.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.moeaframework.benchmarks;

import org.moeaframework.algorithm.NSGAII;
import org.moeaframework.core.population.NondominatedPopulation;

public class Example {

public static void main(String[] args) {
GAA problem = new GAA();

NSGAII algorithm = new NSGAII(problem);
algorithm.run(10000);

NondominatedPopulation result = algorithm.getResult();
result.display();
}

}

0 comments on commit a0743ee

Please sign in to comment.