Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Periodic input iterators #17

Open
mforets opened this issue Mar 10, 2018 · 2 comments
Open

Periodic input iterators #17

mforets opened this issue Mar 10, 2018 · 2 comments
Labels

Comments

@mforets
Copy link
Member

mforets commented Mar 10, 2018

In #15 we implement either constant or varying input iterators. An abstraction of an infinitely periodic input could be useful, and maybe it can be implemented by combining Base.IsInfinite() with an AbstractVector field.

@ueliwechsler
Copy link
Collaborator

Not sure, if I understand the concept and the usage of Input in MathematicalSystems, but I implemented a periodic input in my MPC package something like this:

# TODO:  make immutable (with Ref)
using TreeViews
using Crayons

mutable struct FixedInput{MT<:AbstractMatrix} <: AbstractController
    U::MT
    n::Integer
    k::Integer
end

function control_input(ctrl::FixedInput)
    u = ctrl.U[:, mod(ctrl.k, ctrl.n) + 1]
    ctrl.k += 1
    return u
end

This would be used as

U = [1 2;
     1 2]
input = FixedInput(U, 10, 0)
u1 = control_input(input) # [1, 1]
u2 = control_input(input) # [2, 2]
u3 = control_input(input) # [1, 1]

Maybe this idea can be of use.

@mforets
Copy link
Member Author

mforets commented Feb 11, 2020

Not sure, if I understand the concept and the usage of Input in MathematicalSystems,

We can probably improve the docs, I've commented here. The idea is that this type models an input to a system and it can be iterated over; the concrete interpretation is left for downstream packages. Very much like in your example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants