Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Trying out callback test
  • Loading branch information
gennadiryan committed Oct 23, 2025
commit 200e95f220b938687210d05ccf82f93d8b724aba
35 changes: 35 additions & 0 deletions src/solvers/ipopt_solver/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ using ..DirectTrajOpt
using NamedTrajectories
using Ipopt

using TestItemRunner


# """
# # Callbacks evaluated by Ipopt should have the following signature:
Expand Down Expand Up @@ -220,5 +222,38 @@ function callback_best_rollout_fidelity_factory(problem::DirectTrajOptProblem, s
end
end

function cb_test()
include("test/test_utils.jl")

G, traj = bilinear_dynamics_and_trajectory()

integrators = [
BilinearIntegrator(G, traj, :x, :u),
DerivativeIntegrator(traj, :u, :du),
DerivativeIntegrator(traj, :du, :ddu)
]

J = TerminalObjective(x -> norm(x - traj.goal.x)^2, :x, traj)
J += QuadraticRegularizer(:u, traj, 1.0)
J += QuadraticRegularizer(:du, traj, 1.0)
J += MinimumTimeObjective(traj)

g_u_norm = NonlinearKnotPointConstraint(u -> [norm(u) - 1.0], :u, traj; times=2:traj.T-1, equality=false)

prob = DirectTrajOptProblem(traj, J, integrators; constraints=AbstractConstraint[g_u_norm])

callback = callback_factory(
callback_say_hello_factory("Hello, world!"),
callback_stop_iteration_factory(50),
)

optimizer, variables = get_optimizer_and_variables(prob, IpoptOptions(; max_iter=100), callback)
MOI.optimize!(optimizer)

# solve!(prob; max_iter=100)
end

@testitem begin cb_test() end


end