Skip to content

Commit e0364a0

Browse files
committed
1st commit
1 parent 9b35dcf commit e0364a0

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

src/VariationalInequalitySolver.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function project!(model::NLSVIModel, d::AbstractVector{T}, Px::AbstractVector{T}
5252
return Px
5353
end
5454

55+
include("solvers/projectionVI.jl")
5556
#=
5657
include("projector/ProjNLP.jl")
5758
include("solvers/penalizedVI.jl")

src/solvers/projectionVI.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export ProjectionVI
2+
3+
function ProjectionVI(
4+
model::AbstractVIModel,
5+
x0::AbstractVector;
6+
prec :: Float64 = 1e-6,
7+
rho0 :: Float64 = 0.5,
8+
itmax :: Int64 = 10000,
9+
)
10+
xk = copy(x0)
11+
xkp = similar(xk)
12+
rho = rho0
13+
i=0
14+
OK = false
15+
Fx = similar(xk)
16+
residual!(model, xk, Fx)
17+
Fx .*= rho
18+
Fx .+= xk # xk + rho * F(xk)
19+
20+
#main loop
21+
while !OK
22+
residual!(model, xk, Fx)
23+
Fx .*= rho
24+
Fx .+= xk # xk + rho * F(xk)
25+
proj!(model, Fx, xkp) # possible failure here
26+
27+
i=i+1
28+
OK=(i>=itmax) || (norm(xk-xkp,Inf)<prec*rho )
29+
xk = copy(xkp)
30+
end #end of main loop
31+
32+
return xk
33+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ Random.seed!(1234)
99
vi = NLSVIModel(nls)
1010
xr = rand(2)
1111
@test project(vi, xr) == xr
12+
sol = ProjectionVI(vi, xr)
1213
end

0 commit comments

Comments
 (0)