Skip to content

Commit 2b809b8

Browse files
authored
Merge pull request #305 from SciML/CJM-docs_quickfix
Cjm docs quickfix
2 parents 2acf74a + 8dcb465 commit 2b809b8

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

docs/src/getting_started.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,28 @@ Here is an outline of the required elements and choices:
1313
## Basic usage
1414

1515
```julia
16-
using DataDrivenDiffEq, ModelingToolkit
16+
using DataDrivenDiffEq, ModelingToolkit, LinearAlgebra
1717

1818
# The function we are trying to find
19-
f(u) = u^2 + 4u + 4
20-
X = f.(1:100) # Generate data
21-
X = reshape(X, length(X), 1) # Reshape into a matrix
22-
19+
f(u) = u.^2 .+ 2.0u .- 1.0
20+
#
21+
X = randn(1, 100)
22+
Y = reduce(hcat, map(f, eachcol(X)))
2323
# Create a problem from the data
24-
problem = DiscreteDataDrivenProblem(X)
24+
problem = DirectDataDrivenProblem(X, Y)
2525

2626
# Choose a basis
27-
@variables u[1:1]
28-
using Symbolics: scalarize
29-
u = scalarize(u)
30-
basis = Basis(monomial_basis(u, 2), u)
27+
@variables u
28+
basis = Basis(monomial_basis([u], 2), [u])
29+
println(basis)
30+
31+
32+
3133

3234
# Solve the problem, using the solver of your choosing
3335
res = solve(problem, basis, STLSQ())
36+
println(res)
37+
println(result(res))
3438
```
3539

3640
## Defining a Problem

src/solution.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ function build_solution(prob::DataDrivenProblem, Ξ::AbstractMatrix, opt::Optimi
189189
retcode = size(Ξ, 2) == size(prob.DX, 1) ? :success : :incomplete
190190
pnew = !isempty(parameters(b)) ? [prob.p; ps] : ps
191191
X = get_target(prob)
192-
Y = res_(prob.X, pnew, prob.t, prob.U)
192+
x, _, t, c = get_oop_args(prob)
193+
Y = res_(x, pnew, t, c)
193194

194195
# Build the metrics
195196
sparsity = norm(Ξ, 0)

0 commit comments

Comments
 (0)