-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save / load OCP solution #144
Comments
Questions, remarks, suggestions. Don't be shy. Edit: footnote does not seem to work properly |
I have a stagiaire making a webapp for our toolbox. Maybe we can brainstorm. |
Footnotes
|
Thanks for the footnote help :D Forgot to add a nice suggestion from Olivier: have several methods for the solution constructor depending on the available info in context, such as the ocp. Also the JSON3 version is more an export than a save since the data is not identical (vectors vs functions), so I'll probably split the two at some point. |
FYI, the two formats have been split, now we have
The JLD2 part should be ready to move to CTBase. |
@PierreMartinon Is it done or note? Can we close the issue? |
Both the I propose we wait a bit for the move into Maybe add optional vector arguments in |
@PierreMartinon Do you need more than: T = sol.times # T = [t0, t1, ...]
X = sol.state.(T) # X = [x0, x1, ...]
U = sol.control.(T)
P = sol.costate.(T) and x = ctinterpolate(T, ...)
p = ctinterpolate(T, ...)
u = ctinterpolate(T, ...) |
@ocots I guess that |
Line 151 in eda7872
It is exported. Actually, it is a linear interpolation with a linear extrapolation. |
should be kept internal according to me. minor point, though. |
You lost me there :D What I meant is, we currently have the functions In the case of direct methods these vectors would store the original discrete solution, and in other cases it would simply default to apply the functions to a given time grid. Ah, while we're on Vectors: Functions: |
@jbcaillau On a slightly related topic, when building the boundary constraints in the OCP model, could we set the ordering to always be initial conditions first, followed by final conditions ? I noticed this is not necessarily the case while testing the constraints/multipliers parsing. |
Updated the JSON part. At some point we'll probably move these 4 functions from Note: importing a solution in JSON (text) format requires the corresponding OCP as well, in practice for dimensions, and also because our |
There is no copy of the
|
Oh you're right, I read too quickly. If yes we could add a method taking a named tuple or something similar for this block instead of the ocp. The constructor with the ocp would call this new one, passing the values from the ocp in the tuple. And the new method could be called when the full ocp is not available, eg when reading from a json, since this data block could be saved as text ! @ocots Can you confirm this or did I miss something ? |
Yes indeed, only for that: # data from ocp
sol.initial_time_name = ocp.initial_time_name
sol.final_time_name = ocp.final_time_name
sol.time_name = ocp.time_name
sol.control_dimension = ocp.control_dimension
sol.control_components_names = ocp.control_components_names
sol.control_name = ocp.control_name
sol.state_dimension = ocp.state_dimension
sol.state_components_names = ocp.state_components_names
sol.state_name = ocp.state_name
sol.variable_dimension = ocp.variable_dimension
sol.variable_components_names = ocp.variable_components_names
sol.variable_name = ocp.variable_name |
You can make an issue (Developers), create a branch from the issue and make a PR if you want :-) |
Hi @ocots @jbcaillau,
While working on a GUI and also following a request from a user (Frank), I did a first version of save / load features. The idea is simply to be able to store an OCP solution on disk after a solve, and conversely to load an existing file. The main difficulty is that an OCP solution is a rather elaborate object, containing interpolated functions in particular. This complicates the export in a generic text-like format. Also, data i/o in Julia is still evoving quite a bit. For now I have 2 formats:
I put the first draft in CTDirect but this will eventually move to CTBase since the OCP solution is there. Usage looks like this
Footnotes
this may be straightforward2 since I had already split the OCP Solution constructor in two: one called with the standard ipopt solution, and an internal one that takes raw vectors (T,X,U, multipliers etc) from a parsed solution. I'll try to see if we can use this second constructor starting from the JSON object containing the interpolated solution. ↩
(footnote test) Actually a bit more work is needed on the split to make the raw constructor even more generic, since it currently still takes the DOCP. it should be feasible as it is mostly for dimensions, although some boolean indicators regarding the constraints type are also used. I guess we can go back to manually checking for 'nothing' values in unused fields. I'll need to think a bit about this. ↩
The text was updated successfully, but these errors were encountered: