-
Notifications
You must be signed in to change notification settings - Fork 374
Promote weak form SINDy from a feature library to a sibling SINDy class.
#678
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
Merged
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
d1a0d70
WIP Weak
Jacob-Stevens-Haas cdcf3b8
WIP: Easier reading for integration weights
Jacob-Stevens-Haas e8eccb2
WIP: Save before partition
Jacob-Stevens-Haas 29f8492
Passes 1D change-of-variable test
Jacob-Stevens-Haas 88372cb
Passes 2D change-of-variables test
Jacob-Stevens-Haas ade75e4
WIP
Jacob-Stevens-Haas a579d6b
TST: fix integrate_by_parts()
Jacob-Stevens-Haas 9f7963b
Fix: Allow PDELibrary.get_params()
Jacob-Stevens-Haas 51cfab4
WIP get integrate_product_by_parts
Jacob-Stevens-Haas 1ff387e
feat: Make flatten_libraries() work
Jacob-Stevens-Haas 6896544
feat: Make _integrate_by_parts() work
Jacob-Stevens-Haas 8023547
Integrate time derivative w/test func
Jacob-Stevens-Haas e97c66b
Solve all the integrate by parts; reduce PDELibrary
Jacob-Stevens-Haas ae7c21c
Make weak feature names off of sorted_lib_
Jacob-Stevens-Haas f10ff1f
BLD: Bump min version to 3.11
Jacob-Stevens-Haas 6067dfa
Extract test function to make testing easier
Jacob-Stevens-Haas 9159c23
Make _plan_weak_form figure out correct term ordering
Jacob-Stevens-Haas 5a8a4d5
wip
Jacob-Stevens-Haas 9814b76
CLN: Fix input standardization
Jacob-Stevens-Haas b3de43f
fix: Make feature names line up in WeakSINDy
Jacob-Stevens-Haas 831076e
CI: Add Weak Benchmark
Jacob-Stevens-Haas e1f438a
feat: Add smoothing to WeakSINDy and make it subclass SINDy.
Jacob-Stevens-Haas 426d98f
fix: Fix weak form udot calc; add test
Jacob-Stevens-Haas 70b56db
test(axes): Ensure einsum handles ellipsis names correctly
Jacob-Stevens-Haas d6a6980
test(weak): add tests for _eval_semiterm
Jacob-Stevens-Haas faaf1c0
feat(weak): Allow WeakSINDy to accept x_dot.
Jacob-Stevens-Haas 6e321e6
CLN: Make weak SemiTerm a dataclass
Jacob-Stevens-Haas 159b144
feat(weak): Allow WeakSINDy to accept x_dot.
Jacob-Stevens-Haas ac8572c
feat: add ParallelImplicitSINDy model (SINDy-PI)
Jacob-Stevens-Haas 79b3082
DOC: add/improve docstrings in _weak.py
Jacob-Stevens-Haas 7fa75ec
CLN: Linting/formatting
Jacob-Stevens-Haas 3a3c9fb
DOC: Fix plot_directive in weak
Jacob-Stevens-Haas 5543de7
fix: Call diff_method(), not private diff_method._differentiate()
Jacob-Stevens-Haas a2db3a2
CI: Only lint the diff, not all files
Jacob-Stevens-Haas 56ddb85
fix: Explicitly unpack size-1 arrays when a scalar needed.
Jacob-Stevens-Haas aa12f01
CI: Restore prev ASV results before saving new ones
Jacob-Stevens-Haas 0a7320c
fix: From copilot review, various
Jacob-Stevens-Haas 9565f2f
cln: variable shadowing in _plan_weak_form
Jacob-Stevens-Haas 46021ba
DOC: Consolidate PDE notebooks
Jacob-Stevens-Haas 33ae312
fix: Specify how single/multiple H_xt trajectories passed
Jacob-Stevens-Haas 55d5176
Add howto PDE example
Jacob-Stevens-Haas 467a8ca
fix: Make predict match input shape
Jacob-Stevens-Haas 9a62fa8
CLN: Review comments
Jacob-Stevens-Haas 43d695d
fix: shape predictions correct in presence of controls
Jacob-Stevens-Haas 68f2da1
TST: Bump sindy-exp dependency
Jacob-Stevens-Haas d66d5ff
Merge branch 'main' into weak
Jacob-Stevens-Haas 8d51234
fix: weak adapt_multiple_traj, add test
Jacob-Stevens-Haas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| from abc import ABC | ||
| from abc import abstractmethod | ||
|
|
||
| import sindy_exp | ||
| from asv_runner.benchmarks.mark import SkipNotImplemented | ||
|
|
||
| import pysindy as ps | ||
|
|
||
|
|
||
| class LorenzMixin: | ||
| def make_data(self): | ||
| trajectories, terms = sindy_exp.gen_data( | ||
| "lorenz", 4, noise_abs=0.1, dt=0.03, t_end=10 | ||
| )["data"] | ||
| traj = trajectories[0] | ||
| self.true_eqns = terms | ||
| self.x = traj.x_train | ||
| self.x_dot_true = traj.x_train_true_dot | ||
| self.t = traj.t_train | ||
|
|
||
|
|
||
| class DefaultBM(ABC): | ||
| @abstractmethod | ||
| def make_data(self) -> None: | ||
| ... | ||
|
|
||
| @abstractmethod | ||
| def make_model(self) -> None: | ||
| ... | ||
|
|
||
| def setup(self): | ||
| self.make_data() | ||
| self.make_model() | ||
|
|
||
| def time_fit(self): | ||
| self.model.fit([self.x], [self.t]) | ||
|
|
||
| def peakmem_fit(self): | ||
| self.model.fit([self.x], [self.t]) | ||
|
|
||
| def track_score_fit(self): | ||
| self.model.fit([self.x], [self.t]) | ||
| if not hasattr(self.model, "feature_names_"): | ||
| raise SkipNotImplemented | ||
| true_ode_align, est_ode_align = sindy_exp._utils.unionize_coeff_dicts( | ||
| self.model, self.true_eqns | ||
| ) | ||
| metrics = sindy_exp.coeff_metrics(est_ode_align, true_ode_align) | ||
| return metrics["coeff_mae"] | ||
|
|
||
| def time_fit_predict(self): | ||
| self.model.fit([self.x], [self.t]) | ||
| self.model.predict(self.x) | ||
|
|
||
| def peakmem_fit_predict(self): | ||
| self.model.fit([self.x], [self.t]) | ||
| self.model.predict(self.x) | ||
|
|
||
| def track_score_fit_predict(self): | ||
| self.model.fit([self.x], [self.t]) | ||
| self.model.predict(self.x) | ||
| metrics = sindy_exp.pred_metrics( | ||
| self.model, self.x, self.x_dot_true # type: ignore | ||
| ) | ||
| return metrics["pred_l2_fro"] | ||
|
|
||
|
|
||
| class SINDyMixin: | ||
| def make_model(self): | ||
| self.model = ps.SINDy() | ||
|
|
||
|
|
||
| class SINDyLorenz(LorenzMixin, SINDyMixin, DefaultBM): | ||
| pass | ||
|
|
||
|
|
||
| class WeakMixin: | ||
| def make_model(self): | ||
| if not hasattr(ps, "WeakSINDy"): | ||
| raise SkipNotImplemented | ||
| self.model = ps.WeakSINDy() | ||
|
|
||
|
|
||
| class WeakLorenz(LorenzMixin, WeakMixin, DefaultBM): | ||
| pass | ||
|
|
||
|
|
||
| # class WeakHeat: | ||
|
|
||
| # class WeakBurgers: | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.