Constraints
Constraints restrict the feasible region beyond dynamics. DirectTrajOpt supports bounds, boundary conditions, and nonlinear path constraints.
using DirectTrajOpt
using NamedTrajectories
using LinearAlgebra
N = 50
traj = NamedTrajectory(
(x = randn(2, N), u = randn(1, N), Δt = fill(0.1, N));
timestep=:Δt, controls=:u
)N = 50, (x = 1:2, u = 3:3, → Δt = 4:4)Bounds (Cheapest)
Box constraints on variables:
traj_bounds = NamedTrajectory(
(x = randn(2, N), u = randn(2, N), Δt = fill(0.1, N));
timestep=:Δt, controls=:u,
bounds=(
x = 5.0, # -5 ≤ x ≤ 5
u = (-1.0, 2.0), # -1 ≤ u ≤ 2
Δt = (0.01, 0.5) # 0.01 ≤ Δt ≤ 0.5
)
)N = 50, (x = 1:2, u = 3:4, → Δt = 5:5)Per-component bounds:
traj_component_bounds = NamedTrajectory(
(x = randn(2, N), u = randn(2, N), Δt = fill(0.1, N));
timestep=:Δt, controls=:u,
bounds=(u = ([-1.0, -2.0], [1.0, 3.0]),) # Different bounds per component
)N = 50, (x = 1:2, u = 3:4, → Δt = 5:5)Nonlinear Constraints
Inequality: c(x, u) ≥ 0 (preferred - easier to satisfy)
constraint_ineq = NonlinearKnotPointConstraint(
u -> [1.0 - norm(u)], # ||u|| ≤ 1
:u, traj; times=1:N, equality=false
)NonlinearKnotPointConstraint{DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#2#3"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}, DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#2#3"}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}, DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#2#3"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}}(DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#2#3"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#2#3"}(Main.var"#2#3"()), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[3], [7], [11], [15], [19], [23], [27], [31], [35], [39] … [163], [167], [171], [175], [179], [183], [187], [191], [195], [199]]), DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#2#3"}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#2#3"}(Main.var"#2#3"()), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], [[3], [7], [11], [15], [19], [23], [27], [31], [35], [39] … [163], [167], [171], [175], [179], [183], [187], [191], [195], [199]], [3]), SparseArrays.SparseMatrixCSC[sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4) … sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4)], DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#2#3"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#2#3"}(Main.var"#2#3"()), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[3], [7], [11], [15], [19], [23], [27], [31], [35], [39] … [163], [167], [171], [175], [179], [183], [187], [191], [195], [199]], [3]), SparseArrays.SparseMatrixCSC[sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4) … sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4)], false, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 … 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], 1, 50)Equality: c(x, u) = 0 (more restrictive)
constraint_eq = NonlinearKnotPointConstraint(
x -> [x[1] - 0.5], # x₁ = 0.5
:x, traj; times=[25], equality=true
)NonlinearKnotPointConstraint{DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#5#6"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}, DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#5#6"}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}, DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#5#6"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}}(DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#5#6"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#5#6"}(Main.var"#5#6"()), [nothing], 1, [[97, 98]]), DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#5#6"}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#5#6"}(Main.var"#5#6"()), [nothing], [[97, 98]], [1, 2]), SparseArrays.SparseMatrixCSC[sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4)], DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#5#6"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#5#6"}(Main.var"#5#6"()), [nothing], 1, [[97, 98]], [1, 2]), SparseArrays.SparseMatrixCSC[sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4)], true, [25], 1, 1)Multiple variables:
constraint_multi = NonlinearKnotPointConstraint(
(x, u) -> [x[1]^2 + x[2]^2 - u[1]],
[:x, :u], traj; equality=false
)NonlinearKnotPointConstraint{DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#8#9", Vector{UnitRange{Int64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}, DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#8#9", Vector{UnitRange{Int64}}}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}, DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#8#9", Vector{UnitRange{Int64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}}(DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#8#9", Vector{UnitRange{Int64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}(DirectTrajOpt.Constraints.var"#82#83"{Main.var"#8#9", Vector{UnitRange{Int64}}}(Main.var"#8#9"(), UnitRange{Int64}[1:2, 3:3]), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[1, 2, 3], [5, 6, 7], [9, 10, 11], [13, 14, 15], [17, 18, 19], [21, 22, 23], [25, 26, 27], [29, 30, 31], [33, 34, 35], [37, 38, 39] … [161, 162, 163], [165, 166, 167], [169, 170, 171], [173, 174, 175], [177, 178, 179], [181, 182, 183], [185, 186, 187], [189, 190, 191], [193, 194, 195], [197, 198, 199]]), DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#8#9", Vector{UnitRange{Int64}}}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#82#83"{Main.var"#8#9", Vector{UnitRange{Int64}}}(Main.var"#8#9"(), UnitRange{Int64}[1:2, 3:3]), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], [[1, 2, 3], [5, 6, 7], [9, 10, 11], [13, 14, 15], [17, 18, 19], [21, 22, 23], [25, 26, 27], [29, 30, 31], [33, 34, 35], [37, 38, 39] … [161, 162, 163], [165, 166, 167], [169, 170, 171], [173, 174, 175], [177, 178, 179], [181, 182, 183], [185, 186, 187], [189, 190, 191], [193, 194, 195], [197, 198, 199]], [1, 2, 3]), SparseArrays.SparseMatrixCSC[sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4) … sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4)], DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#8#9", Vector{UnitRange{Int64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#82#83"{Main.var"#8#9", Vector{UnitRange{Int64}}}(Main.var"#8#9"(), UnitRange{Int64}[1:2, 3:3]), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[1, 2, 3], [5, 6, 7], [9, 10, 11], [13, 14, 15], [17, 18, 19], [21, 22, 23], [25, 26, 27], [29, 30, 31], [33, 34, 35], [37, 38, 39] … [161, 162, 163], [165, 166, 167], [169, 170, 171], [173, 174, 175], [177, 178, 179], [181, 182, 183], [185, 186, 187], [189, 190, 191], [193, 194, 195], [197, 198, 199]], [1, 2, 3]), SparseArrays.SparseMatrixCSC[sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4) … sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4)], false, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 … 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], 1, 50)Common Patterns
Obstacle avoidance:
obs_center, obs_radius = [0.5, 0.5], 0.2
constraint_obstacle = NonlinearKnotPointConstraint(
x -> [norm(x - obs_center)^2 - obs_radius^2],
:x, traj; times=1:N, equality=false
)NonlinearKnotPointConstraint{DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#11#12"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}, DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#11#12"}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}, DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#11#12"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}}(DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#11#12"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#11#12"}(Main.var"#11#12"()), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[1, 2], [5, 6], [9, 10], [13, 14], [17, 18], [21, 22], [25, 26], [29, 30], [33, 34], [37, 38] … [161, 162], [165, 166], [169, 170], [173, 174], [177, 178], [181, 182], [185, 186], [189, 190], [193, 194], [197, 198]]), DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#11#12"}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#11#12"}(Main.var"#11#12"()), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], [[1, 2], [5, 6], [9, 10], [13, 14], [17, 18], [21, 22], [25, 26], [29, 30], [33, 34], [37, 38] … [161, 162], [165, 166], [169, 170], [173, 174], [177, 178], [181, 182], [185, 186], [189, 190], [193, 194], [197, 198]], [1, 2]), SparseArrays.SparseMatrixCSC[sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4) … sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4)], DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#11#12"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#11#12"}(Main.var"#11#12"()), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[1, 2], [5, 6], [9, 10], [13, 14], [17, 18], [21, 22], [25, 26], [29, 30], [33, 34], [37, 38] … [161, 162], [165, 166], [169, 170], [173, 174], [177, 178], [181, 182], [185, 186], [189, 190], [193, 194], [197, 198]], [1, 2]), SparseArrays.SparseMatrixCSC[sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4) … sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4)], false, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 … 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], 1, 50)Multiple obstacles:
constraints_obstacles = [
NonlinearKnotPointConstraint(
x -> [norm(x - center)^2 - radius^2],
:x, traj; equality=false
)
for (center, radius) in [([0.3, 0.3], 0.15), ([0.7, 0.7], 0.15)]
]2-element Vector{NonlinearKnotPointConstraint{DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}, DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}, DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}}}:
NonlinearKnotPointConstraint{DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}, DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}, DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}}(DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}(Main.var"#17#18"{Float64, Vector{Float64}}(0.15, [0.3, 0.3])), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[1, 2], [5, 6], [9, 10], [13, 14], [17, 18], [21, 22], [25, 26], [29, 30], [33, 34], [37, 38] … [161, 162], [165, 166], [169, 170], [173, 174], [177, 178], [181, 182], [185, 186], [189, 190], [193, 194], [197, 198]]), DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}(Main.var"#17#18"{Float64, Vector{Float64}}(0.15, [0.3, 0.3])), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], [[1, 2], [5, 6], [9, 10], [13, 14], [17, 18], [21, 22], [25, 26], [29, 30], [33, 34], [37, 38] … [161, 162], [165, 166], [169, 170], [173, 174], [177, 178], [181, 182], [185, 186], [189, 190], [193, 194], [197, 198]], [1, 2]), SparseArrays.SparseMatrixCSC[sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4) … sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4)], DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}(Main.var"#17#18"{Float64, Vector{Float64}}(0.15, [0.3, 0.3])), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[1, 2], [5, 6], [9, 10], [13, 14], [17, 18], [21, 22], [25, 26], [29, 30], [33, 34], [37, 38] … [161, 162], [165, 166], [169, 170], [173, 174], [177, 178], [181, 182], [185, 186], [189, 190], [193, 194], [197, 198]], [1, 2]), SparseArrays.SparseMatrixCSC[sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4) … sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4)], false, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 … 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], 1, 50)
NonlinearKnotPointConstraint{DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}, DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}, DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}}(DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}(Main.var"#17#18"{Float64, Vector{Float64}}(0.15, [0.7, 0.7])), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[1, 2], [5, 6], [9, 10], [13, 14], [17, 18], [21, 22], [25, 26], [29, 30], [33, 34], [37, 38] … [161, 162], [165, 166], [169, 170], [173, 174], [177, 178], [181, 182], [185, 186], [189, 190], [193, 194], [197, 198]]), DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}(Main.var"#17#18"{Float64, Vector{Float64}}(0.15, [0.7, 0.7])), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], [[1, 2], [5, 6], [9, 10], [13, 14], [17, 18], [21, 22], [25, 26], [29, 30], [33, 34], [37, 38] … [161, 162], [165, 166], [169, 170], [173, 174], [177, 178], [181, 182], [185, 186], [189, 190], [193, 194], [197, 198]], [1, 2]), SparseArrays.SparseMatrixCSC[sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4) … sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4), sparse([1, 1], [1, 2], [1.0, 1.0], 1, 4)], DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#17#18"{Float64, Vector{Float64}}}(Main.var"#17#18"{Float64, Vector{Float64}}(0.15, [0.7, 0.7])), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[1, 2], [5, 6], [9, 10], [13, 14], [17, 18], [21, 22], [25, 26], [29, 30], [33, 34], [37, 38] … [161, 162], [165, 166], [169, 170], [173, 174], [177, 178], [181, 182], [185, 186], [189, 190], [193, 194], [197, 198]], [1, 2]), SparseArrays.SparseMatrixCSC[sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4) … sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 1, 2], [1, 1, 2, 2], [1.0, 1.0, 1.0, 1.0], 4, 4)], false, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 … 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], 1, 50)State-dependent control limits:
constraint_state_dep = NonlinearKnotPointConstraint(
(x, u) -> [1.0 - u[1] / (1.0 + abs(x[1]))],
[:x, :u], traj; equality=false
)NonlinearKnotPointConstraint{DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#20#21", Vector{UnitRange{Int64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}, DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#20#21", Vector{UnitRange{Int64}}}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}, DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#20#21", Vector{UnitRange{Int64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}}(DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#20#21", Vector{UnitRange{Int64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}(DirectTrajOpt.Constraints.var"#82#83"{Main.var"#20#21", Vector{UnitRange{Int64}}}(Main.var"#20#21"(), UnitRange{Int64}[1:2, 3:3]), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[1, 2, 3], [5, 6, 7], [9, 10, 11], [13, 14, 15], [17, 18, 19], [21, 22, 23], [25, 26, 27], [29, 30, 31], [33, 34, 35], [37, 38, 39] … [161, 162, 163], [165, 166, 167], [169, 170, 171], [173, 174, 175], [177, 178, 179], [181, 182, 183], [185, 186, 187], [189, 190, 191], [193, 194, 195], [197, 198, 199]]), DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#20#21", Vector{UnitRange{Int64}}}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#82#83"{Main.var"#20#21", Vector{UnitRange{Int64}}}(Main.var"#20#21"(), UnitRange{Int64}[1:2, 3:3]), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], [[1, 2, 3], [5, 6, 7], [9, 10, 11], [13, 14, 15], [17, 18, 19], [21, 22, 23], [25, 26, 27], [29, 30, 31], [33, 34, 35], [37, 38, 39] … [161, 162, 163], [165, 166, 167], [169, 170, 171], [173, 174, 175], [177, 178, 179], [181, 182, 183], [185, 186, 187], [189, 190, 191], [193, 194, 195], [197, 198, 199]], [1, 2, 3]), SparseArrays.SparseMatrixCSC[sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4) … sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4)], DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#20#21", Vector{UnitRange{Int64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#82#83"{Main.var"#20#21", Vector{UnitRange{Int64}}}(Main.var"#20#21"(), UnitRange{Int64}[1:2, 3:3]), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[1, 2, 3], [5, 6, 7], [9, 10, 11], [13, 14, 15], [17, 18, 19], [21, 22, 23], [25, 26, 27], [29, 30, 31], [33, 34, 35], [37, 38, 39] … [161, 162, 163], [165, 166, 167], [169, 170, 171], [173, 174, 175], [177, 178, 179], [181, 182, 183], [185, 186, 187], [189, 190, 191], [193, 194, 195], [197, 198, 199]], [1, 2, 3]), SparseArrays.SparseMatrixCSC[sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4) … sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4)], false, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 … 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], 1, 50)Energy constraints:
E_max = 2.0
constraint_energy = NonlinearKnotPointConstraint(
(x, u) -> [E_max - (0.5 * norm(x)^2 + 0.5 * norm(u)^2)],
[:x, :u], traj; equality=false
)NonlinearKnotPointConstraint{DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#23#24", Vector{UnitRange{Int64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}, DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#23#24", Vector{UnitRange{Int64}}}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}, DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#23#24", Vector{UnitRange{Int64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}}(DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#23#24", Vector{UnitRange{Int64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}(DirectTrajOpt.Constraints.var"#82#83"{Main.var"#23#24", Vector{UnitRange{Int64}}}(Main.var"#23#24"(), UnitRange{Int64}[1:2, 3:3]), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[1, 2, 3], [5, 6, 7], [9, 10, 11], [13, 14, 15], [17, 18, 19], [21, 22, 23], [25, 26, 27], [29, 30, 31], [33, 34, 35], [37, 38, 39] … [161, 162, 163], [165, 166, 167], [169, 170, 171], [173, 174, 175], [177, 178, 179], [181, 182, 183], [185, 186, 187], [189, 190, 191], [193, 194, 195], [197, 198, 199]]), DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#23#24", Vector{UnitRange{Int64}}}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#82#83"{Main.var"#23#24", Vector{UnitRange{Int64}}}(Main.var"#23#24"(), UnitRange{Int64}[1:2, 3:3]), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], [[1, 2, 3], [5, 6, 7], [9, 10, 11], [13, 14, 15], [17, 18, 19], [21, 22, 23], [25, 26, 27], [29, 30, 31], [33, 34, 35], [37, 38, 39] … [161, 162, 163], [165, 166, 167], [169, 170, 171], [173, 174, 175], [177, 178, 179], [181, 182, 183], [185, 186, 187], [189, 190, 191], [193, 194, 195], [197, 198, 199]], [1, 2, 3]), SparseArrays.SparseMatrixCSC[sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4) … sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4), sparse([1, 1, 1], [1, 2, 3], [1.0, 1.0, 1.0], 1, 4)], DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#82#83"{Main.var"#23#24", Vector{UnitRange{Int64}}}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#82#83"{Main.var"#23#24", Vector{UnitRange{Int64}}}(Main.var"#23#24"(), UnitRange{Int64}[1:2, 3:3]), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[1, 2, 3], [5, 6, 7], [9, 10, 11], [13, 14, 15], [17, 18, 19], [21, 22, 23], [25, 26, 27], [29, 30, 31], [33, 34, 35], [37, 38, 39] … [161, 162, 163], [165, 166, 167], [169, 170, 171], [173, 174, 175], [177, 178, 179], [181, 182, 183], [185, 186, 187], [189, 190, 191], [193, 194, 195], [197, 198, 199]], [1, 2, 3]), SparseArrays.SparseMatrixCSC[sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4) … sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4), sparse([1, 2, 3, 1, 2, 3, 1, 2, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 4, 4)], false, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 … 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], 1, 50)Time Selection
All times, specific times, or ranges:
constraint_all = NonlinearKnotPointConstraint(
u -> [1.0 - norm(u)], :u, traj; times=1:N, equality=false
)
constraint_specific = NonlinearKnotPointConstraint(
x -> [x[1]^2 + x[2]^2 - 1.0], :x, traj;
times=[1, 10, 20, 30, 40, 50], equality=false
)
constraint_range = NonlinearKnotPointConstraint(
u -> [0.5 - norm(u)], :u, traj; times=10:40, equality=false
)NonlinearKnotPointConstraint{DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#32#33"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}, DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#32#33"}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}, DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#32#33"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}}(DirectTrajOpt.Constraints.var"#g!#52"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#32#33"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#32#33"}(Main.var"#32#33"()), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[39], [43], [47], [51], [55], [59], [63], [67], [71], [75] … [123], [127], [131], [135], [139], [143], [147], [151], [155], [159]]), DirectTrajOpt.Constraints.var"#∂g!#53"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#32#33"}, Vector{Nothing}, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#32#33"}(Main.var"#32#33"()), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], [[39], [43], [47], [51], [55], [59], [63], [67], [71], [75] … [123], [127], [131], [135], [139], [143], [147], [151], [155], [159]], [3]), SparseArrays.SparseMatrixCSC[sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4) … sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4), sparse([1], [3], [1.0], 1, 4)], DirectTrajOpt.Constraints.var"#μ∂²g!#56"{DirectTrajOpt.Constraints.var"#74#75"{Main.var"#32#33"}, Vector{Nothing}, Int64, Vector{Vector{Int64}}, Vector{Int64}}(DirectTrajOpt.Constraints.var"#74#75"{Main.var"#32#33"}(Main.var"#32#33"()), [nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing … nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing], 1, [[39], [43], [47], [51], [55], [59], [63], [67], [71], [75] … [123], [127], [131], [135], [139], [143], [147], [151], [155], [159]], [3]), SparseArrays.SparseMatrixCSC[sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4) … sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4), sparse([3], [3], [1.0], 4, 4)], false, [10, 11, 12, 13, 14, 15, 16, 17, 18, 19 … 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], 1, 31)Creating a Problem
G_drift = [-0.1 1.0; -1.0 -0.1]
G_drives = [[0.0 1.0; 1.0 0.0]]
G = u -> G_drift + sum(u .* G_drives)
integrator = BilinearIntegrator(G, traj, :x, :u)
obj = QuadraticRegularizer(:u, traj, 1.0)
constraints = [constraint_obstacle, constraint_ineq]
prob = DirectTrajOptProblem(traj, obj, integrator; constraints=constraints)DirectTrajOptProblem
timesteps = 50
duration = 4.899999999999999
variable names = (:x, :u, :Δt)
knot point dimension = 4
Summary
| Constraint Type | Form | Cost | Use Case |
|---|---|---|---|
| Bounds | l ≤ v ≤ u | Very cheap | Physical limits |
| Dynamics | xₖ₊₁ = Φ(xₖ, uₖ) | Moderate | System evolution |
| Boundary | x₁ = x₀, xₖ = xf | Cheap | Initial/final states |
| Nonlinear inequality | c(x, u) ≥ 0 | Moderate | Obstacles, limits |
| Nonlinear equality | c(x, u) = 0 | Expensive | Exact requirements |
Performance Tips
| Recommendation | Rationale |
|---|---|
| Use bounds over nonlinear constraints | Much faster to evaluate |
| Prefer inequalities over equalities | Easier to satisfy, larger feasible region |
| Scale constraint values to O(1) | Better numerical conditioning |
| Add constraints incrementally | Easier to debug, avoids over-constraining |
| Check initial guess feasibility | Prevents infeasible starts |
Troubleshooting
If optimizer struggles:
- Infeasible start: Initial guess violates constraints → improve initial guess
- Over-constrained: Too many/conflicting constraints → relax or remove some
- Poorly scaled: Values span many orders of magnitude → rescale to O(1)
- Tight constraints: Little feasible space → relax bounds or use soft constraints
This page was generated using Literate.jl.