Skip to content

Commit 9b0d87d

Browse files
authored
Merge pull request #9 from JuliaOptimizationVariationalAnalysis/add-prg
1st commit prg
2 parents fb285e6 + 3008a41 commit 9b0d87d

File tree

4 files changed

+45
-8
lines changed

4 files changed

+45
-8
lines changed

src/VariationalInequalitySolver.jl

+1-4
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ function project!(model::NLSVIModel, d::AbstractVector{T}, Px::AbstractVector{T}
7676
end
7777

7878
include("solvers/projectionVI.jl")
79-
#=
80-
include("projector/ProjNLP.jl")
81-
include("solvers/penalizedVI.jl")
82-
=#
79+
include("solvers/projected_reflected_gradient.jl")
8380

8481
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
> Yura Malitsky. Projected reflected gradient methods for monotone variational inequalities.
3+
> SIAM Journal on Optimization, 25(1):502–520, 2015.
4+
"""
5+
function ProjectedReflectedGradientVI(stp::AbstractStopping; rho0::Float64 = 0.5)
6+
xk = stp.current_state.x
7+
xkp = similar(xk)
8+
yk = copy(xk)
9+
rho = rho0
10+
Fx = similar(xk)
11+
12+
OK = update_and_start!(stp)
13+
while !OK
14+
abcresidual!(stp.pb, xk, rho, yk, Fx)
15+
project!(stp.pb, Fx, xk) # possible failure here
16+
yk .= 2 .* xkp .- xk
17+
18+
if norm(xk - xkp, Inf) < stp.meta.atol * rho
19+
stp.meta.optimal = true
20+
end
21+
OK = update_and_stop!(stp, x = xk)
22+
end
23+
24+
return xk
25+
end
26+
27+
export ProjectedReflectedGradientVI
28+
29+
function ProjectedReflectedGradientVI(model::AbstractVIModel, x0::AbstractVector; rho0::Float64 = 0.5, kwargs...)
30+
stp = GenericStopping(model, x0; kwargs...)
31+
return ProjectedReflectedGradientVI(stp, rho0 = rho0)
32+
end
33+
34+
function abcresidual!(model, xk, rho, yk, Fx) # xk - rho * F(yk)
35+
residual!(model, yk, Fx)
36+
Fx .*= -rho
37+
Fx .+= xk
38+
return Fx
39+
end

src/solvers/projectionVI.jl

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@ function ProjectionVI(stp::AbstractStopping; rho0::Float64 = 0.5)
1717
xkp = similar(xk)
1818
rho = rho0
1919
Fx = similar(xk)
20-
abresidual!(stp.pb, xk, rho, Fx)
2120

2221
OK = update_and_start!(stp)
2322
while !OK
2423
abresidual!(stp.pb, xk, rho, Fx)
25-
project!(stp.pb, Fx, xkp) # possible failure here
24+
project!(stp.pb, Fx, xk) # possible failure here
2625

2726
if norm(xk - xkp, Inf) < stp.meta.atol * rho
2827
stp.meta.optimal = true
2928
end
30-
OK = OK || update_and_stop!(stp, x = xk)
29+
OK = update_and_stop!(stp, x = xk)
3130
end
3231

3332
return xk

test/runtests.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ Random.seed!(1234)
99
vi = NLSVIModel(nls)
1010
xr = rand(2)
1111
@test project(vi, xr) == xr
12-
sol = ProjectionVI(vi, xr)
12+
sol1 = ProjectionVI(vi, xr)
13+
sol2 = ProjectedReflectedGradientVI(vi, xr)
14+
@show sol1, sol2
1315
end
1416

1517
@testset "Test API AbstractVIModel" begin

0 commit comments

Comments
 (0)