@@ -101,9 +101,6 @@ def plot_results(t, y, u, figure=None, yf=None):
101
101
# distance form the desired final point while at the same time as not
102
102
# exerting too much control effort to achieve our goal.
103
103
#
104
- # Note: depending on what version of SciPy you are using, you might get a
105
- # warning message about precision loss, but the solution is pretty good.
106
- #
107
104
print ("Approach 1: standard quadratic cost" )
108
105
109
106
# Set up the cost functions
@@ -126,11 +123,8 @@ def plot_results(t, y, u, figure=None, yf=None):
126
123
start_time = time .process_time ()
127
124
result1 = opt .solve_ocp (
128
125
vehicle , horizon , x0 , quad_cost , initial_guess = bend_left , log = True ,
129
- # solve_ivp_kwargs={'atol': 1e-2, 'rtol': 1e-2},
130
- # solve_ivp_kwargs={'method': 'RK23', 'atol': 1e-2, 'rtol': 1e-2},
131
126
minimize_method = 'trust-constr' ,
132
127
minimize_options = {'finite_diff_rel_step' : 0.01 },
133
- # minimize_options={'eps': 0.01}
134
128
)
135
129
print ("* Total time = %5g seconds\n " % (time .process_time () - start_time ))
136
130
@@ -171,7 +165,6 @@ def plot_results(t, y, u, figure=None, yf=None):
171
165
result2 = opt .solve_ocp (
172
166
vehicle , horizon , x0 , traj_cost , constraints , terminal_cost = term_cost ,
173
167
initial_guess = bend_left , log = True ,
174
- # solve_ivp_kwargs={'atol': 1e-4, 'rtol': 1e-2},
175
168
minimize_method = 'SLSQP' , minimize_options = {'eps' : 0.01 })
176
169
print ("* Total time = %5g seconds\n " % (time .process_time () - start_time ))
177
170
@@ -191,13 +184,13 @@ def plot_results(t, y, u, figure=None, yf=None):
191
184
# with a terminal *constraint* on the state. If a solution is found,
192
185
# it guarantees we get to exactly the final state.
193
186
#
194
- # To speeds things up a bit, we initalize the problem using the previous
195
- # optimal controller (which didn't quite hit the final value).
196
- #
197
187
print ("Approach 3: terminal constraints" )
198
188
199
189
# Input cost and terminal constraints
190
+ R = np .diag ([1 , 1 ]) # minimize applied inputs
200
191
cost3 = opt .quadratic_cost (vehicle , np .zeros ((3 ,3 )), R , u0 = uf )
192
+ constraints = [
193
+ opt .input_range_constraint (vehicle , [8 , - 0.1 ], [12 , 0.1 ]) ]
201
194
terminal = [ opt .state_range_constraint (vehicle , xf , xf ) ]
202
195
203
196
# Reset logging to its default values
@@ -209,10 +202,10 @@ def plot_results(t, y, u, figure=None, yf=None):
209
202
start_time = time .process_time ()
210
203
result3 = opt .solve_ocp (
211
204
vehicle , horizon , x0 , cost3 , constraints ,
212
- terminal_constraints = terminal , initial_guess = u2 , log = False ,
213
- solve_ivp_kwargs = {'atol' : 1e-4 , 'rtol' : 1e-2 },
214
- # solve_ivp_kwargs={'method': 'RK23', 'atol': 1e-4, 'rtol': 1e-2} ,
215
- minimize_options = { 'eps' : 0.01 } )
205
+ terminal_constraints = terminal , initial_guess = bend_left , log = False ,
206
+ solve_ivp_kwargs = {'atol' : 1e-3 , 'rtol' : 1e-2 },
207
+ minimize_method = 'trust-constr' ,
208
+ )
216
209
print ("* Total time = %5g seconds\n " % (time .process_time () - start_time ))
217
210
218
211
# If we are running CI tests, make sure we succeeded
@@ -241,12 +234,12 @@ def plot_results(t, y, u, figure=None, yf=None):
241
234
vehicle , horizon , x0 , quad_cost ,
242
235
constraints ,
243
236
terminal_constraints = terminal ,
244
- initial_guess = u3 ,
237
+ initial_guess = bend_left ,
245
238
basis = flat .BezierFamily (4 , T = Tf ),
246
- solve_ivp_kwargs = {'method' : 'RK45' , 'atol' : 1e-2 , 'rtol' : 1e-2 },
239
+ # solve_ivp_kwargs={'method': 'RK45', 'atol': 1e-2, 'rtol': 1e-2},
240
+ solve_ivp_kwargs = {'atol' : 1e-3 , 'rtol' : 1e-2 },
247
241
minimize_method = 'trust-constr' , minimize_options = {'disp' : True },
248
5334
- # method='SLSQP', options={'eps': 0.01}
249
- log = True
242
+ log = False
250
243
)
251
244
print ("* Total time = %5g seconds\n " % (time .process_time () - start_time ))
252
245
0 commit comments