Skip to content

Commit

Permalink
Update problem constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
bjack205 committed Apr 9, 2022
1 parent c280cbb commit 7632b40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ function Problem(models::Vector{<:DiscreteDynamics}, obj::O, x0::AbstractVector,
if dt isa Real
dt = fill(dt,N)
end
@assert sum(dt[1:N-1]) tf "Time steps are inconsistent with final time"
@assert sum(dt[1:N-1]) tf - t0 "Time steps are inconsistent with final time"
if X0 isa AbstractMatrix
X0 = [X0[:,k] for k = 1:size(X0,2)]
end
if U0 isa AbstractMatrix
U0 = [U0[:,k] for k = 1:size(U0,2)]
end
Z = SampledTrajectory{Nx,Nu}(X0,U0,dt=dt)
RD.setinitialtime!(Z, t0)

Problem(models, obj, constraints, MVector{nx[1]}(x0), MVector{nx[end]}(xf),
Z, N, t0, tf)
Expand Down
2 changes: 1 addition & 1 deletion test/hybrid_dynamics_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ models = [
jumpmap
[copy(model2) for k = 1:4];
]
eltype(models) isa UnionAll
@test eltype(models) isa UnionAll
models2 = [copy(model1) for k = 1:10]
nx, nu = RD.dims(models)
@test nx == [4,4,4,4,4, 4, 2,2,2,2,2]
Expand Down

0 comments on commit 7632b40

Please sign in to comment.