Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,38 @@
# filename: /.gitattributes

# Auto detect text files and perform LF normalization
* text=auto

# Binary files - do not change line endings
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.zip binary
*.exe binary
*.dll binary
*.so binary
*.7z binary
*.pdf binary

# Source code files with CRLF to LF normalization
*.cs text eol=lf
*.cpp text eol=lf
*.c text eol=lf
*.h text eol=lf
*.hpp text eol=lf
*.java text eol=lf
*.py text eol=lf
*.sh text eol=lf
*.bat text eol=crlf

# Mark scripts executable on Linux/macOS
*.sh text eol=lf
*.bash text eol=lf
*.zsh text eol=lf

# Ignore proprietary IDE/project files line endings (keep as-is)
*.sln text eol=crlf
*.vcxproj text eol=crlf
*.user text eol=crlf
13 changes: 11 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
# filename: /.gitignore

# ignore ALL .log files
*.log

# ignore ALL .lua files
*.lua

# ignore ALL picture files
# ignore ALL picture files (png)
*.png

# ignore ALL files in ANY directory named temp
.lite_workspace.lua
temp/**

# ignore specific workspace and editor folders/files
*.lite_workspace.lua

.vs/
.vscode/

# ignore build and output directories
nanoscript/
Nano/bin/
Nano/obj/

# ignore entire project folder NanoThe2nd
NanoThe2nd/
263 changes: 263 additions & 0 deletions Augmented-Logic-Network-cybernetickernel.aln
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
# =====================================================================
# Augmented-Logic-Network (ALN) : Cybernetic HCM-FBA / HCM-MCMC Kernel
# Bio-compatible • Secure • Deterministic
# ---------------------------------------------------------------------
# NOTE:
# - This ALN design encodes the same mathematics as the MATLAB script:
# r_M,l = e_l * kM_l * s_l / (KM_l + s_l)
# r_E,l = kE_l * s_l / (KE_l + s_l)
# r_G,l = z_biomass,l * r_M,l
# u_l = ROI_l / sum(ROI)
# v_l = ROI_l / max(ROI)
# μ = Σ_l r_G,l * v_l
# d x_i / dt = Σ_j Σ_l σ_ij * z_jl * r_M,l * v_l
# d e_l / dt = α_l + r_E,l * u_l − (β_l + μ) * e_l
# d c / dt = μ * c
# - All logic is expressed as composable, side-effect-controlled nodes.
# =====================================================================

network Cybernetic_HCM_FBA_MCMC {

# --------------------------------------------------------------
# DIMENSION CONSTANTS
# --------------------------------------------------------------
const L_modes = 3 # number of flux modes [web:1]
const R_rxns = 5 # number of reactions [web:1]
const M_ext = 4 # number of extracellular spp. [web:1]

# --------------------------------------------------------------
# TYPE DEFINITIONS
# --------------------------------------------------------------
type VecL = vector<L_modes,float64> # mode-indexed vector [web:1]
type VecM = vector<M_ext,float64> # species vector [web:1]
type MatMR = matrix<M_ext,R_rxns,float64>
type MatRL = matrix<R_rxns,L_modes,float64>

# --------------------------------------------------------------
# SECURE PARAMETER BLOCK
# - Read-only at runtime
# - Can be loaded from signed config for clinical / bioprocess
# --------------------------------------------------------------
secure.params {

# Kinetic parameters per mode l
kM : VecL = rand(0.0, 1.0) # max reaction rates [web:1]
KM : VecL = rand(0.0, 1.0) # saturation consts [web:1]
kE : VecL = rand(0.0, 1.0) # enzyme synthesis [web:1]
KE : VecL = rand(0.0, 1.0) # enzyme sat. const [web:1]

# Normalized biomass and uptake fluxes
z_biomass : VecL = ones() # normalized biomass [web:1]
z_s : VecL = rand(0.0, 1.0) # substrate uptake [web:1]

# Stoichiometry and mode flux structure
sigma : MatMR = normal(0.0, 1.0) # σ_ij [web:1]
z_jl : MatRL = rand(0.0, 1.0) # z_jl [web:1]

# Enzyme formation / degradation
alpha_l : VecL = rand(0.0, 0.1) # constitutive synth [web:1]
beta_l : VecL = rand(0.0, 0.1) # nonspecific degr. [web:1]
}

# --------------------------------------------------------------
# STATE VARIABLES (BIO-COMPATIBLE REPRESENTATION)
# - x_i : extracellular concentrations (M_ext)
# - e_l : pseudoenzyme concentration per mode (L_modes)
# - c : biomass concentration
# --------------------------------------------------------------
state {

x : VecM = rand(0.0, 1.0) # initial extracellular x_i [web:1]
e : VecL = rand(0.0, 1.0) # initial pseudoenzymes e_l [web:1]
c : float64 = 1.0 # initial biomass [web:1]
}

# --------------------------------------------------------------
# HELPER NODE: MICHAELIS-MENTEN STYLE RATE
# r = amp * s / (K + s)
# Numerically safe & monotone in s
# --------------------------------------------------------------
node mm_rate(amp:VecL, K:VecL, s:float64) -> VecL {
let denom : VecL = K + s
# Avoid division by zero: clamp denominator
let denom_safe : VecL = max(denom, 1e-9)
return amp * s / denom_safe
}

# --------------------------------------------------------------
# NODE: CYBERNETIC CONTROL (u_l, v_l, μ)
# --------------------------------------------------------------
node cybernetic_control(
rM : VecL,
z_bio : VecL,
z_s : VecL
) -> (u:VecL, v:VecL, mu:float64) {

# ROI_l = z_s,l * rM,l
let ROI : VecL = z_s * rM

# u_l = ROI_l / Σ ROI (enzyme synthesis investment)
let ROI_sum : float64 = sum(ROI)
let ROI_sum_safe : float64 = max(ROI_sum, 1e-12)
let u_vec : VecL = ROI / ROI_sum_safe

# v_l = ROI_l / max_l ROI_l (activity modulation)
let ROI_max : float64 = max_element(ROI)
let ROI_max_safe : float64 = max(ROI_max, 1e-12)
let v_vec : VecL = ROI / ROI_max_safe

# Growth rate μ = Σ_l r_G,l * v_l with r_G,l = z_bio,l * rM,l
let rG : VecL = z_bio * rM
let mu_val : float64 = dot(rG, v_vec)

return (u_vec, v_vec, mu_val)
}

# --------------------------------------------------------------
# NODE: EXTRACELLULAR BALANCE (dx/dt)
# d x_i / dt = Σ_j Σ_l σ_ij * z_jl * rM_l * v_l
# --------------------------------------------------------------
node dx_dt(
x : VecM,
rM : VecL,
v : VecL,
sigma : MatMR,
z_jl : MatRL
) -> VecM {

let M_local = M_ext
let L_local = L_modes
let R_local = R_rxns

# Effective mode flux ϕ_l = rM_l * v_l
let phi : VecL = rM * v

var dx : VecM = zeros()

# Triple sum in a structured way
for i in 0..(M_local-1) {
var acc_i : float64 = 0.0
for j in 0..(R_local-1) {
var acc_j : float64 = 0.0
for l in 0..(L_local-1) {
acc_j += z_jl[j,l] * phi[l]
}
acc_i += sigma[i,j] * acc_j
}
dx[i] = acc_i
}

return dx
}

# --------------------------------------------------------------
# NODE: ENZYME BALANCE (de/dt)
# d e_l / dt = α_l + rE,l * u_l − (β_l + μ)*e_l
# --------------------------------------------------------------
node de_dt(
e : VecL,
mu : float64,
rE : VecL,
u : VecL,
alpha_l : VecL,
beta_l : VecL
) -> VecL {

let synth : VecL = alpha_l + rE * u
let loss : VecL = (beta_l + mu) * e
return synth - loss
}

# --------------------------------------------------------------
# NODE: BIOMASS BALANCE (dc/dt)
# d c / dt = μ * c
# --------------------------------------------------------------
node dc_dt(mu:float64, c:float64) -> float64 {
return mu * c
}

# --------------------------------------------------------------
# CORE UPDATE STEP (ONE TIME INCREMENT)
# - Can be embedded into any integrator (Euler, RK4, etc.)
# - Designed to map to secure, bounded hardware for bio-systems
# --------------------------------------------------------------
step evolve(dt:float64) {

# local copies for readability (no side effects yet)
let s : float64 = x[0] # primary substrate [web:1]

# Regulated and unregulated rates
let rM : VecL = e * mm_rate(params.kM, params.KM, s)
let rE : VecL = mm_rate(params.kE, params.KE, s)

# Cybernetic variables u_l, v_l, and μ
let (u, v, mu) = cybernetic_control(
rM,
params.z_biomass,
params.z_s
)

# Time derivatives
let dx = dx_dt(
x,
rM,
v,
params.sigma,
params.z_jl
)

let de = de_dt(
e,
mu,
rE,
u,
params.alpha_l,
params.beta_l
)

let dc = dc_dt(mu, c)

# ----------------------------------------------------------
# STATE UPDATE (EXPLICIT EULER – CAN BE REPLACED BY RK SOLVER)
# ----------------------------------------------------------
x <- x + dt * dx
e <- e + dt * de
c <- c + dt * dc
}

# --------------------------------------------------------------
# SECURE INTERFACES
# - For bio-compatible deployment, IO is separated from dynamics
# --------------------------------------------------------------
io {

# Safe read-only probes (for monitoring / digital twin)
export state_x() : VecM { return x } # extracellular [web:1]
export state_e() : VecL { return e } # enzyme modes [web:1]
export state_c() : float64 { return c } # biomass [web:1]

# Controlled evolution: caller chooses time step and steps
export simulate(dt:float64, steps:int) {

var k : int = 0
while k < steps {
evolve(dt)
k <- k + 1
}
}
}
}
[1](https://oai.zbmath.org/)
[2](https://api.zbmath.org)
[3](https://api.zbmath.org/static/terms-and-conditions.html)
[4](https://oai.zbmath.org/static/terms-and-conditions.html)
[5](https://pmc.ncbi.nlm.nih.gov/articles/PMC4174092/)
[6](https://arxiv.org/abs/1906.06298)
[7](https://github.com/napulen/AugmentedNet)
[8](https://ricardodominguez.net)
[9](https://pubs.acs.org/doi/pdf/10.1021/acs.chemrev.5c00112)
[10](https://naninovel.com/api/)
[11](https://github.com/alantech/alan)
[12](https://arxiv.org/html/2411.14012v1)
[13](https://naninovel.com/guide/script-expressions)
[14](https://github.com/thumpnail/NanoScript)
1 change: 0 additions & 1 deletion Nano/AssamblyInfo.cs

This file was deleted.

Loading