Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DirectTrajOpt"
uuid = "c823fa1f-8872-4af5-b810-2b9b72bbbf56"
version = "0.9.7"
version = "0.9.6"
authors = ["Aaron Trowbridge <aaron.j.trowbridge@gmail.com> and contributors"]

[deps]
Expand Down
3 changes: 2 additions & 1 deletion src/constraints/_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ function test_constraint(

# Compute finite difference Hessian using full vector (datavec + global_data)
# Collect to convert from lazy ApplyArray to regular Vector
μ∂²g_finite_diff = FiniteDiff.finite_difference_hessian(Z⃗ -> μ'ĝ(Z⃗), collect(vec(traj)))
μ∂²g_finite_diff =
FiniteDiff.finite_difference_hessian(Z⃗ -> μ'ĝ(Z⃗), collect(vec(traj)))

if show_hessian_diff
println("\tDifference in Hessian")
Expand Down
5 changes: 0 additions & 5 deletions src/objectives/_objectives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ export MinimumTimeObjective
export KnotPointObjective
export GlobalObjective
export GlobalKnotPointObjective
export KnotHVP
export ConstantLowRankHVP
export CustomKnotHVP
export knot_hvp

using ..Constraints

Expand Down Expand Up @@ -339,7 +335,6 @@ end
# Additional objectives
# ----------------------------------------------------------------------------- #

include("knot_hvp.jl")
include("knot_point_objectives.jl")
include("global_objectives.jl")
include("minimum_time_objective.jl")
Expand Down
267 changes: 0 additions & 267 deletions src/objectives/knot_hvp.jl

This file was deleted.

17 changes: 2 additions & 15 deletions src/objectives/knot_point_objectives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ where ℓ is evaluated on trajectory variables at each knot point.
- `times::Vector{Int}`: Time indices where objective is evaluated
- `params::Vector`: Parameters for each time index
- `Qs::Vector{Float64}`: Weights for each time index
- `knot_hvp::Union{Nothing, KnotHVP}`: Optional declarable matrix-free
per-knot Hessian-vector product capability (see [`KnotHVP`](@ref)).
`nothing` (the default) leaves the existing dense-Hessian behavior
unchanged. Set to a `ConstantLowRankHVP` or `CustomKnotHVP` to
advertise a matrix-free apply to downstream consumers.
- `∂²Ls::Vector{SparseMatrixCSC{Float64, Int}}`: Preallocated sparse Hessian storage (one per timestep)

# Constructor
```julia
Expand All @@ -39,8 +35,7 @@ KnotPointObjective(
traj::NamedTrajectory,
params::AbstractVector;
times::AbstractVector{Int}=1:traj.N,
Qs::AbstractVector{Float64}=ones(length(times)),
knot_hvp::Union{Nothing, KnotHVP}=nothing,
Qs::AbstractVector{Float64}=ones(length(times))
)
```

Expand Down Expand Up @@ -68,7 +63,6 @@ struct KnotPointObjective <: AbstractObjective
times::Vector{Int}
params::Vector
Qs::Vector{Float64}
knot_hvp::Union{Nothing,KnotHVP}
end

function KnotPointObjective(
Expand All @@ -78,7 +72,6 @@ function KnotPointObjective(
params::AbstractVector;
times::AbstractVector{Int} = 1:traj.N,
Qs::AbstractVector{Float64} = ones(length(times)),
knot_hvp::Union{Nothing,KnotHVP} = nothing,
)
@assert length(Qs) == length(times) "Qs must have the same length as times"
@assert length(params) == length(times) "params must have the same length as times"
Expand All @@ -89,7 +82,6 @@ function KnotPointObjective(
Vector{Int}(times),
Vector(params),
Vector{Float64}(Qs),
knot_hvp,
)
end

Expand Down Expand Up @@ -163,11 +155,6 @@ function Base.show(io::IO, obj::KnotPointObjective)
print(io, "KnotPointObjective on [$vars] at $times_str")
end

# `knot_hvp` trait specialization — reads the carrier from the struct
# field. The generic default `knot_hvp(::AbstractObjective, _) = nothing`
# lives in `knot_hvp.jl`.
knot_hvp(obj::KnotPointObjective, ::NamedTrajectory) = obj.knot_hvp

# Implement AbstractObjective interface

function objective_value(obj::KnotPointObjective, traj::NamedTrajectory)
Expand Down
8 changes: 6 additions & 2 deletions test/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ function named_trajectory_type_1(; free_time = true)
Δt = ([0.1], [0.30000000000000004]),
)
else
components =
(Ũ⃗ = data[1:8, :], a = data[9:10, :], da = data[11:12, :], dda = data[13:14, :])
components = (
Ũ⃗ = data[1:8, :],
a = data[9:10, :],
da = data[11:12, :],
dda = data[13:14, :],
)
controls = (:dda,)
timestep = 0.2
bounds = (a = ([-1.0, -1.0], [1.0, 1.0]), dda = ([-1.0, -1.0], [1.0, 1.0]))
Expand Down
Loading