diff --git a/README.md b/README.md index 9d5e613..bf56633 100755 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ optimizing parameters, and model selection metrics. Together with this library, we provide example applications (please refer to their corresponding README files): -- [srsimplify](srsimplify/README.md): a parser and simplification tool supporting the output of many popular SR algorithms. -- [srtools](srtools/README.md): a tool that can be used to evaluate symbolic regression expressions and create nice reports with confidence intervals. -- [tinygp](tinygp/README.md): a simple GP implementation based on tinyGP. +- [srsimplify](apps/srsimplify/README.md): a parser and simplification tool supporting the output of many popular SR algorithms. +- [srtools](apps/srtools/README.md): a tool that can be used to evaluate symbolic regression expressions and create nice reports with confidence intervals. +- [tinygp](apps/tinygp/README.md): a simple GP implementation based on tinyGP. ## Organization diff --git a/eqsatrepr/Main.hs b/apps/eqsatrepr/Main.hs similarity index 100% rename from eqsatrepr/Main.hs rename to apps/eqsatrepr/Main.hs diff --git a/srsimplify/Main.hs b/apps/srsimplify/Main.hs similarity index 98% rename from srsimplify/Main.hs rename to apps/srsimplify/Main.hs index b255adb..453b128 100644 --- a/srsimplify/Main.hs +++ b/apps/srsimplify/Main.hs @@ -99,5 +99,5 @@ main = do opts = info (opt <**> helper) ( fullDesc <> progDesc "Simplify an expression\ \ using equality saturation." - <> header "simplify - a CLI tool to simplify\ + <> header "srsimplify - a CLI tool to simplify\ \ symbolic regression expressions with equality saturation." ) diff --git a/apps/srsimplify/README.md b/apps/srsimplify/README.md new file mode 100644 index 0000000..a55d0d0 --- /dev/null +++ b/apps/srsimplify/README.md @@ -0,0 +1,66 @@ +# srsimplify - a CLI tool to simplify symbolic regression expressions with equality saturation. + +## How to use + +```bash +Usage: srsimplify (-f|--from ['tir'|'hl'|'operon'|'bingo'|'gomea'|'pysr'|'sbp'|'eplex']) + (-t|--to ['python'|'math'|'tikz'|'latex']) + [-i|--input INPUT-FILE] [-o|--output OUTPUT-FILE] + [-v|--varnames VARNAMES] + + Simplify an expression using equality saturation. + +Available options: + -f,--from ['tir'|'hl'|'operon'|'bingo'|'gomea'|'pysr'|'sbp'|'eplex'] + Input expression format + -t,--to ['python'|'math'|'tikz'|'latex'] + Output expression format + -i,--input INPUT-FILE Input file containing expressions. Empty string gets + expression from stdin. (default: "") + -o,--output OUTPUT-FILE Output file to store the stats in CSV format. Empty + string prints expressions to stdout. (default: "") + -v,--varnames VARNAMES Comma separated string of variable names. Empty + string defaults to the algorithm default (x0, x1,..). + (default: "") + -h,--help Show this help text + +``` + +## Instalation + +To install this tool you'll need: + +- `libz` +- `libnlopt` +- `libgmp` +- `ghc-9.6.6` +- `cabal` or `stack` + +### Recommended step-by-step + +After installing the dependencies (e.g., `apt install libz libnlopt libgmp`), install [`ghcup`](https://www.haskell.org/ghcup/#) + +For Linux, macOS, FreeBSD or WSL2: + +```bash +curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh +``` + +For Windows, run the following in a PowerShell: + +```bash +Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { & ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -Interactive -DisableCurl } catch { Write-Error $_ } +``` + +After the installation, run `ghcup tui` and install the latest `stack` or `cabal` together with `ghc-9.6.6` (select the items and press `i`). +To install `srsimplify` simply run: + +```bash +cabal build exe:srsimplify +``` + +or + +```bash +stack build :srsimplify +``` diff --git a/srtools/Args.hs b/apps/srtools/Args.hs similarity index 100% rename from srtools/Args.hs rename to apps/srtools/Args.hs diff --git a/srtools/IO.hs b/apps/srtools/IO.hs similarity index 100% rename from srtools/IO.hs rename to apps/srtools/IO.hs diff --git a/srtools/Main.hs b/apps/srtools/Main.hs similarity index 92% rename from srtools/Main.hs rename to apps/srtools/Main.hs index 4bfbd88..eab516a 100755 --- a/srtools/Main.hs +++ b/apps/srtools/Main.hs @@ -24,6 +24,6 @@ main = do opts = info (opt <**> helper) ( fullDesc <> progDesc "Optimize the parameters of\ \ Symbolic Regression expressions." - <> header "srtree-opt - a CLI tool to (re)optimize the numeric\ + <> header "srtools - a CLI tool to (re)optimize the numeric\ \ parameters of symbolic regression expressions" ) diff --git a/apps/srtools/README.md b/apps/srtools/README.md new file mode 100644 index 0000000..bec08ed --- /dev/null +++ b/apps/srtools/README.md @@ -0,0 +1,204 @@ +# srtools a swiss knife for symbolic regression models + +`srtools` offers a multitude of tools for parsing and processing symbolic models. +It offers two types of output: a **csv** file evaluating the model with different metrics, +and a **detailed report** showing the same information in a more readable style plus with +the confidence intervals of the parameters and the 10 first predictions. + +Besides that, it supports the reoptimization of the parameters of the model using L-BFGS method +and the distribution of choice (Gaussian, Bernoulli, or Poisson). + +The CSV file output will show the following fields: + +- `Index`: the index of the expression in the input file +- `Filename`: filename storing the expressions +- `Number_of_nodes`: number of nodes in the expression +- `Number_of_parameters` : number of numerical parameters in the expression +- `Parameters` : values of the parameters separated by `;` +- `SSE_train_orig` : sum-of-square errors of the original expression in the training set +- `SSE_val_orig` : sum-of-square errors of the original expression in the validation set +- `SSE_test_orig` : sum-of-square errors of the original expression in the test set +- `SSE_train_opt` : sum-of-square errors of the reoptimized expression in the training set +- `SSE_val_opt` : sum-of-square errors of the reoptimized expression in the validation set +- `SSE_test_opt` : sum-of-square errors of the reoptimized expression in the test set +- `BIC, BIC_val` : Bayesian Information Criteria of the reoptimized expression on the training and validation set +- `Evidence, Evidence_val` : Evidence of the reoptimized expression on the training and validation set +- `MDL, MDL_Freq, MDL_Lattice, *_val` : Variations of Minimum Description Length of the reoptimized expression on the training and validation set +- `NegLogLikelihood_*` : negative log-likelihood of the chosen distribution for the training, validation, and test sets. +- `LogFunctional` : the log of the functional complexity as defined by MDL. +- `LogParameters` : log of the parameters complexity as defined by MDL. +- `Fisher` : diagonal of the Fisher information matrix. + +Example of detailed report: + +```bash +=================== EXPR 0 ================== +((212.6989526196226 * x0) / (6.413269696507164e-2 + x0)) + +---------General stats:--------- + +Number of nodes: 7 +Number of params: 2 +theta = [212.6989526196226,6.413269696507164e-2] + +----------Performance:-------- + +SSE (train.): 1195.4494 +SSE (val.): 0.0 +SSE (test): 0.0 +NegLogLiklihood (train.): 44.7294 +NegLogLiklihood (val.): 0.0 +NegLogLiklihood (test): 0.0 + +------Selection criteria:----- + +BIC: 96.9136 +AIC: 95.4588 +MDL: 61.2252 +MDL (freq.): 59.4291 +Functional complexity: 11.2661 +Parameter complexity: 5.2297 + +---------Uncertainties:---------- + +Correlation of parameters: +Array D Seq (Sz (2 :. 2)) + [ [ 1.0, 0.78 ] + , [ 0.78, 1.0 ] + ] +Std. Err.: Array D Seq (Sz1 2) + [ 7.1613, 8.7e-3 ] + +Confidence intervals: + +lower <= val <= upper +198.7435 <= 212.699 <= 227.6097 +4.84e-2 <= 6.41e-2 <= 8.38e-2 + +Confidence intervals (predictions training): + +lower <= val <= upper +43.0051 <= 50.5667 <= 59.3449 +43.0051 <= 50.5667 <= 59.3449 +92.819 <= 102.8107 <= 112.8937 +92.819 <= 102.8107 <= 112.8937 +125.5919 <= 134.3624 <= 142.7414 +125.5919 <= 134.3624 <= 142.7414 +157.5532 <= 164.6898 <= 171.7878 +157.5532 <= 164.6898 <= 171.7878 +181.4728 <= 190.834 <= 200.1936 +181.4728 <= 190.834 <= 200.1936 +============================================================= + +``` + +## How to use + +```bash +srtools - a CLI tool to (re)optimize the numeric parameters of symbolic +regression expressions + +Usage: srtools (-f|--from ['tir'|'hl'|'operon'|'bingo'|'gomea'|'pysr'|'sbp'|'eplex']) + [-i|--input INPUT-FILE] [-o|--output OUTPUT-FILE] + (-d|--dataset DATASET-FILENAME) [--test TEST] [--niter NITER] + [--hasheader] [--simplify] + [--distribution ['gaussian'|'bernoulli'|'poisson']] [--sErr Serr] + [--restart] [--seed SEED] [--report] [--profile] [--alpha ALPHA] + [--ptype [Bates | ODE | Constrained]] + + Optimize the parameters of Symbolic Regression expressions. + +Available options: + -f,--from ['tir'|'hl'|'operon'|'bingo'|'gomea'|'pysr'|'sbp'|'eplex'] + Input expression format + -i,--input INPUT-FILE Input file containing expressions. Empty string gets + expression from stdin. (default: "") + -o,--output OUTPUT-FILE Output file to store the stats in CSV format. Empty + string prints expressions to stdout. (default: "") + -d,--dataset DATASET-FILENAME + Filename of the dataset used for optimizing the + parameters. Empty string omits stats that make use of + the training data. It will auto-detect and handle + gzipped file based on gz extension. It will also + auto-detect the delimiter. The filename can include + extra information: filename.csv:start:end:target:vars + where start and end corresponds to the range of rows + that should be used for fitting, target is the column + index (or name) of the target variable and cols is a + comma separated list of column indeces or names of + the variables in the same order as used by the + symbolic model. + --test TEST Filename of the test dataset. Empty string omits + stats that make use of the training data. It can have + additional information as in the training set, but + the validation range will be discarded. (default: "") + --niter NITER Number of iterations for the optimization algorithm. + (default: 10) + --hasheader Uses the first row of the csv file as header. + --simplify Apply basic simplification. + --distribution ['gaussian'|'bernoulli'|'poisson'] + Minimize negative log-likelihood following one of the + avaliable distributions. The default is Gaussian. + (default: Gaussian) + --sErr Serr Estimated standard error of the data. If not passed, + it uses the model MSE. (default: Nothing) + --restart If set, it samples the initial values of the + parameters using a Gaussian distribution N(0, 1), + otherwise it uses the original values of the + expression. + --seed SEED Random seed to initialize the parameters values. Used + only if restart is enabled. (default: -1) + --report If set, reports the analysis in a user-friendly + format instead of csv. It will also include + confidence interval for the parameters and + predictions + --profile If set, it will use profile likelihood to calculate + the CIs. + --alpha ALPHA Significance level for confidence intervals. + (default: 5.0e-2) + --ptype [Bates | ODE | Constrained] + Profile Likelihood method. Default: Constrained. + NOTE: Constrained method only calculates the + endpoint. (default: Constrained) + -h,--help Show this help text + +``` + +## Instalation + +To install this tool you'll need: + +- `libz` +- `libnlopt` +- `libgmp` +- `ghc-9.6.6` +- `cabal` or `stack` + +### Recommended step-by-step + +After installing the dependencies (e.g., `apt install libz libnlopt libgmp`), install [`ghcup`](https://www.haskell.org/ghcup/#) + +For Linux, macOS, FreeBSD or WSL2: + +```bash +curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh +``` + +For Windows, run the following in a PowerShell: + +```bash +Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { & ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -Interactive -DisableCurl } catch { Write-Error $_ } +``` + +After the installation, run `ghcup tui` and install the latest `stack` or `cabal` together with `ghc-9.6.6` (select the items and press `i`). +To install `srsimplify` simply run: + +```bash +cabal build exe:srtools +``` + +or + +```bash +stack build :srtools +``` diff --git a/srtools/Report.hs b/apps/srtools/Report.hs similarity index 100% rename from srtools/Report.hs rename to apps/srtools/Report.hs diff --git a/tinygp/GP.hs b/apps/tinygp/GP.hs similarity index 98% rename from tinygp/GP.hs rename to apps/tinygp/GP.hs index be96dfc..8f82561 100644 --- a/tinygp/GP.hs +++ b/apps/tinygp/GP.hs @@ -26,6 +26,8 @@ type FitFun = Individual -> Individual data Individual = Individual { _tree :: Fix SRTree, _fit :: Double, _params :: PVector } +instance Show Individual where + show (Individual t f p) = showExpr t <> "," <> show f <> "," <> show p toss :: Rng Bool toss = state random diff --git a/apps/tinygp/Main.hs b/apps/tinygp/Main.hs new file mode 100644 index 0000000..6fc086c --- /dev/null +++ b/apps/tinygp/Main.hs @@ -0,0 +1,72 @@ +module Main (main) where + +import GP ( HyperParams(HP), fitness, evolution ) +import Data.SRTree ( param, var ) +import System.Random ( getStdGen ) +import Control.Monad.State ( evalStateT ) +import Data.SRTree.Datasets ( loadDataset ) +import Options.Applicative +import Data.Massiv.Array + +-- Data type to store command line arguments +data Args = Args + { dataset :: String, + popSize :: Int, + gens :: Int, + pc :: Double, + pm :: Double + } + deriving (Show) + +-- parser of command line arguments +opt :: Parser Args +opt = Args + <$> strOption + ( long "dataset" + <> short 'd' + <> metavar "INPUT-FILE" + <> help "CSV dataset." ) + <*> option auto + ( long "population" + <> short 'p' + <> metavar "POP-SIZE" + <> showDefault + <> value 100 + <> help "Population size." ) + <*> option auto + ( long "generations" + <> short 'g' + <> metavar "GENS" + <> showDefault + <> value 100 + <> help "Number of generations." ) + <*> option auto + ( long "probCx" + <> metavar "PC" + <> showDefault + <> value 0.9 + <> help "Crossover probability." ) + <*> option auto + ( long "probMut" + <> metavar "PM" + <> showDefault + <> value 0.3 + <> help "Mutation probability." ) + +nonterms = [Right (+), Right (-), Right (*), Right (/), Right (\l r -> abs l ** r), Left (1/)] +--nonterms = [Right (+), Right (-), Right (*)] + +main :: IO () +main = do + args <- execParser opts + g <- getStdGen + ((x, y, _, _), _) <- loadDataset (dataset args) True + let hp = HP 2 4 25 (popSize args) 2 (pc args) (pm args) terms nonterms + (Sz2 _ nFeats) = size x + terms = [var ix | ix <- [0 .. nFeats-1]] <> [param ix | ix <- [0 .. 5]] + pop <- evalStateT (evolution (gens args) hp (fitness x y)) g + putStrLn "Fin" + where + opts = info (opt <**> helper) + ( fullDesc <> progDesc "Very simple example of GP using SRTree." + <> header "tinyGP - a very simple example of GP using SRTRee." ) diff --git a/apps/tinygp/README.md b/apps/tinygp/README.md new file mode 100644 index 0000000..5d0240c --- /dev/null +++ b/apps/tinygp/README.md @@ -0,0 +1,68 @@ +# tinyGP - a simple example of tinyGP using SRTree [WORK IN PROGRESS] + +A very basic implementation of a simple GP using SRTree. +It will use the first columns as the input variables and the last column as the target. +The operator set is fixed to the basic math operators, power, and inverse (1/x). +It generates random trees with a minimum and maximum depth of [2, 4] and maximum size of 20. +It selects parents using tournament selection with $2$ contenders. + +The program will output the entire population of every generation. + +## How to use + +```bash +tinyGP - a very simple example of GP using SRTRee. + +Usage: tinygp (-d|--dataset INPUT-FILE) [-p|--population POP-SIZE] + [-g|--generations GENS] [--probCx PC] [--probMut PM] + + Very simple example of GP using SRTree. + +Available options: + -d,--dataset INPUT-FILE CSV dataset. + -p,--population POP-SIZE Population size. (default: 100) + -g,--generations GENS Number of generations. (default: 100) + --probCx PC Crossover probability. (default: 0.9) + --probMut PM Mutation probability. (default: 0.3) + -h,--help Show this help text + +``` + +## Instalation + +To install this tool you'll need: + +- `libz` +- `libnlopt` +- `libgmp` +- `ghc-9.6.6` +- `cabal` or `stack` + +### Recommended step-by-step + +After installing the dependencies (e.g., `apt install libz libnlopt libgmp`), install [`ghcup`](https://www.haskell.org/ghcup/#) + +For Linux, macOS, FreeBSD or WSL2: + +```bash +curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh +``` + +For Windows, run the following in a PowerShell: + +```bash +Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { & ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -Interactive -DisableCurl } catch { Write-Error $_ } +``` + +After the installation, run `ghcup tui` and install the latest `stack` or `cabal` together with `ghc-9.6.6` (select the items and press `i`). +To install `srsimplify` simply run: + +```bash +cabal build exe:tinygp +``` + +or + +```bash +stack build :tinygp +``` diff --git a/docs/html/srtree/Algorithm-EqSat-Egraph.html b/docs/Algorithm-EqSat-Egraph.html similarity index 100% rename from docs/html/srtree/Algorithm-EqSat-Egraph.html rename to docs/Algorithm-EqSat-Egraph.html diff --git a/docs/html/srtree/Algorithm-EqSat-EqSatDB.html b/docs/Algorithm-EqSat-EqSatDB.html similarity index 100% rename from docs/html/srtree/Algorithm-EqSat-EqSatDB.html rename to docs/Algorithm-EqSat-EqSatDB.html diff --git a/docs/html/srtree/Algorithm-EqSat-Simplify.html b/docs/Algorithm-EqSat-Simplify.html similarity index 100% rename from docs/html/srtree/Algorithm-EqSat-Simplify.html rename to docs/Algorithm-EqSat-Simplify.html diff --git a/docs/html/srtree/Algorithm-EqSat.html b/docs/Algorithm-EqSat.html similarity index 100% rename from docs/html/srtree/Algorithm-EqSat.html rename to docs/Algorithm-EqSat.html diff --git a/docs/html/srtree/Algorithm-Massiv-Utils.html b/docs/Algorithm-Massiv-Utils.html similarity index 100% rename from docs/html/srtree/Algorithm-Massiv-Utils.html rename to docs/Algorithm-Massiv-Utils.html diff --git a/docs/html/srtree/Algorithm-SRTree-AD.html b/docs/Algorithm-SRTree-AD.html similarity index 100% rename from docs/html/srtree/Algorithm-SRTree-AD.html rename to docs/Algorithm-SRTree-AD.html diff --git a/docs/html/srtree/Algorithm-SRTree-ConfidenceIntervals.html b/docs/Algorithm-SRTree-ConfidenceIntervals.html similarity index 100% rename from docs/html/srtree/Algorithm-SRTree-ConfidenceIntervals.html rename to docs/Algorithm-SRTree-ConfidenceIntervals.html diff --git a/docs/html/srtree/Algorithm-SRTree-Likelihoods.html b/docs/Algorithm-SRTree-Likelihoods.html similarity index 100% rename from docs/html/srtree/Algorithm-SRTree-Likelihoods.html rename to docs/Algorithm-SRTree-Likelihoods.html diff --git a/docs/html/srtree/Algorithm-SRTree-ModelSelection.html b/docs/Algorithm-SRTree-ModelSelection.html similarity index 100% rename from docs/html/srtree/Algorithm-SRTree-ModelSelection.html rename to docs/Algorithm-SRTree-ModelSelection.html diff --git a/docs/html/srtree/Algorithm-SRTree-NonlinearOpt.html b/docs/Algorithm-SRTree-NonlinearOpt.html similarity index 100% rename from docs/html/srtree/Algorithm-SRTree-NonlinearOpt.html rename to docs/Algorithm-SRTree-NonlinearOpt.html diff --git a/docs/html/srtree/Algorithm-SRTree-Opt.html b/docs/Algorithm-SRTree-Opt.html similarity index 100% rename from docs/html/srtree/Algorithm-SRTree-Opt.html rename to docs/Algorithm-SRTree-Opt.html diff --git a/docs/html/srtree/Data-SRTree-Datasets.html b/docs/Data-SRTree-Datasets.html similarity index 100% rename from docs/html/srtree/Data-SRTree-Datasets.html rename to docs/Data-SRTree-Datasets.html diff --git a/docs/html/srtree/Data-SRTree-Derivative.html b/docs/Data-SRTree-Derivative.html similarity index 100% rename from docs/html/srtree/Data-SRTree-Derivative.html rename to docs/Data-SRTree-Derivative.html diff --git a/docs/html/srtree/Data-SRTree-Eval.html b/docs/Data-SRTree-Eval.html similarity index 100% rename from docs/html/srtree/Data-SRTree-Eval.html rename to docs/Data-SRTree-Eval.html diff --git a/docs/html/srtree/Data-SRTree-Internal.html b/docs/Data-SRTree-Internal.html similarity index 100% rename from docs/html/srtree/Data-SRTree-Internal.html rename to docs/Data-SRTree-Internal.html diff --git a/docs/html/srtree/Data-SRTree-Print.html b/docs/Data-SRTree-Print.html similarity index 100% rename from docs/html/srtree/Data-SRTree-Print.html rename to docs/Data-SRTree-Print.html diff --git a/docs/html/srtree/Data-SRTree-Random.html b/docs/Data-SRTree-Random.html similarity index 100% rename from docs/html/srtree/Data-SRTree-Random.html rename to docs/Data-SRTree-Random.html diff --git a/docs/html/srtree/Data-SRTree-Recursion.html b/docs/Data-SRTree-Recursion.html similarity index 100% rename from docs/html/srtree/Data-SRTree-Recursion.html rename to docs/Data-SRTree-Recursion.html diff --git a/docs/html/srtree/Data-SRTree.html b/docs/Data-SRTree.html similarity index 100% rename from docs/html/srtree/Data-SRTree.html rename to docs/Data-SRTree.html diff --git a/docs/html/srtree/Text-ParseSR-IO.html b/docs/Text-ParseSR-IO.html similarity index 100% rename from docs/html/srtree/Text-ParseSR-IO.html rename to docs/Text-ParseSR-IO.html diff --git a/docs/html/srtree/Text-ParseSR.html b/docs/Text-ParseSR.html similarity index 100% rename from docs/html/srtree/Text-ParseSR.html rename to docs/Text-ParseSR.html diff --git a/docs/html/srtree/doc-index-58.html b/docs/doc-index-58.html similarity index 100% rename from docs/html/srtree/doc-index-58.html rename to docs/doc-index-58.html diff --git a/docs/html/srtree/doc-index-95.html b/docs/doc-index-95.html similarity index 100% rename from docs/html/srtree/doc-index-95.html rename to docs/doc-index-95.html diff --git a/docs/html/srtree/doc-index-A.html b/docs/doc-index-A.html similarity index 100% rename from docs/html/srtree/doc-index-A.html rename to docs/doc-index-A.html diff --git a/docs/html/srtree/doc-index-All.html b/docs/doc-index-All.html similarity index 100% rename from docs/html/srtree/doc-index-All.html rename to docs/doc-index-All.html diff --git a/docs/html/srtree/doc-index-B.html b/docs/doc-index-B.html similarity index 100% rename from docs/html/srtree/doc-index-B.html rename to docs/doc-index-B.html diff --git a/docs/html/srtree/doc-index-C.html b/docs/doc-index-C.html similarity index 100% rename from docs/html/srtree/doc-index-C.html rename to docs/doc-index-C.html diff --git a/docs/html/srtree/doc-index-D.html b/docs/doc-index-D.html similarity index 100% rename from docs/html/srtree/doc-index-D.html rename to docs/doc-index-D.html diff --git a/docs/html/srtree/doc-index-E.html b/docs/doc-index-E.html similarity index 100% rename from docs/html/srtree/doc-index-E.html rename to docs/doc-index-E.html diff --git a/docs/html/srtree/doc-index-F.html b/docs/doc-index-F.html similarity index 100% rename from docs/html/srtree/doc-index-F.html rename to docs/doc-index-F.html diff --git a/docs/html/srtree/doc-index-G.html b/docs/doc-index-G.html similarity index 100% rename from docs/html/srtree/doc-index-G.html rename to docs/doc-index-G.html diff --git a/docs/html/srtree/doc-index-H.html b/docs/doc-index-H.html similarity index 100% rename from docs/html/srtree/doc-index-H.html rename to docs/doc-index-H.html diff --git a/docs/html/srtree/doc-index-I.html b/docs/doc-index-I.html similarity index 100% rename from docs/html/srtree/doc-index-I.html rename to docs/doc-index-I.html diff --git a/docs/html/srtree/doc-index-J.html b/docs/doc-index-J.html similarity index 100% rename from docs/html/srtree/doc-index-J.html rename to docs/doc-index-J.html diff --git a/docs/html/srtree/doc-index-L.html b/docs/doc-index-L.html similarity index 100% rename from docs/html/srtree/doc-index-L.html rename to docs/doc-index-L.html diff --git a/docs/html/srtree/doc-index-M.html b/docs/doc-index-M.html similarity index 100% rename from docs/html/srtree/doc-index-M.html rename to docs/doc-index-M.html diff --git a/docs/html/srtree/doc-index-N.html b/docs/doc-index-N.html similarity index 100% rename from docs/html/srtree/doc-index-N.html rename to docs/doc-index-N.html diff --git a/docs/html/srtree/doc-index-O.html b/docs/doc-index-O.html similarity index 100% rename from docs/html/srtree/doc-index-O.html rename to docs/doc-index-O.html diff --git a/docs/html/srtree/doc-index-P.html b/docs/doc-index-P.html similarity index 100% rename from docs/html/srtree/doc-index-P.html rename to docs/doc-index-P.html diff --git a/docs/html/srtree/doc-index-Q.html b/docs/doc-index-Q.html similarity index 100% rename from docs/html/srtree/doc-index-Q.html rename to docs/doc-index-Q.html diff --git a/docs/html/srtree/doc-index-R.html b/docs/doc-index-R.html similarity index 100% rename from docs/html/srtree/doc-index-R.html rename to docs/doc-index-R.html diff --git a/docs/html/srtree/doc-index-S.html b/docs/doc-index-S.html similarity index 100% rename from docs/html/srtree/doc-index-S.html rename to docs/doc-index-S.html diff --git a/docs/html/srtree/doc-index-T.html b/docs/doc-index-T.html similarity index 100% rename from docs/html/srtree/doc-index-T.html rename to docs/doc-index-T.html diff --git a/docs/html/srtree/doc-index-U.html b/docs/doc-index-U.html similarity index 100% rename from docs/html/srtree/doc-index-U.html rename to docs/doc-index-U.html diff --git a/docs/html/srtree/doc-index-V.html b/docs/doc-index-V.html similarity index 100% rename from docs/html/srtree/doc-index-V.html rename to docs/doc-index-V.html diff --git a/docs/html/srtree/doc-index-W.html b/docs/doc-index-W.html similarity index 100% rename from docs/html/srtree/doc-index-W.html rename to docs/doc-index-W.html diff --git a/docs/html/srtree/doc-index-X.html b/docs/doc-index-X.html similarity index 100% rename from docs/html/srtree/doc-index-X.html rename to docs/doc-index-X.html diff --git a/docs/html/srtree/doc-index-Z.html b/docs/doc-index-Z.html similarity index 100% rename from docs/html/srtree/doc-index-Z.html rename to docs/doc-index-Z.html diff --git a/docs/html/srtree/doc-index.html b/docs/doc-index.html similarity index 100% rename from docs/html/srtree/doc-index.html rename to docs/doc-index.html diff --git a/docs/html/srtree/haddock-bundle.min.js b/docs/haddock-bundle.min.js similarity index 100% rename from docs/html/srtree/haddock-bundle.min.js rename to docs/haddock-bundle.min.js diff --git a/docs/html/srtree/index.html b/docs/index.html similarity index 100% rename from docs/html/srtree/index.html rename to docs/index.html diff --git a/docs/html/srtree/linuwial.css b/docs/linuwial.css similarity index 100% rename from docs/html/srtree/linuwial.css rename to docs/linuwial.css diff --git a/docs/html/srtree/meta.json b/docs/meta.json similarity index 100% rename from docs/html/srtree/meta.json rename to docs/meta.json diff --git a/docs/html/srtree/quick-jump.css b/docs/quick-jump.css similarity index 100% rename from docs/html/srtree/quick-jump.css rename to docs/quick-jump.css diff --git a/docs/html/srtree/srtree.haddock b/docs/srtree.haddock similarity index 100% rename from docs/html/srtree/srtree.haddock rename to docs/srtree.haddock diff --git a/docs/html/srtree/synopsis.png b/docs/synopsis.png similarity index 100% rename from docs/html/srtree/synopsis.png rename to docs/synopsis.png diff --git a/package.yaml b/package.yaml index e8587f4..fb02243 100755 --- a/package.yaml +++ b/package.yaml @@ -51,7 +51,7 @@ library: executables: tinygp: main: Main.hs - source-dirs: tinygp + source-dirs: apps/tinygp ghc-options: - -threaded - -rtsopts @@ -59,10 +59,11 @@ executables: - -O2 - -optc-O3 dependencies: + - optparse-applicative >= 0.17 && < 0.19 - srtree srtools: main: Main.hs - source-dirs: srtools + source-dirs: apps/srtools ghc-options: - -threaded - -rtsopts @@ -76,7 +77,7 @@ executables: - normaldistribution eqsatrepr: main: Main.hs - source-dirs: eqsatrepr + source-dirs: apps/eqsatrepr ghc-options: - -threaded - -rtsopts @@ -87,7 +88,7 @@ executables: - srtree srsimplify: main: Main.hs - source-dirs: srsimplify + source-dirs: apps/srsimplify ghc-options: - -threaded - -rtsopts diff --git a/srsimplify/README.md b/srsimplify/README.md deleted file mode 100644 index 34e03fa..0000000 --- a/srsimplify/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# srsimplify: a parser and simplification tool for symbolic expressions - diff --git a/srtools/README.md b/srtools/README.md deleted file mode 100644 index a9b7967..0000000 --- a/srtools/README.md +++ /dev/null @@ -1 +0,0 @@ -# srtools: a multi-use tools for symbolic regression expressions diff --git a/srtree.cabal b/srtree.cabal index bb90899..ae584af 100755 --- a/srtree.cabal +++ b/srtree.cabal @@ -1,6 +1,6 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0. +-- This file has been generated from package.yaml by hpack version 0.37.0. -- -- see: https://github.com/sol/hpack @@ -82,7 +82,7 @@ executable eqsatrepr other-modules: Paths_srtree hs-source-dirs: - eqsatrepr + apps/eqsatrepr ghc-options: -threaded -rtsopts -with-rtsopts=-N -O2 -optc-O3 build-depends: attoparsec @@ -115,7 +115,7 @@ executable srsimplify other-modules: Paths_srtree hs-source-dirs: - srsimplify + apps/srsimplify ghc-options: -threaded -rtsopts -with-rtsopts=-N -O2 -optc-O3 build-depends: attoparsec @@ -152,7 +152,7 @@ executable srtools Report Paths_srtree hs-source-dirs: - srtools + apps/srtools ghc-options: -threaded -rtsopts -with-rtsopts=-N -O2 -optc-O3 build-depends: attoparsec @@ -188,7 +188,7 @@ executable tinygp GP Paths_srtree hs-source-dirs: - tinygp + apps/tinygp ghc-options: -threaded -rtsopts -with-rtsopts=-N -O2 -optc-O3 build-depends: attoparsec @@ -206,6 +206,7 @@ executable tinygp , massiv >=1.0.4.0 && <1.1 , mtl >=2.2 && <2.4 , nlopt-haskell + , optparse-applicative >=0.17 && <0.19 , random ==1.2.* , split , srtree diff --git a/stack.yaml b/stack.yaml index 71e7964..6c3aa82 100755 --- a/stack.yaml +++ b/stack.yaml @@ -17,7 +17,7 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-22.25 +resolver: lts-22.33 #resolver: nightly-2023-01-13 # User packages to be built. # Various formats can be used as shown in the example below. diff --git a/stack.yaml.lock b/stack.yaml.lock index e4ac719..b5f0926 100755 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -20,7 +20,7 @@ packages: hackage: ieee-0.7@sha256:4f444419a7861f04fb64502d14688c80e8293a86a608f6d14c3010c9bd96b6d1,1327 snapshots: - completed: - sha256: 9b43e51f2c54211993d5954da8b49604704d8288103b8d9150a19a703f4e55e7 - size: 719126 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/25.yaml - original: lts-22.25 + sha256: 098936027eaa1ef14e2b8eb39d9933a973894bb70a68684a1bbf00730249879b + size: 720001 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/33.yaml + original: lts-22.33 diff --git a/tinygp/Main.hs b/tinygp/Main.hs deleted file mode 100644 index c76be7b..0000000 --- a/tinygp/Main.hs +++ /dev/null @@ -1,22 +0,0 @@ -module Main (main) where - -import GP -import Data.SRTree -import Data.SRTree.Print -import System.Random -import Control.Monad.State -import Data.SRTree.Datasets - -terms = [var 0, param 0] -nonterms = [Right (+), Right (-), Right (*), Right (/), Right (\l r -> abs l ** r), Left (1/)] ---nonterms = [Right (+), Right (-), Right (*)] - ---terms = [VarT 0, ParamT] ---nonterms = [Right AddT, Right SubT, Right MulT, Right DivT, Right PowT, Left InvT] -main :: IO () -main = do g <- getStdGen - ((x, y, _, _), _) <- loadDataset "nikuradse_2.csv" True - let hp = HP 2 4 10 200 2 1.0 0.25 terms nonterms - pop <- evalStateT (evolution 500 hp (fitness x y)) g - --print (fmap _fit pop) - putStrLn "Fin" diff --git a/tinygp/README.md b/tinygp/README.md deleted file mode 100644 index 9911044..0000000 --- a/tinygp/README.md +++ /dev/null @@ -1 +0,0 @@ -# tinyGP: a simple-GP based on Python tinyGP