srtree

A general framework to work with Symbolic Regression expression trees.

https://github.com/folivetti/srtree#readme

LTS Haskell 22.39:1.0.0.5
Stackage Nightly 2024-10-31:1.0.0.5
Latest on Hackage:1.0.0.5

See all snapshots srtree appears in

BSD-3-Clause licensed by Fabricio Olivetti de França
Maintained by [email protected]
This version can be pinned in stack with:srtree-1.0.0.5@sha256:38d53bafa56147e2e86ac879b3fcd50f27d7d276ad24c0238d9858e041da5643,1748
Used by 1 package in lts-21.7(full list with versions):

srtree: A symbolic regression expression tree structure.

srtree is a Haskell library with a data structure and supporting functions to manipulate expression trees for symbolic regression.

The tree-like structure is defined as a fixed-point of an n-ary tree. The variables and parameters of the regression model are indexed as Inttype and the constant values are Double.

The tree supports leaf nodes containing a variable, a free parameter, or a constant value; internal nodes that represents binary operators such as the four basic math operations, logarithm with custom base, and the power of two expressions; and unary functions specified by Function data type.

The SRTree structure has instances for Num, Fractional, Floating which allows to create an expression as a valid Haskell expression such as:

x = var 0)
y = var 1
expr = x * 2 + sin(y * pi + x) :: Fix SRTree

Other features:

  • derivative w.r.t. a variable (deriveByVar) and w.r.t. a parameter (deriveByParam)
  • evaluation (evalTree)
  • relabel free parameters sequentially (relabelParams)
  • gradient calculation with forwardMode, or optimized with gradParams if there is only a single occurrence of each parameter (most of the cases).

TODO:

  • support more advanced functions
  • support conditional branching (IF-THEN-ELSE)

Changes

Changelog for srtree

1.0.0.5

  • Changed base and mtl versions

1.0.0.4

  • Removed benchmarking code that demanded more dependencies

1.0.0.3

  • Fixed issue with HUnit test

1.0.0.2

  • Export Fix from Data.SRTRee
  • paramsToConst function

1.0.0.1

  • Fix vector version bounds
  • Included benchmarking of ad package

1.0.0.0

  • Complete refactoring of source
  • We now work with the SRTree data type fixed point
  • Symbolic derivative by Param or Var
  • Forward mode autodiff
  • Optimized gradient calculation of parameters if each parameter occurs only once in the expression

0.1.3.0

  • countParams function

0.1.2.1

  • Better bounds for base (compatible with stackage nightly)

0.1.2.0

  • Implemented deriveParamBy to calculate the derivative by the parameters indexed by ix

0.1.1.0

  • Fixed compilation bug

0.1.0.0

  • Initial version