dymos icon indicating copy to clipboard operation
dymos copied to clipboard

Unify setting values across transcriptions

Open kaushikponnapalli opened this issue 2 months ago • 0 comments

Proposed feature.

Currently each of the different transcriptions require distinct methods of setting state values. For Gauss-Lobatto and Radau-ps, we use set_val('phase.states:{}', val). For explicit shooting, this causes an error since 'states.{}' does not exist. We must instead do set_val('phase.initial_states:{}', val). For Birkhoff, we need to set 'states:{}', 'initial_states:{}', and 'final_states:{}'.

This makes it cumbersome to move between transcriptions. Additionally, in the birkhoff transcription, if the initial and final state values are not set they default to 1. In that case, if fix_initial or fix_final is used, the collocation constraint will drive the initial and/or final value to 1, likely leading to invalid trajectories. This can be confusing, so to simplify the process we should have a single method to set the initial guess for the states.

The proposed change is to use phase.set_state_val() with the signature set_state_val(self, name, vals=None, time_vals=None, units=None, interpolation_kind='linear')

This method will automatically set the appropriate values required for the transcription.

To keep the API consistent, we should also introduce the methods set_control_val, set_polynomial_control_val, set_parameter_val, and set_time_val to Phase. With the signatures

set_time_val(self, initial=None, duration=None, units=None) set_control_val(self, name, vals=None, time_vals=None, units=None, interpolation_kind='linear') set_polynomial_control_val(self, name, vals=None, time_vals=None, units=None, interpolation_kind='linear') set_parameter_val(self, name, val=None, units=None)

Example

No response

kaushikponnapalli avatar Apr 17 '24 16:04 kaushikponnapalli