MadNLP / DynamicNLPModels.jl

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

Defining data structure for LQ dynamic optimization #2

Closed sshin23 closed 2 years ago

sshin23 commented 2 years ago

We should define the following data structure for LQ dynamic optimization

abstract type AbstractDynamicData{T,S} end

struct LQDynamicData{T,S,M} <: AbstractDynamicData{T,S}
s0::S
A::M
B::M
Q::M
R::M
Qf::M
# etc
end

abstract type AbstractDynamicModel{T,S} <: QuadraticModels.AbstractQuadraticModel{T, S} end

mutable struct LQDynamicModel{T, S, M1, M2, M3} <:  AbstractDynamicModel{T,S} 
  meta::NLPModelMeta{T, S}
  counters::Counters
  data::QPData{T, S, M1, M2}
  dynamic_data::LQDynamicData{T,S,M3}
  condense::Bool
end

and

dlcole3 commented 2 years ago

Since we want functions such as set_s0!, should LQDynamicData{T,S,M} be a mutable struct rather than just a struct?

dlcole3 commented 2 years ago

Also, do you want me to get rid of build_H and build_J as well and just implement them internally within LQDynamicModel(::LQDynamicData{T,S,M}; condense = false)? Or should I leave them as stand alone functions?

sshin23 commented 2 years ago

set_s0! should only modify the entry of lq_dyn_data.s0, so the LQDynamicData doesn't need to be mutable. But if you find it is more proper to make it a mutable struct, go ahead and make it mutable (there's no particular reason for it to be immutable either).

sshin23 commented 2 years ago

we can keep _build_H and _build_J, but they should be called internally within LQDynamicModel(::LQDynamicData{T,S,M}; condense = false)

dlcole3 commented 2 years ago

What all should our API be able to do? Right now, I am just building functions to get and set the entries of LQDynamicData (i.e., s0, A, B, R, Q, sl, su, ul, uu). My set! functionalities can also either redefine the matrix entirely or just modify an entry of the matrix. Is there more that I should include within the API functionalities?

sshin23 commented 2 years ago

for now that should be enough, but if there's anything you feel like it will be necessary for the user, you can add them. Those APIs should always change the entry, not the arrays themselves