-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use execution graph and add additional fitting methods #308
base: main
Are you sure you want to change the base?
use execution graph and add additional fitting methods #308
Conversation
As I go through the issues, this fixes #163 by providing an option to return the estimated covariance matrix. |
This is a pretty great set of changes, thanks @andersonjacob. It is a little challenging to work through all the logic, code quality, etc. changes in one big PR, but at a first glance the circuit graph idea seems like a good way to avoid @BGerwe might also find this interesting as well. |
Sorry, I'm just circling back to this; I've been an a conference all week. I totally understand that this is a really large change in the internals of the package and it will (should) take some time to go over.
|
**Execution Graph** * Added support to graph-based function evaluation (Thanks @andersonjacob for the [source code](ECSHackWeek/impedance.py#308)) * Added speed benchmark for the graph on documentation * Update compute methods to return impedance value **Computation Optimization** * Vectorized calculation in circuit elements for fast computation **New Circuit Elements** * Added support to nonlinear RC with constant phase element: (RCDQ, RCDQn), and (RCSQ, RCSQn) * Added more tests to cover the changes **Documentation** * Added Release Notes * Improve docstring for clarity **General Code Improvement** * Minor code improvement for better handling * Bumped version to v0.2 * add networkx dependency to environment.yml * Updated requirement.txt and setup.py **Tests** * Added more tests to cover the changes
I'll just get this out there early. This isn't a small change. I refactored the all the computation of the impedance for a circuit. This eliminates all the string building and calls to
eval(...)
in favor of an execution graph. This makes it easier to debug what is going on. My original goal was to tweak/improve the optimization, but once I ran into debugging difficulties, it all got changed.From the outside things look almost identical with a few additional fitting options, but under the covers a lot of things have changed. All the tests + the new ones are passing, and the new DAG based circuit evaluation could open the door for more advanced things like parallel execution for large problems.
As an example, the circuit string:
![image](https://private-user-images.githubusercontent.com/4662082/364920215-83dd329d-96e2-4090-8802-cb160c0cdc15.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NjQzMTcsIm5iZiI6MTczODk2NDAxNywicGF0aCI6Ii80NjYyMDgyLzM2NDkyMDIxNS04M2RkMzI5ZC05NmUyLTQwOTAtODgwMi1jYjE2MGMwY2RjMTUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDdUMjEzMzM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NjdkZWRiMTIzODdjNGQzN2FhMzM0MWI1YzZiYTlkMjczN2ZjY2MyNzc2ZmNhMGJkODM4Yjc4MDk3OThlMTM0NiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.D4pAj2D5mjX6iVu69qjc4tK2LE5nAXSsZeIhZDIbgso)
R0-p(R1,C1)-p(R2-Wo1,C2)
is parsed into a graph that looks like:where you can see how the different nodes depend on the impedance of other nodes. The computation then proceeds from left to right, with the outputs of each node becoming inputs to successor nodes.
This visualization can be had with this simple example code:
This is a large change; I know that. If the changes are valuable, but splitting them up into more manageable chunks is desirable, I'm open to exploring that.