MadNLP / DynamicNLPModels.jl

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

Added support for constant term in the linear dynamic constraints #45

Closed dlcole3 closed 2 years ago

dlcole3 commented 2 years ago

For $x_{t + 1} = Ax_t + bu_t + w$, The vector w changes the constraint bounds and the linear/constant terms of the objective function. I derived the equations for these and updated the SparseLQDynamicModel and DenseLQDynamicModel to operate with w. I added tests to check this, and I updated the JuMP model that we used for comparison. This also required updating the DenseLQDynamicBlocks significantly to store the needed data to reset s0.

For reference, the equation used for deriving this is $\boldsymbol{x} = \boldsymbol{A} \hat{x} + \boldsymbol{B} \boldsymbol{v} + \tilde{\boldsymbol{A}}\boldsymbol{w}$. In this case, $\tilde{\boldsymbol{A}}$ is the same format as $\boldsymbol{B}$ but with the identity matrix in place of the $B$ matrix.

codecov-commenter commented 2 years ago

Codecov Report

Merging #45 (ca4f58a) into main (7777155) will increase coverage by 0.09%. The diff coverage is 99.52%.

@@            Coverage Diff             @@
##             main      #45      +/-   ##
==========================================
+ Coverage   97.98%   98.08%   +0.09%     
==========================================
  Files           4        4              
  Lines        1590     1721     +131     
==========================================
+ Hits         1558     1688     +130     
- Misses         32       33       +1     
Impacted Files Coverage Δ
src/LinearQuadratic/LinearQuadratic.jl 67.92% <50.00%> (-0.71%) :arrow_down:
src/LinearQuadratic/dense.jl 100.00% <100.00%> (ø)
src/LinearQuadratic/sparse.jl 100.00% <100.00%> (ø)
src/LinearQuadratic/tools.jl 96.61% <100.00%> (+0.19%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

sshin23 commented 2 years ago

@dlcole3 can't w be time-varying? When we have w, typically we have time-variability in w

dlcole3 commented 2 years ago

@dlcole3 can't w be time-varying? When we have w, typically we have time-variability in w

@sshin23 It could be time varying, and that would be a relatively simple change to make. I will update that. In the case of the application in the second example problem (oscillating masses), they are not time varying.