MadNLP / DynamicNLPModels.jl

NLPModels for dynamic optimization
MIT License
11 stars 1 forks source link

Created function `add_jtsj!` and accompanying tests #35

Closed dlcole3 closed 2 years ago

dlcole3 commented 2 years ago

Added add_jtsj! to the source code to calculate $J^T \Sigma J$ from a LQJacobianOperator and a vector, $\Sigma$, and adds this value to a matrix $H$. The code is similar in construct to the _build_H_blocks function, but somewhat less efficient. This is because a new block matrix must be created and multiplied every iteration of the for loop, whereas _build_H_blocks could reuse the same matrix several times (e.g., _build_H_blocks could calculate $QB$ one time and add it N times to $H$, whereas add_jtsj! must calculate separate $\Sigma_i B, \forall i = 1,...,N$).

Also updated LQJacobianOperator and removed the Scaled_Jac attribute (unnecessary) and changed the J1B, J2B, and J3B matrices to SJ1, SJ2, and SJ3 for storing the scaled values of the Jacobian. Also added a function to runtest.jl to test add_jtsj! and a function to test the mul functions with the LQJacobianOperator. This latter function was just to simplify the file.

codecov-commenter commented 2 years ago

Codecov Report

Merging #35 (2e58f2a) into main (c910182) will decrease coverage by 0.48%. The diff coverage is 84.48%.

@@            Coverage Diff             @@
##             main      #35      +/-   ##
==========================================
- Coverage   98.04%   97.56%   -0.49%     
==========================================
  Files           1        1              
  Lines        1025     1068      +43     
==========================================
+ Hits         1005     1042      +37     
- Misses         20       26       +6     
Impacted Files Coverage Δ
src/DynamicNLPModels.jl 97.56% <84.48%> (-0.49%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c910182...2e58f2a. Read the comment docs.

sshin23 commented 2 years ago

one last thing, jac_op should be extended https://github.com/JuliaSmoothOptimizers/NLPModels.jl/blob/51841a1f092bd2fad0bfd1b9c7ec74c3cc94ace0/src/nlp/api.jl#L599-L605