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

Fix affine system corner case #223

Merged
merged 6 commits into from
Dec 8, 2020
Merged

Fix affine system corner case #223

merged 6 commits into from
Dec 8, 2020

Conversation

ueliwechsler
Copy link
Collaborator

@ueliwechsler ueliwechsler commented Dec 4, 2020

closes #221

Adding the condition that the stripped system is only parsed as a black-box system, if f is not an addition, multiplication or subtraction.

Copy link
Member

@schillic schillic 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 again only some heuristics.
The following does not work both in master and here.

julia> @system x' = 2 * f(x)
ERROR: ArgumentError: if there is only one term on the right-hand side, the state needs to be contained

src/macros.jl Outdated Show resolved Hide resolved
src/macros.jl Outdated Show resolved Hide resolved
Co-authored-by: Christian Schilling <[email protected]>
@ueliwechsler
Copy link
Collaborator Author

I think this is again only some heuristics.

Yes and no. You could call @system itself a heuristic since we try to catch as many cases as possible. For your example, we would need some kind of recursion in the parsing of the system which we don't have implement.
But this PR is a fix for a case that returned the false system, it corrects an error in the implementation.

It might be worth to gather information on how the @system macro was used in the last year and from this information, discuss how the macro could be refactored. I suspect, there are some features that are not needed and leaving them out could simplify the implementation or enable to implement a structure as discussed in #221.

@@ -139,7 +139,9 @@ end
end

@testset "@system for affine continuous systems" begin
@test @system(x' = A*x + c) == AffineContinuousSystem(A, c)
b = [1.0]
@test @system(x' = x + b) == AffineContinuousSystem(I(1), b)
Copy link
Member

Choose a reason for hiding this comment

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

just checked that the vector form doesn't work (i'll open an issue):

julia> b = rand(10); @system(x' = x + b)
ERROR: AssertionError: checksquare(A) == length(c)
Stacktrace:
 [1] AffineContinuousSystem(::IdentityMultiple{Float64}, ::Array{Float64,1}) at /home/mforets/.julia/dev/MathematicalSystems/src/systems.jl:189
 [2] top-level scope at REPL[4]:1

Copy link
Member

@mforets mforets Dec 8, 2020

Choose a reason for hiding this comment

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

please note that in pple the transformation can be done (without manually specifying dim=10), because the code would generate I(n) wheren=length(b).

Copy link
Collaborator Author

@ueliwechsler ueliwechsler Dec 9, 2020

Choose a reason for hiding this comment

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

I took me too long to figure out, what you meant by pple 😅
Yes, but from my experience it is a bit akward to get the length from the input vector and return it again in a macro.

@mforets mforets merged commit c10f533 into master Dec 8, 2020
@schillic schillic deleted the ueliwechsler/221 branch November 27, 2021 13:37
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.

IVP macro should return affine system
3 participants