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

Linear Model Type #7

Merged
merged 17 commits into from
Sep 21, 2020
Merged

Linear Model Type #7

merged 17 commits into from
Sep 21, 2020

Conversation

bjack205
Copy link
Member

This PR adds the LinearModel type, as well as a LinearizedModel type useful for linearizing a nonlinear model.

Copy link
Member Author

@bjack205 bjack205 left a comment

Choose a reason for hiding this comment

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

I think this is really close. I'd like to clean up the linearization/discretization methods.

I think it may also be a good idea to have a simple AbstractLinearModel that both LinearizedModel and LinearModel inherit from, just so you can easily cover both with a single dispatch, since they are nearly identical in practice.

@assert is_timevarying(model.linmodel) == true
@assert get_times(trajectory) == (model.linmodel.times)

if is_timevarying(model.linmodel)
Copy link
Member Author

Choose a reason for hiding this comment

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

This check is redundant given your previous assertion that it is time-varying


Linearize `nonlinear_model` about `trajectory` and discretize with given integration type `Q`. Returns a [`LinearizedModel`](@ref)
"""
function linearize_and_discretize(::Type{Q}, nonlinear_model::AbstractModel, trajectory::AbstractTrajectory; is_affine=false) where {Q<:Explicit}
Copy link
Member Author

Choose a reason for hiding this comment

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

Can we simplify these methods to an interface similar to LinearModel? I think it would make sense to have a powerful LinearizedModel constructor that handles continuous/discrete, affine/non-affine, and then have an update_reference!(model, Z) that re-linearized the model about the updated reference trajectory Z (could be a single KnotPoint).

@tpunnoose
Copy link
Contributor

AbstractLinearModel

I agree that it could be nice to have an AbstractLinearModel supertype, it really seems you only really want to access the linmodel field of LinearizedModel when you use call a LinearModel method anyways. It seemed cleaner to just to create a few functions to do this.

@bjack205 bjack205 merged commit 1bc8d6a into master Sep 21, 2020
@bjack205 bjack205 deleted the linmodel_type branch September 21, 2020 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants