{"id":24539139,"url":"https://github.com/i-m-iron-man/nde_foraging","last_synced_at":"2026-04-28T15:36:36.217Z","repository":{"id":218184108,"uuid":"734303542","full_name":"i-m-iron-man/NDE_Foraging","owner":"i-m-iron-man","description":"A dynamical systems approach to adaptive patch foraging by using Neural Differential Equations.","archived":false,"fork":false,"pushed_at":"2024-11-06T13:26:07.000Z","size":11326,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-30T20:06:38.209Z","etag":null,"topics":["dynamical","foraging","jax","neural-differential-equations","python"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/i-m-iron-man.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":"2023-12-21T10:56:26.000Z","updated_at":"2024-11-06T13:26:10.000Z","dependencies_parsed_at":"2024-11-06T14:36:13.812Z","dependency_job_id":null,"html_url":"https://github.com/i-m-iron-man/NDE_Foraging","commit_stats":null,"previous_names":["i-m-iron-man/nde_foraging"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/i-m-iron-man/NDE_Foraging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-m-iron-man%2FNDE_Foraging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-m-iron-man%2FNDE_Foraging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-m-iron-man%2FNDE_Foraging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-m-iron-man%2FNDE_Foraging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/i-m-iron-man","download_url":"https://codeload.github.com/i-m-iron-man/NDE_Foraging/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-m-iron-man%2FNDE_Foraging/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32387911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["dynamical","foraging","jax","neural-differential-equations","python"],"created_at":"2025-01-22T16:15:33.469Z","updated_at":"2026-04-28T15:36:32.519Z","avatar_url":"https://github.com/i-m-iron-man.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NDE Foraging\nThis repository supplements our paper [\"A Dynamical Systems Approach to Optimal Foraging\"](https://doi.org/10.1371/journal.pcsy.0000018)\u003c/br\u003e\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\u003c/br\u003e\n![Alt Text](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/media/foraging.gif)\n\n\n## Overview\nThis repository contains code for the 3 experiments presented in the paper. It is developed using the JAX ecosystem\u003c/br\u003e\n- Experiment 1 highlights the learning process involved in adaptive patch foraging and analysis of the learned agent at various stages of training. \u003c/br\u003e\n- Experiment 2 presents an analysis of evidence accumulation mechanism observed in the adaptive agent. \u003c/br\u003e\n- Experiment 3 presents an analysis of change in average patch residing time of the adaptive agent with respect to change in growth rate of the resources in the environment.\u003c/br\u003e\n- Experiment 4 shows how the setup can be extended to nosiy setup like noise in observations.\n- Experiment 5 shows how the setup can be extended to multi-agent setups.\n\n## Requirements\nIn order to run the code following requirements must be satisfied. \u003c/br\u003e\n- [Python](https://www.python.org/downloads/) - 3.10.10\n- [IPython](https://ipython.org/) - 8.10.0\n- [JAX](https://jax.readthedocs.io/en/latest/installation.html) - 0.4.13\n- [Diffrax](https://github.com/patrick-kidger/diffrax) - 0.4.0\n- [Equinox](https://github.com/patrick-kidger/equinox) - 0.10.6\n- [Optax](https://github.com/google-deepmind/optax) - 0.1.4\n- [NumPy](https://numpy.org/install/) - 1.26.1\n- [Matplotlib](https://matplotlib.org/) - 3.6.3\n\n## File structure\nThis repository is stuctured as follows\n- [source](https://github.com/i-m-iron-man/NDE_Foraging/tree/main/source)\n    - [exp_1_basic_foraging](https://github.com/i-m-iron-man/NDE_Foraging/tree/main/source/exp_1_basic_foraging): directory for Experiment 1.\n        - [main.py](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_1_basic_foraging/main.py): A Python script that executes the learning process for different seeds.\n        - [plot_values.ipynb](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_1_basic_foraging/plot_values.ipynb): An IPython notebook to plot the loss curve.\n        - [analysis.ipynb](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_1_basic_foraging/analysis.ipynb): An IPython notebook to observe the behaviour of agent at various stages of training.\n        - [render.py](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_1_basic_foraging/render.py): A Python Script to render the learned agent.\n    - [exp_2_evidence_accumulation](https://github.com/i-m-iron-man/NDE_Foraging/tree/main/source/exp_2_evidence_accumulation): directory for Experiment 2.\n        - [evidence.ipynb](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_2_evidence_accumulation/evidence.ipynb): An IPython notebook to analyse the neuronal dynamics of the learned agent.\n    - [exp_3_diff_growth_rate](https://github.com/i-m-iron-man/NDE_Foraging/tree/main/source/exp_3_diff_growth_rate): directory for Experiment 3.\n        - [growth_rate_08f.py](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_3_diff_growth_rate/growth_rate_08f.py): A Python file for learning in the environment having growth rate of 0.08.\n        - [growth_rate_10f.py](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_3_diff_growth_rate/growth_rate_10f.py): A Python file for learning in the environment having growth rate of 0.1.\n        - [growth_rate_12f.py](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_3_diff_growth_rate/growth_rate_12f.py): A Python file for learning in the environment having growth rate of 0.12.\n        - [growth_rate_time_analysis.ipynb](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_3_diff_growth_rate/growth_rate_time_analysis.ipynb): An IPython notebook to sample and compare average patch residing time for agent trajectories in the 3 environemts.\n        - [avg_growth_rate_plt.ipynb](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_3_diff_growth_rate/avg_growth_rate_plt.ipynb): An IPython notebook to plot the average patch residing time across the 3 environments for the first 3 patch visits.\n   - [exp_4_noise](https://github.com/i-m-iron-man/NDE_Foraging/tree/main/source/exp_4_noise): directory for Experiment 4.\n    \t- [min.py](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_4_noise/main.py): A python file that executes learning process for noisy setup for different seeds.\n      \t- [render.py](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_4_noise/render.py): A Python script to render the learned agents.\n      \t- [plot.ipynb](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_4_noise/plot.ipynb): An IPython notebook to plot different performance criteria for comparison.\n   - [exp_5_multi_Agent](https://github.com/i-m-iron-man/NDE_Foraging/tree/main/source/exp_5_multi_agent): directory for Experiment 5.\n        - [main_g_01.py](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_5_multi_agent/main_g_01.py): A Python script for learning in an environemt where growth rate of both resources is 0.1.\n        - [main_g_03.py](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_5_multi_agent/main_g_03.py): A Python script for learning in an environemt where growth rate of the first resource is 0.1 and second resource is 0.3\n        - [main_g_10.py](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_5_multi_agent/main_g_10.py): A Python script for learning in an environemt where growth rate of the first resource is 0.1 and second resource is 1.0\n        - [render.py](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_5_multi_agent/render.py): A Python script for rendering the multi-agent setup\n        - [infer.ipynb](https://github.com/i-m-iron-man/NDE_Foraging/blob/main/source/exp_5_multi_agent/infer.ipynb): An IPython notebook to plot relevant trends of the experiment.\n      \n## Acknowledgements\nThis software is part of the project Dutch Brain Interface Initiative (DBI\u003csup\u003e2\u003c/sup\u003e) with project number 024.005.022 of the research programme Gravitation which is (partly) financed by the Dutch Research Council (NWO).\n\n## Citation\nFor citing this work you can cite the paper\n\n```\n@article {Chaturvedi2024.01.20.576399,\n\tauthor = {Siddharth Chaturvedi and Ahmed ElGazzar and Marcel van Gerven},\n\ttitle = {A Dynamical Systems Approach to Optimal Foraging},\n\telocation-id = {2024.01.20.576399},\n\tyear = {2024},\n\tdoi = {10.1101/2024.01.20.576399},\n\tpublisher = {Cold Spring Harbor Laboratory},\n\tURL = {https://www.biorxiv.org/content/early/2024/01/22/2024.01.20.576399},\n\teprint = {https://www.biorxiv.org/content/early/2024/01/22/2024.01.20.576399.full.pdf},\n\tjournal = {bioRxiv}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi-m-iron-man%2Fnde_foraging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fi-m-iron-man%2Fnde_foraging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi-m-iron-man%2Fnde_foraging/lists"}