From 790d9c0bbad2fd6fc19aed51b23d3030b8152dc9 Mon Sep 17 00:00:00 2001 From: Peter Stahlecker Date: Sun, 19 Jan 2025 15:21:36 +0100 Subject: [PATCH] copied from cyipopt code and only changed a few things relevant for opty --- opty/direct_collocation.py | 79 ++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 46 deletions(-) diff --git a/opty/direct_collocation.py b/opty/direct_collocation.py index fcd3497b..ce3f7db0 100644 --- a/opty/direct_collocation.py +++ b/opty/direct_collocation.py @@ -200,59 +200,46 @@ def __init__(self, obj, obj_grad, equations_of_motion, state_symbols, # this is added only to correct the docstring, which is a bit different with # opty compared to cyipopt. def solve(self, free): - """ - - **solve(x)** - - Returns the optimal solution and an info dictionary. + """Returns the optimal solution and an info dictionary. Solves the posed optimization problem starting at point x. - Parameters: - - x (array-like, shape(n*N + q*N + r + s, )) - - Initial guess. - - Returns: - - x (array, shape(n*N + q*N + r + s, )) - - optimal solution. - - info (dictionary) - - x: ndarray, shape(n*N + q*N + r + s, ) - - optimal solution - - g: ndarray, shape(n*(N-1) + o, ) - - constraints at the optimal solution - - obj_val: float - - objective value at optimal solution - - mult_g: ndarray, shape(n*(N-1) + o, ) - - final values of the constraint multipliers - - mult_x_L: ndarray, shape(n*N + q*N + r + s, ) - - bound multipliers at the solution - - mult_x_U: ndarray, shape(n*N + q*N + r + s, ) - - bound multipliers at the solution + Parameters + ---------- + x : array-like, shape(n*N + q*N + r + s, ) + Initial guess. - status: integer + lagrange : array-like, shape(n*(N-1) + o, ), optional (default=[]) + Initial values for the constraint multipliers (only if warm start option is chosen). - gives the status of the algorithm + zl : array-like, shape(n*N + q*N + r + s, ), optional (default=[]) + Initial values for the multipliers for lower variable bounds (only if warm start option is chosen). - status_msg: string + zu : array-like, shape(n*N + q*N + r + s, ), optional (default=[]) + Initial values for the multipliers for upper variable bounds (only if warm start option is chosen). - gives the status of the algorithm as a message + Returns + ------- + x : :py:class:`numpy.ndarray`, shape `(n*N + q*N + r + s, )` + Optimal solution. + info: :py:class:`dict` with the following entries + + ``x``: :py:class:`numpy.ndarray`, shape `(n*N + q*N + r + s, )` + optimal solution + ``g``: :py:class:`numpy.ndarray`, shape `(n*(N-1) + o, )` + constraints at the optimal solution + ``obj_val``: :py:class:`float` + objective value at optimal solution + ``mult_g``: :py:class:`numpy.ndarray`, shape `(n*(N-1) + o, )` + final values of the constraint multipliers + ``mult_x_L``: :py:class:`numpy.ndarray`, shape `(n*N + q*N + r + s, )` + bound multipliers at the solution + ``mult_x_U``: :py:class:`numpy.ndarray`, shape `(n*N + q*N + r + s, )` + bound multipliers at the solution + ``status``: :py:class:`int` + gives the status of the algorithm + ``status_msg``: :py:class:`str` + gives the status of the algorithm as a message """