-
Notifications
You must be signed in to change notification settings - Fork 0
Program Documentation
Quick Sections:
This is where explanations of what methods and algorithms will be.
Description: Takes a string and appends the correct path to the assets folder (containing images) to the string input.
Variables: str ASSETS_PATH (global)
General Algorithm (if applicable): N/A
Returns (if anything): Str, path relative to assets.
Description: Receives input from the fields of the GUI and updates the global variables associated with them.
Variables: str functionStr (global), str variable (global), int point (global), int power (global), str lExpress (global), lambdaFunction lFunc (global)
General Algorithm (if applicable): Assigns each variable and prints the result in console log. lExpress is assigned as "lambda " + variable + ": " + functionStr, then eval(lExpress) is used to generate a lambda function for the input function.
Returns (if anything): N/A
Description: Calculates polynomials and generates graph and CRN.
Variables: TODO
General Algorithm (if applicable):
1. Updates global variables.
2. Determines FuncTypes value.
3. Sets global Function class variable.
4. Generates Polynomial and Rearrangement Coefficients.
4. Generates Circuit Diagram (NetworkX).
4. Generates the Chemical Reaction Network (CRN).
5. Determines the Maclaurin Series and Rearrangement Strings and displays them on GUI.
6. Traces the function to find the expected value and displays it on the GUI.
7. Displays the Chemical Reaction Network (CRN) on the GUI.
8. Displays the Circuit Diagram on the GUI.
Returns (if anything): N/A, everything is done through global variables.
Description: Clears the equation field in the GUI (button press).
Variables: Tkinter Entry entry_4 (global)
General Algorithm (if applicable): Delete from position 0 to end of input string.
Returns (if anything): N/A
Description: Insert a variable into the equation field in the GUI (button press).
Variables: Tkinter Entry entry_4 (global), str variable (global)
General Algorithm (if applicable): Insert at current cursor position.
Returns (if anything): N/A
Description: Inserts something into the equation field in the GUI (button press).
Variables: Object button (pass by value), Tkinter Entry entry_4 (global)
General Algorithm (if applicable): button variable is validated to a corresponding button on the GUI. When pressed, it will add what that button says into the equation field in the GUI.
Returns (if anything): N/A
Description: Back-bone generation of the GUI.
Variables: Tkinter Window window (global), Tkinter Canvas canvas (global), Tkinter Button button_{1-33} (global), PhotoImage button_image_{1-33} (global), Tkinter Entry entry_{1-8} (global), PhotoImage entry_image_{1-8} (global), PhotoImage image_{1-3} (global), PhotoImage image_image_3 (global)
General Algorithm (if applicable):
1. Initialize Tkinter window.
2. Initialize Tkinter canvas and attach to window.
3. Initialize and position buttons, entries, labels, and images.
4. Make window resizeable.
5. Begin GUI loop.
Returns (if anything): N/A
Description: Global variables initialized in self.init().
Variables: NoneType->Graph circuit, NoneType->Dict horner_coeffs, NoneType->Dict doubleNAND_coeffs, NoneType->Dict poli_coeffs, NoneType->Dict taylor_coeffs, NoneType->str taylorString, NoneType->str rearrangeString, NoneType->str CRN, NoneType->str traceString, float traceValue, NoneType->RearrangeType rearrangeType, Lambda Function function, int point, int order, FuncType functype, str title, str `variable
General Algorithm (if applicable): Set defaults in initialization, then as coefficients, graphs, and CRNs are generated, they'll be set to their correct values.
Returns (if anything): N/A, global variables
Description: Generates taylor series, polynomial, and rearrangement coefficients and prints its findings. This step determines type of rearrangement.
Variables: Dict taylor_coeffs (global), Dict poli_coeffs (global), str taylorString (global), RearrangementType rearrangementType (global), str rearrangementString (global), Dict horner_coeffs (global), Dict doubleNAND_coeffs (global)
General Algorithm (if applicable):
1. Determine Taylor Coefficients, print findings.
2. Determine Polynomial Coefficients, print findings.
3. Generate polynomial string (taylorString).
4. Determine Rearrangement Type.
5. Generate rearrangement coefficients (either Horner's or Double-NAND), print findings.
6. Generate rearrangement string.
Returns (if anything): N/A, sets global variables.
Description: Determines which rearrangement conditions the given function satisfies.
Variables: Dict fixedPoliCoeffs (local), int (acting as bool) alternatingSign (local), int (acting as bool) decreasingCoeffs (local), int (acting as bool) decreasingCoeffs (local), int (acting as bool) allPositive (local), float poli_total (local), float lastValue (local)
General Algorithm (if applicable):
1. Determine total of all polynomial coefficients.
2. Determine if the polynomial is all positive.
3. Determine if the polynomial coefficients are decreasing.
4. Determine if the polynomial is alternating signs (skips test if all positive).
5. If 0 <= coefficient total <= 1 and all coefficients are positive, assign Double NAND Replacement. if the coefficients are decreasing and alternating signs, assign Horner's Expansion.
6. Otherwise send Unknown error through gui.py.
Returns (if anything): RearrangementType.DOUBLE_NAND, RearrangementType.HORNER, or RearrangementType.UNKNOWN
Description: Generates a circuit diagram for the given function.
Variables: RearrangeType rearrangeType (global), Graph circuit (global)
General Algorithm (if applicable):
1. If Double-NAND rearrangement, calculate Util.doubleNAND_to_circuit(). If Horner's Expansion, calculate Util.horner_to_circuit(). (The GUI uses the self.circuit = ... to store and function.circuit to load the circuit diagram)
2. If rearrangement type is known (i.e., not unknown), display the generated graph to the user (this is NOT done through the GUI).
Returns (if anything): Produces the generated graph to the user. No value is returned, however.
Description: Using the generated circuit diagram, generate a chemical reaction network (sequence).
Variables: RearrangementType rearrangementType (global), str CRN (global)
General Algorithm (if applicable): If rearrangement type is known (i.e., not unknown), generate the CRN using Util.make_reactions().
Returns (if anything): N/A, sets a global variable.
Description: Find an estimated value for the function at the given point.
Variables: RearrangementType rearrangementType (global), str traceString (global), int x (local), int point (global), float traceValue (global)
General Algorithm (if applicable):
1. Determine traceString (rearrangementString, but forcing "x" to be the variable).
2. Set x to the value of the function's point specification and evaluate the string to generate the trace.
Returns (if anything): N/A, sets a global variable.
Description: Checks if the function's type is Sinusoidal.
Variables: FuncTypes functype (global)
General Algorithm (if applicable): If the function type is SINE, COSINE, or SINUSOIDAL, return true.
Returns (if anything): int either 1 (true) or 0 (false).
Description: Checks if the function's type is Exponential.
Variables: FuncTypes functype (global)
General Algorithm (if applicable): If the function type is EXPONENTIAL, return true.
Returns (if anything): int either 1 (true) or 0 (false).
Description: Checks if the function's type is Logarithmic.
Variables: FuncTypes functype (global)
General Algorithm (if applicable): If the function type is LOGARITHMIC, return true.
Returns (if anything): int either 1 (true) or 0 (false).
Description: Checks if the function's type is a polynomial.
Variables: FuncTypes functype (global)
General Algorithm (if applicable): If the function type is POLYNOMIAL, return true.
Returns (if anything): int either 1 (true) or 0 (false).
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description:
Variables:
General Algorithm (if applicable):
Returns (if anything):
Description: This enum class houses types of polynomial rearrangement such as FuncTypes.SINUSOIDAL and FuncTypes.EXPONENTIAL
Variables: SINE, COSINE, SINUSOIDAL, EXPONENTIAL, LOGARITHMIC, POLYNOMIAL
General Algorithm (if applicable): If the input is a member of the enum class, return 1 (true); otherwise return 0 (false).
Returns (if anything): int, 1 (true) or 0 (false).
Description: This enum class houses types of polynomial rearrangement such as GateTypes.NAND and GateTypes.AND
Variables: NAND, AND, BNAND, BAND, MUX (implementation of BNAND, BAND, and MUX are todo in the future)
General Algorithm (if applicable): If the input is a member of the enum class, return 1 (true); otherwise return 0 (false).
Returns (if anything): int, 1 (true) or 0 (false).
Description: This enum class houses types of polynomial rearrangement such as NotGateTypes.INPUT and NotGateTypes.CONSTANT
Variables: INPUT, OUTPUT, CONSTANT, INTERMEDIATE
General Algorithm (if applicable): If the input is a member of the enum class, return 1 (true); otherwise return 0 (false).
Returns (if anything): int, 1 (true) or 0 (false).
Description: This enum class houses types of polynomial rearrangement such as RearrangeType.HORNER and RearrangeType.DOUBLE_NAND
Variables: HORNER, DOUBLE_NAND, UNKNOWN
General Algorithm (if applicable): If the input is a member of the enum class, return 1 (true); otherwise return 0 (false).
Returns (if anything): int, 1 (true) or 0 (false).
This project uses DNA as logic gates to create a Chemical Reaction Network (CRN) that allows us to compute values of different mathematical functions.
- Project Basis and Horner's Expansion Scholarly Article: https://www.nature.com/articles/s41598-018-26709-6
- Double-NAND Expansion Scholarly Article DOI: http://dx.doi.org/10.1145/3060403.3060410
Project Lead
Dr. Sayed Ahmad Salehi
Assistant Professor
Department of Electrical and Computer Engineering
Director of Computing with Unconventional Technologies (CUT) Lab
University of Kentucky | http://salehi.engr.uky.edu/
This project is supported by the National Science Foundation (NSF) and the University of Kentucky's College of Engineering.

