-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSADNLSModel.jl
More file actions
48 lines (40 loc) · 1.42 KB
/
SADNLSModel.jl
File metadata and controls
48 lines (40 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
SampledADNLSModel
Strucure wrapping an ADNLSModel and a SampledNLSModel to use Automatic Differentiation backend on sampled Bundle Adjustment problems.
"""
mutable struct SampledADNLSModel{T, S, Si, R, J, Jt} <: AbstractNLSModel{T, S}
adnls::ADNLSModel{T, S, Si}
snls::SampledNLSModel{T, S, R, J, Jt}
end
"""
SADNLSModel
Constructor of a Sampled ADNLSModel taking in arguments an ADNLSModel and a SampledBAModel.
"""
function SADNLSModel(adnls::ADNLSModel{T, S, Si}, snls::SampledNLSModel{T, S, R, J, Jt}) where {T, S, Si, R, J, Jt}
return SampledADNLSModel(adnls, snls)
end
# API SampledADNLSModel #
function Base.getproperty(model::SampledADNLSModel, f::Symbol)
if f in fieldnames(ADNLSModel)
getfield(model.adnls, f)
elseif f in fieldnames(SampledNLSModel)
getfield(model.ba, f)
else
getfield(model, f)
end
end
function Base.setproperty!(model::SampledADNLSModel, f::Symbol, x)
if f in fieldnames(ADNLSModel)
setfield!(model.adnls, f, x)
elseif f in fieldnames(SampledNLSModel)
setfield!(model.ba, f, x)
else
setfield!(model, f, x)
end
end
function NLPModels.residual(model::SampledADNLSModel{T, S, Si, R, J, Jt}, x::AbstractVector{T}) where {T, S, Si, R, J, Jt}
return residual(model.snls, x)
end
function NLPModels.residual!(model::SampledADNLSModel{T, S, Si, R, J, Jt}, x::AbstractVector{T}, Fx::AbstractVector{T}) where {T, S, Si, R, J, Jt}
return residual!(model.snls, x, Fx)
end