From a46e44bbb1bf46e8ec95ffd2c6a954993bb888c1 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Dussault Date: Wed, 2 Oct 2019 14:17:54 -0400 Subject: [PATCH 1/2] Quelques essais --- deps/build.log | 14 +++ src/PreProcess/PreProcessKARC.jl | 19 ++++- src/PreProcess/TParamsKARC.jl | 3 +- src/Solvers/ARCqKOp1.jl | 4 + src/Solvers/ARCqKOp1.jl~ | 3 + src/Solvers/SolversStopping/ARCqKOp.jl | 1 + src/Solvers/SolversStopping/ARCqKOp0_5.jl | 17 ++++ src/Solvers/SolversStopping/ARCqKOp0_5.jl~ | 16 ++++ src/Solvers/SolversStopping/ARCqKOp1.jl | 17 ++++ src/Solvers/SolversStopping/ARCqKOp1.jl~ | 16 ++++ src/Solvers/SolversStopping/ARCqKOp2.jl | 17 ++++ src/Solvers/SolversStopping/ARCqKOp2.jl~ | 16 ++++ .../SolversStopping/solvers_stopping.jl | 9 ++ src/Solvers/solvers.jl | 3 + src/TRARCStop.jl | 85 ++++++++++--------- 15 files changed, 196 insertions(+), 44 deletions(-) create mode 100644 deps/build.log create mode 100644 src/Solvers/ARCqKOp1.jl create mode 100644 src/Solvers/ARCqKOp1.jl~ create mode 100644 src/Solvers/SolversStopping/ARCqKOp0_5.jl create mode 100644 src/Solvers/SolversStopping/ARCqKOp0_5.jl~ create mode 100644 src/Solvers/SolversStopping/ARCqKOp1.jl create mode 100644 src/Solvers/SolversStopping/ARCqKOp1.jl~ create mode 100644 src/Solvers/SolversStopping/ARCqKOp2.jl create mode 100644 src/Solvers/SolversStopping/ARCqKOp2.jl~ diff --git a/deps/build.log b/deps/build.log new file mode 100644 index 0000000..fdd2d29 --- /dev/null +++ b/deps/build.log @@ -0,0 +1,14 @@ +ERROR: LoadError: IOError: could not spawn `julia install.jl`: no such file or directory (ENOENT) +Stacktrace: + [1] _spawn_primitive(::String, ::Cmd, ::Array{Any,1}) at ./process.jl:401 + [2] setup_stdios(::getfield(Base, Symbol("##526#527")){Cmd}, ::Array{Any,1}) at ./process.jl:414 + [3] _spawn at ./process.jl:413 [inlined] + [4] #run#536(::Bool, ::typeof(run), ::Cmd) at ./process.jl:727 + [5] run(::Cmd) at ./process.jl:726 + [6] top-level scope at /home/dussault/.julia/dev/ARCTR/deps/build.jl:1 + [7] include at ./boot.jl:328 [inlined] + [8] include_relative(::Module, ::String) at ./loading.jl:1094 + [9] include(::Module, ::String) at ./Base.jl:31 + [10] include(::String) at ./client.jl:431 + [11] top-level scope at none:5 +in expression starting at /home/dussault/.julia/dev/ARCTR/deps/build.jl:1 diff --git a/src/PreProcess/PreProcessKARC.jl b/src/PreProcess/PreProcessKARC.jl index 7cb25d6..3937f45 100644 --- a/src/PreProcess/PreProcessKARC.jl +++ b/src/PreProcess/PreProcessKARC.jl @@ -1,4 +1,4 @@ -function preprocessKARC(Hop, g, params::Tparams, calls, max_calls) +function preprocessKARC(Hop, g, params::Tparams, calls, max_calls) #where T τ = params.τ nshifts = params.nshifts shifts = params.shifts @@ -6,6 +6,12 @@ function preprocessKARC(Hop, g, params::Tparams, calls, max_calls) n = length(g) gNorm2 = BLAS.nrm2(n, g, 1) precision = max(1e-12,min(0.5,(gNorm2^τ))) + + #ϵ = sqrt(eps(T)) # * 100.0 + ϵ = 1e-12#sqrt(eps()) # * 100.0 + cgtol = max(ϵ, min(0.09, 0.01 * norm(g)^(1.0 + τ))) + + (xShift, stats) = cg_lanczos_shift_seq(Hop, -g, shifts, @@ -16,6 +22,17 @@ function preprocessKARC(Hop, g, params::Tparams, calls, max_calls) verbose=false, check_curvature=true) +# (xShift, stats) = cg_lanczos_shift_seq(Hop, +# -g, +# shifts, +# itmax=min(max_calls-sum(calls),2*n), +# #τ = τ, +# atol = cgtol, +# rtol = ϵ, +# verbose=false, +# check_curvature=true) + + positives = collect(findfirst(!, stats.flagged):length(stats.flagged)) success = false diff --git a/src/PreProcess/TParamsKARC.jl b/src/PreProcess/TParamsKARC.jl index 35f5aae..d7d8e73 100644 --- a/src/PreProcess/TParamsKARC.jl +++ b/src/PreProcess/TParamsKARC.jl @@ -2,9 +2,8 @@ mutable struct TparamsKARC{T} <: Tparams{T} # specific parameters for this Kryl τ :: T shifts :: Array{T, 1} nshifts :: Int - function TparamsKARC{T}() where T + function TparamsKARC{T}(shifts) where T τ = 0.5 - shifts = 10.0.^(collect(-15.0:1.0:15.0)) nshifts = size(shifts, 1) return new{T}(τ, shifts, nshifts) end diff --git a/src/Solvers/ARCqKOp1.jl b/src/Solvers/ARCqKOp1.jl new file mode 100644 index 0000000..8ed9e84 --- /dev/null +++ b/src/Solvers/ARCqKOp1.jl @@ -0,0 +1,4 @@ +fname = :ARCqKOp1 +shifts = 10.0.^(collect(-15.0:1.0:15.0)) +c = Combi(hessian_operator,PDataK,solve_modelKARC,preprocessKARC,decreaseKARC,TparamsKARC(shifts)) +include("Template.jl") diff --git a/src/Solvers/ARCqKOp1.jl~ b/src/Solvers/ARCqKOp1.jl~ new file mode 100644 index 0000000..46cd2b4 --- /dev/null +++ b/src/Solvers/ARCqKOp1.jl~ @@ -0,0 +1,3 @@ +fname = :ARCqKOp +c = Combi(hessian_operator,PDataK,solve_modelKARC,preprocessKARC,decreaseKARC,TparamsKARC()) +include("Template.jl") diff --git a/src/Solvers/SolversStopping/ARCqKOp.jl b/src/Solvers/SolversStopping/ARCqKOp.jl index c5c8eaa..a356093 100644 --- a/src/Solvers/SolversStopping/ARCqKOp.jl +++ b/src/Solvers/SolversStopping/ARCqKOp.jl @@ -1,5 +1,6 @@ export ARCqKOp + function ARCqKOp(nlp :: AbstractNLPModel, nlpstop :: NLPStopping; kwargs... diff --git a/src/Solvers/SolversStopping/ARCqKOp0_5.jl b/src/Solvers/SolversStopping/ARCqKOp0_5.jl new file mode 100644 index 0000000..c06bdb0 --- /dev/null +++ b/src/Solvers/SolversStopping/ARCqKOp0_5.jl @@ -0,0 +1,17 @@ +export ARCqKOp05 + + +function ARCqKOp05(nlp :: AbstractNLPModel, + nlpstop :: NLPStopping; + kwargs... + ) + + shifts = 10.0.^(collect(-15.0:0.50:15.0)) + + return TRARC2(nlp, + nlpstop; + TR = TrustRegion(10.0), + c = Combi(hessian_operator, PDataK{eltype(nlp.meta.x0)}, solve_modelKARC, preprocessKARC, decreaseKARC, TparamsKARC{eltype(nlp.meta.x0)}(shifts)), + kwargs... + ) +end diff --git a/src/Solvers/SolversStopping/ARCqKOp0_5.jl~ b/src/Solvers/SolversStopping/ARCqKOp0_5.jl~ new file mode 100644 index 0000000..744c518 --- /dev/null +++ b/src/Solvers/SolversStopping/ARCqKOp0_5.jl~ @@ -0,0 +1,16 @@ +export ARCqKOp2 + +shifts = 10.0.^(collect(-15.0:2.0:15.0)) + +function ARCqKOp2(nlp :: AbstractNLPModel, + nlpstop :: NLPStopping; + kwargs... + ) + + return TRARC2(nlp, + nlpstop; + TR = TrustRegion(10.0), + c = Combi(hessian_operator, PDataK{eltype(nlp.meta.x0)}, solve_modelKARC, preprocessKARC, decreaseKARC, TparamsKARC{eltype(nlp.meta.x0)}(shifts)), + kwargs... + ) +end diff --git a/src/Solvers/SolversStopping/ARCqKOp1.jl b/src/Solvers/SolversStopping/ARCqKOp1.jl new file mode 100644 index 0000000..750549d --- /dev/null +++ b/src/Solvers/SolversStopping/ARCqKOp1.jl @@ -0,0 +1,17 @@ +export ARCqKOp1 + + +function ARCqKOp1(nlp :: AbstractNLPModel, + nlpstop :: NLPStopping; + kwargs... + ) + + shifts = 10.0.^(collect(-15.0:1.0:15.0)) + + return TRARC2(nlp, + nlpstop; + TR = TrustRegion(10.0), + c = Combi(hessian_operator, PDataK{eltype(nlp.meta.x0)}, solve_modelKARC, preprocessKARC, decreaseKARC, TparamsKARC{eltype(nlp.meta.x0)}(shifts)), + kwargs... + ) +end diff --git a/src/Solvers/SolversStopping/ARCqKOp1.jl~ b/src/Solvers/SolversStopping/ARCqKOp1.jl~ new file mode 100644 index 0000000..fb7dd5c --- /dev/null +++ b/src/Solvers/SolversStopping/ARCqKOp1.jl~ @@ -0,0 +1,16 @@ +export ARCqKOp1 + +shifts = 10.0.^(collect(-15.0:1.0:15.0)) + +function ARCqKOp1(nlp :: AbstractNLPModel, + nlpstop :: NLPStopping; + kwargs... + ) + + return TRARC2(nlp, + nlpstop; + TR = TrustRegion(10.0), + c = Combi(hessian_operator, PDataK{eltype(nlp.meta.x0)}, solve_modelKARC, preprocessKARC, decreaseKARC, TparamsKARC{eltype(nlp.meta.x0)}(shifts)), + kwargs... + ) +end diff --git a/src/Solvers/SolversStopping/ARCqKOp2.jl b/src/Solvers/SolversStopping/ARCqKOp2.jl new file mode 100644 index 0000000..33c034a --- /dev/null +++ b/src/Solvers/SolversStopping/ARCqKOp2.jl @@ -0,0 +1,17 @@ +export ARCqKOp2 + + +function ARCqKOp2(nlp :: AbstractNLPModel, + nlpstop :: NLPStopping; + kwargs... + ) + + shifts = 10.0.^(collect(-15.0:2.0:15.0)) + + return TRARC2(nlp, + nlpstop; + TR = TrustRegion(10.0), + c = Combi(hessian_operator, PDataK{eltype(nlp.meta.x0)}, solve_modelKARC, preprocessKARC, decreaseKARC, TparamsKARC{eltype(nlp.meta.x0)}(shifts)), + kwargs... + ) +end diff --git a/src/Solvers/SolversStopping/ARCqKOp2.jl~ b/src/Solvers/SolversStopping/ARCqKOp2.jl~ new file mode 100644 index 0000000..744c518 --- /dev/null +++ b/src/Solvers/SolversStopping/ARCqKOp2.jl~ @@ -0,0 +1,16 @@ +export ARCqKOp2 + +shifts = 10.0.^(collect(-15.0:2.0:15.0)) + +function ARCqKOp2(nlp :: AbstractNLPModel, + nlpstop :: NLPStopping; + kwargs... + ) + + return TRARC2(nlp, + nlpstop; + TR = TrustRegion(10.0), + c = Combi(hessian_operator, PDataK{eltype(nlp.meta.x0)}, solve_modelKARC, preprocessKARC, decreaseKARC, TparamsKARC{eltype(nlp.meta.x0)}(shifts)), + kwargs... + ) +end diff --git a/src/Solvers/SolversStopping/solvers_stopping.jl b/src/Solvers/SolversStopping/solvers_stopping.jl index d3b553d..1d41463 100644 --- a/src/Solvers/SolversStopping/solvers_stopping.jl +++ b/src/Solvers/SolversStopping/solvers_stopping.jl @@ -54,6 +54,15 @@ push!(ALL_solvers_stopping, TRLDLt_abs) include("ARCqKOp.jl") push!(ALL_solvers_stopping, ARCqKOp) +include("ARCqKOp1.jl") +push!(ALL_solvers_stopping, ARCqKOp1) + +include("ARCqKOp2.jl") +push!(ALL_solvers_stopping, ARCqKOp2) + +include("ARCqKOp0_5.jl") +push!(ALL_solvers_stopping, ARCqKOp05) + include("ARCqKSparse.jl") push!(ALL_solvers_stopping, ARCqKsparse) diff --git a/src/Solvers/solvers.jl b/src/Solvers/solvers.jl index a302c4f..ec55274 100644 --- a/src/Solvers/solvers.jl +++ b/src/Solvers/solvers.jl @@ -42,6 +42,9 @@ push!(ALL_solvers,eval(fname)) include("ARCqKOp.jl") #works in 0.7/1.1 push!(ALL_solvers,eval(fname)) +include("ARCqKOp1.jl") #works in 0.7/1.1 +push!(ALL_solvers,eval(fname)) + include("ARCqKsparse.jl") #works in 0.7/1.1 push!(ALL_solvers,eval(fname)) diff --git a/src/TRARCStop.jl b/src/TRARCStop.jl index dc15979..5e7400c 100644 --- a/src/TRARCStop.jl +++ b/src/TRARCStop.jl @@ -2,84 +2,87 @@ export TRARC2 function TRARC2(nlp :: AbstractNLPModel, nlp_stop :: NLPStopping; - TR :: TrustRegion = TrustRegion(eltype(nlp.meta.x0)(10.0)), - c :: Combi = Combi{eltype(nlp.meta.x0)}(hessian_dense, PDataLDLt{eltype(nlp.meta.x0)}, solve_modelTRDiag, preprocessLDLt, decreaseFact, Tparam{eltype(nlp.meta.x0)}()), - robust :: Bool = true, + TR :: TrustRegion = TrustRegion(eltype(nlp.meta.x0)(10.0)), + c :: Combi = Combi{eltype(nlp.meta.x0)}(hessian_dense, PDataLDLt{eltype(nlp.meta.x0)}, solve_modelTRDiag, preprocessLDLt, decreaseFact, Tparam{eltype(nlp.meta.x0)}()), + robust :: Bool = true, verbose :: Bool = false ) - - T = eltype(nlp.meta.x0) - - nlp_at_x = nlp_stop.current_state + + T = eltype(nlp.meta.x0) + + nlp_at_x = nlp_stop.current_state hessian_rep, PData, solve_model, pre_process, decrease, params = extract(c) α = TR.α₀ # initial Trust Region size xt, xtnext, d, Df = copy(nlp.meta.x0), copy(nlp.meta.x0), copy(nlp.meta.x0), 0.0 - xopt = xt + xopt = xt λ = 1.0 - + n = length(xt) ∇f = Array{T}(undef, n) ∇fnext = Array{T}(undef, n) - ∇fnext - + ∇fnext + ft = obj(nlp, xt) fopt = ft grad!(nlp, xt, ∇f) - OK = update_and_start!(nlp_stop, x = xt, fx = ft, gx = ∇f, g0 = copy(∇f)) + OK = update_and_start!(nlp_stop, x = xt, fx = ft, gx = ∇f, g0 = copy(∇f)) + + nlp_stop.meta.optimality0 = nlp_stop.optimality_check(nlp,nlp_at_x) - norm_∇f = norm(nlp_at_x.gx) + + norm_∇f = norm(nlp_at_x.gx) norm_∇f0 = norm_∇f ∇fopt = ∇f norm_∇fopt = norm_∇f - !OK && update!(nlp_at_x, Hx = hessian_rep(nlp, xt)) - - - global cgtol = 1.0 - + !OK && update!(nlp_at_x, Hx = hessian_rep(nlp, xt)) + + + global cgtol = 1.0 + ftnext = ft iter = 0 - + verbose && display_header_iterations() verbose && display_success(iter, ftnext, norm_∇f0, 0.0, α) - + succ, unsucc, verysucc, unsuccinarow = 0, 0, 0, 0 - + max_unsuccinarow = TR.max_unsuccinarow - + calls = [0, 0, 0, 0] - - global xdemi = NaN * rand(n) - + + global xdemi = NaN * rand(n) + while !OK PData = pre_process(nlp_at_x.Hx, ∇f, params, calls, nlp_stop.meta.max_eval) - + if ~PData.OK - @warn("Something wrong with PData") - return nlp_at_x, nlp_stop.meta.optimal - end - + @warn("Something wrong with PData") + return nlp_at_x, nlp_stop.meta.optimal + end + success = false - Ht = nothing - + Ht = nothing + while !success & !OK & (unsuccinarow < TR.max_unsuccinarow) - # printstyled("avant de calculer d \n", color = :bold) - # @show solve_model - # @show nlp_at_x.x - try + # printstyled("avant de calculer d \n", color = :bold) + # @show solve_model + # @show nlp_at_x.x + try d, xdemi, λ = solve_model(nlp_stop, PData, α) catch println(" Problem in solve_model") return nlp_at_x, nlp_stop.meta.optimal end - - # @show d - + + # @show d + Δq = -(∇f + 0.5 * nlp_at_x.Hx * d)⋅d - + if Δq < 0.0 println("******* Ascent direction in SolveModel: Δq = $Δq") println(" g⋅d = $(∇f⋅d), 0.5 d'Hd = $(0.5*(nlp_at_x.Hx*d)⋅d) α = $α λ = $λ") - #@bp + #@bp #try println(" cond(H) = $(cond(full(H)))") catch println("sparse hessian, no cond") end #D, Q = eig(full(H)) #lm = findmin(D); lM = findmax(D) From 45c6409cba6df3fd912067185c19182b51bd5e4e Mon Sep 17 00:00:00 2001 From: Jean-Pierre Dussault Date: Mon, 2 Dec 2019 14:37:45 -0500 Subject: [PATCH 2/2] zeta--tau --- src/PreProcess/PreProcessKARC.jl | 7 ++++--- src/PreProcess/PreProcessKTR.jl | 7 ++++--- src/PreProcess/PreProcessST_TR.jl | 4 ++-- src/PreProcess/TParamsKARC.jl | 8 +++++--- src/PreProcess/TParamsKTR.jl | 8 ++++---- src/PreProcess/TParamsST.jl | 6 +++--- src/SolveModel/SolveModelST_TR.jl | 2 +- src/Solvers/SolversStopping/ARCqKOp1.jl | 14 ++++++++------ src/Solvers/SolversStopping/ARCqKOp1b.jl | 19 +++++++++++++++++++ src/Solvers/SolversStopping/ARCqKOp1b.jl~ | 19 +++++++++++++++++++ .../SolversStopping/solvers_stopping.jl | 3 +++ src/Types/Types.jl | 5 +++-- 12 files changed, 75 insertions(+), 27 deletions(-) create mode 100644 src/Solvers/SolversStopping/ARCqKOp1b.jl create mode 100644 src/Solvers/SolversStopping/ARCqKOp1b.jl~ diff --git a/src/PreProcess/PreProcessKARC.jl b/src/PreProcess/PreProcessKARC.jl index 3937f45..de59689 100644 --- a/src/PreProcess/PreProcessKARC.jl +++ b/src/PreProcess/PreProcessKARC.jl @@ -1,15 +1,16 @@ function preprocessKARC(Hop, g, params::Tparams, calls, max_calls) #where T τ = params.τ + ζ = params.ζ nshifts = params.nshifts shifts = params.shifts n = length(g) gNorm2 = BLAS.nrm2(n, g, 1) - precision = max(1e-12,min(0.5,(gNorm2^τ))) + precision = max(1e-12,min(0.5,(gNorm2^ζ))) #ϵ = sqrt(eps(T)) # * 100.0 ϵ = 1e-12#sqrt(eps()) # * 100.0 - cgtol = max(ϵ, min(0.09, 0.01 * norm(g)^(1.0 + τ))) + cgtol = max(ϵ, min(0.09, 0.01 * norm(g)^(1.0 + ζ))) (xShift, stats) = cg_lanczos_shift_seq(Hop, @@ -44,7 +45,7 @@ function preprocessKARC(Hop, g, params::Tparams, calls, max_calls) #where T Ndirs = map(norm, dirs); d = g # bidon - return PDataK(d, -1.0, τ, 0 , positives, xShift, shifts, nshifts, Ndirs, true) + return PDataK(d, -1.0, ζ, τ, 0 , positives, xShift, shifts, nshifts, Ndirs, true) end diff --git a/src/PreProcess/PreProcessKTR.jl b/src/PreProcess/PreProcessKTR.jl index cdbb3d1..e24997e 100644 --- a/src/PreProcess/PreProcessKTR.jl +++ b/src/PreProcess/PreProcessKTR.jl @@ -1,12 +1,13 @@ export preprocessKTR, decreaseKTR function preprocessKTR(Hop, g, params::Tparams, calls, max_calls) - τ = params.τ + ζ = params.ζ + #τ = params.τ nshifts = params.nshifts shifts = params.shifts n = length(g) gNorm2 = BLAS.nrm2(n, g, 1) - precision = max(1e-12,min(0.5,(gNorm2^τ))) + precision = max(1e-12,min(0.5,(gNorm2^ζ))) (xShift, stats) = cg_lanczos_shift_seq(Hop, -g, shifts, @@ -29,7 +30,7 @@ function preprocessKTR(Hop, g, params::Tparams, calls, max_calls) d = g # bidon - return PDataK(d,-1.0,τ,0,positives,xShift,shifts,nshifts,Ndirs,true) + return PDataK(d,-1.0, ζ, 0.0, 0, positives,xShift,shifts,nshifts,Ndirs,true) end function decreaseKTR(X :: PDataK, α:: Float64, TR:: TrustRegion) diff --git a/src/PreProcess/PreProcessST_TR.jl b/src/PreProcess/PreProcessST_TR.jl index 141e6af..4db8663 100644 --- a/src/PreProcess/PreProcessST_TR.jl +++ b/src/PreProcess/PreProcessST_TR.jl @@ -1,5 +1,5 @@ function preprocessST(H, g, params::TparamsST, n1, n2) - τ = params.τ + ζ = params.ζ - return PDataST(H, g, τ, true) + return PDataST(H, g, ζ, true) end diff --git a/src/PreProcess/TParamsKARC.jl b/src/PreProcess/TParamsKARC.jl index d7d8e73..33e0795 100644 --- a/src/PreProcess/TParamsKARC.jl +++ b/src/PreProcess/TParamsKARC.jl @@ -1,10 +1,12 @@ mutable struct TparamsKARC{T} <: Tparams{T} # specific parameters for this Krylov variant + ζ :: T τ :: T shifts :: Array{T, 1} nshifts :: Int - function TparamsKARC{T}(shifts) where T - τ = 0.5 + function TparamsKARC{T}(shifts; τin::T = 1.0, ζin ::T = 0.5) where T + τ = τin # temporary testing + ζ = ζin # inexact Newton nshifts = size(shifts, 1) - return new{T}(τ, shifts, nshifts) + return new{T}(ζ, τ, shifts, nshifts) end end diff --git a/src/PreProcess/TParamsKTR.jl b/src/PreProcess/TParamsKTR.jl index 60a905a..37a3cab 100644 --- a/src/PreProcess/TParamsKTR.jl +++ b/src/PreProcess/TParamsKTR.jl @@ -1,13 +1,13 @@ export TparamsKTR mutable struct TparamsKTR{T} <: Tparams{T} # specific parameters for this Krylov variant - τ :: T + ζ :: T shifts :: Array{T, 1} nshifts :: Int - function TparamsKTR{T}() where T - τ = 0.5 + function TparamsKTR{T}(; ζin ::T = 0.5) where T + ζ = ζin shifts = [0.0; 10.0.^(collect(-15.0:1.0:15.0))] nshifts = size(shifts, 1) - return new{T}(τ, shifts, nshifts) + return new{T}(ζ, shifts, nshifts) end end diff --git a/src/PreProcess/TParamsST.jl b/src/PreProcess/TParamsST.jl index dd00ddf..a6081cc 100644 --- a/src/PreProcess/TParamsST.jl +++ b/src/PreProcess/TParamsST.jl @@ -1,10 +1,10 @@ export TparamsST mutable struct TparamsST{T} <: Tparams{T} # specific parameters for this Krylov variant - τ :: T + ζ :: T function TparamsST{T}() where T - τ = 0.5 - return new{T}(τ) + ζ = 0.5 + return new{T}(ζ) end end diff --git a/src/SolveModel/SolveModelST_TR.jl b/src/SolveModel/SolveModelST_TR.jl index 22fcdc0..a8730cd 100644 --- a/src/SolveModel/SolveModelST_TR.jl +++ b/src/SolveModel/SolveModelST_TR.jl @@ -2,7 +2,7 @@ function solve_modelST_TR(nlp_stop, X :: PDataST, δ:: T; cgtol :: T = 0.1) wher # cas particulier Steihaug-Toint ϵ = sqrt(eps(T)) # * 100.0 n = length(X.g) - cgtol = max(ϵ, min(cgtol, 9 * cgtol / 10, 0.01 * norm(X.g)^(1.0 + X.τ))) + cgtol = max(ϵ, min(cgtol, 9 * cgtol / 10, 0.01 * norm(X.g)^(1.0 + X.ζ))) (d, cg_stats) = cg(X.H, -X.g, atol = cgtol, rtol = ϵ, radius = δ, itmax = max(2 * n, 50), diff --git a/src/Solvers/SolversStopping/ARCqKOp1.jl b/src/Solvers/SolversStopping/ARCqKOp1.jl index 750549d..468b049 100644 --- a/src/Solvers/SolversStopping/ARCqKOp1.jl +++ b/src/Solvers/SolversStopping/ARCqKOp1.jl @@ -2,16 +2,18 @@ export ARCqKOp1 function ARCqKOp1(nlp :: AbstractNLPModel, - nlpstop :: NLPStopping; - kwargs... - ) - + nlpstop :: NLPStopping; + ζ = 0.5, + τ = 1.0, + kwargs... + ) + shifts = 10.0.^(collect(-15.0:1.0:15.0)) - + return TRARC2(nlp, nlpstop; TR = TrustRegion(10.0), - c = Combi(hessian_operator, PDataK{eltype(nlp.meta.x0)}, solve_modelKARC, preprocessKARC, decreaseKARC, TparamsKARC{eltype(nlp.meta.x0)}(shifts)), + c = Combi(hessian_operator, PDataK{eltype(nlp.meta.x0)}, solve_modelKARC, preprocessKARC, decreaseKARC, TparamsKARC{eltype(nlp.meta.x0)}(shifts, ζin = ζ, τin = τ)), kwargs... ) end diff --git a/src/Solvers/SolversStopping/ARCqKOp1b.jl b/src/Solvers/SolversStopping/ARCqKOp1b.jl new file mode 100644 index 0000000..347d6fd --- /dev/null +++ b/src/Solvers/SolversStopping/ARCqKOp1b.jl @@ -0,0 +1,19 @@ +export ARCqKOp1b + + +function ARCqKOp1b(nlp :: AbstractNLPModel, + nlpstop :: NLPStopping; + ζ = 0.5, + τ = 0.5, + kwargs... + ) + + shifts = 10.0.^(collect(-15.0:1.0:15.0)) + + return TRARC2(nlp, + nlpstop; + TR = TrustRegion(10.0), + c = Combi(hessian_operator, PDataK{eltype(nlp.meta.x0)}, solve_modelKARC, preprocessKARC, decreaseKARC, TparamsKARC{eltype(nlp.meta.x0)}(shifts, ζin = ζ, τin = τ)), + kwargs... + ) +end diff --git a/src/Solvers/SolversStopping/ARCqKOp1b.jl~ b/src/Solvers/SolversStopping/ARCqKOp1b.jl~ new file mode 100644 index 0000000..468b049 --- /dev/null +++ b/src/Solvers/SolversStopping/ARCqKOp1b.jl~ @@ -0,0 +1,19 @@ +export ARCqKOp1 + + +function ARCqKOp1(nlp :: AbstractNLPModel, + nlpstop :: NLPStopping; + ζ = 0.5, + τ = 1.0, + kwargs... + ) + + shifts = 10.0.^(collect(-15.0:1.0:15.0)) + + return TRARC2(nlp, + nlpstop; + TR = TrustRegion(10.0), + c = Combi(hessian_operator, PDataK{eltype(nlp.meta.x0)}, solve_modelKARC, preprocessKARC, decreaseKARC, TparamsKARC{eltype(nlp.meta.x0)}(shifts, ζin = ζ, τin = τ)), + kwargs... + ) +end diff --git a/src/Solvers/SolversStopping/solvers_stopping.jl b/src/Solvers/SolversStopping/solvers_stopping.jl index 1d41463..ae72983 100644 --- a/src/Solvers/SolversStopping/solvers_stopping.jl +++ b/src/Solvers/SolversStopping/solvers_stopping.jl @@ -57,6 +57,9 @@ push!(ALL_solvers_stopping, ARCqKOp) include("ARCqKOp1.jl") push!(ALL_solvers_stopping, ARCqKOp1) +include("ARCqKOp1b.jl") +push!(ALL_solvers_stopping, ARCqKOp1b) + include("ARCqKOp2.jl") push!(ALL_solvers_stopping, ARCqKOp2) diff --git a/src/Types/Types.jl b/src/Types/Types.jl index 149019c..aa7706d 100644 --- a/src/Types/Types.jl +++ b/src/Types/Types.jl @@ -17,7 +17,8 @@ mutable struct Tparam{T} <: Tparams{T} end mutable struct PDataK{T} <: PDataIter{T} d :: Array{T,1} # (H+λI)\g ; on first call = g λ :: T # "active" value of λ; on first call = 0 - τ :: T # Inexact Newton order parameter: stop when ||∇q||<||g||^(1+τ ) + ζ :: T # Inexact Newton order parameter: stop when ||∇q||<||g||^(1+ζ ) + τ :: T # temporary testing parameter for decreaseARCqK indmin :: Int # index of best shift value within "positive". On first call = 0 @@ -33,7 +34,7 @@ end mutable struct PDataST{T} <: PDataIter{T} H # Hessian representation, most likely as a linear operator or a sparse matrix g # gradient vector - τ :: T # Inexact Newton order parameter: stop when ||∇q||<||g||^(1+τ) + ζ :: T # Inexact Newton order parameter: stop when ||∇q||<||g||^(1+ζ) OK :: Bool # preprocess success end