use execution graph and add additional fitting methods #308
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.