Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

About the "horizon" parameter in the solve_ocp() method #782

Closed
Assignees
murrayrm
Labels
Milestone
@zhengzl18

Description

@zhengzl18

Discussed in#781

Originally posted byzhengzl18 October 17, 2022
Hi,
I'm running the example code of theoptimal module:https://python-control.readthedocs.io/en/0.9.2/optimal.html#example
When calling thesolve_ocp method, a parameter called "horizon" is required:

horizon = np.linspace(0, Tf, 3, endpoint=True)result = opt.solve_ocp(    vehicle, horizon, x0, traj_cost, constraints,    terminal_cost=term_cost, initial_guess=u0)

In this setting, it works just fine.

But when I tried to change the horizon into something like (changing nothing but the number of points in the linspace):

horizon = np.linspace(0, Tf, 4, endpoint=True)

the result seemed to be extremely strange, with the inputs u always remaining the same:

Summary statistics:* Cost function calls: 9* Constraint calls: 20* System simulations: 27* Final cost: 16000.0    cost: 16000.0     fun: 16000.0  inputs: array([[10., 10., 10., 10.],       [ 0.,  0.,  0.,  0.]])     jac: array([ 0.00000000e+00,  2.44140625e-04,  1.22070312e-04,  0.00000000e+00,       -3.62099047e+06, -6.84054738e+06, -2.12256850e+06, -7.49211857e+05]) message: 'Optimization terminated successfully'    nfev: 9     nit: 5    njev: 1 problem: <control.optimal.OptimalControlProblem object at 0x7ff0cb281df0>  states: array([[  0.        ,  33.33333333,  66.66666667, 100.        ],       [ -2.        ,  -2.        ,  -2.        ,  -2.        ],       [  0.        ,   0.        ,   0.        ,   0.        ]])  status: 0 success: True    time: array([ 0.        ,  3.33333333,  6.66666667, 10.        ])       x: array([10., 10., 10., 10.,  0.,  0.,  0.,  0.])

It's the case for allnum except 3 in the np.linspace(0, Tf, num).

I'm confused by this results and wonder what's the actual use of 'horizon'? (I do notice from the comments that it's a "List of times at which the optimal input should be computed", but I still can't understand)

Hope for any help.

Thanks!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp