Skip to content

Discrete-time variables are forced to Float64 #3501

Open
@baggepinnen

Description

@baggepinnen

The example below creates a discrete-time system with a boolean discrete-time variable, it fails with

julia> prob = DiscreteProblem(sys, [], (0,10))
ERROR: MethodError: no method matching !(::Float64)
function Model(; name)
    @variables begin
        x(t)::Bool = true
    end
    equations = [
        x(k) ~ !x(k-1)
    ]
    DiscreteSystem(equations, t; name)
end

@mtkbuild sys = Model()
prob = DiscreteProblem(sys, [], (0,10))
sol = solve(prob, FunctionMap())
x = sol[sys.x(k+1)]
@test eltype(x) <: Bool

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions