@@ -280,14 +280,20 @@ function _parse_system(exprs::NTuple{N, Expr}) where {N}
280
280
dynamic_equation = stripped
281
281
state_var = subject
282
282
AT = abstract_system_type
283
- # if the system has the structure x_ = A_*x_ + B_*u_ ,
284
- # handle u_ as input variable
283
+ # if the stripped system has the structure x_ = A_*x_ + B_*u_ or
284
+ # one of the other patterns, handle u_ as input variable
285
285
if @capture (stripped, (x_ = A_* x_ + B_* u_) |
286
286
(x_ = x_ + B_* u_) |
287
287
(x_ = A_* x_ + B_* u_ + c_) |
288
288
(x_ = x_ + B_* u_ + c_) |
289
289
(x_ = f_ (x_, u_)) )
290
- input_var = u
290
+ if (f == :+ ) || (f == :- ) || (f == :* )
291
+ # pattern x_ = f_(x_, u_) also catches the cases:
292
+ # x_ = x_ + u_, x_ = x_ - u_ and x_ = x_*u_
293
+ # where u_ doesn't necessarily need to be the input
294
+ else
295
+ input_var = u
296
+ end
291
297
end
292
298
293
299
elseif @capture (ex, (dim = (f_dims_)) | (dims = (f_dims_)))
@@ -407,14 +413,13 @@ function extract_dyn_equation_parameters(equation, state, input, noise, dim, AT)
407
413
rhs = rhscode
408
414
end
409
415
410
- # if rhs is a sum, => affine system which is controlled, noisy or both
416
+ # if rhs is parsed as addition => affine system which is controlled, noisy or both
411
417
if @capture (rhs, A_ + B__)
412
418
# parse summands of rhs and add * if needed
413
419
summands = add_asterisk .([A, B... ], Ref (state), Ref (input), Ref (noise))
414
420
push! (rhs_params, extract_sum (summands, state, input, noise)... )
415
-
416
- # If rhs is function call => black-box system
417
- elseif @capture (rhs, f_ (a__)) && f != :(* ) && f != :(- )
421
+ # if rhs is a function call except `*` or `-` => black-box system
422
+ elseif @capture (rhs, f_ (a__)) && f != :(* ) && f != :(- )
418
423
# the dimension argument needs to be a iterable
419
424
(dim == nothing ) && throw (ArgumentError (" for a blackbox system, the dimension has to be defined" ))
420
425
dim_vec = [dim... ]
0 commit comments