Skip to content

Commit

Permalink
Get tests back up running.
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Dec 29, 2024
1 parent b7bff5e commit 4174d9a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
38 changes: 34 additions & 4 deletions src/plans/vectorial_plan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ function get_jacobian!(
FT,VGF<:AbstractVectorGradientFunction{<:InplaceEvaluation,FT,<:CoordinateVectorialType}
}
vgf.jacobian!!(M, JF, p)
_change_basis!(JF, vgf.jacobian_type.basis, basis)
_change_basis!(M, p, JF, vgf.jacobian_type.basis, basis)
return JF
end

Expand Down Expand Up @@ -1119,7 +1119,7 @@ This function can perform the evalutation inplace of `V`.
get_value(M::AbstractManifold, vgf::AbstractVectorFunction, p, i)
function get_value(
M::AbstractManifold, vgf::AbstractVectorFunction{E,<:FunctionVectorialType}, p, i=:
) where {E<:AbstractEvaluationType}
) where {E<:AllocatingEvaluation}
c = vgf.value!!(M, p)
if isa(c, Number)
return c
Expand All @@ -1140,9 +1140,25 @@ function get_value(
) where {E<:AbstractEvaluationType}
return [f(M, p) for f in vgf.value!![i]]
end
function get_value(
M::AbstractManifold,
vgf::AbstractVectorFunction{E,<:FunctionVectorialType},
p,
i=:;
value_cache=zeros(vgf.range_dimension),
) where {E<:InplaceEvaluation}
vgf.value!!(M, value_cache, p)
return value_cache[i]
end
# A ComponentVectorialType Inplace does that make sense, since those would be real - valued functions

function get_value!(
M::AbstractManifold, V, vgf::AbstractVectorFunction{E,<:FunctionVectorialType}, p, i=:
) where {E<:AbstractEvaluationType}
M::AbstractManifold,
V,
vgf::AbstractVectorFunction{AllocatingEvaluation,<:FunctionVectorialType},
p,
i=:,
)
c = vgf.value!!(M, p)
if isa(c, Number)
V .= c

Check warning on line 1164 in src/plans/vectorial_plan.jl

View check run for this annotation

Codecov / codecov/patch

src/plans/vectorial_plan.jl#L1164

Added line #L1164 was not covered by tests
Expand All @@ -1151,6 +1167,20 @@ function get_value!(
end
return V
end

function get_value!(
M::AbstractManifold,
V,
vgf::AbstractVectorFunction{InplaceEvaluation,<:FunctionVectorialType},
p,
i=:;
value_cache=zeros(vgf.range_dimension),
)
vgf.value!!(M, value_cache, p)
V .= value_cache[i]
return V
end

@doc raw"""
get_value_function(vgf::VectorGradientFunction, recursive=false)
Expand Down
10 changes: 6 additions & 4 deletions test/plans/test_constrained_plan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ include("../utils/dummy_types.jl")
hess_f!(M, Y, p, X) = (Y .= [2.0, 2.0, 2.0])
# Inequality constraints
g(M, p) = [p[1] - 1, -p[2] - 1]
g!(M, V, p) = (V .= [p[1] - 1, -p[2] - 1])
# # Function
grad_g(M, p) = [[1.0, 0.0, 0.0], [0.0, -1.0, 0.0]]
grad_gA(M, p) = [1.0 0.0; 0.0 -1.0; 0.0 0.0]
Expand Down Expand Up @@ -41,6 +42,7 @@ include("../utils/dummy_types.jl")
) == 2
# Equality Constraints
h(M, p) = [2 * p[3] - 1]
h!(M, V, p) = (V .= [2 * p[3] - 1])
h1(M, p) = 2 * p[3] - 1
grad_h(M, p) = [[0.0, 0.0, 2.0]]
grad_hA(M, p) = [[0.0, 0.0, 2.0];;]
Expand Down Expand Up @@ -83,9 +85,9 @@ include("../utils/dummy_types.jl")
cofm = ConstrainedManifoldObjective(
f,
grad_f!,
g,
g!,
grad_g!,
h,
h!,
grad_h!;
evaluation=InplaceEvaluation(),
inequality_constraints=2,
Expand Down Expand Up @@ -149,9 +151,9 @@ include("../utils/dummy_types.jl")
cofhm = ConstrainedManifoldObjective(
f,
grad_f!,
g,
g!,
grad_g!,
h,
h!,
grad_h!;
hess_f=hess_f!,
hess_g=hess_g!,
Expand Down
7 changes: 4 additions & 3 deletions test/plans/test_vectorial_plan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using Manopt: get_value, get_value_function, get_gradient_function
@testset "VectorialGradientCost" begin
M = ManifoldsBase.DefaultManifold(3)
g(M, p) = [p[1] - 1, -p[2] - 1]
g!(M, V, p) = (V .= [p[1] - 1, -p[2] - 1])
# # Function
grad_g(M, p) = [[1.0, 0.0, 0.0], [0.0, -1.0, 0.0]]
hess_g(M, p, X) = [copy(X), -copy(X)]
Expand Down Expand Up @@ -37,7 +38,7 @@ using Manopt: get_value, get_value_function, get_gradient_function
function_type=ComponentVectorialType(),
jacobian_type=ComponentVectorialType(),
)
vgf_fi = VectorGradientFunction(g, grad_g!, 2; evaluation=InplaceEvaluation())
vgf_fi = VectorGradientFunction(g!, grad_g!, 2; evaluation=InplaceEvaluation())
vgf_vi = VectorGradientFunction(
[g1, g2],
[grad_g1!, grad_g2!],
Expand All @@ -50,7 +51,7 @@ using Manopt: get_value, get_value_function, get_gradient_function
g, jac_g, 2; jacobian_type=CoordinateVectorialType(DefaultOrthonormalBasis())
)
vgf_ji = VectorGradientFunction(
g,
g!,
jac_g!,
2;
jacobian_type=CoordinateVectorialType(DefaultOrthonormalBasis()),
Expand All @@ -71,7 +72,7 @@ using Manopt: get_value, get_value_function, get_gradient_function
jacobian_type=ComponentVectorialType(),
hessian_type=ComponentVectorialType(),
)
vhf_fi = VectorHessianFunction(g, grad_g!, hess_g!, 2; evaluation=InplaceEvaluation())
vhf_fi = VectorHessianFunction(g!, grad_g!, hess_g!, 2; evaluation=InplaceEvaluation())
vhf_vi = VectorHessianFunction(
[g1, g2],
[grad_g1!, grad_g2!],
Expand Down

0 comments on commit 4174d9a

Please sign in to comment.