Open jtheinen opened 2 years ago
There is, but it's the incredibly unintuitive and bad-practice problem.solution._time_
.
This highlights that the API here definitely needs changing and making more intuitive!
I would maybe suggest making problem.solution.time
return the array of discretised time in normal units, problem.solution.initial_time
and problem.solution.final_time
would return the endpoints of the time array, and problem.solution.normalized_time
return what is currently problem.solution.tau
.
Part of the reason for the current behaviour is that we have problem.solution.state
, problem.solution.control
etc return the values of the actual decision variables used in the NLP subproblem, so problem.solution.time
currently does the same for the time variables. I would probably need to think a bit more about my above suggestion because it does clobber this nice consistency that we currently have for the NLP decision variables.
What are your thoughts? What would you find most intuitive?
I see that there are many variables stored double, such as: ._u = .control ._y = .state ._Tf = .finaltime and many more. Is there a reason for this? Do the variables starting with have something in common?
The reason why I didn't find problem.solution.time is because python does not give a suggestion to this option when I use a tab to check the options.
If changing the .time would clobber the consistency, would adding a .time_discretised maybe be an intuitive option?
In Python, attributes (and variables) prepended with an underscore (e.g. ._u
) are used to indicate "protected" attributes, i.e. ones that aren't part of a class's public API and should not be mutated by a user. The reason for duplication is so that Pycollo can internally mutate the protected versions and then the public versions (e.g. .control
) are actually properties without setters, which means that the user can't accidentally overwrite these.
I suspect that the autocomplete didn't work was because problem.solution._time_
is technically protected. Replacing with a renamed public attribute should mean that you get autocompletion here.
Is there an option to find the time vector to plot with the position solution? I have found problem.solution.tau, which always has a range from 0-1.
problem.solution.time just gives end time. Would multiplying tau by end time give a valid time vector?