1+ @with_kw mutable struct Options{T}
2+ # Ipopt settings: https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_print_options_documentation
3+ tol:: T = 1e-6
4+ s_max:: T = 100.0
5+ max_iter:: Int = 1000
6+ # max_wall_time = 300.0
7+ max_cpu_time = 300.0
8+ dual_inf_tol:: T = 1.0
9+ constr_viol_tol:: T = 1.0e-3
10+ compl_inf_tol:: T = 1.0e-3
11+ acceptable_tol:: T = 1.0e-6
12+ acceptable_iter:: Int = 15
13+ acceptable_dual_inf_tol:: T = 1.0e10
14+ acceptable_constr_viol_tol:: T = 1.0e-2
15+ acceptable_compl_inf_tol:: T = 1.0e-2
16+ acceptable_obj_change_tol:: T = 1.0e-5
17+ diverging_iterates_tol:: T = 1.0e8
18+ mu_target:: T = 1.0e-4
19+ print_level:: Int = 5
20+ output_file = joinpath (dirname (pathof (DirectTrajectoryOptimization)), " .." , " output.txt" )
21+ print_user_options = " no"
22+ # print_options_documentation = "no"
23+ # print_timing_statistics = "no"
24+ print_options_mode = " text"
25+ # print_advanced_options = "no"
26+ print_info_string = " no"
27+ inf_pr_output = " original"
28+ print_frequency_iter = 1
29+ print_frequency_time = 0.0
30+ skip_finalize_solution_call = " no"
31+ # timing_statistics = :no
32+ end
33+
134struct Solver{T}
235 p:: Problem{T}
336 nlp_bounds:: Vector{MOI.NLPBoundsPair}
@@ -6,18 +39,19 @@ struct Solver{T}
639 z:: Vector{MOI.VariableIndex}
740end
841
9- function Solver (trajopt:: TrajectoryOptimizationProblem ; eval_hess= false , options= nothing )
42+ function Solver (trajopt:: TrajectoryOptimizationProblem ; eval_hess= false , options= Options () )
1043 p = Problem (trajopt, eval_hess= eval_hess)
1144
1245 nlp_bounds = MOI. NLPBoundsPair .(p. con_bnds... )
1346 block_data = MOI. NLPBlockData (nlp_bounds, p, true )
1447
48+ # instantiate NLP solver
1549 solver = Ipopt. Optimizer ()
16-
17- # TODO : options
18- solver . options[ " max_iter " ] = 1000
19- solver. options[" tol " ] = 1.0e-3
20- solver . options[ " constr_viol_tol " ] = 1.0e-3
50+
51+ # set NLP solver options
52+ for name in fieldnames ( typeof (options))
53+ solver. options[String (name) ] = getfield (options, name)
54+ end
2155
2256 z = MOI. add_variables (solver, p. num_var)
2357
0 commit comments