Skip to content

Commit 3fd4fd8

Browse files
authored
Merge pull request #514 from moorepants/bounds-property
Make Problem.bounds and .eom_bounds properties.
2 parents 6e800c9 + 5d94298 commit 3fd4fd8

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

opty/direct_collocation.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,19 +190,20 @@ def __init__(self, obj, obj_grad, equations_of_motion, state_symbols,
190190
instance_constraints, time_symbol, tmp_dir, integration_method,
191191
parallel, show_compile_output=show_compile_output, backend=backend)
192192

193-
self.bounds = bounds
193+
self._bounds = bounds
194194

195195
# Check that the keys of eom_bounds correspond to equations of motion
196196
if eom_bounds is not None:
197197
key_list = []
198198
for key in eom_bounds.keys():
199-
if key not in range(len(equations_of_motion)):
199+
if key not in range(self.collocator.num_eom):
200200
key_list.append(key)
201201
if len(key_list) > 0:
202202
raise ValueError(f'Keys {key_list} in eom_bounds do not '
203203
'correspond to equations of motion.')
204204

205-
self.eom_bounds = eom_bounds
205+
self._eom_bounds = eom_bounds
206+
206207
# This only counts the explicit args in the function signature, not the
207208
# kwargs. See: https://stackoverflow.com/a/61941161
208209
self._obj_num_args = (obj.__code__.co_argcount -
@@ -244,6 +245,18 @@ def __init__(self, obj, obj_grad, equations_of_motion, state_symbols,
244245

245246
self.obj_value = []
246247

248+
@property
249+
def bounds(self):
250+
"""Returns the bounds dictionary that maps tupples of floats to the
251+
unknown variables."""
252+
return self._bounds
253+
254+
@property
255+
def eom_bounds(self):
256+
"""Returns the equation of motion bounds dictionary that maps tupples
257+
of floats to the equation of motion index."""
258+
return self._eom_bounds
259+
247260
def solve(self, free, lagrange=[], zl=[], zu=[], respect_bounds=False):
248261
"""Returns the optimal solution and an info dictionary.
249262

0 commit comments

Comments
 (0)