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

Ipynb linear model #551

Closed
wants to merge 22 commits into from
Closed

Ipynb linear model #551

wants to merge 22 commits into from

Conversation

aqitya
Copy link
Contributor

@aqitya aqitya commented Jun 7, 2023

Jupyter Notebook for Linear Model Example.

@aqitya aqitya requested review from teubert and kjjarvis June 7, 2023 17:57
@github-actions
Copy link

github-actions bot commented Jun 7, 2023

Thank you for opening this PR. Each PR into dev requires a code review. For the code review, look at the following:

  • Reviewer (someone other than author) should look for bugs, efficiency, readability, testing, and coverage in examples (if relevant).
  • Ensure that each PR adding a new feature should include a test verifying that feature.
  • All errors from static analysis must be resolved.
  • Review the test coverage reports (if there is a change) - will be added as comment on PR if there is a change
  • Review the software benchmarking results (if there is a change) - will be added as comment on PR
  • Any added dependencies are included in requirements.txt, setup.py, and dev_guide.rst (this document)
  • All warnings from static analysis must be reviewed and resolved - if deemed appropriate.

@github-actions
Copy link

github-actions bot commented Jun 7, 2023

Benchmarking Results
From:

Test Time (s)
import main 0.17498769999999997
import thrown object 0.6610395
model initialization 0.14872279999999982
set noise 0.8364532000000002
simulate 0.36079919999999976
simulate with saving 1.1300227000000005
simulate with saving, dt 1.2235417000000002
simulate with printing results, dt 1.4729229999999998
Plot results 17.8378393
Metrics 0.044613599999998144
Surrogate Model Generation 1.9165188999999998
surrogate sim 1.2823789000000012
surrogate sim, dt 3.578487599999999
To:
Test Time (s)
--- ---
import main 0.17808179999999996
import thrown object 0.6815331999999998
model initialization 0.1459526000000002
set noise 0.8587342000000002
simulate 0.3595028
simulate with saving 1.1286415999999995
simulate with saving, dt 1.2397731999999992
simulate with printing results, dt 1.4980029000000004
Plot results 17.7078031
Metrics 0.04600969999999904
Surrogate Model Generation 1.9203706999999994
surrogate sim 1.2878944000000025
surrogate sim, dt 3.5333229000000017

Copy link
Contributor

@kjjarvis kjjarvis left a comment

Choose a reason for hiding this comment

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

Very nice! Just a few wording suggestions. I really like how you set up the LinearModel structure with thorough explanation at the top. Very clear.

examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
@github-actions
Copy link

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.14680440000000017
import thrown object 0.5446046
model initialization 0.12866599999999995
set noise 0.7104542
simulate 0.3112887
simulate with saving 0.9784937999999999
simulate with saving, dt 1.0722288
simulate with printing results, dt 1.2771787999999997
Plot results 15.7929524
Metrics 0.03735679999999775
Surrogate Model Generation 1.6773594000000003
surrogate sim 1.1257270999999989
surrogate sim, dt 3.1261526999999987

To:

Test Time (s)
import main 0.14972239999999992
import thrown object 0.5539313999999997
model initialization 0.13006289999999998
set noise 0.6987842
simulate 0.3198409
simulate with saving 0.9945673000000004
simulate with saving, dt 1.1043266999999997
simulate with printing results, dt 1.3218609
Plot results 15.6299942
Metrics 0.04001750000000115
Surrogate Model Generation 1.7059813999999989
surrogate sim 1.139463899999999
surrogate sim, dt 3.1449201

Copy link
Collaborator

@teubert teubert left a comment

Choose a reason for hiding this comment

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

Looking good. A few small suggestions

examples/linear_model.ipynb Outdated Show resolved Hide resolved
" states = ['x', 'v']\n",
" outputs = ['x']\n",
" \n",
" A = np.array([[0, 1], [0, 0]])\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add some more description of why these are the right values in the markdown

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a more general description of what these values are supposed to represent near the top where we originally defined these values.

examples/linear_model.ipynb Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jun 12, 2023

Codecov Report

Merging #551 (1029cb0) into dev (6aff960) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##              dev     #551   +/-   ##
=======================================
  Coverage   84.50%   84.50%           
=======================================
  Files          45       45           
  Lines        3504     3504           
=======================================
  Hits         2961     2961           
  Misses        543      543           

Co-authored-by: Katy Jarvis <[email protected]>
Co-authored-by: Christopher Teubert <[email protected]>
@github-actions
Copy link

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.14538459999999986
import thrown object 0.5536768000000001
model initialization 0.1648512000000002
set noise 0.7014695999999998
simulate 0.5125845
simulate with saving 1.4755077
simulate with saving, dt 1.8957984999999997
simulate with printing results, dt 2.3880523999999994
Plot results 15.033693399999999
Metrics 0.03845450000000028
Surrogate Model Generation 2.245751500000001
surrogate sim 1.4847762000000024
surrogate sim, dt 3.8995146999999974

To:

Test Time (s)
import main 0.14713449999999995
import thrown object 0.5507907999999999
model initialization 0.1678550999999997
set noise 0.7152624999999997
simulate 0.5296818000000001
simulate with saving 1.4631575000000003
simulate with saving, dt 1.9116280000000003
simulate with printing results, dt 2.3867822
Plot results 15.181203499999999
Metrics 0.03954660000000132
Surrogate Model Generation 2.2795847999999985
surrogate sim 1.495190700000002
surrogate sim, dt 3.9494789000000026

@github-actions
Copy link

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.14737620000000007
import thrown object 0.5533882000000001
model initialization 0.16506769999999982
set noise 0.7413594999999997
simulate 0.5147392000000002
simulate with saving 1.4554721000000002
simulate with saving, dt 1.8726297999999995
simulate with printing results, dt 2.3089674999999996
Plot results 15.768817299999998
Metrics 0.03854679999999888
Surrogate Model Generation 2.239958699999999
surrogate sim 1.4750186999999997
surrogate sim, dt 3.833826700000003

To:

Test Time (s)
import main 0.1427704999999999
import thrown object 0.5275274999999997
model initialization 0.16615689999999983
set noise 0.7076447999999997
simulate 0.5028599000000002
simulate with saving 1.4562150000000003
simulate with saving, dt 1.846133
simulate with printing results, dt 2.3095259000000006
Plot results 15.6835606
Metrics 0.03901210000000077
Surrogate Model Generation 2.2458296000000004
surrogate sim 1.4723238999999992
surrogate sim, dt 3.8644731000000014

@github-actions
Copy link

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.11915969999999998
import thrown object 0.4964955
model initialization 0.15603370000000005
set noise 0.6784862
simulate 0.5030554
simulate with saving 1.3962797999999998
simulate with saving, dt 1.8094753999999993
simulate with printing results, dt 2.2694562000000005
Plot results 14.205926200000002
Metrics 0.04223179999999971
Surrogate Model Generation 2.1723706000000007
surrogate sim 1.3547195000000016
surrogate sim, dt 3.677010499999998

To:

Test Time (s)
import main 0.11655460000000017
import thrown object 0.5302416000000001
model initialization 0.15560669999999988
set noise 0.6825060999999999
simulate 0.49681940000000013
simulate with saving 1.3942980999999999
simulate with saving, dt 1.8060817999999994
simulate with printing results, dt 2.257653499999999
Plot results 14.141307400000002
Metrics 0.0425627999999989
Surrogate Model Generation 2.160715999999997
surrogate sim 1.3622954000000007
surrogate sim, dt 3.6795740000000023

@aqitya aqitya requested review from teubert and kjjarvis June 21, 2023 20:23
@github-actions
Copy link

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.14335429999999993
import thrown object 0.5337065000000001
model initialization 0.16433530000000007
set noise 0.6961938999999999
simulate 0.5079115999999999
simulate with saving 1.4582707
simulate with saving, dt 1.8514263999999994
simulate with printing results, dt 2.2971601999999995
Plot results 15.813961400000002
Metrics 0.03944880000000239
Surrogate Model Generation 2.256625400000001
surrogate sim 1.4796742000000016
surrogate sim, dt 3.8849391000000004

To:

Test Time (s)
import main 0.14352390000000015
import thrown object 0.5355498999999999
model initialization 0.16454700000000022
set noise 0.7091961000000002
simulate 0.5024691000000003
simulate with saving 1.4615864000000003
simulate with saving, dt 1.8445337999999998
simulate with printing results, dt 2.3037159999999997
Plot results 15.567654800000001
Metrics 0.039127499999999316
Surrogate Model Generation 2.2382028
surrogate sim 1.4979999
surrogate sim, dt 3.8624442999999964

Copy link
Contributor

@kjjarvis kjjarvis left a comment

Choose a reason for hiding this comment

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

Just a few more comments, but I'm approving the PR. Looks good!

examples/linear_model.ipynb Outdated Show resolved Hide resolved
Comment on lines 263 to 264
"def future_loading(t, x=None):\n",
" return m.InputContainer({})\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Since future loading isn't required anymore, should we consider deleting this (and the above description of it) to reduce confusion?

Copy link
Collaborator

Choose a reason for hiding this comment

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

And adding a note describing how we don't need a future loading equation because the model has no inputs

examples/linear_model.ipynb Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Jul 1, 2023

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.12188220000000016
import thrown object 0.5138013000000001
model initialization 0.15358690000000008
set noise 0.6760287000000003
simulate 0.4881245999999999
simulate with saving 1.3707186000000005
simulate with saving, dt 1.7768382999999996
simulate with printing results, dt 2.2374304999999994
Plot results 13.957667400000002
Metrics 0.04156109999999913
Surrogate Model Generation 2.1476331
surrogate sim 1.3460108999999996
surrogate sim, dt 3.628866500000001

To:

Test Time (s)
import main 0.1122398
import thrown object 0.5148604999999999
model initialization 0.15430939999999982
set noise 0.6769103999999997
simulate 0.49290959999999995
simulate with saving 1.3739515999999998
simulate with saving, dt 1.7796395
simulate with printing results, dt 2.2225529999999996
Plot results 14.022593900000002
Metrics 0.041404899999999856
Surrogate Model Generation 2.1542493999999976
surrogate sim 1.3434389000000024
surrogate sim, dt 3.654307799999998

Copy link
Collaborator

@teubert teubert left a comment

Choose a reason for hiding this comment

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

A few more comments.

Note: there are also still unresolved comments from Katy and my last review

" default_parameters = {\n",
" 'thrower_height': 1.83,\n",
" 'throwing_speed': 40,\n",
" 'g': -9.81\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we actually want to have g as a property, since it doesn't change anything (the value is hard coded in E)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I remove the value 'g', in a later cell where we are creating the future loading function and are simulating to threshold, I receive an error saying: KeyError: 'g'.

Comment on lines 263 to 264
"def future_loading(t, x=None):\n",
" return m.InputContainer({})\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

And adding a note describing how we don't need a future loading equation because the model has no inputs

@github-actions
Copy link

github-actions bot commented Jul 5, 2023

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.14670270000000007
import thrown object 0.5747958000000002
model initialization 0.18085020000000007
set noise 0.7572996999999999
simulate 0.5564355999999999
simulate with saving 1.5941169000000004
simulate with saving, dt 2.0318195999999995
simulate with printing results, dt 2.5944981999999994
Plot results 17.3341505
Metrics 0.04361030000000099
Surrogate Model Generation 2.491723999999998
surrogate sim 1.6402873000000007
surrogate sim, dt 4.250680799999998

To:

Test Time (s)
import main 0.15418810000000005
import thrown object 0.5801295000000002
model initialization 0.1769940000000001
set noise 0.7440906999999997
simulate 0.5679253000000002
simulate with saving 1.5875751999999999
simulate with saving, dt 2.0584013
simulate with printing results, dt 2.590718400000001
Plot results 17.0193557
Metrics 0.04513820000000024
Surrogate Model Generation 2.5448758
surrogate sim 1.6670229000000027
surrogate sim, dt 4.218349400000001

@github-actions
Copy link

github-actions bot commented Jul 5, 2023

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.12262459999999997
import thrown object 0.5005879000000002
model initialization 0.15446329999999997
set noise 0.6742098999999999
simulate 0.5024997999999998
simulate with saving 1.3938717999999999
simulate with saving, dt 1.8179478000000007
simulate with printing results, dt 2.2741688
Plot results 14.041795
Metrics 0.04218810000000062
Surrogate Model Generation 2.1892476999999992
surrogate sim 1.360281299999997
surrogate sim, dt 3.671453200000002

To:

Test Time (s)
import main 0.11587429999999999
import thrown object 0.49184439999999996
model initialization 0.15459379999999978
set noise 0.6638954999999997
simulate 0.49049129999999996
simulate with saving 1.3700032000000002
simulate with saving, dt 1.7766929999999999
simulate with printing results, dt 2.2644273999999998
Plot results 14.102789600000001
Metrics 0.0424451000000019
Surrogate Model Generation 2.165967199999997
surrogate sim 1.3581703999999988
surrogate sim, dt 3.6523533000000015

@github-actions
Copy link

github-actions bot commented Jul 6, 2023

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.12418070000000014
import thrown object 0.5126364999999999
model initialization 0.1545259000000001
set noise 0.6821395000000001
simulate 0.4930151999999999
simulate with saving 1.4074459000000004
simulate with saving, dt 1.8028363
simulate with printing results, dt 2.2674162000000004
Plot results 14.1142756
Metrics 0.04195980000000077
Surrogate Model Generation 2.1744488000000004
surrogate sim 1.3714245999999974
surrogate sim, dt 3.6547997000000016

To:

Test Time (s)
import main 0.12286920000000001
import thrown object 0.5131312999999997
model initialization 0.15380169999999982
set noise 0.6855077
simulate 0.49426320000000024
simulate with saving 1.4033642000000004
simulate with saving, dt 1.8065391999999996
simulate with printing results, dt 2.2481127
Plot results 14.005706700000001
Metrics 0.04383879999999962
Surrogate Model Generation 2.175039799999997
surrogate sim 1.360989700000001
surrogate sim, dt 3.6728442

Copy link
Collaborator

@teubert teubert left a comment

Choose a reason for hiding this comment

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

A few last recommended changes, then it should be ready

examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Outdated Show resolved Hide resolved
examples/linear_model.ipynb Show resolved Hide resolved
aqitya and others added 2 commits July 12, 2023 20:30
Co-authored-by: Christopher Teubert <[email protected]>
Co-authored-by: Christopher Teubert <[email protected]>
@github-actions
Copy link

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.11128690000000008
import thrown object 0.5039601999999999
model initialization 0.15611050000000004
set noise 0.6890658000000001
simulate 0.5040467
simulate with saving 1.4058345000000005
simulate with saving, dt 1.8444934000000002
simulate with printing results, dt 2.2935358
Plot results 14.0959247
Metrics 0.04364010000000107
Surrogate Model Generation 2.2002003000000023
surrogate sim 1.3721373000000021
surrogate sim, dt 3.6939884999999997

To:

Test Time (s)
import main 0.11345729999999987
import thrown object 0.4959193999999998
model initialization 0.15632309999999983
set noise 0.6858575
simulate 0.5034691000000002
simulate with saving 1.3977955
simulate with saving, dt 1.8189712
simulate with printing results, dt 2.2703457999999994
Plot results 14.114858600000002
Metrics 0.042780699999998006
Surrogate Model Generation 2.204059300000001
surrogate sim 1.3698540999999977
surrogate sim, dt 3.691079200000001

@github-actions
Copy link

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.14295049999999998
import thrown object 0.5495127
model initialization 0.16532069999999988
set noise 0.6945298000000002
simulate 0.5127682999999998
simulate with saving 1.4624009000000004
simulate with saving, dt 1.8726451000000006
simulate with printing results, dt 2.3409354
Plot results 15.034599700000001
Metrics 0.038577500000002374
Surrogate Model Generation 2.2603623000000006
surrogate sim 1.5045552999999998
surrogate sim, dt 3.8644544999999972

To:

Test Time (s)
import main 0.14268590000000003
import thrown object 0.5385357999999998
model initialization 0.1640874000000001
set noise 0.6971261000000002
simulate 0.5117332000000001
simulate with saving 1.4587155999999997
simulate with saving, dt 1.8765504000000002
simulate with printing results, dt 2.3335291000000007
Plot results 15.029019700000001
Metrics 0.04010560000000041
Surrogate Model Generation 2.2727150000000016
surrogate sim 1.4999224000000027
surrogate sim, dt 3.8695491000000004

@github-actions
Copy link

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.149154
import thrown object 0.547944
model initialization 0.1660473
set noise 0.7027535
simulate 0.5110364000000001
simulate with saving 1.4605446
simulate with saving, dt 1.8792347000000005
simulate with printing results, dt 2.3397731000000004
Plot results 15.303271800000001
Metrics 0.04000770000000031
Surrogate Model Generation 2.2785592999999977
surrogate sim 1.516429500000001
surrogate sim, dt 3.906891200000004

To:

Test Time (s)
import main 0.14369349999999992
import thrown object 0.5315876000000002
model initialization 0.1656228000000004
set noise 0.6994623
simulate 0.5210075000000001
simulate with saving 1.4622990000000002
simulate with saving, dt 1.8776886
simulate with printing results, dt 2.3473504000000007
Plot results 15.611779299999998
Metrics 0.03897930000000116
Surrogate Model Generation 2.2701513999999996
surrogate sim 1.5028322000000003
surrogate sim, dt 3.8757646

@aqitya aqitya requested a review from teubert July 13, 2023 08:32
@github-actions
Copy link

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.1470492000000001
import thrown object 0.5378624999999999
model initialization 0.16546660000000002
set noise 0.7182029999999999
simulate 0.5210249999999998
simulate with saving 1.4632151999999996
simulate with saving, dt 1.8875458000000007
simulate with printing results, dt 2.3506099999999988
Plot results 15.377780999999999
Metrics 0.03858849999999947
Surrogate Model Generation 2.2758509999999994
surrogate sim 1.5170163000000016
surrogate sim, dt 3.8893129

To:

Test Time (s)
import main 0.14638430000000002
import thrown object 0.572328
model initialization 0.16528929999999997
set noise 0.6946734999999999
simulate 0.5168272000000003
simulate with saving 1.4639983
simulate with saving, dt 1.8671176999999997
simulate with printing results, dt 2.3809989000000007
Plot results 15.195861799999998
Metrics 0.03868990000000139
Surrogate Model Generation 2.259918899999999
surrogate sim 1.4790728000000009
surrogate sim, dt 3.8461979

@github-actions
Copy link

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.17470889999999994
import thrown object 0.6420368000000003
model initialization 0.23526990000000003
set noise 0.8390371000000001
simulate 0.7085066000000007
simulate with saving 2.0632652
simulate with saving, dt 2.593683799999999
simulate with printing results, dt 3.3506561999999995
Plot results 22.187086900000004
Metrics 0.04815320000000156
Surrogate Model Generation 3.2733624000000034
surrogate sim 2.3267688999999976
surrogate sim, dt 5.418286100000003

To:

Test Time (s)
import main 0.16349270000000016
import thrown object 0.6218718999999999
model initialization 0.22678480000000034
set noise 0.8432542000000001
simulate 0.7085622999999996
simulate with saving 2.0699031999999997
simulate with saving, dt 2.589222799999999
simulate with printing results, dt 3.3327430000000007
Plot results 22.497490300000003
Metrics 0.04872110000000163
Surrogate Model Generation 3.250726400000005
surrogate sim 2.3358041000000043
surrogate sim, dt 5.4108977

@github-actions
Copy link

Benchmarking Results [Update]
From:

Test Time (s)
import main 0.1425594000000001
import thrown object 0.5500748
model initialization 0.1658965000000001
set noise 0.6957999000000004
simulate 0.5108617999999998
simulate with saving 1.4564197
simulate with saving, dt 1.8626189000000002
simulate with printing results, dt 2.3174643999999995
Plot results 15.1249688
Metrics 0.03880669999999853
Surrogate Model Generation 2.2500009999999975
surrogate sim 1.4865995999999981
surrogate sim, dt 3.861313299999999

To:

Test Time (s)
import main 0.14250549999999995
import thrown object 0.5403239
model initialization 0.16628520000000035
set noise 0.7002572000000002
simulate 0.5150757000000001
simulate with saving 1.4674886999999996
simulate with saving, dt 1.8851445
simulate with printing results, dt 2.3527831
Plot results 15.0653826
Metrics 0.03857810000000228
Surrogate Model Generation 2.2478257
surrogate sim 1.4891070000000006
surrogate sim, dt 3.8565851

@teubert
Copy link
Collaborator

teubert commented Jul 18, 2023

Moved to nasa/progpy#70

@teubert teubert closed this Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants