You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To add a new problem to **OptimalControlProblems**, you should follow these steps:
3
+
To add a new problem to **OptimalControlProblems**, you must follow these steps:
4
4
5
5
**1.** Create a new file in the `ext/MetaData` directory with the name of your problem, containing the required information about the problem in a dictionary. For example, if your problem is called `new_problem`, create a file named `new_problem.jl`. The dictionary should follow the template:
6
6
7
7
```julia
8
8
new_problem_meta = OrderedDict(
9
-
:name =>"new_problem", # Problem name
10
-
:N =>100, # Number of steps
11
-
:minimise =>true, # Whether the objective is minimised (true) or maximised (false)
12
-
:state_name => ["x1", "x2"], # Names of the state components
13
-
:costate_name => ["∂x1", "∂x2"], # Names of the costate components (dual variables of the dynamics constraints)
14
-
:control_name => ["u"], # Names of the control components
15
-
:variable_name => ["v"], # Names of the optimisation variables
16
-
:final_time => (:fixed, 1), # Final time information
9
+
:name =>"new_problem", # Problem name
10
+
:N =>100, # Number of steps
11
+
:minimise =>true, # Whether we minimise (true) or maximise (false)
12
+
:state_name => ["x1", "x2"], # Names of the state components
13
+
:costate_name => ["∂x1", "∂x2"], # Names of the dynamics constraints (for the costate)
14
+
:control_name => ["u"], # Names of the control components
15
+
:variable_name => ["v"], # Names of the optimisation variables
16
+
:final_time => (:fixed, 1), # Final time information
17
17
)
18
18
```
19
19
20
20
!!! note
21
21
22
22
For more details about the metadata, see the [MetaData](@ref problems-introduction-metadata) section.
23
23
24
-
**2.** Define the DOCP **OptimalControl** model of the problem in a file named `new_problem.jl` in the `ext/OptimalControlModels` directory.
24
+
**2.** Define the **OptimalControl** model of the problem in a file named `new_problem.jl` in the `ext/OptimalControlModels` directory, following the template:
25
25
26
26
```julia
27
27
"""
28
28
Documentation of the method
29
29
"""
30
-
function OptimalControlProblems.new_problem(::OptimalControlBackend, description::Symbol...; N::Int=steps_number_data(:new_problem), kwargs...)
30
+
function OptimalControlProblems.new_problem(
31
+
::OptimalControlBackend,
32
+
description::Symbol...;
33
+
N::Int=steps_number_data(:new_problem),
34
+
kwargs...,
35
+
)
31
36
32
37
# if tf is fixed
33
38
tf = final_time_data(:new_problem)
@@ -41,7 +46,7 @@ function OptimalControlProblems.new_problem(::OptimalControlBackend, description
41
46
# initial guess for the problem
42
47
init = ()
43
48
44
-
#DOCP and NLP
49
+
#discretise the optimal control problem
45
50
docp = direct_transcription(
46
51
ocp,
47
52
description...;
@@ -57,25 +62,28 @@ function OptimalControlProblems.new_problem(::OptimalControlBackend, description
57
62
end
58
63
```
59
64
60
-
**3.** Define the NLP **JuMP** model of the problem in a file named `new_problem.jl` in the `ext/JuMPModels` directory.
65
+
**3.** Define the **JuMP** model of the problem in a file named `new_problem.jl` in the `ext/JuMPModels` directory, following the template:
61
66
62
67
```julia
63
68
"""
64
69
Documentation of the method
65
70
"""
66
-
function OptimalControlProblems.new_problem(::JuMPBackend, args...; N::Int=steps_number_data(:new_problem), kwargs...)
**4.** Describe the problem in a file named `new_problem.jl` in the `ext/Descriptions` directory.
89
+
**4.** Describe the problem in a file named `new_problem.jl` in the `ext/Descriptions` directory. Please get inspiration from the already existing descriptions in [OptimalControlProblems.jl/ext/Descriptions](https://github.com/control-toolbox/OptimalControlProblems.jl/tree/main/ext/Descriptions).
Copy file name to clipboardExpand all lines: docs/src/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ The **OptimalControlProblems.jl** package is part of the [control-toolbox ecosys
4
4
5
5
If you would like to define and solve your own optimal control problem, please refer to the [OptimalControl.jl documentation](https://control-toolbox.org/OptimalControl.jl).
6
6
7
-
In **OptimalControlProblems.jl**, you will find a collection of optimal control problems modelled with JuMP and OptimalControl. These problems can be used for benchmarking.
7
+
In **OptimalControlProblems.jl**, you will find a collection of optimal control problems modelled with JuMP and OptimalControl that can be used for benchmarking.
8
8
9
9
## Installation
10
10
@@ -24,7 +24,7 @@ If you use OptimalControlProblems.jl in your work, please cite us:
24
24
or in bibtex format:
25
25
26
26
```bibtex
27
-
@software{Caillau_OptimalControlProblems_jl,
27
+
@software{OptimalControlProblems_jl,
28
28
author = {Caillau, Jean-Baptiste and Cots, Olivier and Gergaud, Joseph and Martinon, Pierre},
0 commit comments