# PBFE
## Table of contents
- [Overview](#overview)
- [Introduction](#introduction)
- [Results](#results)
- [Usage](#usage)
- [Setup](#setup)
- [Running](#running)
- [Authors](#authors)
- [Contact](#contact)
- [Citation](#citation)
- [License](#license)
- [Acknowledgements](#acknowledgements)
- [Funding](#funding)
## Overview
### Introduction
PBFE stands for [Performance Based Engineering for Resilient Food Industry](https://food-manufacturing.berkeley.edu/performance-based-eng-for-resilient-food-ind/). We aim at developing a food system management framework by combining Performance Based Engineering (PBE) and Artificial Intelligence (AI), to increase the efficiency, safety & resilience of agricultural production by improving food yield in terms of both quantity and quality, controlling crop diseases, decreasing resource consumption & waste, and increasing traceability. Traditionally, agricultural management is based on empirical judgement resulting from experiments & experience, which is no longer adequate because of increased complexity and added uncertainty of food systems due to the increasing demands of the world population. Thus, uncertainty quantification in food systems has been recently adopted. However, a robust framework is still lacking and this project aims at filling this gap.
*Figure 1. Overview of the PBFE framework.*
<!--- Everything Here Will Be Commented OUT --->
<!--- ![Figure 1](./figures/PBFE.png) --->
<p align="center">
<img src="https://raw.githubusercontent.com/hufanyoung/PBFE/main/figures/PBFE.png" width="80%">
</p>
### Results
PBFE consists of four phases (environmental hazard analysis, crop growth analysis, crop yield analysis and loss analysis) and uses the total probability theorem to compute the loss curve which represents the Probability of Exceedance (POE) of different values of a Decision Variable (DV). We developed the *Python* script for implementing the PBFE methodology, where the selections of the variables in each phase are shown in Figure 2.
<!--- $$P(DV_n) = \sum\limits_m \sum\limits_i \sum\limits_k P(DV_n | YP_k) p(YP_k | SM_i) p(SM_i | IM_m) p(IM_m)$$ --->
*Figure 2. PBFE formulation and variable selections.*
<!--- ![Figure 2](./figures/pbfe_formulation.png) --->
<p align="center">
<img src="https://raw.githubusercontent.com/hufanyoung/PBFE/main/figures/pbfe_formulation.png" width="60%">
</p>
A branch graph (Figure 3) can be used to visualize the computations and to clarify the formulation and the numerical process. Since currently there is not sufficient data to quantify the probabilities, the developed script used some hypothetical values for each phase, resulting in the loss curve shown in Figure 4 as a demonstrative application.
*Figure 3. Branch graph for the formulation process visualization.*
<!--- ![Figure 3](./figures/branch_hl.png) --->
<p align="center">
<img src="https://raw.githubusercontent.com/hufanyoung/PBFE/main/figures/branch_hl.png" width="60%">
</p>
*Figure 4. Example loss curve obtained by the PBFE methodology.*
<!--- ![Figure 4](./figures/loss_curve.png) --->
<p align="center">
<img src="https://raw.githubusercontent.com/hufanyoung/PBFE/main/figures/loss_curve.png" width="50%">
</p>
We selected *drought* as the environmental hazard variable in phase 1. For environmental hazard analysis, we collected weather data in California and developed a decision tree and a random forest model for drought classifications (D0, D1, D2, D3, & D4). The details and results can be found in the [./scripts/drought](https://github.com/hufanyoung/PBFE/tree/main/scripts/drought) folder.
## Usage
### Setup
<!--- Mention the environment the code was run on during development and testing as well as any dependencies that are needed. --->
This code has been tested with `Python 3.8`.
To prevent dependency problems, please use either `virtualenv`
```
# Activate Python virtualenv
virtualenv env_name
source ./env_name/bin/activate # Linux or Mac
# Dectivate Python virtualenv
deactivate
```
or `conda`.
```
# Activate Conda environment
conda create -n env_name python=3.8
# Deactivate Conda environment
conda deactivate
```
These platforms are convenient since they have the mostly used Python libraries pre-installed. If any error is incurred, please install the required python packages in your environment according to the error message.
### Running
The code for PBFE execution is straightforward and ready to use with the proper configuration of the parameters in four different phases.
In order to reproduce the results in the drought prediction work, please follow the detailed steps below to run the code.
#### Step 1.
Download all the input weather data following the instructions in the script.
#### Step 2.
Preprocessing the weather data for training the model, split the data into train, test, and validation sets.
#### Step 3.
Train the decision tree/random forest model.
## Authors
* Khalid M. Mosalam<sup>1,2,3</sup>
* Fan Hu<sup>1,3</sup>
1. Department of Civil and Environmental Engineering, University of California at Berkeley
2. Pacific Earthquake Engineering Research (PEER) Center, University of California at Davis
3. USDA/NSF AI Institute for Next Generation Food Systems (AIFS)
## Contact
For any questions, please contact us at mosalam@berkeley.edu.
## Citation
Citation will be updated later.
## License
This project is licensed under the [Name of license]. Please see the [LICENSE](https://github.com/AI-Institute-Food-Systems/aifs-github-best-practices/blob/main/LICENSE) file for details.
## Acknowledgements
Acknowledgements will be updated later.
## Funding
* USDA-NIFA AI Institute for Next Generation Food Systems (AIFS), USDA-NIFA award number 2020-67021-32855.
Raw data
{
"_id": null,
"home_page": null,
"name": "pbfe",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "dynamics, integration, seismic, earthquake-engineering",
"author": null,
"author_email": "Fan Hu <50180406+x@users.noreply.github.com>",
"download_url": "https://files.pythonhosted.org/packages/2e/ad/f22d76506508f370a5ad64ca9be0781f0d74b807b3cb031050968ded233f/pbfe-0.0.1.tar.gz",
"platform": null,
"description": "# PBFE \n\n## Table of contents\n\n- [Overview](#overview)\n - [Introduction](#introduction)\n - [Results](#results)\n- [Usage](#usage)\n - [Setup](#setup)\n - [Running](#running)\n- [Authors](#authors)\n- [Contact](#contact)\n- [Citation](#citation)\n- [License](#license)\n- [Acknowledgements](#acknowledgements)\n- [Funding](#funding)\n\n## Overview\n\n### Introduction\n\nPBFE stands for [Performance Based Engineering for Resilient Food Industry](https://food-manufacturing.berkeley.edu/performance-based-eng-for-resilient-food-ind/). We aim at developing a food system management framework by combining Performance Based Engineering (PBE) and Artificial Intelligence (AI), to increase the efficiency, safety & resilience of agricultural production by improving food yield in terms of both quantity and quality, controlling crop diseases, decreasing resource consumption & waste, and increasing traceability. Traditionally, agricultural management is based on empirical judgement resulting from experiments & experience, which is no longer adequate because of increased complexity and added uncertainty of food systems due to the increasing demands of the world population. Thus, uncertainty quantification in food systems has been recently adopted. However, a robust framework is still lacking and this project aims at filling this gap.\n\n*Figure 1. Overview of the PBFE framework.*\n\n<!--- Everything Here Will Be Commented OUT --->\n<!--- ![Figure 1](./figures/PBFE.png) --->\n<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/hufanyoung/PBFE/main/figures/PBFE.png\" width=\"80%\">\n</p>\n\n### Results\n\nPBFE consists of four phases (environmental hazard analysis, crop growth analysis, crop yield analysis and loss analysis) and uses the total probability theorem to compute the loss curve which represents the Probability of Exceedance (POE) of different values of a Decision Variable (DV). We developed the *Python* script for implementing the PBFE methodology, where the selections of the variables in each phase are shown in Figure 2.\n\n<!--- $$P(DV_n) = \\sum\\limits_m \\sum\\limits_i \\sum\\limits_k P(DV_n | YP_k) p(YP_k | SM_i) p(SM_i | IM_m) p(IM_m)$$ --->\n\n*Figure 2. PBFE formulation and variable selections.*\n\n<!--- ![Figure 2](./figures/pbfe_formulation.png) --->\n<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/hufanyoung/PBFE/main/figures/pbfe_formulation.png\" width=\"60%\">\n</p>\n\nA branch graph (Figure 3) can be used to visualize the computations and to clarify the formulation and the numerical process. Since currently there is not sufficient data to quantify the probabilities, the developed script used some hypothetical values for each phase, resulting in the loss curve shown in Figure 4 as a demonstrative application.\n\n*Figure 3. Branch graph for the formulation process visualization.*\n\n<!--- ![Figure 3](./figures/branch_hl.png) --->\n<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/hufanyoung/PBFE/main/figures/branch_hl.png\" width=\"60%\">\n</p>\n\n*Figure 4. Example loss curve obtained by the PBFE methodology.*\n\n<!--- ![Figure 4](./figures/loss_curve.png) --->\n<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/hufanyoung/PBFE/main/figures/loss_curve.png\" width=\"50%\">\n</p>\n\nWe selected *drought* as the environmental hazard variable in phase 1. For environmental hazard analysis, we collected weather data in California and developed a decision tree and a random forest model for drought classifications (D0, D1, D2, D3, & D4). The details and results can be found in the [./scripts/drought](https://github.com/hufanyoung/PBFE/tree/main/scripts/drought) folder. \n\n## Usage\n\n### Setup\n\n<!--- Mention the environment the code was run on during development and testing as well as any dependencies that are needed. --->\nThis code has been tested with `Python 3.8`.\n\nTo prevent dependency problems, please use either `virtualenv`\n```\n# Activate Python virtualenv\nvirtualenv env_name\nsource ./env_name/bin/activate # Linux or Mac\n\n# Dectivate Python virtualenv\ndeactivate\n```\nor `conda`.\n```\n# Activate Conda environment\nconda create -n env_name python=3.8\n\n# Deactivate Conda environment\nconda deactivate\n```\n\nThese platforms are convenient since they have the mostly used Python libraries pre-installed. If any error is incurred, please install the required python packages in your environment according to the error message. \n\n### Running\n\nThe code for PBFE execution is straightforward and ready to use with the proper configuration of the parameters in four different phases. \n\nIn order to reproduce the results in the drought prediction work, please follow the detailed steps below to run the code.\n\n#### Step 1.\n\nDownload all the input weather data following the instructions in the script.\n\n#### Step 2.\n\nPreprocessing the weather data for training the model, split the data into train, test, and validation sets. \n\n#### Step 3.\n\nTrain the decision tree/random forest model. \n\n## Authors\n\n* Khalid M. Mosalam<sup>1,2,3</sup>\n* Fan Hu<sup>1,3</sup>\n\n1. Department of Civil and Environmental Engineering, University of California at Berkeley\n2. Pacific Earthquake Engineering Research (PEER) Center, University of California at Davis\n3. USDA/NSF AI Institute for Next Generation Food Systems (AIFS)\n\n## Contact\n\nFor any questions, please contact us at mosalam@berkeley.edu.\n\n## Citation\n\nCitation will be updated later.\n\n## License\n\nThis project is licensed under the [Name of license]. Please see the [LICENSE](https://github.com/AI-Institute-Food-Systems/aifs-github-best-practices/blob/main/LICENSE) file for details.\n\n## Acknowledgements\n\nAcknowledgements will be updated later.\n\n## Funding\n\n* USDA-NIFA AI Institute for Next Generation Food Systems (AIFS), USDA-NIFA award number 2020-67021-32855.\n",
"bugtrack_url": null,
"license": null,
"summary": ".",
"version": "0.0.1",
"project_urls": {
"Repository": "http://github.com/hufanyoung/PBFE"
},
"split_keywords": [
"dynamics",
" integration",
" seismic",
" earthquake-engineering"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "edc52e73084ece6e4179285fab93c5951a64a3fd4ee6c877aede9884b01cc86a",
"md5": "06fcd0e5bf5a18f1fc549bcf357bf859",
"sha256": "3e2e05b077b3d8a7e876064c7c6eca7faa27455c3570aa6a6121e0f75aef06d9"
},
"downloads": -1,
"filename": "pbfe-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "06fcd0e5bf5a18f1fc549bcf357bf859",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8079,
"upload_time": "2024-08-28T02:41:53",
"upload_time_iso_8601": "2024-08-28T02:41:53.171841Z",
"url": "https://files.pythonhosted.org/packages/ed/c5/2e73084ece6e4179285fab93c5951a64a3fd4ee6c877aede9884b01cc86a/pbfe-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2eadf22d76506508f370a5ad64ca9be0781f0d74b807b3cb031050968ded233f",
"md5": "993261dbb733ab01c938202e3c181d55",
"sha256": "4483ee442540902c92e143cdb039ac98aa1e8e2a7efff6ff28a0c7e197f61f53"
},
"downloads": -1,
"filename": "pbfe-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "993261dbb733ab01c938202e3c181d55",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8224,
"upload_time": "2024-08-28T02:41:54",
"upload_time_iso_8601": "2024-08-28T02:41:54.416870Z",
"url": "https://files.pythonhosted.org/packages/2e/ad/f22d76506508f370a5ad64ca9be0781f0d74b807b3cb031050968ded233f/pbfe-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-28 02:41:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hufanyoung",
"github_project": "PBFE",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "pbfe"
}