Skip to content

Commit

Permalink
Merge pull request #157 from control-toolbox/documentation
Browse files Browse the repository at this point in the history
update doc
  • Loading branch information
ocots authored Jun 16, 2024
2 parents 439e039 + 1e55996 commit fad9005
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 12 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ makedocs(
"api-description.md",
"api-diffgeom.md",
"api-exceptions.md",
"api-init.md",
"api-model.md",
"api-parser.md",
"api-plot.md",
Expand Down
19 changes: 19 additions & 0 deletions docs/src/api-init.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Initialisation

## Index

```@index
Pages = ["api-init.md"]
Modules = [CTBase]
Order = [:module, :constant, :type, :function, :macro]
Private = false
```

## Documentation

```@autodocs
Modules = [CTBase]
Order = [:module, :constant, :type, :function, :macro]
Pages = ["init.jl"]
Private = false
```
3 changes: 0 additions & 3 deletions src/CTBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ See also: [`ctVector`](@ref), [`DState`](@ref).
"""
const DCostate = ctVector

__auto() = AutoForwardDiff() # default AD backend

#
include("exception.jl")
include("description.jl")
Expand All @@ -214,7 +212,6 @@ include("model.jl")
include("differential_geometry.jl")
#
include("ctparser_utils.jl")
##include("ctparser.jl")
include("onepass.jl")
include("repl.jl")
#
Expand Down
9 changes: 9 additions & 0 deletions src/default.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
"""
$(TYPEDSIGNATURES)
Used to set the default value of Automatic Differentiation backend.
The default value is `AutoForwardDiff()`, that is the `ForwardDiff` package is used by default.
"""
__auto() = AutoForwardDiff() # default AD backend

"""
$(TYPEDSIGNATURES)
Used to set the default value of the time dependence of the functions.
The default value is `Autonomous`, which means that the functions are considered time independent.
Expand Down
8 changes: 7 additions & 1 deletion src/onepass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,13 @@ p_bolza!(p, ocp, e1, e2, type; log=false) = begin
end, p.lnum, p.line)
end

# redirection to Model() to avoid confusion with other functions Model from other packages
"""
$(TYPEDSIGNATURES)
Redirection to [`Model`](@ref) to avoid confusion with other functions Model from other packages
if imported. This function is used by [`@def`](@ref).
"""
function __OCPModel(args...; kwargs...)
return CTBase.Model(args...; kwargs...)
end
Expand Down
31 changes: 23 additions & 8 deletions src/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,35 @@ function Base.show(io::IO, ::MIME"text/plain", ocp::OptimalControlModel{<: TimeD
#is_variable_dependent(ocp) && push!(header, "variable")
push!(header, "variable")
push!(header, "dynamics*", "objective*", "constraints")
data = hcat(__is_time_not_set(ocp) ? "" : "",
__is_state_not_set(ocp) ? "" : "",
__is_control_not_set(ocp) ? "" : "")
data = hcat(__is_time_not_set(ocp) ? "X" : "V",
__is_state_not_set(ocp) ? "X" : "V",
__is_control_not_set(ocp) ? "X" : "V")
#is_variable_dependent(ocp) &&
begin
(data = hcat(data,
__is_variable_not_set(ocp) ? "" : ""))
__is_variable_not_set(ocp) ? "X" : "V"))
end
data = hcat(data,
__is_dynamics_not_set(ocp) ? "" : "",
__is_objective_not_set(ocp) ? "" : "",
isempty(ocp.constraints) ? "" : "")
__is_dynamics_not_set(ocp) ? "X" : "V",
__is_objective_not_set(ocp) ? "X" : "V",
isempty(ocp.constraints) ? "X" : "V")
println("")
pretty_table(data, header=header, header_crayon=crayon"yellow")
h1 = Highlighter(
(data, i, j) -> data[i, j] == "X",
bold = true,
foreground = :red )
h2 = Highlighter(
(data, i, j) -> data[i, j] == "V",
bold = true,
foreground = :green )
pretty_table(io, data;
tf=tf_unicode_rounded,
header=header,
header_crayon=crayon"yellow",
crop=:none,
highlighters=(h1, h2),
alignment=:c,
compact_printing=true)
nothing

end
Expand Down
6 changes: 6 additions & 0 deletions src/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ global ct_repl_is_set::Bool = false
global ct_repl_data::CTRepl
global ct_repl_ct_repl_history::HistoryRepl

"""
$(TYPEDSIGNATURES)
Update the model adding the expression e. It must be public since in the ct repl, this function
is quoted each time an expression is parsed and is valid.
"""
function ct_repl_update_model(e::Expr)

ct_repl_data.debug && (println("debug> expression to add: ", e))
Expand Down

0 comments on commit fad9005

Please sign in to comment.