Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docstrings changed for solve to match opty #301

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 4 commits
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
48 changes: 48 additions & 0 deletions opty/direct_collocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,54 @@ def __init__(self, obj, obj_grad, equations_of_motion, state_symbols,

self.obj_value = []

# this is added only to correct the docstring, which is a bit different with
# opty compared to cyipopt.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines are not need. If is common to overwrite methods in sub classes for this reason and it needs no explanation.

def solve(self, free):
Copy link
Member

@moorepants moorepants Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This signature does not match cyipopt's.

"""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.

lagrange : array-like, shape(n*(N-1) + o, ), optional (default=[])
Initial values for the constraint multipliers (only if warm start option is chosen).

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).

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).

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

"""

return super().solve(free)
Copy link
Member

@moorepants moorepants Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not correct because it will not handle the optional keyword arguments.


def _generate_bound_arrays(self):
lb = -self.INF * np.ones(self.num_free)
ub = self.INF * np.ones(self.num_free)
Expand Down
Loading