import streamlit as st import numpy as np import matplotlib.pyplot as plt # Define a function to calculate assembly A def calculate_assembly(ai_values, ni_values, N_T): return sum([np.exp(ai) * ((ni - 1) / N_T) for ai, ni in zip(ai_values, ni_values)]) # Sample data for top ten geometric assemblies example_assemblies = { "Lighthouse": {"ai": 2.5, "ni": 1}, "Eyeglasses": {"ai": 1.8, "ni": 2}, "Stool": {"ai": 1.2, "ni": 3}, "Window": {"ai": 1.5, "ni": 4}, "Hand": {"ai": 2.0, "ni": 5}, "Dice": {"ai": 0.8, "ni": 6}, "Heaven": {"ai": 2.3, "ni": 7}, "Gate": {"ai": 1.7, "ni": 8}, "Cat": {"ai": 2.1, "ni": 9}, "Toes": {"ai": 1.0, "ni": 10}, } # Streamlit App st.title("The Assembly Equation Interactive Simulator") # Display the Assembly Equation using LaTeX st.latex(r''' A = \sum_{i=1}^{N} e^{a_i} \left(\frac{n_i - 1}{N_T}\right) ''') st.write("Where:") st.latex(r''' A \quad \text{is the assembly of the ensemble} ''') st.latex(r''' a_i \quad \text{is the assembly index of object } i ''') st.latex(r''' n_i \quad \text{is the copy number of object } i ''') st.latex(r''' N \quad \text{is the total number of unique objects} ''') st.latex(r''' N_T \quad \text{is the total number of objects in the ensemble} ''') # Sidebar for inputs st.sidebar.header("Input Parameters") N_T = st.sidebar.number_input("Enter the total number of objects in the ensemble (N_T):", min_value=1, value=50) # Display example assemblies st.sidebar.write("Example Assemblies:") for assembly, params in example_assemblies.items(): st.sidebar.write(f"{assembly}: ai = {params['ai']}, ni = {params['ni']}") # Button to calculate assembly if st.sidebar.button('Calculate Assembly'): ai_values = [params['ai'] for params in example_assemblies.values()] ni_values = [params['ni'] for params in example_assemblies.values()] A = calculate_assembly(ai_values, ni_values, N_T) st.write("The assembly of the ensemble (A) is:", A) # Plotting the assembly index fig, ax = plt.subplots() ax.bar(example_assemblies.keys(), ai_values, color='skyblue') ax.set_xlabel('Objects') ax.set_ylabel('Assembly Index') ax.set_title('Assembly Index of Each Object') st.pyplot(fig) else: st.write("Press 'Calculate Assembly' to see the result.") # Showing the dictionary of examples st.write("Example inputs for simple assemblies:") st.json(example_assemblies) st.sidebar.markdown("The Assembly Equation, Creation, and Conception of Intelligence and AGI: https://youtu.be/CGiDqhSdLHk?t=773")