srtree

A general framework to work with Symbolic Regression expression trees.

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

Version on this page:1.0.0.3
LTS Haskell 22.18:1.0.0.5
Stackage Nightly 2024-04-24: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.3@sha256:24f75d56883020d7f2ccb36b1362008b906c4506a36453bd4dd2ca856edbb70d,2173
Used by 2 packages in nightly-2023-05-26(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.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