Optimizer Interfaces¶
Pockit transcribes an optimal-control model into a sparse nonlinear program (NLP). It provides interfaces to Ipopt and SciPy's trust-constr.
Ipopt is usually the practical choice for fine meshes and large constrained models. SciPy has fewer native installation requirements and is useful for modest problems and diagnostics. Neither solver can compensate for poor scaling, inconsistent constraints, or an implausible initial guess.
Single-Phase Call¶
If a system has one phase and no static parameters, pass one Variable and receive one Variable:
from pockit.optimizer import ipopt
solution, info = ipopt.solve(
system,
guess,
optimizer_options={"tol": 1e-8, "max_iter": 1000},
)
if info["status"] not in (0, 1):
status_message = info["status_msg"]
if isinstance(status_message, bytes):
status_message = status_message.decode()
raise RuntimeError(status_message)
The SciPy form is identical, but its option names and result object differ:
from pockit.optimizer import scipy
solution, result = scipy.solve(
system,
guess,
optimizer_options={"maxiter": 1000},
)
if not result.success:
raise RuntimeError(result.message)
Multi-Phase Call¶
Pass one phase guess per phase followed by the static-parameter guess. The result preserves that layout:
[solution_0, solution_1, static], info = ipopt.solve(
system,
[guess_0, guess_1, static_guess],
optimizer_options={"tol": 1e-8, "max_iter": 1500},
)
Static parameters commonly hold shared event times and boundary states. Their position as the final list element is part of the model interface, not another phase.
Ipopt Linear Solver¶
At each iteration Ipopt solves a sparse linear system derived from the Karush-Kuhn-Tucker conditions. These systems can be indefinite and may become poorly conditioned, so the available sparse linear solver can materially affect robustness and speed. Pass the selection through optimizer_options only if that solver is included in the installed Ipopt build:
See the Ipopt options reference and record non-default solver options with published results.