-
Notifications
You must be signed in to change notification settings - Fork 6
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
IVP macro should return affine system #221
Comments
This at least works @system(x' = x + b, input=u)
AffineContinuousSystem{Float64,IdentityMultiple{Float64},Array{Float64,1}}([1.0], [1.0]) So it has to interpret |
Ah wow a really interesting "feature" of the implementation 😅
So maybe just add a condition here to not allow MathematicalSystems.jl/src/macros.jl Lines 285 to 291 in 80abafb
|
Very neat! Yesterday I thought it would be more involved, but you are right, maybe we just have to add one new condition in line 289, ie. be sure that |
I am surprised that this case is not captured by any test.
Are there any other corner cases that are not working? Or should be added to the tests? |
Nice! There is no rush. I think adding unit tests as you propose is more than enough.
Do you mean for this issue? (I think the answer is no, at least we haven't found more cases). On the other hand, there are some open issues related to the macros. I will now create a new label |
Exactly.
I am (was) working on these issues on my holidays. There are two branches still open, that I have to make a PR from, that solve some of the issues. I hope to come back to them once I have a bit more time. |
The fix works for the example. But every time I tried to fix something, I figure out that there are more corner cases that are not caught by the logic or ar have not a clean implementation. MathematicalSystems.jl/src/macros.jl Lines 411 to 414 in 80abafb
For example here, we do not consider minus signs which is why the following does not work: julia> @system(x' = x - [1.0])
ERROR: ArgumentError: the entry () does not match a `MathematicalSystems.jl` structure Additionally, the expression |
The Maybe we should think about the inner workings of the macros without breaking the existing coverage, with the aim of making them easier to fix corner cases and to create new use cases. I'm not sure how, but an idiomatic way may be to have a mechanism that lets you define system's patterns (*) and a dictionary of registered patterns to which to compare the expression given by the user. (*) for example |
The idea is that if I want that register(expr=:(M*x'' + C*x' + K*x = 0), vars=:x, fields=(:M, :C, :K), target=SecondOrderLinearContinuousSystem)
register(expr=:(M*x'' + K*x = 0), vars=:x, fields=(:M, :zeros(...), :K), target=SecondOrderLinearContinuousSystem)
# other cases... |
I agree with you. It is too much work to extent / adjust the current source code of I like your proposed idea, it looks quite clean and extendable. However, it is not clear to me, if it is easier to implement this. We might have the same problem in the end. Maybe the flexibility of the macro should be limited. E.g. the equations need to have I am afraid, I will most likely not have a lot of time to help to refactor the macro in the next months. But to add to your idea: What about having a check at the beginning of the |
Concerning your idea and the second order system, I played a bit around and it might be not too difficult to do it, if we can figure out how to parse expressions to the I did achieve the following:
with the idea outlined in the post before. See the source code here: MathematicalSystems.jl/src/macros.jl Lines 886 to 889 in 4bce55c
|
If this is a problem I'm fine with removing that feature (or keep it but in some other way, like with a global option). |
Reopening as there are some ideas left in this thread. The second order system construction is nice, I opened a draft PR #225 . I'll play with it. |
Even though I like the feature, I think it is not worth to keep it around in a second iteration. Since it introduces "non-mathematical" parsing pattern and therefore does not generalize well. |
The answer is OK but I would expect an
AffineContinuousSystem
instead. This way we can use the type information to know that the affine term is a singleton (and notBu(t)
as in the LCCS which is much more general).The text was updated successfully, but these errors were encountered: