Skip to content

Commit a0743ee

Browse files
committed
Add example and update CI to only run on Linux
1 parent 5936f26 commit a0743ee

File tree

4 files changed

+78
-99
lines changed

4 files changed

+78
-99
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,35 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
os: [ 'ubuntu-latest', 'windows-latest' ]
13+
os: [ 'ubuntu-latest' ]
1414
java: [ '17', '18', '19', '20', '21' ]
1515
steps:
1616
- name: Setup build
1717
uses: MOEAFramework/.github/actions/setup-build@main
1818
with:
1919
java-version: ${{ matrix.java }}
20-
- name: Set up Matlab
21-
if: runner.os == 'Linux'
22-
uses: matlab-actions/setup-matlab@v1
23-
- name: Setup Radar Waveform code (Linux only)
24-
if: runner.os == 'Linux'
20+
setup-matlab: true
21+
- name: Setup Radar Waveform code
2522
run: |
2623
cd native/Radar/bin
2724
wget https://perspectival-classi.000webhostapp.com/code/radar_many.zip \
2825
|| wget https://github.com/MOEAFramework/Archive/raw/main/evanhughes/radar_many.zip
2926
unzip radar_many.zip
3027
cp web_code/testpris.p testpris.p
3128
- name: Build native programs
32-
run: make -C native
33-
- name: Build and test with Maven
34-
run: mvn package
35-
- name: Test with latest MOEA Framework JAR (Linux only)
36-
if: false && runner.os == 'Linux'
3729
run: |
38-
VERSION=$(curl https://api.github.com/repos/MOEAFramework/MOEAFramework/releases/latest | jq '.tag_name' | grep -oEi '[0-9]+\.[0-9]+(\.[0-9]+)?')
39-
wget https://github.com/MOEAFramework/MOEAFramework/releases/download/v${VERSION}/MOEAFramework-${VERSION}.tar.gz
40-
tar -xzf MOEAFramework-${VERSION}.tar.gz
41-
42-
MOEAFRAMEWORK_ROOT=$(realpath -s MOEAFramework-${VERSION})
43-
ln -s $(realpath -s native/) ${MOEAFRAMEWORK_ROOT}/native
44-
cp target/real-world-benchmarks-[0-9].[0-9].[0-9].jar ${MOEAFRAMEWORK_ROOT}/lib
45-
46-
rm native/shared/*
47-
cp ${MOEAFRAMEWORK_ROOT}/examples/moeaframework.[ch] native/shared
4830
make -C native
49-
50-
cd ${MOEAFRAMEWORK_ROOT}
51-
java -cp "lib/*" org.moeaframework.analysis.tools.Solve -a NSGAII -b LRGV -n 1000 -f output.set
31+
- name: Build and test with Maven
32+
run: |
33+
mvn package
34+
- name: Test example
35+
run: |
36+
mvn compile exec:java -Dexec.mainClass="org.moeaframework.benchmarks.Example"
37+
- name: Test solve
38+
run: |
39+
mvn compile exec:java -Dexec.mainClass="org.moeaframework.analysis.tools.Solve" \
40+
-Dexec.args="--algorithm NSGAII --problem LRGV --numberOfEvaluations 10000 --output LRGV_Result.txt"
41+
cat LRGV_Result.txt
42+
- name: Validate README
43+
run: |
44+
mvn compile exec:java -Dexec.mainClass="org.moeaframework.util.cli.UpdateCodeSamples" -Dexec.args="README.md"

.github/workflows/stage.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,7 @@ on:
2525
type: boolean
2626

2727
jobs:
28-
build:
29-
runs-on: windows-latest
30-
steps:
31-
- uses: actions/checkout@v4
32-
- name: Build Windows native files
33-
run: make -C native
34-
- uses: actions/upload-artifact@v4
35-
with:
36-
name: native-windows
37-
path: native/
3828
stage:
39-
needs: build
4029
runs-on: ubuntu-latest
4130
steps:
4231
- name: Setup release
@@ -61,24 +50,13 @@ jobs:
6150
ossrh-username: ${{ secrets.OSSRH_USERNAME }}
6251
ossrh-password: ${{ secrets.OSSRH_TOKEN }}
6352
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
64-
- name: Remove native/ folder
65-
run: rm -rf native/
66-
- name: Download Windows native files
67-
uses: actions/download-artifact@v4
68-
with:
69-
name: native-windows
70-
path: native/
71-
- name: Zip Windows native files
72-
run: zip -r native-windows.zip native
7353
- name: Stage GitHub release
7454
if: ${{ inputs.publish-github }}
7555
uses: MOEAFramework/.github/actions/publish-github@main
7656
with:
77-
extra-files: native-windows.zip
7857
github-token: ${{ secrets.GITHUB_TOKEN }}
7958
- name: Trigger integration tests
8059
if: ${{ inputs.trigger-tests }}
8160
uses: MOEAFramework/.github/actions/integration-test@main
8261
with:
8362
github-token: ${{ secrets.PAT }}
84-

README.md

Lines changed: 43 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Real World Benchmarks
22

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

76
> 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
87
@@ -13,74 +12,66 @@ Please cite the following if using this code:
1312
These codes are intended for use with the MOEA Framework. Follow the steps below to setup these real-world
1413
benchmark problems:
1514

16-
#### Prerequisites
15+
### Requirements
16+
17+
These codes are intended to run on a Unix-like system (e.g., Ubuntu). In addition, please ensure the following
18+
dependencies are installed:
1719

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

24-
#### Setup MOEA Framework
25+
### Setup with Eclipse
26+
27+
First, clone this repository:
2528

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

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

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

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

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

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

47-
## Maven
49+
```bash
50+
mvn package
51+
```
4852

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

53-
```xml
54-
<dependency>
55-
<groupId>org.moeaframework</groupId>
56-
<artifactId>real-world-benchmarks</artifactId>
57-
<version>1.1.0</version>
58-
</dependency>
55+
```bash
56+
mvn compile exec:java -Dexec.mainClass="org.moeaframework.benchmarks.Example"
5957
```
6058

61-
## Usage
59+
## Example
6260

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

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

67-
Problem problem = new GAA();
67+
```java
68+
GAA problem = new GAA();
6869

6970
NSGAII algorithm = new NSGAII(problem);
7071
algorithm.run(10000);
7172

7273
NondominatedPopulation result = algorithm.getResult();
73-
```
74-
75-
or reference it by name if using the `Executor`:
76-
77-
```java
78-
79-
NondominatedPopulation result = new Executor()
80-
.withProblem("GAA")
81-
.withAlgorithm("NSGAII")
82-
.withMaxEvaluations(10000)
83-
.run();
74+
result.display();
8475
```
8576

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

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

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

118-
Additional information for specific problems can be found in the cited papers as well as
119-
the README files and other documentation for each problem.
109+
Additional information for specific problems can be found in the cited papers as well as the `README` files and other
110+
documentation for each problem.
120111

121112
## License
122113

123-
Most of the software contained in this repository is copyright by the respective authors
124-
who developed each benchmark problem. Please cite these original works if using any of the
125-
benchmark problems.
114+
Most of the software contained in this repository is copyright by the respective authors who developed each benchmark
115+
problem. Please cite these original works if using any of the benchmark problems.
126116

127117
## References
128118

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.moeaframework.benchmarks;
2+
3+
import org.moeaframework.algorithm.NSGAII;
4+
import org.moeaframework.core.population.NondominatedPopulation;
5+
6+
public class Example {
7+
8+
public static void main(String[] args) {
9+
GAA problem = new GAA();
10+
11+
NSGAII algorithm = new NSGAII(problem);
12+
algorithm.run(10000);
13+
14+
NondominatedPopulation result = algorithm.getResult();
15+
result.display();
16+
}
17+
18+
}

0 commit comments

Comments
 (0)