Add MOEA Framework to Kotlin project

I want to use the MOEA framework in my Kotlin/IntelliJ project on OS X 10.15.

I downloaded the compiled binaries from: https://github.com/MOEAFramework/MOEAFramework/releases/download/v2.12/MOEAFramework-2.12.tar.gz and added the *.jar files as library to my Kotlin project. Than I converted one java file out of the examples folder to a Kotlin file and tried to compile it.

I get this error message: Unresolved reference: moeaframework

After I added the MOEA lib files I see that this lib is available in the IDE and the lib is referenced correctly, but unfortunately I can’t build the project.

This is the converted Kotlin example file:

import org.moeaframework.Executor
import org.moeaframework.core.NondominatedPopulation 
import org.moeaframework.core.Solution

object Example1 {

@JvmStatic
fun main(args: Array<String>) {
    //configure and run this experiment
    val result = Executor()
        .withProblem("UF1")
        .withAlgorithm("NSGAII")
        .withMaxEvaluations(10000)
        .run()

    //display the results
    System.out.format("Objective1  Objective2%n")

    for (solution in result) {
        System.out.format(
            "%.4f      %.4f%n",
            solution.getObjective(0),
            solution.getObjective(1)
        )
    }
}

}

The lib is also available in Project Settings / Libraries
I use JDK 13.0.1
JVM 1.8

Looks like it’s an issue with how you’re including the lib in your project.

You could use always Gradle if you want (org.moeaframework:moeaframework:2.12). There’s a bit of a learning curve as with any build system, but it sure makes working with dependencies easier.
You can create a Kotlin Gradle project using IntelliJ or by yourself (Redirecting to https://docs.gradle.org/current/samples)

this is working with

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "org.moeaframework:moeaframework:2.12"

compile 'io.github.microutils:kotlin-logging:1.6.20'
compile 'org.slf4j:slf4j-simple:1.7.25'
}

in build.gradle

thank you