Giter Site home page Giter Site logo

lgp's Introduction

LGP

A robust LGP implementation on the JVM using Kotlin.

license docs build

About

An implementation of Linear Genetic Programming that follows that outlined by Linear Genetic Programming (Brameier, M. F. and Banzhaf, W. 2007).

The core API is implemented in Kotlin which allows for easily interoperability with Java (and other JVM languages), while adding the benefit of modern programming language features.

To get started with how to use the system, see the documentation.

If you find the system useful or have any queries, please feel free to:

Installation

A JAR containing the core API can be downloaded from the releases page. The command below can be used to download the JAR from a terminal so that development against the API can begin:

curl -L https://github.com/JedS6391/LGP/releases/download/v-1.1/LGP-core-1.1.jar > LGP.jar

Usage

The system is built using Kotlin and the easiest way to use it is through the Kotlin API. Instructions for installation and usage of the Kotlin compiler, kotlinc, can be found for the Command Line or IntelliJ IDEA.

Here, we'll focus on how to use the system through Kotlin (particularly from the command line) but documentation is provided for using the API through Java.

Assuming that kotlinc is installed and available at the command line, the first step is to download the core API JAR file as described in the Installation section.

Next, create a blank Kotlin file that will contain the problem definition --- typically this would have a filename matching that of the problem:

touch MyProblem.kt

We're not going to fully define the problem as that would be a needlessly extensive exercise, so we'll simply show how to import classes from the API and build against the imported classes.

In MyProblem.kt, enter the following content:

import lgp.core.environment.config.Configuration
import lgp.core.evolution.Description
import lgp.lib.BaseProblem
import lgp.lib.BaseProblemParameters

fun main(args: Array<String>) {
    val parameters = BaseProblemParameters(
            name = "My Problem",
            description = Description("A simple example problem definition"),
            // A problem will generally need custom configuration
            config = Config()
    )

    val problem = BaseProblem(parameters)

    println(problem.name)
    println(problem.description)
}

Here, we use the BaseProblem implementation to use a default set of parameters that we can quickly test against using a data set (which is omitted here).

To compile, we use kotlinc:

kotlinc -cp LGP.jar -no-jdk -no-stdlib MyProblem.kt

This will generate a class file in the directory called MyProblemKt.class. To interpret the class file using the Kotlin interpreter is simple:

kotlin -cp LGP.jar:. MyProblemKt

You should see the following output:

My Problem
Description(description=A simple example problem definition)

Alternatively, the same result can be achieved by setting the destination to another JAR file and executing using the Java interpreter:

# Compile to a JAR using kotlinc 
kotlinc -cp LGP.jar -no-jdk -no-stdlib -d MyProblem.jar MyProblem.kt

# Use the Java interpreter to execute the main function
java -cp LGP.jar:MyProblem.jar MyProblemKt

Please refer to the usage guide for instructions on using the API from the context of a Java program.

lgp's People

Contributors

jeds6391 avatar hongyujerrywang avatar

Watchers

Ulrik Günther avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.