From e1f8deeae40708b4c2ebaa34f0cea133055a90cb Mon Sep 17 00:00:00 2001 From: chrismo-schmidt Date: Tue, 7 Jan 2025 14:37:22 +0100 Subject: [PATCH] Add num_instance_constraints to constraints and ensure that squeeze specified values for the case of single unknown trajectories --- opty/direct_collocation.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/opty/direct_collocation.py b/opty/direct_collocation.py index db6607c..316c119 100644 --- a/opty/direct_collocation.py +++ b/opty/direct_collocation.py @@ -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() @@ -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)