Skip to content

Commit

Permalink
Enable defining bounds for timeshift parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-konrad committed Jan 7, 2025
1 parent e1f8dee commit 91d2cba
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions opty/direct_collocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ def _generate_bound_arrays(self):
num_state_nodes = N*self.collocator.num_states
num_non_par_nodes = N*(self.collocator.num_states +
self.collocator.num_unknown_input_trajectories)
num_var_dur_node = num_non_par_nodes + \
self.collocator.num_unknown_parameters
num_tshift_nodes = num_var_dur_node + int(self.collocator._variable_duration)
state_syms = self.collocator.state_symbols
unk_traj = self.collocator.unknown_input_trajectories
unk_par = self.collocator.unknown_parameters
Expand All @@ -230,8 +233,12 @@ def _generate_bound_arrays(self):
ub[idx] = bounds[1]
elif (self.collocator._variable_duration and
var == self.collocator.time_interval_symbol):
lb[-1] = bounds[0]
ub[-1] = bounds[1]
lb[num_var_dur_node] = bounds[0]
ub[num_var_dur_node] = bounds[1]
elif var in self.collocator.unknown_tshift_parameters:
i = self.collocator.unknown_tshift_parameters.index(var)
lb[num_tshift_nodes+i] = bounds[0]
ub[num_tshift_nodes+i] = bounds[1]
else:
msg = 'Bound variable {} not present in free variables.'
raise ValueError(msg.format(var))
Expand Down

0 comments on commit 91d2cba

Please sign in to comment.