-
Notifications
You must be signed in to change notification settings - Fork 3
refactoring + add getters and setters #249
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
Conversation
@jbcaillau We should make the |
👍🏽 go ahead! |
Done! |
In the future documentation, if we use the getters, then, we will have something like: sol = solve(ocp)
x = get_state(sol) Do we prefer: sol = solve(ocp)
x = state(sol) Here is the list of getters: # OptimalControlModel
get_dim_control_constraints
get_dim_state_constraints
get_dim_mixed_constraints
get_dim_path_constraints
get_dim_boundary_constraints
get_dim_variable_constraints
get_dim_control_range
get_dim_state_range,
get_dim_variable_range
get_model_expression
get_initial_time
get_initial_time_name
get_final_time
get_final_time_name
get_time_name
get_control_dimension
get_control_components_names
get_control_name
get_state_dimension
get_state_components_names
get_state_name
get_variable_dimension
get_variable_components_names
get_variable_name
get_lagrange
get_mayer
get_criterion
get_dynamics
# in the previous getters, some are common with OptimalControlSolution
# OptimalControlSolution
get_times
get_control
get_state, get_variable
get_costate
get_objective
get_iterations
get_stopping
get_message
get_success
get_infos |
The most used by the user I guess are those on an times # or time_grid since times is very common
control # this will be used to define also some control law. Will be there any conflict?
state
variable
costate
objective
iterations
stopping
message
success
infos If we have that, not clear to write something like: Usually we would write: times = time_grid(sol)
u = control(sol)
x = state(sol)
v = variable(sol)
p = costate(sol)
obj = objective(sol)
Niter = iterations(sol)
stopping # ??
message # ??
success # ??
infos # ?? |
@PierreMartinon @jbcaillau Please make a comment. |
Thanks @ocots I like this best: times = time_grid(sol)
u = control(sol)
x = state(sol)
v = variable(sol)
p = costate(sol)
obj = objective(sol)
Niter = iterations(sol)
...
|
If you have several types, getters are a good idea. We just have one but with getters we can make some checkings, some computations, etc. Maybe we can have both as you said with aliases. We can make the aliases inside OptimalControl.jl and let in CTBase.jl the functiins with |
@jbcaillau @PierreMartinon I will rename some getters to have something like times = time_grid(sol)
u = control(sol)
x = state(sol)
v = variable(sol)
p = costate(sol)
obj = objective(sol)
Niter = iterations(sol)
... |
I have removed all the prefixes I make a push soon. |
I have made some modifications. I have added getters for a solution but I have also renamed getters for a model. It is clearer for me with the prefix
get_
. I have thus updated theProject.toml
.I will take a look at #144 (comment).
I have also restructured the code to simplify in the future documentation, the organisation of the presentation the model, the solution and their setters and getters.
@PierreMartinon @jbcaillau Please comment.