1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
"""Definition of an optimization problem
Provides the cost function, constraints and additional
penalty-type constraints.
"""
"""Construct an optimization problem
Args:
u: decision variable (CasADi variable)
p: parameter (CasADi variable)
cost: cost function (CasADi function of u and p)
Example:
>>> import casadi.casadi as cs
>>> import opengen as og
>>> # Define u and p
>>> u = cs.SX.sym('u', 5)
>>> p = cs.SX.sym('p', 2)
>>> # Cost function
>>> phi = og.functions.rosenbrock(u, p)
>>> # Define optimization problem
>>> problem = og.builder.Problem(u, p, phi)
"""
=
=
=
= None
= None
= None
= None
# ---------- SETTERS -----------------------------------------------
"""Specify or update the constraints of the problem
Args:
u_constraints: constraints on the decision variable; must
be a Constraint object (such as
\link opengen.constraints.ball2.Ball2 Ball2 \endlink
and \link opengen.constraints.rectangle.Rectangle Rectangle \endlink)
Returns:
Current object
"""
=
return
"""Constraints to for the penalty method
Specify the constraints to be treated with the penalty method (that is,
function c(u; p)) and the penalty function, g. If no penalty function
is specified, the quadratic penalty will be used.
Args:
penalty_constraints: a function <code>c(u, p)</code>, of the decision
variable <code>u</code> and the parameter vector <code>p</code>, which
corresponds to the constraints <code>c(u, p)</code>
penalty_function: a function <code>g: R -> R</code>, used to define the
penalty in the penalty method; the default is <code>g(z) = z^2</code>.
You typically will not need to change this, but if you very much want to,
you need to provide an instance of <code>casadi.casadi.Function</code>
(not a CasADi symbol such as <code>SX</code>).
Returns:
self
"""
pass
=
# default penalty function: quadratic
=
=
=
return
"""Not implemented yet"""
# ---------- DIMENSIONS --------------------------------------------
"""Number of decision variables"""
return
"""Number of parameters"""
return
"""Number of penalty-type constraints"""
return 0
"""Not implemented yet"""
return 0
# ---------- OTHER GETTERS -----------------------------------------
"""Cost function as a CaADi symbol"""
return
"""Penalty constraints as a CasADi symbol (function c)"""
return
"""Penalty function, <code>g</code>"""
return
"""Hard constraints"""
return
"""Not implemented yet"""
"""Decision variables (CasADi symbol)"""
return
"""Parameter variables (CasADi symbol)"""
return