Skip to content

Commit

Permalink
fixed minor issues and made optimized example cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
Santos Michelena committed Jan 19, 2024
1 parent 5b56ac3 commit b8cd770
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 322 deletions.
395 changes: 81 additions & 314 deletions examples/optimizedSolver.ipynb

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/fixedPointSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ function solverPreprocessing(
n = L * N * K
Y_o = [[Y[i][l:(l+n-1)] for l in 1:n:n*m] for i in eachindex(Y)]
Y_p = [[Y[i][l:(l+n-1)] for l in m*n:n:(length(Y[i])-n)] for i in eachindex(Y)]
G_o = [covariance(kernels[i], Y_o[i], Y_o[i]) for i in eachindex(Y_data)]
G_p = [covariance(kernels[i], Y_o[i], Y_p[i]) for i in eachindex(Y_data)]
G_o = [covariance(kernels[i], Y_o[i], Y_o[i]) for i in eachindex(Y_o)]
G_p = [covariance(kernels[i], Y_o[i], Y_p[i]) for i in eachindex(Y_p)]
C = [cholesky(G_o[i] + λ[i] * I) for i in eachindex(G_o)]
D = [G_p[i] * (C[i] \ Q[i, i]) for i in axes(Q_data, 1)]
D = [G_p[i] * (C[i] \ Q[i, i]) for i in axes(Q, 1)]
Q_f = deepcopy(Q)
for i in axes(Q_data, 1)
for i in axes(Q, 1)
Q_f[i, i] =
BlockDiagonal([D[i][l:(l+L-1), :] for l in 1:L:size(D[1], 1)])
end
Expand All @@ -269,7 +269,7 @@ end
optimizedGaussSeidel(
G_p::Vector{<:Matrix},
C::Vector,
Q::Matrix{<:AbstractMatrix},
Q_f::Matrix{<:AbstractMatrix},
R::Vector{<:Vector};
iterations = 10,
)
Expand All @@ -282,7 +282,7 @@ Other methods can be implemented by using the function `solverPreprocessing` and
function optimizedGaussSeidel(
G_p::Vector{<:Matrix},
C::Vector,
Q::Matrix{<:AbstractMatrix},
Q_f::Matrix{<:AbstractMatrix},
R::Vector{<:Vector};
iterations = 10,
)
Expand All @@ -292,11 +292,11 @@ function optimizedGaussSeidel(
append!(
g[i],
[
-Q[i, i] \ (
-Q_f[i, i] \ (
G_p[i] * (
C[i] \ (
sum([
Q[i, j] * g[j][end] for
Q_f[i, j] * g[j][end] for
j in setdiff(eachindex(R), i)
]) + R[i]
)
Expand Down
2 changes: 2 additions & 0 deletions src/quadTeamProblems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ function GammaNorm(F::Vector{<:Function}, Y::AbstractVector)
return sqrt(sum([gammaNorm(f, y) for (f, y) in zip(F, Y)]))
end

using BlockDiagonals

"""
reformatData(Y_data::Vector{<:Vector}, Q_data::Matrix{<:Vector}, R_Data::Vector{<:Vector})
Expand Down

0 comments on commit b8cd770

Please sign in to comment.