-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lagrange [WIP] #31
base: main
Are you sure you want to change the base?
Lagrange [WIP] #31
Conversation
S = model.structure.S | ||
dG = (S.T @ model.parameters.dgf + 2.4788191*[email protected](conc)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can these lines be deleted?
src/enzax/steady_state.py
Outdated
lagrangian, | ||
solver, | ||
jnp.concat([jnp.log(guess), lambda_guess]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more readable and can avoid annoying copy/paste bugs later:
lagrangian, | |
solver, | |
jnp.concat([jnp.log(guess), lambda_guess]), | |
fn=lagrangian, | |
solver=solver, | |
y0=jnp.concat([jnp.log(guess), lambda_guess]), |
src/enzax/steady_state.py
Outdated
def lagrangian( | ||
z: Float[Array, " n_balanced*2"], | ||
model: RateEquationModel, | ||
) -> Float[Array, " n_balanced*2"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a docstring for this function?
) -> Float: | ||
S = model.structure.S | ||
dG = (S.T @ model.parameters.dgf + 2.4788191*[email protected](conc)) | ||
return sum(jnp.square(model.dcdt(0, x))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe either jnp.square(model.dcdt(0, x)).sum()
or jnp.sum(jnp.square(model.dcdt(0, x)))
would be better here - I'm not sure exactly what happens when you use the standard sum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I think there are just a few lint things to fix before merging.
I think we should also add unit tests for steady state functions but that can wait
Summary
Steady-state solving is difficult and errors are problematic. This approach is not necessarily better than the method posed in diffrax but it has the potential to fail in a detectable way; this may be desirable for mcmc. Preliminary tests suggest that is may be faster than standard ODE solving, up to 3 times faster for the methionine cycle “BAD_GUESS” test case, and it achieves steady state.
Checklist:
README.md
up to date