gep_toolkit 0.2.0

Gene Expressions Programming toolkit
Documentation

GEP Toolkit

Implementation of Gene Expression Programming in Rust. Supports SL-GEP (Self-Learning Gene Expression Programming), check out references at the bottom of this README.

Usage

Add the GEP Toolkit dependency in your Cargo.toml file:

[dependencies]
gep_toolkit = "0.2.0"

Use KExpressions as your genetic population chromosomes, and use k_expr.expression(ExpressionTreeType::RGEP) to build an expression tree and compute it (GEP and PGEP are not supported yet).

use gep_toolkit::operations::primitives::*;
use gep_toolkit::operations::op_set::PrimitiveOperationSet;
use gep_toolkit::k_expr::builder::KExpressions;
use gep_toolkit::k_expr::core::{ExpressionTreeType, KExpressionParams};
use gep_toolkit::k_expr::serialize::KExpressionSer;

fn main() {
    let operations: Vec<PrimitiveOperation> = vec![
        PrimitiveOperation::Constant(Constant::C100),
        PrimitiveOperation::Constant(Constant::C1),
        PrimitiveOperation::Constant(Constant::CNeg1),
        PrimitiveOperation::Operator(Operator::Plus),
        PrimitiveOperation::Operator(Operator::Multiply),
        PrimitiveOperation::Operator(Operator::Pow),
    ];
    
    let args_count = 2;
    let set = PrimitiveOperationSet::new(operations, args_count);
    let params = KExpressionParams {
        root_length: 5,
        sub_length: 10,
        subs_count: 3,
        reuse_sub_expr: true,
        ..KExpressionParams::default()
    };
    let ctx = KExpressions::new(set, params);

    let k_expr = ctx.new_k_expr();
    let root_expr = k_expr.expression(ExpressionTreeType::RGEP);

    let args = vec![1.0, 2.0];
    println!("{:?}", root_expr.compute_result(&args));
}

Note that the library is intended for expression trees generation and computing them. In order to run a simulation, you will need to use a separate GA library. Check out examples.

Examples

There's an example of running a GEP simulation on oxigen.

Not implemented

  • GEP and PGEP expressions parsing (only RGEP is supported currently)
  • Support pure ADFs without arguments
  • Support restricting usage of primitive operations in main expression to support only-ADFs approach

References