Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Configuration file for JuliaFormatter.jl
# For more information, see: https://domluna.github.io/JuliaFormatter.jl/stable/config/

always_for_in = true
always_use_return = true
margin = 92
remove_extra_newlines = true
short_to_long_function_def = true
8 changes: 5 additions & 3 deletions src/MPCCModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using NLPModels, LinearAlgebra, SparseArrays
s.t. lbc ≤ c(w) ≤ ubc
lbG ≤ G(w) ⟂ H(w) ≥ lbH
"""
abstract type AbstractMPCCModel{T, VT} end
abstract type AbstractMPCCModel{T,VT} end

include("utils.jl")
include("lifted_model.jl")
Expand All @@ -25,8 +25,10 @@ export comp_left, comp_left!, comp_right, comp_right!
export lcomp_left, lcomp_left!, lcomp_right, lcomp_right!
export comp_res_left, comp_res_left!, comp_res_right, comp_res_right!
export comp_res_prod!
export jac_comp_left_structure, jac_comp_left_structure!, jac_comp_right_structure, jac_comp_right_structure!
export jac_comp_left_coord, jac_comp_left_coord!, jac_comp_right_coord, jac_comp_right_coord!
export jac_comp_left_structure,
jac_comp_left_structure!, jac_comp_right_structure, jac_comp_right_structure!
export jac_comp_left_coord,
jac_comp_left_coord!, jac_comp_right_coord, jac_comp_right_coord!
export jac_comp_left, jac_comp_right
export comp_residual, comp_residual_product, comp_residual_sum
end
41 changes: 20 additions & 21 deletions src/lifted_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
The lifting variables then take on the bounds of the original
"""
######################### Metadata Definition #########################
struct LiftedNLPModelMeta{T, VT, MT <: AbstractNLPModelMeta{T, VT}} <:
AbstractNLPModelMeta{T, VT}
struct LiftedNLPModelMeta{T,VT,MT<:AbstractNLPModelMeta{T,VT}} <: AbstractNLPModelMeta{T,VT}
parent::MT

ind_lift::IndexSet
Expand All @@ -20,10 +19,10 @@ struct LiftedNLPModelMeta{T, VT, MT <: AbstractNLPModelMeta{T, VT}} <:
end

######################### LiftedNLPModel Definition #########################
struct LiftedNLPModel{T, VT, NLP <: AbstractNLPModel{T, VT}, NMT} <: AbstractNLPModel{T, VT}
struct LiftedNLPModel{T,VT,NLP<:AbstractNLPModel{T,VT},NMT} <: AbstractNLPModel{T,VT}
nlp::NLP

meta::LiftedNLPModelMeta{T, VT, NMT}
meta::LiftedNLPModelMeta{T,VT,NMT}
counters::NLPModels.Counters
end

Expand Down Expand Up @@ -64,15 +63,15 @@ function LiftedNLPModel(nlp::AbstractNLPModel, ind_lift::IndexSet)

parent_meta = NLPModels.NLPModelMeta(
nlp.meta,
nvar=nvar,
lcon=lcon,
ucon=ucon,
lvar=lvar,
uvar=uvar,
x0=x0,
nnzj=nnzj,
nln_nnzj=nln_nnzj,
lin_nnzj=lin_nnzj,
nvar = nvar,
lcon = lcon,
ucon = ucon,
lvar = lvar,
uvar = uvar,
x0 = x0,
nnzj = nnzj,
nln_nnzj = nln_nnzj,
lin_nnzj = lin_nnzj,
)

meta = LiftedNLPModelMeta(
Expand Down Expand Up @@ -273,36 +272,36 @@ function NLPModels.hess_structure!(
end

function NLPModels.hess_coord!(
lnlp::LiftedNLPModel{T, VT},
lnlp::LiftedNLPModel{T,VT},
x::AbstractVector{T},
y::AbstractVector{T},
H::AbstractVector{T};
obj_weight::Real=one(T),
) where {T, VT}
obj_weight::Real = one(T),
) where {T,VT}
return @views hess_coord!(
lnlp.nlp,
x[1:get_nvar(lnlp.nlp)],
y,
H;
obj_weight=obj_weight,
obj_weight = obj_weight,
)
end

function NLPModels.hprod!(
lnlp::LiftedNLPModel{T, VT},
lnlp::LiftedNLPModel{T,VT},
x::AbstractVector{T},
y::AbstractVector{T},
v::AbstractVector{T},
Hv::AbstractVector;
obj_weight::Real=one(T),
) where {T, VT}
obj_weight::Real = one(T),
) where {T,VT}
@views hprod!(
lnlp.nlp,
x[1:get_nvar(lnlp.nlp)],
y,
v[1:get_nvar(lnlp.nlp)],
Hv[1:get_nvar(lnlp.nlp)];
obj_weight=obj_weight,
obj_weight = obj_weight,
)
Hv[(get_nvar(lnlp.nlp)+1):get_nvar(lnlp)] .= 0
return Hv
Expand Down
Loading
Loading