From 137cd4231fc001041ecf4830ccbf88c6d3c9f843 Mon Sep 17 00:00:00 2001 From: schillic Date: Wed, 3 Jan 2024 15:59:55 +0100 Subject: [PATCH] parse black-box system with variable dimension --- src/macros.jl | 6 +++++- test/@system.jl | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/macros.jl b/src/macros.jl index 3c8eb72e..5912a843 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -422,7 +422,11 @@ function extract_dyn_equation_parameters(equation, state, input, noise, dim, AT) # the dimension argument needs to be a iterable isnothing(dim) && throw(ArgumentError("for a blackbox system, the dimension has to be defined")) - dim_vec = [dim...] + if dim isa Symbol + dim_vec = [dim] + else + dim_vec = [dim...] + end push!(rhs_params, extract_blackbox_parameter(rhs, dim_vec)...) # if rhs is a single term => affine system (e.g. A*x, Ax, 2x, x or 0) diff --git a/test/@system.jl b/test/@system.jl index d21165ca..4225ea6d 100644 --- a/test/@system.jl +++ b/test/@system.jl @@ -188,6 +188,10 @@ end # allow for arbitrary input with definition for rhs of the form f_(x_, u_) sys = @system(x' = f1(x, u123), x ∈ X, u123 ∈ U, dims = (2, 3)) @test sys == ConstrainedBlackBoxControlContinuousSystem(f1, 2, 3, X, U) + # parametric dimension + n = 3 + sys = @system(x' = f1(x), dim:n) + @test sys == BlackBoxContinuousSystem(f1, 3) end # ==================