-
Notifications
You must be signed in to change notification settings - Fork 10
Add option for Bk in sparse format #313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ function R2NSolver( | |
| reg_nlp::AbstractRegularizedNLPModel{T, V}; | ||
| subsolver = R2Solver, | ||
| m_monotone::Int = 1, | ||
| sparse = false | ||
| ) where {T, V} | ||
| x0 = reg_nlp.model.meta.x0 | ||
| l_bound = reg_nlp.model.meta.lvar | ||
|
|
@@ -69,7 +70,8 @@ function R2NSolver( | |
| has_bnds ? shifted(reg_nlp.h, xk, l_bound_m_x, u_bound_m_x, reg_nlp.selected) : | ||
| shifted(reg_nlp.h, xk) | ||
|
|
||
| Bk = hess_op(reg_nlp, xk) | ||
| sparse = isa(reg_nlp.model, QuasiNewtonModel) ? false : sparse | ||
| Bk = sparse ? hess(reg_nlp, xk) : hess_op(reg_nlp, xk) | ||
| sub_nlp = QuadraticModel(∇fk, Bk, σ = T(1), x0 = x0) | ||
|
Comment on lines
+73
to
75
|
||
| subpb = RegularizedNLPModel(sub_nlp, ψ) | ||
| substats = RegularizedExecutionStats(subpb) | ||
|
|
@@ -464,6 +466,8 @@ function SolverCore.solve!( | |
| qn_update_y!(nlp, solver, stats) | ||
| push!(nlp, s, solver.y) | ||
| qn_copy!(nlp, solver, stats) | ||
| elseif isa(solver.subpb.model.data.H, AbstractMatrix) | ||
| hess_coord!(reg_nlp, xk, solver.subpb.model.data.H.nzval) | ||
|
Comment on lines
+469
to
+470
|
||
| end | ||
|
|
||
| if opnorm_maxiter ≤ 0 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ function TRSolver( | |
| χ::X = NormLinf(one(T)), | ||
| subsolver = R2Solver, | ||
| m_monotone::Int = 1, | ||
| sparse::Bool = false, | ||
| ) where {T, V, X} | ||
| x0 = reg_nlp.model.meta.x0 | ||
| l_bound = reg_nlp.model.meta.lvar | ||
|
|
@@ -69,7 +70,8 @@ function TRSolver( | |
| shifted(reg_nlp.h, xk, l_bound_m_x, u_bound_m_x, reg_nlp.selected) : | ||
| shifted(reg_nlp.h, xk, T(1), χ) | ||
|
|
||
| Bk = hess_op(reg_nlp, xk) | ||
| sparse = isa(reg_nlp.model, QuasiNewtonModel) ? false : sparse | ||
| Bk = sparse ? hess(reg_nlp, xk) : hess_op(reg_nlp, xk) | ||
| sub_nlp = QuadraticModel(∇fk, Bk, x0 = x0) | ||
| subpb = RegularizedNLPModel(sub_nlp, ψ) | ||
| substats = RegularizedExecutionStats(subpb) | ||
|
|
@@ -468,6 +470,8 @@ function SolverCore.solve!( | |
| if quasiNewtTest | ||
| @. ∇fk⁻ = ∇fk - ∇fk⁻ | ||
| push!(nlp, s, ∇fk⁻) # update QN operator | ||
| elseif isa(solver.subpb.model.data.H, AbstractMatrix) | ||
| hess_coord!(reg_nlp, xk, solver.subpb.model.data.H.nzval) | ||
|
Comment on lines
+473
to
+474
|
||
| end | ||
|
|
||
| if opnorm_maxiter ≤ 0 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we want to evaluate the Hessian, even if it is available and sparse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my penalty method, for example :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but generally speaking, we don't want to evaluate the Hessian explicitly. Yours is a special case. It feels like we need a level of abstraction here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could dispatch
hess_optohessfor my penalized subproblem type, though i don't see how i could justify this