Skip to content
Open
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
24 changes: 18 additions & 6 deletions src/dci_feasibility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ function feasibility_step(
d, Jd, infeasible, solved =
eval(meta.TR_compute_step)(cz, Jz, ctol, Δ, normcz, Jd, meta.TR_compute_step_struct)

if meta.TR_compute_step == :TR_lsmr
lsmr_stats = meta.TR_compute_step_struct.lsmr_solver.stats
nd = lsmr_stats.xNorm
nczJd = lsmr_stats.residual
else
nd = norm(d)
nczJd = zero(T)
end

if infeasible #the direction is too small
failed_step_comp = true #too small step
status = :too_small
Expand All @@ -73,8 +82,11 @@ function feasibility_step(
cons_norhs!(nlp, zp, czp)
normczp = norm(czp)

Jd .+= cz
Pred = T(0.5) * (normcz^2 - norm(Jd)^2) # T(0.5) * (normcz^2 - norm(Jd + cz)^2)
if meta.TR_compute_step != :TR_lsmr
Jd .+= cz
nczJd = norm(Jd)
end
Pred = T(0.5) * (normcz^2 - nczJd^2)
Ared = T(0.5) * (normcz^2 - normczp^2)

if Ared / Pred < η₁
Expand All @@ -91,7 +103,7 @@ function feasibility_step(
end
normcz = normczp
status = :success
if Ared / Pred > η₂ && norm(d) >= T(0.99) * Δ
if Ared / Pred > η₂ && nd >= T(0.99) * Δ
Δ *= σ₂
end
end
Expand All @@ -109,7 +121,7 @@ function feasibility_step(
Float64,
ρ,
status,
norm(d),
nd,
Δ,
time() - start_time,
],
Expand Down Expand Up @@ -304,14 +316,14 @@ function TR_lsmr(
itmax = meta.itmax,
)

infeasible = norm(d) < ctol * min(normcz, one(T))
solved = stats.solved
if !solved
@warn "Fail lsmr in TR_lsmr: $(stats.status)"
end

infeasible = stats.xNorm < ctol * min(normcz, one(T))
@. d = -d
Comment thread
arnavk23 marked this conversation as resolved.
mul!(Jd, Jz, d) #lsmr doesn't return this information
Jd .= Jz * d

return d, Jd, infeasible, solved
end