|  | 
|  | 1 | +@fallback_iip_specialize function SciMLBase.ImplicitDiscreteFunction{iip, spec}( | 
|  | 2 | +        sys::System, _d = nothing, u0 = nothing, p = nothing; | 
|  | 3 | +        t = nothing, eval_expression = false, eval_module = @__MODULE__, | 
|  | 4 | +        checkbounds = false, analytic = nothing, simplify = false, cse = true, | 
|  | 5 | +        initialization_data = nothing, check_compatibility = true, kwargs...) where { | 
|  | 6 | +        iip, spec} | 
|  | 7 | +    check_complete(sys, ImplicitDiscreteFunction) | 
|  | 8 | +    check_compatibility && check_compatible_system(ImplicitDiscreteFunction, sys) | 
|  | 9 | + | 
|  | 10 | +    iv = get_iv(sys) | 
|  | 11 | +    dvs = unknowns(sys) | 
|  | 12 | +    ps = parameters(sys) | 
|  | 13 | +    f = generate_rhs(sys, dvs, ps; expression = Val{false}, implicit_dae = true, | 
|  | 14 | +        eval_expression, eval_module, checkbounds = checkbounds, cse, | 
|  | 15 | +        kwargs...) | 
|  | 16 | + | 
|  | 17 | +    if spec === SciMLBase.FunctionWrapperSpecialize && iip | 
|  | 18 | +        if u0 === nothing || p === nothing || t === nothing | 
|  | 19 | +            error("u0, p, and t must be specified for FunctionWrapperSpecialize on ImplicitDiscreteFunction.") | 
|  | 20 | +        end | 
|  | 21 | +        f = SciMLBase.wrapfun_iip(f, (u0, u0, u0, p, t)) | 
|  | 22 | +    end | 
|  | 23 | + | 
|  | 24 | +    observedfun = ObservedFunctionCache( | 
|  | 25 | +        sys; steady_state = false, eval_expression, eval_module, checkbounds, cse) | 
|  | 26 | + | 
|  | 27 | +    ImplicitDiscreteFunction{iip, spec}(f; | 
|  | 28 | +        sys = sys, | 
|  | 29 | +        observed = observedfun, | 
|  | 30 | +        analytic = analytic, | 
|  | 31 | +        initialization_data) | 
|  | 32 | +end | 
|  | 33 | + | 
|  | 34 | +@fallback_iip_specialize function SciMLBase.ImplicitDiscreteProblem{iip, spec}( | 
|  | 35 | +        sys::System, u0map, tspan, parammap = SciMLBase.NullParameters(); | 
|  | 36 | +        check_compatibility = true, kwargs...) where {iip, spec} | 
|  | 37 | +    check_complete(sys, ImplicitDiscreteProblem) | 
|  | 38 | +    check_compatibility && check_compatible_system(ImplicitDiscreteProblem, sys) | 
|  | 39 | + | 
|  | 40 | +    dvs = unknowns(sys) | 
|  | 41 | +    u0map = to_varmap(u0map, dvs) | 
|  | 42 | +    u0map = shift_u0map_forward(sys, u0map, defaults(sys)) | 
|  | 43 | +    f, u0, p = process_SciMLProblem( | 
|  | 44 | +        ImplicitDiscreteFunction{iip, spec}, sys, u0map, parammap; | 
|  | 45 | +        t = tspan !== nothing ? tspan[1] : tspan, check_compatibility, kwargs...) | 
|  | 46 | + | 
|  | 47 | +    kwargs = process_kwargs(sys; kwargs...) | 
|  | 48 | +    # Call `remake` so it runs initialization if it is trivial | 
|  | 49 | +    return remake(ImplicitDiscreteProblem{iip}(f, u0, tspan, p; kwargs...)) | 
|  | 50 | +end | 
|  | 51 | + | 
|  | 52 | +function check_compatible_system( | 
|  | 53 | +        T::Union{Type{ImplicitDiscreteFunction}, Type{ImplicitDiscreteProblem}}, sys::System) | 
|  | 54 | +    check_time_dependent(sys, T) | 
|  | 55 | +    check_not_dde(sys) | 
|  | 56 | +    check_no_cost(sys, T) | 
|  | 57 | +    check_no_constraints(sys, T) | 
|  | 58 | +    check_no_jumps(sys, T) | 
|  | 59 | +    check_no_noise(sys, T) | 
|  | 60 | +    check_is_discrete(sys, T) | 
|  | 61 | +    check_is_implicit(sys, T, DiscreteProblem) | 
|  | 62 | +end | 
0 commit comments