Skip to content
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

Default values #195

Closed
ocots opened this issue Aug 7, 2024 · 6 comments
Closed

Default values #195

ocots opened this issue Aug 7, 2024 · 6 comments
Assignees

Comments

@ocots
Copy link
Member

ocots commented Aug 7, 2024

Replace default values by the ones defined in CTBase.jl when the new release is released: control-toolbox/CTBase.jl#220.

const __grid_size_direct() = 100

@PierreMartinon
Copy link
Member

By the way, how do we organize the default values ? I find it a bit confusing to redefine default values at multiple levels.

We could

  • define everything in CTBase since every package is supposed to use it anyway
  • define the 'generic' ones in CTBase and the 'specific' ones (such as the grid size above) in their related packages ?

@ocots
Copy link
Member Author

ocots commented Aug 7, 2024

So here: https://github.com/control-toolbox/CTBase.jl/pull/222/files

I let __ocp_init but we keep the others in CTDirect.jl?

This is fine for me also.

@ocots
Copy link
Member Author

ocots commented Aug 7, 2024

Can you take a look at the end of this comment: control-toolbox/CTBase.jl#222 (comment)

With 200 there is a problem on an example.

@ocots
Copy link
Member Author

ocots commented Aug 7, 2024

You are right for the default values. We already do that here: https://github.com/control-toolbox/CTFlows.jl/blob/main/src/default.jl

I will just add a file with the specific default values with docstrings in CTDirect.jl.

@ocots
Copy link
Member Author

ocots commented Aug 7, 2024

To keep track:

# ------------------------------------------------------------------------------------
# Direct methods

"""
$(TYPEDSIGNATURES)

Used to set the default grid size.
The default value is `100`.
"""
__grid_size() = 100

"""
$(TYPEDSIGNATURES)

Used to set the default time grid.
The default value is `nothing`.
"""
__time_grid() = nothing

"""
$(TYPEDSIGNATURES)

Used to set the default tolerance.
The default value is `1e-8`.
"""
__tolerance() = 1e-8

"""
$(TYPEDSIGNATURES)

Used to set the default maximum of iterations.
The default value is `1000`.
"""
__max_iterations() = 1000

# ------------------------------------------------------------------------------------
# IPOPT

"""
$(TYPEDSIGNATURES)

Used to set the default value of the print level of Ipopt for the direct method.
The default va  lue is `5`.
"""
__ipopt_print_level() = 5

"""
$(TYPEDSIGNATURES)

Used to set the default value of the μ strategy of Ipopt for the direct method.
The default value is `adaptive`.
"""
__ipopt_mu_strategy() = "adaptive"

"""
$(TYPEDSIGNATURES)

Used to set the default value of the linear solver of Ipopt for the direct method.
The default value is `mumps`.
"""
__ipopt_linear_solver() = "mumps"

# ------------------------------------------------------------------------------------
# MadNLP

"""
$(TYPEDSIGNATURES)

Used to set the default value of the linear solver of MadNLP for the direct method.
The default value is `umfpack`.
"""
__madnlp_linear_solver() = "umfpack"

and

    @testset "Default value for direct solver" begin
        @test CTBase.__grid_size_direct() isa Integer
        @test isnothing(CTBase.__time_grid_direct())
        @test CTBase.__tolerance_direct() < 1
        @test CTBase.__max_iterations_direct() isa Integer
        @test CTBase.__linear_solver_direct() isa Symbol
    end

    @testset "Default value of the print level of ipopt for the direct method" begin
        @test CTBase.__ipopt_print_level() isa Integer
        @test CTBase.__ipopt_print_level()  12
        @test CTBase.__ipopt_print_level()  0
    end

    @testset "Default value of the mu strategy of ipopt for the direct method" begin
        @test CTBase.__ipopt_mu_strategy() isa String
    end

@PierreMartinon
Copy link
Member

PierreMartinon commented Aug 7, 2024

@ocots I added the default.jl file and tests in CTDirect :-)

@ocots ocots closed this as completed Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants