-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add-goddardrocket #183
base: main
Are you sure you want to change the base?
Add-goddardrocket #183
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @indyalardjane for the PR!
Here is a first batch of comments.
src/ADNLPProblems/goddardrocket.jl
Outdated
return constraints | ||
|
||
end | ||
Δt = T(1/(n-1)) # Indya, ce n'est pas 1/(n-1) à la place ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Δt = T(1/(n-1))
src/ADNLPProblems/goddardrocket.jl
Outdated
|
||
end | ||
|
||
function constraints(X :: Vector{S}) where {S} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function constraints(x)
S = eltype(x)
will give more flexibility
src/ADNLPProblems/goddardrocket.jl
Outdated
T_max = T(3.5 * g_0 * m_0) # maximal rocket thrust | ||
D_c = T(1/2 * v_c * (m_0/g_0)) # Drag scaling | ||
|
||
function Objective(X :: Vector{S}) where {S} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function f(x)
S = eltype(x)
will give more flexibility
src/ADNLPProblems/goddardrocket.jl
Outdated
@@ -0,0 +1,82 @@ | |||
using ADNLPModels, NLPModels, NLPModelsIpopt, DataFrames, LinearAlgebra, Distances, SolverCore, Plots |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the using
for the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of additional comments. Could you remove the two minimalsurface.jl files?
lcon = zeros(T, 3 * n) | ||
ucon = T[i ≤ 2n ? T(Inf) : ( T(m_0 - m_f)) for i=1:3n] | ||
|
||
return ADNLPModel(f, X0, lvar, uvar, constraints, lcon, ucon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest you use a lowercase x
and x0
everywhere.
return ADNLPModel(f, X0, lvar, uvar, constraints, lcon, ucon) | |
return ADNLPModels.ADNLPModel(f, x0, lvar, uvar, constraints, lcon, ucon) |
m[k] = S(m[k - 1] - Δt * X[k - 1] / c) # update mass vector | ||
v[k] = S(v[k - 1] + Δt *((X[k - 1] - D[k - 1]) / m[k - 1] - g[k - 1])) # update speed vector | ||
h[k] = S(h[k - 1] + Δt * v[k - 1]) # update height vector | ||
D[k] = S(D_c*(v[k]^2)*exp(-h_c*(h[k]-h_0)/h_0)) # update drag vector | ||
g[k] = S(g_0*(h_0/h[k])^2) # update gravity vector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the S(
as we should not convert the variable X
within a constraint or objective function
for k=2:n | ||
m[k] = S(m[k - 1] - Δt * X[k - 1] / c) | ||
v[k] = S(v[k - 1] + Δt *((X[k - 1] - D[k - 1]) / m[k - 1] - g[k - 1])) | ||
h[k] = S(h[k - 1] + Δt * v[k - 1]) | ||
D[k] = S(D_c*(v[k]^2)*exp(-h_c*(h[k]-h_0)/h_0)) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above. If it is exactly the same lines of code, maybe you should have it in a function?
@indyalardjane It looks like there are still a few comments to address here, please. |
No description provided.