Skip to content
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

Stochsystem overhaul #76

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft

Stochsystem overhaul #76

wants to merge 28 commits into from

Conversation

oameye
Copy link
Member

@oameye oameye commented Apr 21, 2024

Work on #75, #42 and #22

@oameye oameye mentioned this pull request Apr 21, 2024
@reykboerner
Copy link
Collaborator

I've taken a quick look at this and have three comments:

  • CoupledSDEs now has one parameter field p for both functions f and g, but I still think there should be a constructor function that lets you pass individual parameter fields pf and pg as input arguments (because otherwise it will be difficult to combine existing CoupledODEs drift functions with different noise functions).
  • We should also import the step! and set_state! functions used in DynamicalSystemsBase and then rewrite the callbacks in e.g. transition in terms of these functions. This seems to be faster than callbacks.
  • It makes sense to me that in DynamicalSystemsBase the function should be called CoupledSDEs to match the nomenclature of CoupledODEs, but our package focuses more on noise- and rate-induced transitions, so should we still keep an alias like StochSystem or StochasticSystem?

@oameye
Copy link
Member Author

oameye commented Apr 23, 2024

We should also import the step! and set_state! functions used in DynamicalSystemsBase and then rewrite the callbacks in e.g. transition in terms of these functions. This seems to be faster than callbacks.

The documentation of DynamicalSystems.jl says that recommend using ODEProblem when using callbacks.
image

@oameye
Copy link
Member Author

oameye commented May 7, 2024

We should only merge once the CI, Dowgrade and docs are working. Will take a look tonight :)

@reykboerner
Copy link
Collaborator

The transition function throws an error in the tests:

ERROR: cannot assign a value to imported variable CriticalTransitions.trajectory from module Main

Can check later what the issue is. Also, trajectory seems to be a lot slower than simulate. Do you know why @oameye ?

@@ -30,7 +30,7 @@ The minimization can be performed in blocks to save intermediate results.
If `save_info`, returns `Optim.OptimizationResults`. Else, returns only the optimizer (path).
If `blocks > 1`, a vector of results/optimizers is returned.
"""
function min_action_method(sys::StochSystem, x_i::State, x_f::State, N::Int, T::Real;
function min_action_method(sys::CoupledSDEs, x_i::SVector, x_f::SVector, N::Int, T::Real;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is best to not force to user to use Svector

@@ -50,6 +50,7 @@ export equilib, fixedpoints, basins, basinboundary, basboundary
export simulate, relax
export transition, transitions
export fw_integrand, fw_action, om_action, action, geometric_action
export div_drift
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep the namespace minimal, we should limit the amount of functions we export. I don't think we need to export div_drift

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be convenient to export because it is quite central to the Onsager-Machlup action. Of course one can compute it pretty easily. We could also consider not exporting fw_integrand

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But a user would never call it in a usual workflow right? If they want to call they can just import the function in the namespace or calll it with Criticaltransition.div_drift

@oameye
Copy link
Member Author

oameye commented May 8, 2024

We need to update the docs.

@oameye
Copy link
Member Author

oameye commented May 8, 2024

dev, examples and ext have still to be updated

@@ -14,7 +14,7 @@ As this module is not published yet, there are two ways to access it:
## Basic usage
The general workflow of `CriticalTransitions` essentially follows two steps:

1. Define your system (see [Define a CoupledSDE](@ref))
1. Define your system (see [Define a CoupledSDEs system](@ref))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a reference to a tag. So if we change it here. It should be changed everywhere

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, yes.

@@ -16,6 +16,11 @@ using Symbolics
using Optim, Dierckx
using Printf, DrWatson, Dates, Statistics

# Define custom types
Parameters = Union{Vector{Any}, Nothing};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding these types also means we should use it. In general, we try to not restrict to use specific types (generic programminf), e.g,, the parameter type in SciML ecosystem can be a tuple, array, dictionary, etc. I think we should follow what JuliaDynamics does.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I just re-added these custom types because some functions are still dependent on them, which caused an error when they were removed. In the long-run we should follow the style conventions, absolutely.

@oameye
Copy link
Member Author

oameye commented May 23, 2024

  • check how DynamicalSystems of the state and parameters and it similarly
  • Get docs up to date with this branch
  • Make extention out of baisins
  • Make helpful constructors for CoupledSDEs
  • Normalise g function in CoupledSDEs and noise strength field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants