{"id":15445113,"url":"https://github.com/salvatorebarone/pyals-rf","last_synced_at":"2025-08-20T22:07:31.120Z","repository":{"id":114359761,"uuid":"426745571","full_name":"SalvatoreBarone/pyALS-RF","owner":"SalvatoreBarone","description":"Approximate Logic Synthesis of Random Forest classifiers","archived":false,"fork":false,"pushed_at":"2025-03-08T20:50:27.000Z","size":6147,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T08:15:10.124Z","etag":null,"topics":["approximate-computing","approximation","decision-tree-classifier","random-forest"],"latest_commit_sha":null,"homepage":"","language":"VHDL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SalvatoreBarone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-10T19:11:58.000Z","updated_at":"2024-01-29T15:38:30.000Z","dependencies_parsed_at":"2023-12-18T15:58:44.690Z","dependency_job_id":"b59b3d48-3c04-4a2f-94a9-4a41faca31b9","html_url":"https://github.com/SalvatoreBarone/pyALS-RF","commit_stats":{"total_commits":262,"total_committers":2,"mean_commits":131.0,"dds":0.4312977099236641,"last_synced_commit":"ec5dcd9c5319b742b520c3c8bcf468700f89916d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalvatoreBarone%2FpyALS-RF","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalvatoreBarone%2FpyALS-RF/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalvatoreBarone%2FpyALS-RF/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalvatoreBarone%2FpyALS-RF/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SalvatoreBarone","download_url":"https://codeload.github.com/SalvatoreBarone/pyALS-RF/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248952085,"owners_count":21188421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["approximate-computing","approximation","decision-tree-classifier","random-forest"],"created_at":"2024-10-01T19:44:01.375Z","updated_at":"2025-04-14T19:54:16.257Z","avatar_url":"https://github.com/SalvatoreBarone.png","language":"VHDL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyALS-RF\nApproximate Logic Synthesis of Random-Forest classifiers.\n\nThe tool allows applying either or both the approximation methods from  the following papers.\n\n\u003e [Barbareschi, M., Barone, S. \u0026 Mazzocca, N. Advancing synthesis of decision tree-based multiple classifier systems: an approximate computing case study. Knowl Inf Syst 63, 1577–1596 (2021) DOI: 0.1007/s10115-021-01565-5](https://doi.org/10.1007/s10115-021-01565-5)\n\n\n\u003e [M. Barbareschi, S. Barone, N. Mazzocca and A. Moriconi, \"A Catalog-based AIG-Rewriting Approach to the Design of Approximate Components\" in IEEE Transactions on Emerging Topics in Computing, DOI: 10.1109/TETC.2022.3170502](https://doi.ieeecomputersociety.org/10.1109/TETC.2022.3170502)\n\n\nPlease, cite us!\n```\n@article{barbareschi2021advancing,\n  title={Advancing synthesis of decision tree-based multiple classifier systems: an approximate computing case study},\n  author={Barbareschi, Mario and Barone, Salvatore and Mazzocca, Nicola},\n  journal={Knowledge and Information Systems},\n  volume={63},\n  number={6},\n  pages={1577--1596},\n  year={2021},\n  publisher={Springer}\n}\n\n@article{barbareschi2022catalog,\n  title={A Catalog-based AIG-Rewriting Approach to the Design of Approximate Components},\n  author={Barbareschi, Mario and Barone, Salvatore and Mazzocca, Nicola and Moriconi, Alberto},\n  journal={IEEE Transactions on Emerging Topics in Computing},\n  year={2022},\n  publisher={IEEE}\n}\n```\n\n# Using the ready-to-use docker container\npyALS has quite a lot of dependencies. You need to install Yosys (and its dependencies), GHDL (and, again, its dependencies), and so forth.\nBefore you get a headache, ***you can use the Docker image I have made available to you [here](https://hub.docker.com/r/salvatorebarone/pyals-docker-image).***  \n\nPlease, use the following script to run the container, that allows specifying which catalog and which folder to share with the container.\n```bash\n#!/bin/bash\n\nusage() {\n  echo \"Usage: $0 -c catalog -s path_to_shared_folder\";\n  exit 1;\n}\n\nwhile getopts \"c:s:\" o; do\n    case \"${o}\" in\n        c)\n            catalog=${OPTARG}\n            ;;\n        s)\n            shared=${OPTARG}\n            ;;\n        *)\n            usage\n            ;;\n    esac\ndone\nshift $((OPTIND-1))\n\nif [ -z \"${catalog}\" ] || [ -z \"${shared}\" ] ; then\n    usage\nfi\n\ncatalog=`realpath ${catalog}`\nshared=`realpath ${shared}`\n[ ! -d $shared ] \u0026\u0026 mkdir -p $shared\nxhost local:docker\ndocker run --rm -e DISPLAY=unix$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix -v ${catalog}:/root/lut_catalog.db -v ${shared}:/root/shared -w /root --privileged -it salvatorebarone/pyals-docker-image /bin/zsh\n```\n\nIf, on the other hand, you really feel the need to install everything by hand, follow the guide below step by step. \nI'm sure it will be very helpful.\n\n# Running pyALS-RF\n\npyALS-rf provides several approximation flows, through a unified command line interface. You can select between the following commands:\n```\n  ps        Performs precision-scaling approximation\n  pruning   Performs the Hedge Trimming flow\n  als       Performs ALS approximation\n  full      Performs ps and als combined\n```\n\nsee\n```\n./pyals-rf --help\n```\nand\n```\n./pyals-rf COMMAND --help\n```\nfor more details.\n\nPlease kindly note you have to specify the path of the file where synthesized Boolean functions are stored.\nYou can find a ready to use cache at ```git@github.com:SalvatoreBarone/pyALS-lut-catalog```.\nIf you do not want to use the one I mentioned, pyALS-rf will perform the exact synthesis as needed.\n\n## The configuration file\nHere, I report the basic structure of a configuration file. You will find it within the pyALS root directory.\n\n\n### Configuration file for the ```ps``` command\n```\n\n```\n\n### Configuration file for the ```als``` and ```full``` commands\n\n```\n\n```\n\n#### Configuration file for the ```als-twostep``` and ```full-twostep``` commands\n\n```\n\n```\n\n\n# Manual Installation\npyALS-rf has quite a lot of dependencies. You need to install Yosys (and its dependencies), GHDL (and, again, its dependencies), and so forth.\nBefore you get a headache, ***you can use the Docker image I have made available to you [here](https://hub.docker.com/r/salvatorebarone/pyals-docker-image).***  \n\nIf, on the other hand, you really feel the need to install everything by hand, follow this guide step by step. \nI'm sure it will be very helpful.\nThe guide has been tested on Debian 11.\n\n## Preliminaries\nYou need to install some basic dependencies. So, run\n```\n# apt-get install --fix-missing -y git bison clang cmake curl flex fzf g++ gnat gawk libffi-dev libreadline-dev libsqlite3-dev  libssl-dev make p7zip-full pkg-config python3 python3-dev python3-pip tcl-dev vim-nox wget xdot zlib1g-dev zlib1g-dev zsh libboost-dev libboost-filesystem-dev libboost-graph-dev libboost-iostreams-dev libboost-program-options-dev libboost-python-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev\n```\n\nYou also need to create some symbolic links.\n```\n# ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so /usr/lib/x86_64-linux-gnu/libtinfo.so.5\n# ln -fs /usr/lib/x86_64-linux-gnu/libboost_python39.a /usr/lib/x86_64-linux-gnu/libboost_python.a\n# ln -fs /usr/lib/x86_64-linux-gnu/libboost_python39.so /usr/lib/x86_64-linux-gnu/libboost_python.so\n```\nPlease, kindly note you are required to amend any differences concerning the python version. I'm using python 3.9 here.\n\n\n## Installing Yosys\nFirst, you need to clone Yosys from its public repository\n```\n$ git clone https://github.com/YosysHQ/yosys\n```\nThis will create a ```yosys``` sub-directory inside your current directory. Now move into the ```yosys``` directory, and create a ```Makefile.conf``` file.\n```\n$ cd yosys\n$ touch Makefile.conf\n```\nPaste the following into the ```Makefile.conf``` file.\n```\nCONFIG := clang\nCXXFLAGS += -I/usr/include/python3.9/ -fPIC\nENABLE_LIBYOSYS=1\nENABLE_PYOSYS=1\nPYTHON_EXECUTABLE=/usr/bin/python3 \nPYTHON_VERSION=3.9 \nPYTHON_CONFIG=python3-config \nPYTHON_DESTDIR=/usr/local/lib/python3.9/dist-packages\nBOOST_PYTHON_LIB=/usr/lib/x86_64-linux-gnu/libboost_python.so -lpython3.9\n```\nPlease, kindly note you are required to amend any differences concerning the python version. I'm using python 3.9 here.\nNow you need to a little quick fix to yosys: edit the ```kernel/yosys.cc``` file, searching for the definition of the \n```run_pass``` function. Comment the call to the ```log``` function as follows.\n```\nvoid run_pass(std::string command, RTLIL::Design *design)\n{\n\tif (design == nullptr)\n\t\tdesign = yosys_design;\n\n\t//log(\"\\n-- Running command `%s' --\\n\", command.c_str());\n\n\tPass::call(design, command);\n}\n```\nThis will remove redundant logs while running the optimizer.\nOk, now you are ready.\n```\n$ make -j `nproc`\n# make install\n# ln -s `realpath yosys` /usr/bin\n# ln -s `realpath yosys-abc` /usr/bin\n```\n\n## Installing GHDL\nGHDL and its Yosys plugin are required to process VHDL-encoded designs. \nPlease, kindly note that you will be able to successfully install the GHDL Yosys plugin only if you successfully installed Yosys. \nLet's install GHDL first. As always, you need to clone GHDL from ist public repository and compile it.\n```\n$ git clone https://github.com/ghdl/ghdl.git\n$ cd ghdl\n$ ./configure --prefix=/usr/local\n$ make\n# make install\n```\nThe same applies to its Yosys plugin. \n```\n$ git clone https://github.com/ghdl/ghdl-yosys-plugin.git\n$ cd ghdl-yosys-plugin\n$ make\n# make install\n```\n\n## Installing python dependencies\nYou're almost done. The last step is to install python dependencies. Some of them can be installed automatically, some others must be installed manually.Let's start with the latter ones. \n\nYou must install the [pyAMOSA](https://github.com/SalvatoreBarone/pyAMOSA) module\n```\n$ git clone https://github.com/SalvatoreBarone/pyAMOSA.git\n$ cd pyAMOSA\n# python3 setup.py install\n$ cd ..\n```\nand the [pyALSlib](https://github.com/SalvatoreBarone/pyALSlib) module\n```\n$ git clone https://github.com/SalvatoreBarone/pyALSlib.git\n$ cd pyALSlib\n# python3 setup.py install\n$ cd ..\n```\n\nPertaining to other dependencies, installing them is quite simple, and you just need to issue the following command from within the pyALS directory.\n```bash\npip3 install -r requirements.txt \n```\n\n\n## References\n1. Bandyopadhyay, S., Saha, S., Maulik, U., \u0026 Deb, K. (2008). A simulated annealing-based multiobjective optimization algorithm: AMOSA. IEEE transactions on evolutionary computation, 12(3), 269-283.\n2. Blank, Julian, and Kalyanmoy Deb. \"A running performance metric and termination criterion for evaluating evolutionary multi-and many-objective optimization algorithms.\" 2020 IEEE Congress on Evolutionary Computation (CEC). IEEE, 2020.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalvatorebarone%2Fpyals-rf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalvatorebarone%2Fpyals-rf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalvatorebarone%2Fpyals-rf/lists"}