ProcessGraph


NameProcessGraph JSON
Version 1.26 PyPI version JSON
download
home_pageNone
SummaryConnecting Process Network Synthesis (PNS) to Modern Programming Ecosystems
upload_time2024-11-15 16:09:56
maintainerNone
docs_urlNone
authorSin Yong Teng
requires_pythonNone
licenseBSD 2-Clause
keywords process optimization process network synthesis artificial intelligence
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pgraph : Process Graphs for Process Network Synthesis (PNS)

![Pgraphlogo](https://user-images.githubusercontent.com/19692103/176261331-5ec5fd1d-eec6-467c-b79c-ed48691eecfb.png)
[![DOI](https://zenodo.org/badge/507569838.svg)](https://zenodo.org/badge/latestdoi/507569838)

<!-- TABLE OF CONTENTS -->
## Table of Contents

* [About the Project](#about-the-project)
* [Getting Started](#getting-started)
* [Usage Examples](#usage-examples)
* [Contributing](#contributing)
* [License](#license)
* [Contact](#contact)
* [References](#references)


<!-- ABOUT THE PROJECT -->
## About The Project
This project aims at enabling the classical P-graph Framework (www.p-graph.org) to interface with modern Python programming ecosystems. The backend solver is the original executable from P-graph, staying true to the original implementation of P-graph. For manual network manipulation, the P-graph studio can be downloaded from this link: https://p-graph.org/downloads/. 

# Changelog
14/11/2024: Due to update of P-graph studio, mutual exclusion is not properly processed. This is now fixed. Custom solvers can now also be selected for advanced users.

18/10/2024: Due to update of networkx draw, older versions of Pgraph crashes when it draws the graph. This has now been fixed. Users now need to adjust axis size themselves.


<!-- GETTING STARTED -->
## Getting Started

Install this library either from the official PyPI or from this Github repository:

## Install a Stable Version (PyPI)
```bat
pip install ProcessGraph
```
## Install most updated version from Github

In a environment terminal or CMD:
```bat
pip install git+https://github.com/tsyet12/Pgraph
```


<!-- USAGE EXAMPLES -->
## Usage Examples

See [`examples`](https://github.com/tsyet12/Pgraph/tree/main/examples) for all code examples.

### Simple Example
```python
from Pgraph.Pgraph import Pgraph #This is our Pgraph library
import networkx as nx
import matplotlib.pyplot as plt
##### STEP 1 : Problem Specification ######
G = nx.DiGraph()
G.add_node("M1",names="Product D",type='product',flow_rate_lower_bound=100, flow_rate_upper_bound=100)
G.add_node("M2",names="Chemical A",type='raw_material',price=200,flow_rate_lower_bound=0)
G.add_node("M3",names="Chemical B", type='raw_material',price=100,flow_rate_lower_bound=0)
G.add_node("M4",names="Chemical C", type='raw_material',price=10,flow_rate_lower_bound=0)
G.add_node("O1",names="Reactor 1",fix_cost=2000, proportional_cost=400)
G.add_node("O2", names="Reactor 2",fix_cost=1000, proportional_cost=400)
G.add_edge("M2","O1", weight = 1)
G.add_edge("M3","O2", weight = 1)
G.add_edge("M4","O2", weight = 2)
G.add_edge("O1","M1", weight = 0.7) 
G.add_edge("O2","M1", weight = 0.9) 
ME=[["O1","O2"]]  #Reactor 1 and Reactor 2 are mutually excluded. Only one can be chosen as solution.

#### Step 2:  Setup Solver ####
P=Pgraph(problem_network=G, mutual_exclusion=ME, solver="INSIDEOUT",max_sol=100)

#### Step 2.1:  Plot Problem #####
ax1=P.plot_problem(figsize=(5,5))
ax1.set_xlim(0,200)
plt.show()
##################################
```

![fullnetwork](https://user-images.githubusercontent.com/19692103/176417558-2506be4e-5283-4c7c-9dd7-d271e52555d0.png)

```python
#### Step 3: Run ####
P.run()
#### Step 3.1: Plot Solution########
total_sol_num=P.get_sol_num() 
for i in range(total_sol_num): # Here we loop through all the solutions to plot everything
    ax=P.plot_solution(sol_num=i) #Plot Solution Function
    ax.set_xlim(0,200)
    plt.show()
```

![example](https://user-images.githubusercontent.com/19692103/176265167-3e41b536-9f2b-48df-b559-9290277065e7.png)
![sol2](https://user-images.githubusercontent.com/19692103/176417706-dd2817eb-a6e0-4804-9c86-5d443d4567e6.png)

```python
#### Step 3.2: Export to P-graph Studio ####
from google.colab import files #This is only for google colab
string = P.to_studio(path='./',verbose=False) #export to p-graph studio
files.download("./studio_file.pgsx") #download for google colab
#Note: Please be reminded to press "Generate Layout" button in P-graph Studio after opening
```

Press "Generate Layout" Button:

![layout](https://user-images.githubusercontent.com/19692103/176418041-e970a0bd-1b93-4a64-9cdb-544ae8c6a88b.PNG)


<!-- CONTRIBUTING -->
## Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b testbranch/prep`)
3. Commit your Changes (`git commit -m 'Improve testbranch/prep'`)
4. Push to the Branch (`git push origin testbranch/prep`)
5. Open a Pull Request


<!-- LICENSE -->
## License

Distributed under the Open Sourced BSD-2-Clause License. See [`LICENSE`](https://github.com/tsyet12/Pgraph/blob/main/LICENSE) for more information.


<!-- CONTACT -->
## Contact
Main Developer:

Sin Yong Teng sinyong.teng@ru.nl or tsyet12@gmail.com
Radboud University Nijmegen

<!-- References -->
## References

Teng, S.Y., Orosz, Á., How, B.S., Pimentel, J., Friedler, F. and Jansen, J.J., 2022. Framework to Embed Machine Learning Algorithms in P-graph: Communication from the Chemical Process Perspectives. Chemical Engineering Research and Design. (Paper explaining the software)

Friedler, F., Tarjan, K., Huang, Y.W. and Fan, L.T., 1992. Graph-theoretic approach to process synthesis: axioms and theorems. Chemical Engineering Science, 47(8), pp.1973-1988.

Friedler, F., Tarjan, K., Huang, Y.W. and Fan, L.T., 1992. Combinatorial algorithms for process synthesis. Computers & chemical engineering, 16, pp.S313-S320.

Friedler, F., Tarjan, K., Huang, Y.W. and Fan, L.T., 1993. Graph-theoretic approach to process synthesis: polynomial algorithm for maximal structure generation. Computers & Chemical Engineering, 17(9), pp.929-942.


## Acknowledgements
The research contribution from S.Y. Teng is supported by the European Union's Horizon Europe Research and Innovation Program, under Marie Skłodowska-Curie Actions grant agreement no. 101064585 (MoCEGS).


## How to cite this software

S.Y. Teng (2022). tsyet12/Pgraph: Process Graphs for Process Network Synthesis (PNS), Zenodo Release 2 (v1.0-zenodo-2). Zenodo. https://doi.org/10.5281/zenodo.6778354

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ProcessGraph",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "Process Optimization, Process Network Synthesis, Artificial Intelligence",
    "author": "Sin Yong Teng",
    "author_email": "tsyet12@gmail.com",
    "download_url": null,
    "platform": null,
    "description": "# Pgraph : Process Graphs for Process Network Synthesis (PNS)\n\n![Pgraphlogo](https://user-images.githubusercontent.com/19692103/176261331-5ec5fd1d-eec6-467c-b79c-ed48691eecfb.png)\n[![DOI](https://zenodo.org/badge/507569838.svg)](https://zenodo.org/badge/latestdoi/507569838)\n\n<!-- TABLE OF CONTENTS -->\n## Table of Contents\n\n* [About the Project](#about-the-project)\n* [Getting Started](#getting-started)\n* [Usage Examples](#usage-examples)\n* [Contributing](#contributing)\n* [License](#license)\n* [Contact](#contact)\n* [References](#references)\n\n\n<!-- ABOUT THE PROJECT -->\n## About The Project\nThis project aims at enabling the classical P-graph Framework (www.p-graph.org) to interface with modern Python programming ecosystems. The backend solver is the original executable from P-graph, staying true to the original implementation of P-graph. For manual network manipulation, the P-graph studio can be downloaded from this link: https://p-graph.org/downloads/. \n\n# Changelog\n14/11/2024: Due to update of P-graph studio, mutual exclusion is not properly processed. This is now fixed. Custom solvers can now also be selected for advanced users.\n\n18/10/2024: Due to update of networkx draw, older versions of Pgraph crashes when it draws the graph. This has now been fixed. Users now need to adjust axis size themselves.\n\n\n<!-- GETTING STARTED -->\n## Getting Started\n\nInstall this library either from the official PyPI or from this Github repository:\n\n## Install a Stable Version (PyPI)\n```bat\npip install ProcessGraph\n```\n## Install most updated version from Github\n\nIn a environment terminal or CMD:\n```bat\npip install git+https://github.com/tsyet12/Pgraph\n```\n\n\n<!-- USAGE EXAMPLES -->\n## Usage Examples\n\nSee [`examples`](https://github.com/tsyet12/Pgraph/tree/main/examples) for all code examples.\n\n### Simple Example\n```python\nfrom Pgraph.Pgraph import Pgraph #This is our Pgraph library\nimport networkx as nx\nimport matplotlib.pyplot as plt\n##### STEP 1 : Problem Specification ######\nG = nx.DiGraph()\nG.add_node(\"M1\",names=\"Product D\",type='product',flow_rate_lower_bound=100, flow_rate_upper_bound=100)\nG.add_node(\"M2\",names=\"Chemical A\",type='raw_material',price=200,flow_rate_lower_bound=0)\nG.add_node(\"M3\",names=\"Chemical B\", type='raw_material',price=100,flow_rate_lower_bound=0)\nG.add_node(\"M4\",names=\"Chemical C\", type='raw_material',price=10,flow_rate_lower_bound=0)\nG.add_node(\"O1\",names=\"Reactor 1\",fix_cost=2000, proportional_cost=400)\nG.add_node(\"O2\", names=\"Reactor 2\",fix_cost=1000, proportional_cost=400)\nG.add_edge(\"M2\",\"O1\", weight = 1)\nG.add_edge(\"M3\",\"O2\", weight = 1)\nG.add_edge(\"M4\",\"O2\", weight = 2)\nG.add_edge(\"O1\",\"M1\", weight = 0.7) \nG.add_edge(\"O2\",\"M1\", weight = 0.9) \nME=[[\"O1\",\"O2\"]]  #Reactor 1 and Reactor 2 are mutually excluded. Only one can be chosen as solution.\n\n#### Step 2:  Setup Solver ####\nP=Pgraph(problem_network=G, mutual_exclusion=ME, solver=\"INSIDEOUT\",max_sol=100)\n\n#### Step 2.1:  Plot Problem #####\nax1=P.plot_problem(figsize=(5,5))\nax1.set_xlim(0,200)\nplt.show()\n##################################\n```\n\n![fullnetwork](https://user-images.githubusercontent.com/19692103/176417558-2506be4e-5283-4c7c-9dd7-d271e52555d0.png)\n\n```python\n#### Step 3: Run ####\nP.run()\n#### Step 3.1: Plot Solution########\ntotal_sol_num=P.get_sol_num() \nfor i in range(total_sol_num): # Here we loop through all the solutions to plot everything\n    ax=P.plot_solution(sol_num=i) #Plot Solution Function\n    ax.set_xlim(0,200)\n    plt.show()\n```\n\n![example](https://user-images.githubusercontent.com/19692103/176265167-3e41b536-9f2b-48df-b559-9290277065e7.png)\n![sol2](https://user-images.githubusercontent.com/19692103/176417706-dd2817eb-a6e0-4804-9c86-5d443d4567e6.png)\n\n```python\n#### Step 3.2: Export to P-graph Studio ####\nfrom google.colab import files #This is only for google colab\nstring = P.to_studio(path='./',verbose=False) #export to p-graph studio\nfiles.download(\"./studio_file.pgsx\") #download for google colab\n#Note: Please be reminded to press \"Generate Layout\" button in P-graph Studio after opening\n```\n\nPress \"Generate Layout\" Button:\n\n![layout](https://user-images.githubusercontent.com/19692103/176418041-e970a0bd-1b93-4a64-9cdb-544ae8c6a88b.PNG)\n\n\n<!-- CONTRIBUTING -->\n## Contributing\n\nContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b testbranch/prep`)\n3. Commit your Changes (`git commit -m 'Improve testbranch/prep'`)\n4. Push to the Branch (`git push origin testbranch/prep`)\n5. Open a Pull Request\n\n\n<!-- LICENSE -->\n## License\n\nDistributed under the Open Sourced BSD-2-Clause License. See [`LICENSE`](https://github.com/tsyet12/Pgraph/blob/main/LICENSE) for more information.\n\n\n<!-- CONTACT -->\n## Contact\nMain Developer:\n\nSin Yong Teng sinyong.teng@ru.nl or tsyet12@gmail.com\nRadboud University Nijmegen\n\n<!-- References -->\n## References\n\nTeng, S.Y., Orosz, \u00c1., How, B.S., Pimentel, J., Friedler, F. and Jansen, J.J., 2022. Framework to Embed Machine Learning Algorithms in P-graph: Communication from the Chemical Process Perspectives. Chemical Engineering Research and Design. (Paper explaining the software)\n\nFriedler, F., Tarjan, K., Huang, Y.W. and Fan, L.T., 1992. Graph-theoretic approach to process synthesis: axioms and theorems. Chemical Engineering Science, 47(8), pp.1973-1988.\n\nFriedler, F., Tarjan, K., Huang, Y.W. and Fan, L.T., 1992. Combinatorial algorithms for process synthesis. Computers & chemical engineering, 16, pp.S313-S320.\n\nFriedler, F., Tarjan, K., Huang, Y.W. and Fan, L.T., 1993. Graph-theoretic approach to process synthesis: polynomial algorithm for maximal structure generation. Computers & Chemical Engineering, 17(9), pp.929-942.\n\n\n## Acknowledgements\nThe research contribution from S.Y. Teng is supported by the European Union's Horizon Europe Research and Innovation Program, under Marie Sk\u0142odowska-Curie Actions grant agreement no. 101064585 (MoCEGS).\n\n\n## How to cite this software\n\nS.Y. Teng (2022). tsyet12/Pgraph: Process Graphs for Process Network Synthesis (PNS), Zenodo Release 2 (v1.0-zenodo-2). Zenodo. https://doi.org/10.5281/zenodo.6778354\n",
    "bugtrack_url": null,
    "license": "BSD 2-Clause",
    "summary": "Connecting Process Network Synthesis (PNS) to Modern Programming Ecosystems",
    "version": "1.26",
    "project_urls": null,
    "split_keywords": [
        "process optimization",
        " process network synthesis",
        " artificial intelligence"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c548783c671f165fb3af78174041b0f226e4c6129596edb8b6b9122d9358e6f2",
                "md5": "12b2b5d0b5246d9aeecb794c836e40cf",
                "sha256": "47ba941ca5433587fa8ed51e0da0d8b92c249a2b58c9d91a4f2b7c40a10a5734"
            },
            "downloads": -1,
            "filename": "ProcessGraph-1.26-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "12b2b5d0b5246d9aeecb794c836e40cf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7683974,
            "upload_time": "2024-11-15T16:09:56",
            "upload_time_iso_8601": "2024-11-15T16:09:56.842892Z",
            "url": "https://files.pythonhosted.org/packages/c5/48/783c671f165fb3af78174041b0f226e4c6129596edb8b6b9122d9358e6f2/ProcessGraph-1.26-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-15 16:09:56",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "processgraph"
}
        
Elapsed time: 0.91262s