import matplotlib
if not hasattr(matplotlib.RcParams, "_get"):
matplotlib.RcParams._get = dict.get
Lecture 39: Assignment 3 Discussion#
Single-Server Queueing Systems
a. Implement the single-server queueing system \(\text{ssq}(n, A, S)\) in Python for \(n\) customers, given inter-arrival times \(A\) and service times \(S\), returning average delay \(d\), average queue length \(q\), and average server utilization \(u\).
def ssq(n, A, S, silent=False):
"""
This function simulates a single-server queueing system for n customers given their inter-arrival times - A, and service times - S
Parameters
---
n: int
number of customers
A: list[float]
customer inter-arrival times
S: list[float]
customer service times
silent=False: bool
run in silence if True else display system
Returns
---
d: float
average delay
q: float
average queue length
u: float
average utilization
"""
# System Status
t = 0 # simulation clock
z = 0 # server status
Q = [] # queue
# System Dynamics
Ta = [] # customer arrival time
Ts = [] # customer service initiation time
Td = [] # customer depature time
# System Log
To = [0] # event time (customer arrival/service initiation/departure time)
Z = [0] # server status at event time
J = [0] # queue length at event time
# Initialization
i = -1 # index of last customer serviced
j = 0 # queue length
k = 0 # customers serviced
ta = A[0] # next arrival event time
td = A[0] + S[0] # next departure event time
# Loop
while k < n:
if ta <= td: # time jump to next customer arrival event
e = 1
t = ta
else: # time jump to next customer departure event
e = -1
t = td
if e == 1: # update system status for customer arrival
To.append(t)
Ta.append(t)
if z == 0:
e = 0
i = i + 1
else:
Q.append(i+j+1)
j = j + 1
ta = round(ta + A[i+j+1], 1) if i+j+1 < len(A) else float('inf')
Z.append(z)
J.append(j)
if not silent: print("Arrival : ", " ", "X", i , Q)
elif e == -1: # update system status for customer departure
if not silent: print("Departure : ", i, "X", " ", Q)
To.append(t)
Td.append(t)
if j == 0:
z = 0
td = float('inf')
else:
e = 0
i = Q.pop(0)
j = j - 1
Z.append(z)
J.append(j)
k = k + 1
if e == 0: # update system status for customer service initiation
To.append(t)
Ts.append(t)
z = 1
td = t + S[i]
Z.append(z)
J.append(j)
if not silent: print("Service : ", " ", "X", i, Q)
T = [To[i]-To[i-1] for i in range(1,len(To))] + [0.0]
d = round(sum([Ts[i] - Ta[i] for i in range(n)]) / n, 3) # average delay
q = round(sum([J[i] * T[i] for i in range(len(T))]) / t, 3) # average queue length
u = round(sum([Z[i] * T[i] for i in range(len(T))]) / t, 3) # average utilization
return d, q, u
b. Implement a Monte Carlo simulation \(\text{mcs}(m, n, \lambda, \mu)\) in Python, simulating \(m\) runs for a single-server queueing system with \(n\) customers, exponential inter-arrivals (rate \(\lambda\)), and exponential service times (rate \(\mu\)).
import random
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def simulate(sims=1000, n=100, lam=0.8, mu=1.0):
"""
Run Monte Carlo simulation of SSQ using exponential inter-arrivals and service times.
Parameters
----------
sims : int
number of simulations (default=1000)
n : int
number of customers per run (default=100)
lam : float
arrival rate λ
mu : float
service rate μ
Returns
-------
df : pandas.DataFrame
Results with columns ['d','q','u']
"""
# Random simulations
results = []
for k in range(sims):
rng = random.Random(k)
# Generate n+5 to avoid indexing issues in ssq
A = [rng.expovariate(lam) for _ in range(n+5)]
S = [rng.expovariate(mu) for _ in range(n+5)]
d, q, u = ssq(n, A, S, silent=True)
results.append((d, q, u))
return pd.DataFrame(results, columns=["d","q","u"])
# Descriptive statistics
def describe_series(x: pd.Series):
arr = np.asarray(x, dtype=float)
mean = float(np.mean(arr))
median = float(np.median(arr))
rng = float(np.max(arr) - np.min(arr))
sd = float(np.std(arr, ddof=1))
iqr = np.percentile(arr, 75) - np.percentile(arr, 25)
skew = np.mean((arr - mean)**3) / (sd**3) if sd > 0 else np.nan
kurt = np.mean((arr - mean)**4) / (sd**4) - 3 if sd > 0 else np.nan
return {
"mean": mean, "median": median, "range": rng,
"sd": sd, "iqr": iqr, "skewness": skew, "kurtosis": kurt
}
def summarize_df(df: pd.DataFrame):
return pd.DataFrame({col: describe_series(df[col]) for col in df.columns}).T
c. For a 1000-customer single-server queueing system with inter-arrival rate of 0.8 per minute and service rate of 1.0 per minutes, run 5000 simulations to
report the measure of location, dispersion, and shape
develop histogram plots
for average delay \(d\), avereage queue length \(q\), and average server utilization \(u\).
# Run and visualize
if __name__ == "__main__":
df = simulate(sims=5000, n=1000, lam=0.8, mu=1.0)
summary = summarize_df(df).round(4)
print("\nSummary Statistics (1000 runs, n=100)\n")
print(summary.to_string())
print("\nNote: kurtosis is excess kurtosis.\n")
# Histograms
for metric in ["d","q","u"]:
plt.figure()
plt.hist(df[metric], bins=40)
plt.title(f"Histogram of {metric}")
plt.xlabel(metric)
plt.ylabel("Frequency")
plt.show()
Summary Statistics (1000 runs, n=100)
mean median range sd iqr skewness kurtosis
d 3.9284 3.6485 17.869 1.3675 1.4980 2.4358 13.9735
q 3.1592 2.9195 15.685 1.1587 1.2512 2.5094 15.0328
u 0.7978 0.7970 0.252 0.0351 0.0470 0.1227 0.1329
Note: kurtosis is excess kurtosis.
d. For a 1000-customer single-server queueing system with inter-arrival rate \(\lambda \in [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]\) and service rate \(\mu \in [1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0]\), use Symbolic Regression to explore the relation between average delay \(d\), average queue length \(q\), average server utilization \(u\), and inter-arrival rate \(\lambda\), service rate \(\mu\). (Hint: Run Monte Carlo simulation for each \((\lambda, \mu)\) combination to produce a dataset of 100 single-server queueing systems, each with unique \((\lambda, \mu)\) and corresponding \(d\), \(q\), \(u\). Then apply symbolic regression to explore the relation between the exogenous variables (\(\lambda\), \(\mu\), \(\rho = \lambda / \mu\)) and endogenous variables (\(d\), \(q\), \(u\)), each)
from pysr import PySRRegressor
L = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
M = [1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0]
data = []
for l in L:
for m in M:
df = simulate(sims=5000, n=1000, lam=l, mu=m)
d = float(df['d'].mean())
q = float(df['q'].mean())
u = float(df['u'].mean())
print(f"λ={l}, μ={m}, ρ = {round(l/m, 2)}, d={round(d, 2)}, q={round(q, 2)}, u={round(u, 2)}")
data.append({"λ": l, "μ": m, "ρ": l / m, "d": d, "q": q, "u": u})
df = pd.DataFrame(data)
λ=0.1, μ=1.1, ρ = 0.09, d=0.09, q=0.01, u=0.09
λ=0.1, μ=1.2, ρ = 0.08, d=0.08, q=0.01, u=0.08
λ=0.1, μ=1.3, ρ = 0.08, d=0.06, q=0.01, u=0.08
λ=0.1, μ=1.4, ρ = 0.07, d=0.05, q=0.01, u=0.07
λ=0.1, μ=1.5, ρ = 0.07, d=0.05, q=0.0, u=0.07
λ=0.1, μ=1.6, ρ = 0.06, d=0.04, q=0.0, u=0.06
λ=0.1, μ=1.7, ρ = 0.06, d=0.04, q=0.0, u=0.06
λ=0.1, μ=1.8, ρ = 0.06, d=0.03, q=0.0, u=0.06
λ=0.1, μ=1.9, ρ = 0.05, d=0.03, q=0.0, u=0.05
λ=0.1, μ=2.0, ρ = 0.05, d=0.03, q=0.0, u=0.05
λ=0.2, μ=1.1, ρ = 0.18, d=0.2, q=0.04, u=0.18
λ=0.2, μ=1.2, ρ = 0.17, d=0.17, q=0.03, u=0.17
λ=0.2, μ=1.3, ρ = 0.15, d=0.14, q=0.03, u=0.15
λ=0.2, μ=1.4, ρ = 0.14, d=0.12, q=0.02, u=0.14
λ=0.2, μ=1.5, ρ = 0.13, d=0.1, q=0.02, u=0.13
λ=0.2, μ=1.6, ρ = 0.12, d=0.09, q=0.02, u=0.13
λ=0.2, μ=1.7, ρ = 0.12, d=0.08, q=0.02, u=0.12
λ=0.2, μ=1.8, ρ = 0.11, d=0.07, q=0.01, u=0.11
λ=0.2, μ=1.9, ρ = 0.11, d=0.06, q=0.01, u=0.11
λ=0.2, μ=2.0, ρ = 0.1, d=0.06, q=0.01, u=0.1
λ=0.3, μ=1.1, ρ = 0.27, d=0.34, q=0.1, u=0.27
λ=0.3, μ=1.2, ρ = 0.25, d=0.28, q=0.08, u=0.25
λ=0.3, μ=1.3, ρ = 0.23, d=0.23, q=0.07, u=0.23
λ=0.3, μ=1.4, ρ = 0.21, d=0.19, q=0.06, u=0.21
λ=0.3, μ=1.5, ρ = 0.2, d=0.17, q=0.05, u=0.2
λ=0.3, μ=1.6, ρ = 0.19, d=0.14, q=0.04, u=0.19
λ=0.3, μ=1.7, ρ = 0.18, d=0.13, q=0.04, u=0.18
λ=0.3, μ=1.8, ρ = 0.17, d=0.11, q=0.03, u=0.17
λ=0.3, μ=1.9, ρ = 0.16, d=0.1, q=0.03, u=0.16
λ=0.3, μ=2.0, ρ = 0.15, d=0.09, q=0.03, u=0.15
λ=0.4, μ=1.1, ρ = 0.36, d=0.52, q=0.21, u=0.36
λ=0.4, μ=1.2, ρ = 0.33, d=0.42, q=0.17, u=0.33
λ=0.4, μ=1.3, ρ = 0.31, d=0.34, q=0.14, u=0.31
λ=0.4, μ=1.4, ρ = 0.29, d=0.29, q=0.11, u=0.29
λ=0.4, μ=1.5, ρ = 0.27, d=0.24, q=0.1, u=0.27
λ=0.4, μ=1.6, ρ = 0.25, d=0.21, q=0.08, u=0.25
λ=0.4, μ=1.7, ρ = 0.24, d=0.18, q=0.07, u=0.24
λ=0.4, μ=1.8, ρ = 0.22, d=0.16, q=0.06, u=0.22
λ=0.4, μ=1.9, ρ = 0.21, d=0.14, q=0.06, u=0.21
λ=0.4, μ=2.0, ρ = 0.2, d=0.13, q=0.05, u=0.2
λ=0.5, μ=1.1, ρ = 0.45, d=0.76, q=0.38, u=0.45
λ=0.5, μ=1.2, ρ = 0.42, d=0.59, q=0.3, u=0.42
λ=0.5, μ=1.3, ρ = 0.38, d=0.48, q=0.24, u=0.38
λ=0.5, μ=1.4, ρ = 0.36, d=0.4, q=0.2, u=0.36
λ=0.5, μ=1.5, ρ = 0.33, d=0.33, q=0.17, u=0.33
λ=0.5, μ=1.6, ρ = 0.31, d=0.28, q=0.14, u=0.31
λ=0.5, μ=1.7, ρ = 0.29, d=0.25, q=0.12, u=0.29
λ=0.5, μ=1.8, ρ = 0.28, d=0.21, q=0.11, u=0.28
λ=0.5, μ=1.9, ρ = 0.26, d=0.19, q=0.09, u=0.26
λ=0.5, μ=2.0, ρ = 0.25, d=0.17, q=0.08, u=0.25
λ=0.6, μ=1.1, ρ = 0.55, d=1.09, q=0.65, u=0.55
λ=0.6, μ=1.2, ρ = 0.5, d=0.83, q=0.5, u=0.5
λ=0.6, μ=1.3, ρ = 0.46, d=0.66, q=0.4, u=0.46
λ=0.6, μ=1.4, ρ = 0.43, d=0.54, q=0.32, u=0.43
λ=0.6, μ=1.5, ρ = 0.4, d=0.44, q=0.27, u=0.4
λ=0.6, μ=1.6, ρ = 0.37, d=0.38, q=0.23, u=0.38
λ=0.6, μ=1.7, ρ = 0.35, d=0.32, q=0.19, u=0.35
λ=0.6, μ=1.8, ρ = 0.33, d=0.28, q=0.17, u=0.33
λ=0.6, μ=1.9, ρ = 0.32, d=0.24, q=0.15, u=0.32
λ=0.6, μ=2.0, ρ = 0.3, d=0.21, q=0.13, u=0.3
λ=0.7, μ=1.1, ρ = 0.64, d=1.58, q=1.11, u=0.64
λ=0.7, μ=1.2, ρ = 0.58, d=1.16, q=0.82, u=0.58
λ=0.7, μ=1.3, ρ = 0.54, d=0.89, q=0.63, u=0.54
λ=0.7, μ=1.4, ρ = 0.5, d=0.71, q=0.5, u=0.5
λ=0.7, μ=1.5, ρ = 0.47, d=0.58, q=0.41, u=0.47
λ=0.7, μ=1.6, ρ = 0.44, d=0.49, q=0.34, u=0.44
λ=0.7, μ=1.7, ρ = 0.41, d=0.41, q=0.29, u=0.41
λ=0.7, μ=1.8, ρ = 0.39, d=0.35, q=0.25, u=0.39
λ=0.7, μ=1.9, ρ = 0.37, d=0.31, q=0.22, u=0.37
λ=0.7, μ=2.0, ρ = 0.35, d=0.27, q=0.19, u=0.35
λ=0.8, μ=1.1, ρ = 0.73, d=2.4, q=1.93, u=0.73
λ=0.8, μ=1.2, ρ = 0.67, d=1.66, q=1.33, u=0.67
λ=0.8, μ=1.3, ρ = 0.62, d=1.22, q=0.98, u=0.62
λ=0.8, μ=1.4, ρ = 0.57, d=0.95, q=0.76, u=0.57
λ=0.8, μ=1.5, ρ = 0.53, d=0.76, q=0.61, u=0.53
λ=0.8, μ=1.6, ρ = 0.5, d=0.62, q=0.5, u=0.5
λ=0.8, μ=1.7, ρ = 0.47, d=0.52, q=0.42, u=0.47
λ=0.8, μ=1.8, ρ = 0.44, d=0.44, q=0.36, u=0.44
λ=0.8, μ=1.9, ρ = 0.42, d=0.38, q=0.31, u=0.42
λ=0.8, μ=2.0, ρ = 0.4, d=0.33, q=0.27, u=0.4
λ=0.9, μ=1.1, ρ = 0.82, d=4.0, q=3.62, u=0.82
λ=0.9, μ=1.2, ρ = 0.75, d=2.47, q=2.24, u=0.75
λ=0.9, μ=1.3, ρ = 0.69, d=1.72, q=1.55, u=0.69
λ=0.9, μ=1.4, ρ = 0.64, d=1.28, q=1.16, u=0.64
λ=0.9, μ=1.5, ρ = 0.6, d=1.0, q=0.9, u=0.6
λ=0.9, μ=1.6, ρ = 0.56, d=0.8, q=0.72, u=0.56
λ=0.9, μ=1.7, ρ = 0.53, d=0.66, q=0.6, u=0.53
λ=0.9, μ=1.8, ρ = 0.5, d=0.56, q=0.5, u=0.5
λ=0.9, μ=1.9, ρ = 0.47, d=0.47, q=0.43, u=0.47
λ=0.9, μ=2.0, ρ = 0.45, d=0.41, q=0.37, u=0.45
λ=1.0, μ=1.1, ρ = 0.91, d=8.12, q=8.14, u=0.9
λ=1.0, μ=1.2, ρ = 0.83, d=4.06, q=4.08, u=0.83
λ=1.0, μ=1.3, ρ = 0.77, d=2.53, q=2.55, u=0.77
λ=1.0, μ=1.4, ρ = 0.71, d=1.77, q=1.78, u=0.71
λ=1.0, μ=1.5, ρ = 0.67, d=1.33, q=1.33, u=0.67
λ=1.0, μ=1.6, ρ = 0.62, d=1.04, q=1.04, u=0.62
λ=1.0, μ=1.7, ρ = 0.59, d=0.84, q=0.84, u=0.59
λ=1.0, μ=1.8, ρ = 0.56, d=0.69, q=0.7, u=0.56
λ=1.0, μ=1.9, ρ = 0.53, d=0.58, q=0.59, u=0.53
λ=1.0, μ=2.0, ρ = 0.5, d=0.5, q=0.5, u=0.5
# Delay
X = df[["λ", "μ", "ρ"]].to_numpy()
y = df["d"].to_numpy()
model = PySRRegressor(
niterations=1000,
binary_operators=["+", "-", "*", "/"],
maxsize=20,
populations=40,
progress=False,
)
model.fit(X,y)
Compiling Julia backend...
[ Info: Started!
Expressions evaluated per second: 6.930e+05
Progress: 3938 / 40000 total iterations (9.845%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.501e-01 0.000e+00 y = x₀
3 6.076e-01 1.679e-01 y = x₂ * 2.2502
5 9.564e-03 2.076e+00 y = x₂ / (x₁ - x₀)
7 4.093e-04 1.576e+00 y = x₂ / (x₁ + (x₀ * -0.98912))
9 9.313e-05 7.403e-01 y = ((-1.0783 / (x₂ + -1.0166)) + -1.078) / x₁
11 9.313e-05 5.573e-06 y = ((-1.0783 / ((x₀ / x₁) + -1.0166)) + -1.078) / x₁
13 9.313e-05 4.381e-06 y = ((-1.0783 / (((x₂ * x₁) / x₁) + -1.0166)) + -1.078) / ...
x₁
17 9.313e-05 7.451e-08 y = ((((-1.0783 / (((x₂ * x₁) / x₁) + -1.0166)) + -1.078) ...
/ x₁) / x₀) * x₀
19 9.313e-05 1.997e-06 y = ((((-1.0783 / (((x₂ * (x₀ / x₂)) / x₁) + -1.0166)) + -...
1.078) / x₁) / x₂) * x₂
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.080e+05
Progress: 7150 / 40000 total iterations (17.875%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.501e-01 0.000e+00 y = x₀
3 6.076e-01 1.679e-01 y = x₂ * 2.2502
5 9.564e-03 2.076e+00 y = x₂ / (x₁ - x₀)
7 4.093e-04 1.576e+00 y = x₂ / (x₁ + (x₀ * -0.98912))
9 9.313e-05 7.403e-01 y = ((-1.0783 / (x₂ + -1.0166)) + -1.078) / x₁
11 9.313e-05 5.573e-06 y = ((-1.0783 / ((x₀ / x₁) + -1.0166)) + -1.078) / x₁
13 9.313e-05 4.381e-06 y = ((-1.0783 / (((x₂ * x₁) / x₁) + -1.0166)) + -1.078) / ...
x₁
15 9.313e-05 1.252e-06 y = ((-1.0783 / (((x₂ * (x₀ / x₂)) / x₁) + -1.0166)) + -1....
078) / x₁
19 9.313e-05 4.470e-07 y = ((((-1.0783 / (((x₂ * (x₀ / x₂)) / x₁) + -1.0166)) + -...
1.078) / x₁) / x₂) * x₂
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.930e+05
Progress: 10418 / 40000 total iterations (26.045%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.501e-01 0.000e+00 y = x₀
3 6.076e-01 1.679e-01 y = x₂ * 2.2502
5 9.564e-03 2.076e+00 y = x₂ / (x₁ - x₀)
7 4.093e-04 1.576e+00 y = x₂ / (x₁ + (x₀ * -0.98912))
9 9.313e-05 7.403e-01 y = ((-1.0783 / (x₂ + -1.0166)) + -1.078) / x₁
11 3.897e-05 4.356e-01 y = ((-1.0933 / (x₂ + -1.019)) + -0.10535) * (x₂ / x₁)
15 3.897e-05 8.643e-07 y = ((-1.0933 / (x₂ + -1.019)) + -0.10535) / ((x₁ * x₁) / ...
(x₂ * x₁))
17 3.761e-05 1.772e-02 y = (((-1.0939 / (x₂ + -1.0192)) + -0.10526) / x₁) * ((x₂ ...
/ x₁) * (x₁ + 0.0014633))
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.860e+05
Progress: 13777 / 40000 total iterations (34.443%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.501e-01 0.000e+00 y = x₀
3 6.076e-01 1.679e-01 y = x₂ * 2.2502
5 9.564e-03 2.076e+00 y = x₂ / (x₁ - x₀)
7 4.093e-04 1.576e+00 y = x₂ / (x₁ + (x₀ * -0.98912))
9 9.313e-05 7.403e-01 y = ((-1.0783 / (x₂ + -1.0166)) + -1.078) / x₁
11 3.860e-05 4.403e-01 y = (((-1.0933 / (x₂ + -1.019)) + -0.10239) / x₁) * x₂
13 2.767e-05 1.665e-01 y = (((-1.1135 / (x₂ + -1.0206)) + -0.15505) * (x₂ / x₁)) ...
- -0.005072
17 2.767e-05 9.090e-07 y = (((((-1.1135 / (x₂ + -1.0206)) + -0.15505) * (x₂ / x₁)...
) - -0.005072) - x₀) + x₀
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.660e+05
Progress: 17244 / 40000 total iterations (43.110%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.501e-01 0.000e+00 y = x₀
3 6.076e-01 1.679e-01 y = x₂ * 2.2502
5 9.564e-03 2.076e+00 y = x₂ / (x₁ - x₀)
7 4.093e-04 1.576e+00 y = x₂ / (x₁ + (x₀ * -0.98912))
9 9.313e-05 7.403e-01 y = ((-1.0783 / (x₂ + -1.0166)) + -1.078) / x₁
11 3.860e-05 4.403e-01 y = (((-1.0933 / (x₂ + -1.019)) + -0.10239) / x₁) * x₂
13 2.767e-05 1.665e-01 y = (((-1.1135 / (x₂ + -1.0206)) + -0.15505) * (x₂ / x₁)) ...
- -0.005072
17 2.767e-05 9.090e-07 y = (((((-1.1135 / (x₂ + -1.0206)) + -0.15505) * (x₂ / x₁)...
) - -0.005072) - x₀) + x₀
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.740e+05
Progress: 20571 / 40000 total iterations (51.428%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.501e-01 0.000e+00 y = x₀
3 6.076e-01 1.679e-01 y = x₂ * 2.2502
5 9.564e-03 2.076e+00 y = x₂ / (x₁ - x₀)
7 4.093e-04 1.576e+00 y = x₂ / (x₁ + (x₀ * -0.98912))
9 9.313e-05 7.403e-01 y = ((-1.0783 / (x₂ + -1.0166)) + -1.078) / x₁
11 3.860e-05 4.403e-01 y = (((-1.0933 / (x₂ + -1.019)) + -0.10239) / x₁) * x₂
13 2.766e-05 1.667e-01 y = (((-1.1135 / (x₂ + -1.0206)) + -0.15505) * (x₂ / x₁)) ...
- -0.0049862
15 2.766e-05 1.192e-07 y = (((-1.1135 / (x₂ + -1.0206)) + -0.15505) * ((x₀ / x₁) ...
/ x₁)) - -0.0049862
17 2.766e-05 8.345e-07 y = (((-1.1135 / (x₂ + -1.0206)) + -0.15505) * (((x₂ * x₁)...
/ x₁) / x₁)) - -0.0049862
19 2.766e-05 3.874e-06 y = (((-1.1135 / (((x₂ * x₁) / x₁) + -1.0206)) + -0.15505)...
* ((x₀ / x₁) / x₁)) - -0.0049862
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.860e+05
Progress: 24176 / 40000 total iterations (60.440%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.501e-01 0.000e+00 y = x₀
3 6.076e-01 1.679e-01 y = x₂ * 2.2502
5 9.564e-03 2.076e+00 y = x₂ / (x₁ - x₀)
7 4.093e-04 1.576e+00 y = x₂ / (x₁ + (x₀ * -0.98912))
9 9.313e-05 7.403e-01 y = ((-1.0783 / (x₂ + -1.0166)) + -1.078) / x₁
11 3.860e-05 4.403e-01 y = (((-1.0933 / (x₂ + -1.019)) + -0.10239) / x₁) * x₂
13 2.712e-05 1.765e-01 y = (((-1.1182 / (x₂ + -1.021)) + -0.16788) * (x₂ / x₁)) -...
-0.0054924
15 2.678e-05 6.344e-03 y = (((((-1.1182 / (x₂ + -1.021)) + -0.16788) * x₂) / x₁) ...
- -0.0054926) * 1.0009
17 2.678e-05 6.646e-06 y = ((((-1.1182 / ((x₀ / x₁) + -1.021)) + -0.16788) * (x₂ ...
/ x₁)) - -0.0054926) * 1.0009
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.910e+05
Progress: 27627 / 40000 total iterations (69.067%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.501e-01 0.000e+00 y = x₀
3 6.076e-01 1.679e-01 y = x₂ * 2.2502
5 9.564e-03 2.076e+00 y = x₂ / (x₁ - x₀)
7 4.093e-04 1.576e+00 y = x₂ / (x₁ + (x₀ * -0.98912))
9 9.313e-05 7.403e-01 y = ((-1.0783 / (x₂ + -1.0166)) + -1.078) / x₁
11 3.860e-05 4.403e-01 y = (((-1.0933 / (x₂ + -1.019)) + -0.10239) / x₁) * x₂
13 2.671e-05 1.841e-01 y = (((-1.1182 / (x₂ + -1.021)) + -0.16788) * (x₂ / x₁)) -...
-0.005938
15 2.656e-05 2.853e-03 y = ((((-1.1182 / (x₂ + -1.021)) + -0.16788) * (x₂ / x₁)) ...
- -0.0059352) * 1.0005
17 2.656e-05 4.679e-06 y = ((((-1.1182 / ((x₀ / x₁) + -1.021)) + -0.16788) * (x₂ ...
/ x₁)) - -0.0059352) * 1.0005
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.930e+05
Progress: 31094 / 40000 total iterations (77.735%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.501e-01 0.000e+00 y = x₀
3 6.076e-01 1.679e-01 y = x₂ * 2.2502
5 9.564e-03 2.076e+00 y = x₂ / (x₁ - x₀)
7 4.093e-04 1.576e+00 y = x₂ / (x₁ + (x₀ * -0.98912))
9 9.313e-05 7.403e-01 y = ((-1.0783 / (x₂ + -1.0166)) + -1.078) / x₁
11 3.860e-05 4.403e-01 y = (((-1.0933 / (x₂ + -1.019)) + -0.10239) / x₁) * x₂
13 2.671e-05 1.841e-01 y = (((-1.1182 / (x₂ + -1.021)) + -0.16788) * (x₂ / x₁)) -...
-0.005938
15 2.655e-05 2.939e-03 y = ((((-1.1182 / (x₂ + -1.021)) + -0.16788) * (x₂ / x₁)) ...
* 1.0005) - -0.0058641
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.010e+05
Progress: 34520 / 40000 total iterations (86.300%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.501e-01 0.000e+00 y = x₀
3 6.076e-01 1.679e-01 y = x₂ * 2.2502
5 9.564e-03 2.076e+00 y = x₂ / (x₁ - x₀)
7 4.093e-04 1.576e+00 y = x₂ / (x₁ + (x₀ * -0.98912))
9 9.313e-05 7.403e-01 y = ((-1.0783 / (x₂ + -1.0166)) + -1.078) / x₁
11 3.860e-05 4.403e-01 y = (((-1.0933 / (x₂ + -1.019)) + -0.10239) / x₁) * x₂
13 2.656e-05 1.869e-01 y = (((-1.1184 / (x₂ + -1.021)) + -0.16788) * (x₂ / x₁)) -...
-0.0061194
15 2.639e-05 3.233e-03 y = ((((-1.1182 / (x₂ + -1.021)) + -0.16919) * (x₂ / x₁)) ...
- -0.0061194) * 1.0005
17 2.639e-05 2.593e-06 y = ((((-1.1182 / ((x₀ / x₁) + -1.021)) + -0.16919) * (x₂ ...
/ x₁)) - -0.0061194) * 1.0005
19 2.637e-05 4.139e-04 y = ((1.0005 - (-0.00025605 / x₀)) * (((-1.1182 / (x₂ + -1...
.021)) + -0.16919) * (x₂ / x₁))) - -0.0058644
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.870e+05
Progress: 37842 / 40000 total iterations (94.605%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.501e-01 0.000e+00 y = x₀
3 6.076e-01 1.679e-01 y = x₂ * 2.2502
5 9.564e-03 2.076e+00 y = x₂ / (x₁ - x₀)
7 4.093e-04 1.576e+00 y = x₂ / (x₁ + (x₀ * -0.98912))
9 9.313e-05 7.403e-01 y = ((-1.0783 / (x₂ + -1.0166)) + -1.078) / x₁
11 3.860e-05 4.403e-01 y = (((-1.0933 / (x₂ + -1.019)) + -0.10239) / x₁) * x₂
13 2.656e-05 1.869e-01 y = (((-1.1184 / (x₂ + -1.021)) + -0.16788) * (x₂ / x₁)) -...
-0.0061194
15 2.639e-05 3.364e-03 y = ((((-1.1182 / (x₂ + -1.021)) + -0.16935) * (x₂ / x₁)) ...
- -0.0061224) * 1.0005
19 2.637e-05 1.429e-04 y = ((1.0005 - (-0.00025605 / x₀)) * (((-1.1182 / (x₂ + -1...
.021)) + -0.16919) * (x₂ / x₁))) - -0.0058644
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
[ Info: Final population:
[ Info: Results saved to:
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.501e-01 0.000e+00 y = x₀
3 6.076e-01 1.679e-01 y = x₂ * 2.2502
5 9.564e-03 2.076e+00 y = x₂ / (x₁ - x₀)
7 4.093e-04 1.576e+00 y = x₂ / (x₁ + (x₀ * -0.98912))
9 9.313e-05 7.403e-01 y = ((-1.0783 / (x₂ + -1.0166)) + -1.078) / x₁
11 3.860e-05 4.403e-01 y = (((-1.0933 / (x₂ + -1.019)) + -0.10239) / x₁) * x₂
13 2.656e-05 1.870e-01 y = (((-1.1184 / (x₂ + -1.021)) + -0.16788) * (x₂ / x₁)) -...
-0.0060147
15 2.639e-05 3.272e-03 y = ((((-1.1182 / (x₂ + -1.021)) + -0.16935) * (x₂ / x₁)) ...
- -0.0061224) * 1.0005
19 2.637e-05 1.429e-04 y = ((1.0005 - (-0.00025605 / x₀)) * (((-1.1182 / (x₂ + -1...
.021)) + -0.16919) * (x₂ / x₁))) - -0.0058644
───────────────────────────────────────────────────────────────────────────────────────────────────
- outputs\20251030_115837_Gftqf4\hall_of_fame.csv
PySRRegressor.equations_ = [ pick score equation \ 0 0.000000 x0 1 0.167916 x2 * 2.250233 2 2.075782 x2 / (x1 - x0) 3 1.575594 x2 / (x1 + (x0 * -0.9891189)) 4 0.740271 ((-1.0782743 / (x2 + -1.0165653)) + -1.0779631... 5 >>>> 0.440328 (((-1.093268 / (x2 + -1.0190246)) + -0.1023856... 6 0.186996 (((-1.1183727 / (x2 + -1.0209731)) + -0.167883... 7 0.003272 ((((-1.1181574 / (x2 + -1.0209731)) + -0.16935... 8 0.000143 ((1.0004759 - (-0.0002560543 / x0)) * (((-1.11... loss complexity 0 0.850107 1 1 0.607608 3 2 0.009564 5 3 0.000409 7 4 0.000093 9 5 0.000039 11 6 0.000027 13 7 0.000026 15 8 0.000026 19 ]In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
| model_selection | 'best' | |
| binary_operators | ['+', '-', ...] | |
| unary_operators | None | |
| expression_spec | None | |
| niterations | 1000 | |
| populations | 40 | |
| population_size | 27 | |
| max_evals | None | |
| maxsize | 20 | |
| maxdepth | None | |
| warmup_maxsize_by | None | |
| timeout_in_seconds | None | |
| constraints | None | |
| nested_constraints | None | |
| elementwise_loss | None | |
| loss_function | None | |
| loss_function_expression | None | |
| loss_scale | 'log' | |
| complexity_of_operators | None | |
| complexity_of_constants | None | |
| complexity_of_variables | None | |
| complexity_mapping | None | |
| parsimony | 0.0 | |
| dimensional_constraint_penalty | None | |
| dimensionless_constants_only | False | |
| use_frequency | True | |
| use_frequency_in_tournament | True | |
| adaptive_parsimony_scaling | 1040.0 | |
| alpha | 3.17 | |
| annealing | False | |
| early_stop_condition | None | |
| ncycles_per_iteration | 380 | |
| fraction_replaced | 0.00036 | |
| fraction_replaced_hof | 0.0614 | |
| weight_add_node | 2.47 | |
| weight_insert_node | 0.0112 | |
| weight_delete_node | 0.87 | |
| weight_do_nothing | 0.273 | |
| weight_mutate_constant | 0.0346 | |
| weight_mutate_operator | 0.293 | |
| weight_swap_operands | 0.198 | |
| weight_rotate_tree | 4.26 | |
| weight_randomize | 0.000502 | |
| weight_simplify | 0.00209 | |
| weight_optimize | 0.0 | |
| crossover_probability | 0.0259 | |
| skip_mutation_failures | True | |
| migration | True | |
| hof_migration | True | |
| topn | 12 | |
| should_simplify | True | |
| should_optimize_constants | True | |
| optimizer_algorithm | 'BFGS' | |
| optimizer_nrestarts | 2 | |
| optimizer_f_calls_limit | None | |
| optimize_probability | 0.14 | |
| optimizer_iterations | 8 | |
| perturbation_factor | 0.129 | |
| probability_negate_constant | 0.00743 | |
| tournament_selection_n | 15 | |
| tournament_selection_p | 0.982 | |
| parallelism | None | |
| procs | None | |
| cluster_manager | None | |
| heap_size_hint_in_bytes | None | |
| batching | False | |
| batch_size | 50 | |
| fast_cycle | False | |
| turbo | False | |
| bumper | False | |
| precision | 32 | |
| autodiff_backend | None | |
| random_state | None | |
| deterministic | False | |
| warm_start | False | |
| verbosity | 1 | |
| update_verbosity | None | |
| print_precision | 5 | |
| progress | False | |
| logger_spec | None | |
| input_stream | 'stdin' | |
| run_id | None | |
| output_directory | None | |
| temp_equation_file | False | |
| tempdir | None | |
| delete_tempfiles | True | |
| update | False | |
| output_jax_format | False | |
| output_torch_format | False | |
| extra_sympy_mappings | None | |
| extra_torch_mappings | None | |
| extra_jax_mappings | None | |
| denoise | False | |
| select_k_features | None |
# Queue Length
X = df[["λ", "μ", "ρ"]].to_numpy()
y = df["q"].to_numpy()
model = PySRRegressor(
niterations=1000,
binary_operators=["+", "-", "*", "/"],
maxsize=20,
populations=40,
progress=False,
)
model.fit(X,y)
[ Info: Started!
Expressions evaluated per second: 6.460e+05
Progress: 3740 / 40000 total iterations (9.350%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.261e-01 0.000e+00 y = x₂
3 6.655e-01 1.081e-01 y = x₂ * 1.9482
5 3.880e-02 1.421e+00 y = x₂ / (x₁ - x₀)
7 9.121e-03 7.239e-01 y = (x₂ / (x₁ - x₀)) * x₀
9 5.813e-04 1.377e+00 y = (x₂ / (x₁ - (x₀ + -0.010469))) * x₀
11 1.227e-04 7.777e-01 y = ((x₂ / (x₁ - (x₀ + -0.016275))) * x₀) * 1.0446
13 6.733e-05 3.001e-01 y = (x₀ * ((x₂ / (x₁ - (x₀ + -0.018897))) - 0.021379)) * 1...
.0692
15 5.490e-05 1.021e-01 y = (((x₂ / ((x₁ - x₀) + 0.019418)) * 1.0747) - (x₀ * 0.03...
5301)) * x₀
17 4.051e-05 1.519e-01 y = ((x₀ * 0.95455) - ((x₂ * x₀) * -0.15636)) * (x₂ / ((x₁...
- x₀) + 0.02246))
19 3.349e-05 9.521e-02 y = x₂ / ((x₁ - (x₂ * (x₁ + -0.022219))) / ((x₀ * 0.94639)...
- (x₂ * (x₀ * -0.14249))))
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.450e+05
Progress: 7534 / 40000 total iterations (18.835%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.261e-01 0.000e+00 y = x₂
3 6.655e-01 1.081e-01 y = x₂ * 1.9482
5 3.880e-02 1.421e+00 y = x₂ / (x₁ - x₀)
7 9.121e-03 7.239e-01 y = (x₂ / (x₁ - x₀)) * x₀
9 5.813e-04 1.377e+00 y = (x₂ / (x₁ - (x₀ + -0.010469))) * x₀
11 1.227e-04 7.777e-01 y = ((x₂ / (x₁ - (x₀ + -0.016275))) * x₀) * 1.0446
13 6.693e-05 3.031e-01 y = (x₀ * ((x₂ / (x₁ - (x₀ + -0.018661))) - 0.01985)) * 1....
0669
15 5.490e-05 9.909e-02 y = ((x₂ / (((x₁ - x₀) + 0.019418) / 1.0747)) - (x₀ * 0.03...
5301)) * x₀
17 3.203e-05 2.694e-01 y = (x₂ / ((x₁ - (x₂ * (x₁ + -0.022533))) / x₀)) * (0.9384...
6 - (x₂ * -0.15516))
19 3.203e-05 4.202e-06 y = (x₂ / ((x₁ - (x₂ * ((x₀ / x₂) + -0.022533))) / x₀)) * ...
(0.93846 - (x₂ * -0.15516))
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.490e+05
Progress: 11305 / 40000 total iterations (28.262%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.261e-01 0.000e+00 y = x₂
3 6.655e-01 1.081e-01 y = x₂ * 1.9482
5 3.880e-02 1.421e+00 y = x₂ / (x₁ - x₀)
7 7.086e-04 2.001e+00 y = (x₂ / (1.0093 - x₂)) * x₂
9 1.177e-04 8.975e-01 y = ((x₂ / (1.0164 - x₂)) * x₂) * 1.0583
11 9.412e-05 1.118e-01 y = (((x₂ / (1.0172 - x₂)) * x₂) * 1.0666) - 0.0060141
13 6.693e-05 1.705e-01 y = (x₀ * ((x₂ / (x₁ - (x₀ + -0.018661))) - 0.01985)) * 1....
0669
15 5.490e-05 9.909e-02 y = ((x₂ / (((x₁ - x₀) + 0.019418) / 1.0747)) - (x₀ * 0.03...
5301)) * x₀
17 3.069e-05 2.907e-01 y = (((0.93766 - (x₂ * -0.15394)) * x₂) / (x₁ - (x₂ * (x₁ ...
+ -0.022273)))) * x₀
19 3.069e-05 1.788e-06 y = (((0.93766 - (x₂ * -0.15394)) * x₂) / (x₁ - (x₂ * (x₁ ...
+ -0.022273)))) * (x₂ * x₁)
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.380e+05
Progress: 14906 / 40000 total iterations (37.265%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.261e-01 0.000e+00 y = x₂
3 6.655e-01 1.081e-01 y = x₂ * 1.9482
5 3.880e-02 1.421e+00 y = x₂ / (x₁ - x₀)
7 7.086e-04 2.001e+00 y = (x₂ / (1.0093 - x₂)) * x₂
9 1.157e-04 9.059e-01 y = (x₂ / ((1.0161 - x₂) / x₂)) / 0.9465
11 5.865e-05 3.399e-01 y = x₂ * (((x₂ / (1.0191 - x₂)) * 1.0897) - 0.044405)
15 5.490e-05 1.652e-02 y = ((x₂ / (((x₁ - x₀) + 0.019418) / 1.0747)) - (x₀ * 0.03...
5301)) * x₀
17 3.069e-05 2.907e-01 y = (((0.93766 - (x₂ * -0.15394)) * x₂) / (x₁ - (x₂ * (x₁ ...
+ -0.022273)))) * x₀
19 2.728e-05 5.884e-02 y = ((0.92543 - (x₂ * -0.16979)) * ((x₂ / (x₁ - (x₂ * (x₁ ...
+ -0.0226)))) * x₀)) - -0.0026812
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.350e+05
Progress: 18624 / 40000 total iterations (46.560%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.261e-01 0.000e+00 y = x₂
3 6.655e-01 1.081e-01 y = x₂ * 1.9482
5 3.880e-02 1.421e+00 y = x₂ / (x₁ - x₀)
7 7.086e-04 2.001e+00 y = (x₂ / (1.0093 - x₂)) * x₂
9 1.155e-04 9.068e-01 y = (x₂ * x₂) / ((1.016 - x₂) * 0.94646)
11 5.865e-05 3.391e-01 y = x₂ * (((x₂ / (1.0191 - x₂)) * 1.0897) - 0.044405)
13 5.820e-05 3.840e-03 y = (x₂ * ((x₂ / ((1.0192 - x₂) / 1.0897)) - 0.044405)) / ...
0.99857
15 5.490e-05 2.920e-02 y = ((x₂ / (((x₁ - x₀) + 0.019418) / 1.0747)) - (x₀ * 0.03...
5301)) * x₀
17 2.814e-05 3.342e-01 y = ((0.9357 - (x₂ * -0.17673)) * x₂) / (((x₁ - (x₁ * x₂))...
/ x₀) - -0.022445)
19 2.415e-05 7.639e-02 y = ((0.93269 - (x₂ * -0.17425)) * x₂) / (((x₁ - (x₂ * (x₁...
+ -0.0030183))) / x₀) - -0.019016)
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.290e+05
Progress: 22248 / 40000 total iterations (55.620%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.261e-01 0.000e+00 y = x₂
3 6.655e-01 1.081e-01 y = x₂ * 1.9482
5 3.880e-02 1.421e+00 y = x₂ / (x₁ - x₀)
7 7.086e-04 2.001e+00 y = (x₂ / (1.0093 - x₂)) * x₂
9 1.155e-04 9.068e-01 y = x₂ * (x₂ / ((1.0161 - x₂) * 0.94646))
11 5.865e-05 3.390e-01 y = x₂ * (((x₂ / (1.0191 - x₂)) * 1.0897) - 0.044405)
13 2.713e-05 3.855e-01 y = x₂ * (((x₂ / (1.0339 - x₂)) * 1.3426) - (x₂ * x₂))
15 2.483e-05 4.420e-02 y = ((0.93775 - (x₂ * -0.16926)) * x₂) / (((x₁ - x₀) / x₀)...
- -0.021821)
17 2.233e-05 5.313e-02 y = (((0.93504 - (x₂ * -0.16879)) * x₂) / (((x₁ - x₀) / x₀...
) - -0.021497)) + 0.001489
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.250e+05
Progress: 26000 / 40000 total iterations (65.000%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.261e-01 0.000e+00 y = x₂
3 6.655e-01 1.081e-01 y = x₂ * 1.9482
5 3.880e-02 1.421e+00 y = x₂ / (x₁ - x₀)
7 7.086e-04 2.001e+00 y = (x₂ / (1.0093 - x₂)) * x₂
9 1.155e-04 9.068e-01 y = x₂ * (x₂ / ((1.0161 - x₂) * 0.94646))
11 2.698e-05 7.273e-01 y = (x₂ * x₂) * ((1.3426 / (1.0338 - x₂)) - x₂)
13 1.007e-05 4.925e-01 y = ((x₂ * x₂) * ((1.3511 / (1.0347 - x₂)) - x₂)) + -0.004...
6151
15 1.007e-05 2.623e-06 y = ((x₂ * (x₀ / x₁)) * ((1.3511 / (1.0347 - x₂)) - x₂)) +...
-0.0046151
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.260e+05
Progress: 29484 / 40000 total iterations (73.710%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.261e-01 0.000e+00 y = x₂
3 6.655e-01 1.081e-01 y = x₂ * 1.9482
5 3.880e-02 1.421e+00 y = x₂ / (x₁ - x₀)
7 7.086e-04 2.001e+00 y = (x₂ / (1.0093 - x₂)) * x₂
9 1.155e-04 9.072e-01 y = (x₂ * x₂) / (0.9638 - (x₂ * 0.94888))
11 2.698e-05 7.270e-01 y = (x₂ * x₂) * ((1.3426 / (1.0338 - x₂)) - x₂)
13 8.664e-06 5.679e-01 y = ((x₂ * x₂) * ((1.3522 / (1.0347 - x₂)) - x₂)) + -0.006...
7663
17 8.276e-06 1.145e-02 y = 0.99404 + (((x₂ * x₂) * ((1.3522 / (1.0347 - x₂)) - x₂...
)) - (x₂ / x₂))
19 8.030e-06 1.508e-02 y = (((x₂ * (x₂ * ((1.351 / (1.0346 - x₂)) - x₂))) + 0.849...
2) - (x₂ / x₂)) + 0.14525
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.200e+05
Progress: 33148 / 40000 total iterations (82.870%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.261e-01 0.000e+00 y = x₂
3 6.655e-01 1.081e-01 y = x₂ * 1.9482
5 3.880e-02 1.421e+00 y = x₂ / (x₁ - x₀)
7 7.086e-04 2.001e+00 y = (x₂ / (1.0093 - x₂)) * x₂
9 1.155e-04 9.072e-01 y = (x₂ * x₂) / (0.9638 - (x₂ * 0.94888))
11 2.697e-05 7.271e-01 y = (x₂ * x₂) * ((1.3412 / (1.0338 - x₂)) - x₂)
13 7.926e-06 6.123e-01 y = (((1.351 / (1.0346 - x₂)) - x₂) * (x₂ * x₂)) + -0.0060...
325
17 7.926e-06 1.296e-06 y = ((((1.351 / (1.0346 - x₂)) - x₂) * (x₀ / (x₀ / x₂))) *...
x₂) + -0.0060325
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.250e+05
Progress: 36895 / 40000 total iterations (92.237%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.261e-01 0.000e+00 y = x₂
3 6.655e-01 1.081e-01 y = x₂ * 1.9482
5 3.880e-02 1.421e+00 y = x₂ / (x₁ - x₀)
7 7.086e-04 2.001e+00 y = (x₂ / (1.0093 - x₂)) * x₂
9 1.155e-04 9.072e-01 y = (x₂ * x₂) / (0.9638 - (x₂ * 0.94888))
11 2.697e-05 7.271e-01 y = (x₂ * x₂) * ((1.3412 / (1.0338 - x₂)) - x₂)
13 7.926e-06 6.123e-01 y = (((1.351 / (1.0346 - x₂)) - x₂) * (x₂ * x₂)) + -0.0060...
325
15 7.926e-06 2.533e-06 y = ((((1.351 / (1.0346 - x₂)) - x₂) * (x₀ / x₁)) * x₂) + ...
-0.0060325
17 7.926e-06 5.960e-08 y = ((((1.351 / (1.0346 - x₂)) - x₂) * (x₀ / (x₀ / x₂))) *...
x₂) + -0.0060325
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.261e-01 0.000e+00 y = x₂
3 6.655e-01 1.081e-01 y = x₂ * 1.9482
5 3.880e-02 1.421e+00 y = x₂ / (x₁ - x₀)
7 7.086e-04 2.001e+00 y = (x₂ / (1.0093 - x₂)) * x₂
9 1.152e-04 9.082e-01 y = (x₂ * x₂) / (0.96314 - (x₂ * 0.94812))
11 2.663e-05 7.325e-01 y = x₂ * (x₂ * ((1.3414 / (1.0337 - x₂)) - x₂))
13 7.914e-06 6.066e-01 y = (((1.351 / (1.0346 - x₂)) - x₂) * (x₂ * x₂)) + -0.0058...
126
15 7.914e-06 3.040e-06 y = ((((1.351 / (1.0346 - x₂)) - x₂) * (x₀ / x₁)) * x₂) + ...
-0.0058126
17 7.914e-06 1.729e-06 y = (((((1.351 / (1.0346 - x₂)) - x₂) * (x₂ * x₂)) + -0.00...
58126) - x₁) + x₁
19 7.914e-06 2.056e-06 y = ((((((1.351 / (1.0346 - x₂)) - x₂) * (x₀ / x₁)) * x₂) ...
+ -0.0058126) - x₁) + x₁
───────────────────────────────────────────────────────────────────────────────────────────────────
[ Info: Final population:
[ Info: Results saved to:
PySRRegressor.equations_ = [ pick score equation \ 0 0.000000 x2 1 0.108108 x2 * 1.948201 2 1.421110 x2 / (x1 - x0) 3 2.001393 (x2 / (1.0093329 - x2)) * x2 4 0.908203 (x2 * x2) / (0.9631403 - (x2 * 0.9481157)) 5 0.732458 x2 * (x2 * ((1.3414102 / (1.0337074 - x2)) - x2)) 6 >>>> 0.606639 (((1.3510028 / (1.0345931 - x2)) - x2) * (x2 *... 7 0.000003 ((((1.3510028 / (1.0345931 - x2)) - x2) * (x0 ... 8 0.000002 (((((1.3510028 / (1.0345931 - x2)) - x2) * (x2... 9 0.000002 ((((((1.3510028 / (1.0345931 - x2)) - x2) * (x... loss complexity 0 0.826133 1 1 0.665502 3 2 0.038796 5 3 0.000709 7 4 0.000115 9 5 0.000027 11 6 0.000008 13 7 0.000008 15 8 0.000008 17 9 0.000008 19 ]In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
| model_selection | 'best' | |
| binary_operators | ['+', '-', ...] | |
| unary_operators | None | |
| expression_spec | None | |
| niterations | 1000 | |
| populations | 40 | |
| population_size | 27 | |
| max_evals | None | |
| maxsize | 20 | |
| maxdepth | None | |
| warmup_maxsize_by | None | |
| timeout_in_seconds | None | |
| constraints | None | |
| nested_constraints | None | |
| elementwise_loss | None | |
| loss_function | None | |
| loss_function_expression | None | |
| loss_scale | 'log' | |
| complexity_of_operators | None | |
| complexity_of_constants | None | |
| complexity_of_variables | None | |
| complexity_mapping | None | |
| parsimony | 0.0 | |
| dimensional_constraint_penalty | None | |
| dimensionless_constants_only | False | |
| use_frequency | True | |
| use_frequency_in_tournament | True | |
| adaptive_parsimony_scaling | 1040.0 | |
| alpha | 3.17 | |
| annealing | False | |
| early_stop_condition | None | |
| ncycles_per_iteration | 380 | |
| fraction_replaced | 0.00036 | |
| fraction_replaced_hof | 0.0614 | |
| weight_add_node | 2.47 | |
| weight_insert_node | 0.0112 | |
| weight_delete_node | 0.87 | |
| weight_do_nothing | 0.273 | |
| weight_mutate_constant | 0.0346 | |
| weight_mutate_operator | 0.293 | |
| weight_swap_operands | 0.198 | |
| weight_rotate_tree | 4.26 | |
| weight_randomize | 0.000502 | |
| weight_simplify | 0.00209 | |
| weight_optimize | 0.0 | |
| crossover_probability | 0.0259 | |
| skip_mutation_failures | True | |
| migration | True | |
| hof_migration | True | |
| topn | 12 | |
| should_simplify | True | |
| should_optimize_constants | True | |
| optimizer_algorithm | 'BFGS' | |
| optimizer_nrestarts | 2 | |
| optimizer_f_calls_limit | None | |
| optimize_probability | 0.14 | |
| optimizer_iterations | 8 | |
| perturbation_factor | 0.129 | |
| probability_negate_constant | 0.00743 | |
| tournament_selection_n | 15 | |
| tournament_selection_p | 0.982 | |
| parallelism | None | |
| procs | None | |
| cluster_manager | None | |
| heap_size_hint_in_bytes | None | |
| batching | False | |
| batch_size | 50 | |
| fast_cycle | False | |
| turbo | False | |
| bumper | False | |
| precision | 32 | |
| autodiff_backend | None | |
| random_state | None | |
| deterministic | False | |
| warm_start | False | |
| verbosity | 1 | |
| update_verbosity | None | |
| print_precision | 5 | |
| progress | False | |
| logger_spec | None | |
| input_stream | 'stdin' | |
| run_id | None | |
| output_directory | None | |
| temp_equation_file | False | |
| tempdir | None | |
| delete_tempfiles | True | |
| update | False | |
| output_jax_format | False | |
| output_torch_format | False | |
| extra_sympy_mappings | None | |
| extra_torch_mappings | None | |
| extra_jax_mappings | None | |
| denoise | False | |
| select_k_features | None |
- outputs\20251030_115941_cCFLiT\hall_of_fame.csv
# Utilization
X = df[["λ", "μ", "ρ"]].to_numpy()
y = df["u"].to_numpy()
model = PySRRegressor(
niterations=1000,
binary_operators=["+", "-", "*", "/"],
maxsize=20,
populations=40,
progress=False,
)
model.fit(X,y)
[ Info: Started!
Expressions evaluated per second: 6.330e+05
Progress: 3727 / 40000 total iterations (9.318%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.626e-07 0.000e+00 y = x₂
3 7.661e-07 5.935e-02 y = x₂ * 0.99926
5 6.221e-07 1.041e-01 y = (x₂ * 0.99768) - -0.00076905
7 2.923e-07 3.778e-01 y = x₂ * ((x₂ * -0.009023) + 1.0044)
9 1.842e-07 2.309e-01 y = x₂ * (1.0024 - (x₂ * (x₂ * 0.0088272)))
11 8.187e-08 4.053e-01 y = ((0.0014764 / (x₀ - (x₁ / x₂))) + x₂) - -0.00053783
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.220e+05
Progress: 7335 / 40000 total iterations (18.337%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.626e-07 0.000e+00 y = x₂
3 7.661e-07 5.935e-02 y = x₂ * 0.99926
5 6.221e-07 1.041e-01 y = (x₂ * 0.99768) - -0.00076905
7 2.923e-07 3.778e-01 y = x₂ * ((x₂ * -0.009023) + 1.0044)
9 7.603e-08 6.733e-01 y = (0.0007465 / (x₀ - x₁)) + (x₂ - -0.00091496)
11 5.405e-09 1.322e+00 y = ((0.001003 / ((x₀ - x₁) / x₂)) + x₂) / 0.99842
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.140e+05
Progress: 10899 / 40000 total iterations (27.247%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.626e-07 0.000e+00 y = x₂
3 7.661e-07 5.935e-02 y = x₂ * 0.99926
5 6.221e-07 1.041e-01 y = (x₂ * 0.99768) - -0.00076905
7 2.923e-07 3.778e-01 y = x₂ * ((x₂ * -0.0090226) + 1.0044)
9 7.603e-08 6.733e-01 y = (0.0007465 / (x₀ - x₁)) + (x₂ - -0.00091496)
11 1.512e-09 1.959e+00 y = (0.00097413 / ((x₀ - x₁) / x₀)) + (x₂ / 0.99781)
13 3.528e-10 7.277e-01 y = x₂ * ((0.00050793 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011)
15 3.008e-10 7.976e-02 y = (x₂ * ((0.00050994 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011...
)) - 1.6207e-05
17 3.006e-10 4.031e-04 y = ((x₂ * ((0.00050997 / ((x₀ - x₁) / (x₀ + x₂))) + 1.001...
1)) - -1.7225) + -1.7225
19 2.769e-10 4.094e-02 y = ((x₂ * ((0.00050834 / ((x₀ - x₁) / (x₀ + x₂))) + 1.001...
1)) - 1.7849e-05) + (x₀ * 4.9498e-05)
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.140e+05
Progress: 14479 / 40000 total iterations (36.197%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.626e-07 0.000e+00 y = x₂
3 7.661e-07 5.935e-02 y = x₂ * 0.99926
5 6.221e-07 1.041e-01 y = (x₂ * 0.99768) - -0.00077094
7 2.923e-07 3.778e-01 y = x₂ * ((x₂ * -0.0090226) + 1.0044)
9 5.362e-09 1.999e+00 y = x₂ * ((0.0010115 / (x₀ - x₁)) + 1.0016)
11 1.512e-09 6.329e-01 y = (0.00097413 / ((x₀ - x₁) / x₀)) + (x₂ / 0.99781)
13 3.528e-10 7.277e-01 y = x₂ * ((0.00050793 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011)
15 3.008e-10 7.976e-02 y = (x₂ * ((0.00050994 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011...
)) - 1.6207e-05
17 3.004e-10 7.392e-04 y = ((x₂ * ((0.00050999 / ((x₀ - x₁) / (x₀ + x₂))) + 1.001...
1)) - -1.8097) + -1.8097
19 2.769e-10 4.071e-02 y = (((0.00050834 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011) * (...
x₂ - 1.7849e-05)) + (x₀ * 4.9498e-05)
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.980e+05
Progress: 17762 / 40000 total iterations (44.405%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.626e-07 0.000e+00 y = x₂
3 7.661e-07 5.935e-02 y = x₂ * 0.99926
5 6.221e-07 1.041e-01 y = (x₂ * 0.99768) - -0.00077094
7 2.923e-07 3.778e-01 y = x₂ * ((x₂ * -0.0090226) + 1.0044)
9 5.362e-09 1.999e+00 y = x₂ * ((0.0010114 / (x₀ - x₁)) + 1.0016)
11 1.512e-09 6.328e-01 y = (0.00097413 / ((x₀ - x₁) / x₀)) + (x₂ / 0.99781)
13 3.528e-10 7.277e-01 y = x₂ * ((0.00050793 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011)
15 3.008e-10 7.968e-02 y = (x₂ * ((0.00050994 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011...
)) - 1.6207e-05
17 3.004e-10 7.392e-04 y = ((x₂ * ((0.00050999 / ((x₀ - x₁) / (x₀ + x₂))) + 1.001...
1)) - -1.8097) + -1.8097
19 2.769e-10 4.071e-02 y = (((0.00050834 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011) * (...
x₂ - 1.7849e-05)) + (x₀ * 4.9498e-05)
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.880e+05
Progress: 21245 / 40000 total iterations (53.112%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.626e-07 0.000e+00 y = x₂
3 7.661e-07 5.935e-02 y = x₂ * 0.99926
5 6.221e-07 1.041e-01 y = (x₂ * 0.99768) - -0.00077094
7 2.923e-07 3.778e-01 y = x₂ * ((x₂ * -0.0090226) + 1.0044)
9 5.362e-09 1.999e+00 y = x₂ * ((0.0010114 / (x₀ - x₁)) + 1.0016)
11 1.512e-09 6.328e-01 y = (0.00097413 / ((x₀ - x₁) / x₀)) + (x₂ / 0.99781)
13 3.528e-10 7.277e-01 y = x₂ * ((0.00050793 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011)
15 3.008e-10 7.968e-02 y = (x₂ * ((0.00050994 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011...
)) - 1.6207e-05
17 1.995e-10 2.055e-01 y = x₂ * ((-0.00078602 / ((x₀ - x₁) / ((x₂ / x₀) + (-1.268...
8 - x₂)))) - -1.0014)
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.820e+05
Progress: 24621 / 40000 total iterations (61.553%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.626e-07 0.000e+00 y = x₂
3 7.661e-07 5.935e-02 y = x₂ * 0.99926
5 6.221e-07 1.041e-01 y = (x₂ * 0.99768) - -0.00077094
7 2.923e-07 3.778e-01 y = x₂ * ((x₂ * -0.0090226) + 1.0044)
9 5.362e-09 1.999e+00 y = x₂ * ((0.0010114 / (x₀ - x₁)) + 1.0016)
11 1.510e-09 6.336e-01 y = (x₂ * 1.0022) + (0.00097577 / ((x₀ - x₁) / x₀))
13 3.528e-10 7.269e-01 y = x₂ * ((0.00050793 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011)
15 3.008e-10 7.968e-02 y = (x₂ * ((0.00050994 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011...
)) - 1.6207e-05
17 1.966e-10 2.125e-01 y = x₂ * ((-0.0007674 / ((x₀ - x₁) / ((x₂ / x₀) + (-1.3002...
- x₂)))) - -1.0014)
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.760e+05
Progress: 28125 / 40000 total iterations (70.312%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.626e-07 0.000e+00 y = x₂
3 7.661e-07 5.935e-02 y = x₂ * 0.99926
5 6.221e-07 1.041e-01 y = (x₂ * 0.99768) - -0.00077094
7 2.923e-07 3.778e-01 y = x₂ * ((x₂ * -0.0090226) + 1.0044)
9 5.362e-09 1.999e+00 y = x₂ * ((0.0010114 / (x₀ - x₁)) + 1.0016)
11 1.509e-09 6.338e-01 y = ((x₂ * 1.0022) + -1.0012) / ((x₀ - x₁) / x₀)
13 3.528e-10 7.268e-01 y = x₂ * ((0.00050793 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011)
15 3.008e-10 7.968e-02 y = (x₂ * ((0.00050994 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011...
)) - 1.6207e-05
17 1.966e-10 2.125e-01 y = x₂ * ((-0.0007674 / ((x₀ - x₁) / ((x₂ / x₀) + (-1.3002...
- x₂)))) - -1.0014)
19 1.453e-10 1.512e-01 y = (x₂ * ((-0.00077109 / ((x₀ - x₁) / ((x₂ / x₀) + (-1.29...
92 - x₂)))) - -1.0014)) + -1.618e-05
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.840e+05
Progress: 31600 / 40000 total iterations (79.000%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.626e-07 0.000e+00 y = x₂
3 7.661e-07 5.935e-02 y = x₂ * 0.99926
5 6.221e-07 1.041e-01 y = (x₂ * 0.99768) - -0.00077094
7 2.923e-07 3.778e-01 y = x₂ * ((x₂ * -0.0090226) + 1.0044)
9 5.362e-09 1.999e+00 y = x₂ * ((0.0010114 / (x₀ - x₁)) + 1.0016)
11 1.509e-09 6.338e-01 y = ((x₂ * 1.0022) + -1.0012) / ((x₀ - x₁) / x₀)
13 3.528e-10 7.268e-01 y = x₂ * ((0.00050793 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011)
15 3.008e-10 7.968e-02 y = (x₂ * ((0.00050994 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011...
)) - 1.6207e-05
17 1.966e-10 2.128e-01 y = x₂ * ((-0.00076798 / ((x₀ - x₁) / ((x₂ / x₀) + (-1.299...
2 - x₂)))) - -1.0014)
19 1.453e-10 1.510e-01 y = (x₂ * ((-0.00077109 / ((x₀ - x₁) / ((x₂ / x₀) + (-1.29...
92 - x₂)))) - -1.0014)) + -1.618e-05
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 5.920e+05
Progress: 35248 / 40000 total iterations (88.120%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.626e-07 0.000e+00 y = x₂
3 7.661e-07 5.935e-02 y = x₂ * 0.99926
5 6.221e-07 1.041e-01 y = (x₂ * 0.99768) - -0.00077094
7 2.923e-07 3.778e-01 y = x₂ * ((x₂ * -0.0090226) + 1.0044)
9 5.362e-09 1.999e+00 y = x₂ * ((0.0010114 / (x₀ - x₁)) + 1.0016)
11 1.509e-09 6.338e-01 y = ((x₂ * 1.0022) + -1.0012) / ((x₀ - x₁) / x₀)
13 3.528e-10 7.268e-01 y = x₂ * ((0.00050793 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011)
15 3.008e-10 7.968e-02 y = (x₂ * ((0.00050994 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011...
)) - 1.6207e-05
17 1.966e-10 2.128e-01 y = x₂ * ((-0.00076798 / ((x₀ - x₁) / ((x₂ / x₀) + (-1.299...
2 - x₂)))) - -1.0014)
19 1.453e-10 1.510e-01 y = (x₂ * ((-0.00077109 / ((x₀ - x₁) / ((x₂ / x₀) + (-1.29...
92 - x₂)))) - -1.0014)) + -1.618e-05
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
Expressions evaluated per second: 6.010e+05
Progress: 38862 / 40000 total iterations (97.155%)
════════════════════════════════════════════════════════════════════════════════════════════════════
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.626e-07 0.000e+00 y = x₂
3 7.661e-07 5.935e-02 y = x₂ * 0.99926
5 6.221e-07 1.041e-01 y = (x₂ * 0.99768) - -0.00077094
7 2.923e-07 3.778e-01 y = x₂ * ((x₂ * -0.0090226) + 1.0044)
9 5.362e-09 1.999e+00 y = x₂ * ((0.0010114 / (x₀ - x₁)) + 1.0016)
11 1.509e-09 6.338e-01 y = ((x₂ * 1.0022) + -1.0012) / ((x₀ - x₁) / x₀)
13 3.528e-10 7.268e-01 y = x₂ * ((0.00050793 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011)
15 3.008e-10 7.968e-02 y = (x₂ * ((0.00050994 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011...
)) - 1.6207e-05
17 1.966e-10 2.128e-01 y = x₂ * ((-0.00076798 / ((x₀ - x₁) / ((x₂ / x₀) + (-1.299...
2 - x₂)))) - -1.0014)
19 1.453e-10 1.510e-01 y = (x₂ * ((-0.00077109 / ((x₀ - x₁) / ((x₂ / x₀) + (-1.29...
92 - x₂)))) - -1.0014)) + -1.6179e-05
───────────────────────────────────────────────────────────────────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════════════════════════
Press 'q' and then <enter> to stop execution early.
───────────────────────────────────────────────────────────────────────────────────────────────────
Complexity Loss Score Equation
1 8.626e-07 0.000e+00 y = x₂
3 7.661e-07 5.935e-02 y = x₂ * 0.99926
5 6.221e-07 1.041e-01 y = (x₂ * 0.99768) - -0.00077094
7 2.923e-07 3.778e-01 y = x₂ * ((x₂ * -0.0090226) + 1.0044)
9 5.362e-09 1.999e+00 y = x₂ * ((0.0010114 / (x₀ - x₁)) + 1.0016)
11 1.509e-09 6.338e-01 y = ((x₂ * 1.0022) + -1.0012) / ((x₀ - x₁) / x₀)
13 3.528e-10 7.268e-01 y = x₂ * ((0.00050793 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011)
15 3.008e-10 7.968e-02 y = (x₂ * ((0.00050994 / ((x₀ - x₁) / (x₀ + x₂))) + 1.0011...
)) - 1.6207e-05
17 1.966e-10 2.128e-01 y = x₂ * ((-0.00076798 / ((x₀ - x₁) / ((x₂ / x₀) + (-1.299...
2 - x₂)))) - -1.0014)
19 1.453e-10 1.510e-01 y = (x₂ * ((-0.00077109 / ((x₀ - x₁) / ((x₂ / x₀) + (-1.29...
92 - x₂)))) - -1.0014)) + -1.6179e-05
───────────────────────────────────────────────────────────────────────────────────────────────────
- outputs\20251030_120036_c1OLnc\hall_of_fame.csv
[ Info: Final population:
[ Info: Results saved to:
PySRRegressor.equations_ = [ pick score equation \ 0 0.000000 x2 1 0.059345 x2 * 0.99926406 2 0.104069 (x2 * 0.99767673) - -0.00077094254 3 0.377752 x2 * ((x2 * -0.009022583) + 1.0043627) 4 1.999183 x2 * ((0.0010113808 / (x0 - x1)) + 1.0016068) 5 0.633779 ((x2 * 1.0021956) + -1.00122) / ((x0 - x1) / x0) 6 0.726805 x2 * ((0.00050792616 / ((x0 - x1) / (x0 + x2))... 7 0.079681 (x2 * ((0.0005099375 / ((x0 - x1) / (x0 + x2))... 8 >>>> 0.212754 x2 * ((-0.00076798367 / ((x0 - x1) / ((x2 / x0... 9 0.151040 (x2 * ((-0.0007710862 / ((x0 - x1) / ((x2 / x0... loss complexity 0 8.626243e-07 1 1 7.660815e-07 3 2 6.221305e-07 5 3 2.922608e-07 7 4 5.361693e-09 9 5 1.509415e-09 11 6 3.527880e-10 13 7 3.008181e-10 15 8 1.965661e-10 17 9 1.453173e-10 19 ]In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
| model_selection | 'best' | |
| binary_operators | ['+', '-', ...] | |
| unary_operators | None | |
| expression_spec | None | |
| niterations | 1000 | |
| populations | 40 | |
| population_size | 27 | |
| max_evals | None | |
| maxsize | 20 | |
| maxdepth | None | |
| warmup_maxsize_by | None | |
| timeout_in_seconds | None | |
| constraints | None | |
| nested_constraints | None | |
| elementwise_loss | None | |
| loss_function | None | |
| loss_function_expression | None | |
| loss_scale | 'log' | |
| complexity_of_operators | None | |
| complexity_of_constants | None | |
| complexity_of_variables | None | |
| complexity_mapping | None | |
| parsimony | 0.0 | |
| dimensional_constraint_penalty | None | |
| dimensionless_constants_only | False | |
| use_frequency | True | |
| use_frequency_in_tournament | True | |
| adaptive_parsimony_scaling | 1040.0 | |
| alpha | 3.17 | |
| annealing | False | |
| early_stop_condition | None | |
| ncycles_per_iteration | 380 | |
| fraction_replaced | 0.00036 | |
| fraction_replaced_hof | 0.0614 | |
| weight_add_node | 2.47 | |
| weight_insert_node | 0.0112 | |
| weight_delete_node | 0.87 | |
| weight_do_nothing | 0.273 | |
| weight_mutate_constant | 0.0346 | |
| weight_mutate_operator | 0.293 | |
| weight_swap_operands | 0.198 | |
| weight_rotate_tree | 4.26 | |
| weight_randomize | 0.000502 | |
| weight_simplify | 0.00209 | |
| weight_optimize | 0.0 | |
| crossover_probability | 0.0259 | |
| skip_mutation_failures | True | |
| migration | True | |
| hof_migration | True | |
| topn | 12 | |
| should_simplify | True | |
| should_optimize_constants | True | |
| optimizer_algorithm | 'BFGS' | |
| optimizer_nrestarts | 2 | |
| optimizer_f_calls_limit | None | |
| optimize_probability | 0.14 | |
| optimizer_iterations | 8 | |
| perturbation_factor | 0.129 | |
| probability_negate_constant | 0.00743 | |
| tournament_selection_n | 15 | |
| tournament_selection_p | 0.982 | |
| parallelism | None | |
| procs | None | |
| cluster_manager | None | |
| heap_size_hint_in_bytes | None | |
| batching | False | |
| batch_size | 50 | |
| fast_cycle | False | |
| turbo | False | |
| bumper | False | |
| precision | 32 | |
| autodiff_backend | None | |
| random_state | None | |
| deterministic | False | |
| warm_start | False | |
| verbosity | 1 | |
| update_verbosity | None | |
| print_precision | 5 | |
| progress | False | |
| logger_spec | None | |
| input_stream | 'stdin' | |
| run_id | None | |
| output_directory | None | |
| temp_equation_file | False | |
| tempdir | None | |
| delete_tempfiles | True | |
| update | False | |
| output_jax_format | False | |
| output_torch_format | False | |
| extra_sympy_mappings | None | |
| extra_torch_mappings | None | |
| extra_jax_mappings | None | |
| denoise | False | |
| select_k_features | None |
The symbolic regression should render equations akin to,
\(\text{E}[d] = \rho / (\mu - \lambda)\)
\(\text{E}[q] = \rho^2 / (1 - \rho)\)
\(\text{E}[u] = \rho\)
Cellular Automata for Single-Lane Car Following
a. Implement Nagel–Schreckenberg Model \(\text{NaSchCA}(l, n, v, p, k, \text{seed})\) in Python for length of lattice \(l\), number of vehicles \(n\), maximum velocity \(v\), stochastic braking probability \(p\), and number of iterations \(k\), with random number generator \(\text{seed}\).
import numpy as np
def NaSchCA(l, n, v, p, k, seed):
"""
Simulate the Nagel–Schreckenberg (NaSch) cellular automaton model of traffic flow
on a single-lane ring road.
Parameters
----------
l : int
Length of the lattice (number of discrete cells in the ring road).
n : int
Number of vehicles on the lattice.
v : int
Maximum velocity (cells per time step) allowed for a vehicle.
p : float
Stochastic braking probability (0 <= p <= 1).
k : int
Number of time steps (iterations) to simulate.
seed : int
Random seed for reproducibility of stochastic braking.
Returns
-------
dict
A dictionary containing:
- ``X`` : ndarray of shape (n,)
Final positions of vehicles on the lattice.
- ``V`` : ndarray of shape (n,)
Final velocities of vehicles.
- ``Z`` : ndarray of shape (k, l)
Space–time raster of the system, where each entry indicates
the velocity of a vehicle occupying a cell, or -1 if empty.
- ``f`` : float
Mean flow over the simulation horizon, normalized by lattice length.
"""
# Intialize
rng = np.random.default_rng(seed)
s = l // n
X = np.arange(0, s*n, s) % l
V = np.zeros(n, dtype=int)
# Iterate
f = 0
Z = np.full((k, l), -1, dtype=int) # cell entry indicates speed of the vehicle occupying it; -1 if it is empty
for t in range(k):
Z[t, X] = V
# Perception
I = (np.arange(n) + 1) % n
H = (X[I] - X - 1) % l
# Decision-Making | Action | Environment Update
## Acceleration
V = np.minimum(V + 1, v)
## Deceleration
V = np.minimum(V, H)
## Stochastic Braking
r = rng.random(n)
K = (r < p) & (V > 0)
V[K] -= 1
X = (X + V) % l
f += V.sum() / (k * l)
return {"X": X, "V": V, "Z": Z, "f": f}
b. For a lattice with 300 cells, 60 vehicles, each with maximum velocity of 5 cells per unit time and stochastic braking probability of 20%, run 400 iterations in time to create a time-space occupancy diagram.
# Time–space occupancy diagram
import matplotlib.pyplot as plt
# Input Parameters
l = 300
n = 60
v = 5
p = 0.2
k = 400
seed = 5540
# Output
R = NaSchCA(l, n, v, p, k, seed)
Z = (R["Z"] >= 0).astype(int)
# Plot
plt.figure()
plt.imshow(Z, aspect='auto', origin='lower', interpolation='nearest')
plt.xlabel("Space (cell index)")
plt.ylabel("Time step")
plt.title("NaSch Time–Space Diagram (occupied=1, empty=0)")
plt.show()
c. Develop the fundamental flow diagram (flow vs density) relationship for this single-lane traffic.
# Fundamental diagram (flow vs density) via density sweep
import numpy as np
import matplotlib.pyplot as plt
# Input Parameters
l = 300
n = 60
v = 5
p = 0.2
k1 = 300
k2 = 600
seed = 0
D = np.linspace(0.05, 0.95, 19)
F = []
for d in D:
n = max(1, int(round(d*l)))
_ = NaSchCA(l, n, v, p, k1, seed)
R = NaSchCA(l, n, v, p, k2, seed)
F.append(R["f"])
plt.figure()
plt.plot(D, F, marker='o')
plt.xlabel("Density (veh/cell)")
plt.ylabel("Flow (veh/cell/step)")
plt.title("Fundamental Diagram")
plt.show()