Skip to content

Commit

Permalink
Add num_instance_constraints to constraints and ensure that squeeze s…
Browse files Browse the repository at this point in the history
…pecified values for the case of single unknown trajectories
  • Loading branch information
chris-konrad committed Jan 7, 2025
1 parent e29d5db commit e1f8dee
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions opty/direct_collocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ def __init__(self, equations_of_motion, state_symbols,
self._generate_timeshift_constraints()
self._precalc_timshift_input_derivatives()
self.num_instance_constraints = len(self.instance_constraints)
self.num_constraints += self.num_instance_constraints
self._identify_functions_in_instance_constraints()
self._find_closest_free_index()
self.eval_instance_constraints = self._instance_constraints_func()
Expand Down Expand Up @@ -1957,6 +1958,9 @@ def constraints(free):
eom_con_vals = func(free_states, all_specified, all_constants,
time_interval)

if all_specified.shape[0] == 1:
all_specified.squeeze()

if self.instance_constraints is not None:
if typ == 'con':
ins_con_vals = self.eval_instance_constraints(free)
Expand Down

0 comments on commit e1f8dee

Please sign in to comment.