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

Improve markov function, add mimo support, change api to TimeResponseData#1022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

KybernetikJo
Copy link
Contributor

@KybernetikJoKybernetikJo commentedJul 3, 2024
edited
Loading

This PR adds

  • MIMO support to the markov function and
  • it uses the TimeResponseData Type.
T=np.linspace(0,10,100)U=np.ones((1,100))response=ct.forced_response(ct.tf([1], [1,0.5],True),T,U)H=ct.markov(response,3)

This breaks old user code!
Does not break old user code!

T=np.linspace(0,10,100)U=np.ones((1,100))T,Y=ct.forced_response(ct.tf([1], [1,0.5],True),T,U)H=ct.markov(Y,U,3,transpose=False)

@coveralls
Copy link

Coverage Status

coverage: 94.519% (-0.01%) from 94.533%
when pullingec38f2e on KybernetikJo:improve_markove_mimo
into4acc78b on python-control:main.

@KybernetikJoKybernetikJo marked this pull request as draftJuly 4, 2024 12:03
@coveralls
Copy link

Coverage Status

coverage: 94.519% (-0.01%) from 94.533%
when pulling4c1f4ca on KybernetikJo:improve_markove_mimo
into4acc78b on python-control:main.

@coveralls
Copy link

Coverage Status

coverage: 94.519% (-0.01%) from 94.533%
when pulling446a161 on KybernetikJo:improve_markove_mimo
into4acc78b on python-control:main.

@murrayrm
Copy link
Member

Rather than breaking old code, it would be nice to do this in a way that preserved prior functionality. So use*args processing to allow both of the following to work:

H = ct.markov(response, 3)H = ct.markov(Y, U, 3)

It also seems a bit odd (to me) to have the return type be aTimeResponseData object. It true that the Markov parameters are the impulse response, but are people going to be plotting that impulse response as the primary way they interact with the output of themarkov command?

@KybernetikJo
Copy link
ContributorAuthor

Rather than breaking old code, it would be nice to do this in a way that preserved prior functionality. So use*args processing to allow both of the following to work:

H = ct.markov(response, 3)H = ct.markov(Y, U, 3)

I will update this one.

It also seems a bit odd (to me) to have the return type be aTimeResponseData object. It true that the Markov parameters are the impulse response, but are people going to be plotting that impulse response as the primary way they interact with the output of themarkov command?

I do not have strong feelings about that. The idea was to simplify the joint use of markov and era:

impulse_response=ct.markov(response,m=10)sysd=ct.era(impulse_response,r=4)

Direct access of Markov parameters:

_,H=ct.markov(response,m=10)

I can change the return value to an array. I think it is also better for the old API.
I guess I should also keep the old API for era.

H=ct.markov(Y,U,m=10)sysd=ct.era(H,r=4)

@coveralls
Copy link

Coverage Status

coverage: 94.538% (+0.005%) from 94.533%
when pulling317d261 on KybernetikJo:improve_markove_mimo
into4acc78b on python-control:main.

@coveralls
Copy link

Coverage Status

coverage: 94.516% (-0.02%) from 94.533%
when pulling2b1cd21 on KybernetikJo:improve_markove_mimo
into4acc78b on python-control:main.

@coveralls
Copy link

Coverage Status

coverage: 94.516% (-0.02%) from 94.533%
when pullingcee59d1 on KybernetikJo:improve_markove_mimo
into4acc78b on python-control:main.

@coveralls
Copy link

coveralls commentedJul 11, 2024
edited
Loading

Coverage Status

coverage: 94.669% (+0.04%) from 94.629%
when pullinge61ac53 on KybernetikJo:improve_markove_mimo
intoda64e0e on python-control:main.

@KybernetikJoKybernetikJo marked this pull request as ready for reviewJuly 11, 2024 13:25
Copy link
Member

@murrayrmmurrayrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Overall this looks OK. It would be good to add unit tests to cover some of thelines that are not currently covered.

"""markov(Y, U, [, m])

Calculate the first `m` Markov parameters [D CB CAB ...]
from data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should end in a period.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done.

if Umat.shape[0] != 1 or Ymat.shape[0] != 1:
raise ControlMIMONotImplemented
# Get the system description
if (len(args) < 1):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Parenthesis are not needed here. The more standard style convention would be

if len(args) < 1:

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done.

elif (len(args) > 2):
raise ControlArgument("too many positional arguments")
else:
if (len(args) < 2):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

OK to remove parens (here and below).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done.

dt : True of float, optional
True indicates discrete time with unspecified sampling time,
positive number is discrete time with specified sampling time.It
can be used to scale the markov parameters in order to match the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Markov should be capitalized.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done.

Comment on lines 447 to 450
dt : True of float, optional
True indicates discrete time with unspecified sampling time,
positive number is discrete time with specified sampling time.It
can be used to scale the markov parameters in order to match the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In the case that a TimeResponseData object is given, shoulddt default to the value coming from the time array? You could set the default value ofdt toNone and then if the input isY, U then you default todt=1 and the input is data, you default todata.time[1] - data.time[0] (perhaps with a check to make sure that time points are equally spaced?).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done.

@murrayrmmurrayrm merged commit9809a78 intopython-control:mainAug 6, 2024
23 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@murrayrmmurrayrmAwaiting requested review from murrayrm

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
0.10.1
Development

Successfully merging this pull request may close these issues.

3 participants
@KybernetikJo@coveralls@murrayrm

[8]ページ先頭

©2009-2025 Movatter.jp