# How to bring differential equations to wanted value with DiffEqFlux?

I modified as you suggested, but how do I write the solver?

``````julia> condition1(u, t, integrator) = t==integrator.p[4]         ###
condition1 (generic function with 1 method)
julia> affect1!(integrator) = integrator.u[3] += integrator.p[5] ###
affect1! (generic function with 1 method)
julia> cb1 = DiscreteCallback(condition1, affect1!)
DiscreteCallback{typeof(condition1),typeof(affect1!),typeof(DiffEqBase.INITIALIZE_DEFAULT),typeof(DiffEqBase.FINALIZE_DEFAULT)}(condition1, affect1!, DiffEqBase.INITIALIZE_DEFAULT, DiffEqBase.FINALIZE_DEFAULT, Bool[1, 1])
...
julia> prob = ODEProblem(growth!, u0, tspan, parms)
ODEProblem with uType Array{Float64,1} and tType Float64. In-place: true
timespan: (0.0, 4000.0)
u0: [1.0e7, 0.0, 0.0]

julia> EnsembleProblem(prob;
output_func = (sol,i) -> (sol,false),
prob_func= (prob,i,repeat)->(prob),
reduction = (u,data,I)->(append!(u,data),false),
u_init = [], safetycopy = prob_func !== DEFAULT_PROB_FUNC)
ERROR: UndefVarError: prob_func not defined
Stacktrace:
[1] top-level scope at none:1

ERROR: UndefVarError: ensembleprob not defined
Stacktrace:
[1] top-level scope at none:1
``````

Here I think the problem is that I do not need `prob_func` but simply pass an array with the values to test for both p[4] and p[5]… How would I do that? Thanks

Don’t copy the kwargs.

I tried with:

``````julia> prob = ODEProblem(growth!, u0, tspan, parms)
ODEProblem with uType Array{Float64,1} and tType Float64. In-place: true
timespan: (0.0, 4000.0)
u0: [1.0e7, 0.0, 0.0]

julia> EnsembleProblem(prob;
output_func = (sol,i) -> (sol,false),
reduction = (u,data,I)->(append!(u,data),false))
EnsembleProblem with problem ODEProblem

retcode: Success
Interpolation: automatic order switching interpolation
t: 33-element Array{Float64,1}:
0.0
0.15303314059544662
...
``````

Looks like it starts to work… Thank you

1 Like

An update: the process did not crash, but how should it be interpreted? I `soln` is a dataframe of 3 columns and 33 rows. Where do all the combinations come into play? If I do `EnsembleSummary(soln)` I get the error:

``````┌ Warning: `MonteCarloSummary(args...)` is deprecated, use `EnsembleSummary(args...)` instead.
│   caller = ip:0x0
└ @ Core :-1
``````

and then the core stops the execution after few hours. The plot of `soln` columns gives:

How shall I read the results from EnsembleProblem? Thanks

I have no idea what the question is. Start a new thread with an MWE.