Coder Social home page Coder Social logo

nloptcontrol.jl's Introduction

NLOptControl.jl

Build Status travis

This software solves nonlinear control problems at a high-level very quickly.

Adds to juliaOpt community by:

  • Providing an implementation of direct-collocation methods for solving optimal control problems in julia
  • Solving nonlinear optimal control problems at a high-level
  • Visualizing the solution

Documentation

Stable Latest

Installation

If you are using Linux make sure that you have gfortran to run Ipopt:

sudo apt-get update
sudo apt-get install gfortran
sudo apt-get install liblapack-dev
sudo apt-get install libblas-dev

Also, make sure that you are using at least julia 1.0.0

Then open up julia and install NLOptControl

Pkg.add("https://github.com/JuliaMPC/NLOptControl.jl")
Pkg.pin("KNITRO",v"0.4")
Pkg.clone("https://github.com/JuliaMPC/NLOptControl.jl")

Citation

If you find NLOptControl.jl useful, please cite it:

@software{nlopt,
  author = {{Huckleberry Febbo}},
  title = {NLOptControl.jl},
  url = {https://github.com/JuliaMPC/NLOptControl.jl},
  version = {0.0.1},
  date = {2017-06-17},
}

Acknowledgements

  • JuMP.jl is an important part of this NLOptControl.jl and discussions with Miles Lubin where helpful
  • Chris Rackauckas is a very helpful member of the julia community and has provided me support and advice multiple times his software DifferentialEquations.jl is also part of NLOptControl.jl

nloptcontrol.jl's People

Contributors

alexjbuck avatar chrisrackauckas avatar huckl3b3rry87 avatar mfalt avatar quantumbits avatar tkelman avatar tulgaersal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nloptcontrol.jl's Issues

enabling scaling of the states and controls

I am developing functionality to enable the user to easily scale the states and control variables inside the NLP - scaling affects convergence, numerical conditioning, and termination tests.

A preliminary version of of this functionality in NLOptControl enables this, however, several of the tests are breaking.

Consider the example:

using NLOptControl
BrysonDenham_EXP=[:(x2[j]),:(u1[j])]; L=1/6;
integrationConfig = :trapezoidal 
n=define(numStates=2,numControls=1,X0=[0.,1],XF=[0.,-1.],XL=[0.,NaN],XU=[L,NaN]);
dynamics!(n,BrysonDenham_EXP)
configure!(n;(:integrationScheme=>integrationConfig),(:finalTimeDV=>false),(:tf=>1.0));
obj=integrate!(n,:(0.5*u1[j]^2));
@NLobjective(n.ocp.mdl,Min,obj);
optimize!(n);
@show n.r.ocp.dfsOpt[:tSolve]
@show 4/(9*L)
@show n.r.ocp.objVal[1]

Before this commit , the objective function values were very close and tests where passing and the solution looks like this
before

However, after turning the variables into @NLexpression()s so they can be used later with the scaling factor, which is set to one for this example, the trajectory looks like this

jump

I am having trouble figuring out why this is happening. It only happens when I change

 n.r.ocp.x = x

To

  n.r.ocp.x = Matrix{Any}(n.ocp.state.pts,n.ocp.state.num)
  for st in 1:n.ocp.state.num
      n.r.ocp.x[:,st] = @NLexpression(n.ocp.mdl, [j=1:n.ocp.state.pts], n.ocp.XS[st]*x[j,st])
  end

and the same type of change for the control variable.

and then

function DiffEq(n::NLOpt,x::Array{JuMP.Variable,2},u::Array{JuMP.Variable,2},L::Int64,st::Int64)

to

function DiffEq(n::NLOpt,x::Array{Any,2},u::Array{Any,2},L::Int64,st::Int64)

and finally

function addCon(n::NLOpt,x::Array{Any,2},u::Array{Any,2},L::Int64,num::Int64)

to

function addCon(n::NLOpt,x::Array{JuMP.Variable,2},u::Array{JuMP.Variable,2},L::Int64,num::Int64)

So, effectively, I am creating a whole bunch of new @NLexpression()s and then nesting them. I know that this is not a very elegant solution, but I cannot understand the problem.

@tkelman or @ChrisRackauckas or @mlubin @blegat

I know that this is likely confusing thing, but if any of you mind taking a look to see if you can figure out what I am doing wrong, I would greatly appreciate it.

Thanks!

Starting point for optimization

We're currently working on feeding a solution to the solver to avoid local minimum, I checked the documentation, but I didn't find where to change it.

Thanks for your help

How to use the "saveData(n)" function

This is my code. The first task from the tutorial "Brachistochrona".
using NLOptControl
using DataFrames, IndexedTables
using StatsPlots
using CSV
X0=[0.0,0.0,0.0]
XF=[2.,-2.,NaN]
n=define(numStates=3,numControls=1,X0=X0,XF=XF,XL=[0.0,-2.,NaN],XU=[2.,0.,NaN])
states!(n,[:x,:y,:v],descriptions=["x(t)","y(t)","v(t)"]);
controls!(n,[:u],descriptions=["u(t)"]);
typeof(n.r.ocp.x)
typeof(n.r.ocp.u)
dx=Array{Expr}(undef,3);
dx[1] = :(v[j]*sin(u[j]))
dx[2] = :(-v[j]cos(u[j]))
dx[3] = :(9.81
cos(u[j]))
dynamics!(n,dx)
typeof(n.r.ocp.x)
typeof(n.r.ocp.u)
XX = 0.5
XY = -1.5
x_p = :(x[j])
y_p = :(y[j])
constraints!(n, [:((($x_p - $XX)^2 + ($y_p - $XY)^2) - 0.55 >= 0)])
configure!(n;(:Nck=>[100]),(:finalTimeDV=>true));
@NLobjective(n.ocp.mdl,Min,n.ocp.tf)
n.s.ocp.evalCostates = true
optimize!(n);
using Plots
allPlots(n)
st=statePlot(n,1,1,2)
df = n.r.ocp.dfs #записали путь до дата фрейма в переменную df
df[1][:c] = @. (df[1][:x] ^2 + df[1][:y] ^2) #записали новый столбец "c" в наш дата фрейм
@show df
df_table = convert(Matrix, df[1][:1:6]) #перевели наш дата фрейм в массив и положили в новую переменную "df_table"
df2 = convert(DataFrame, df_table) #перевели наш массив в дата фрейм, чтоб получить новую переменную с дата фреймом(будем получать доступ к дата фрейму из одной переменной, не используя путь n.r.ocp.dfs)
@show df2
b = @df df2 plot(:x1, [:x6], color = :red, size = (2500,2000), linewidth = 4, thickness_scaling = 4) #отрисовали наш график, используя настройки: цвет, размер графика, размер линии, размер надписей на графике
savefig("D:\Users\kolenov_va\Desktop\julia\Брахистохрона\5\results\c.png") #сохранили в нужную нам папку график в формате png
df[1][:d] = @. ((9.81 * df[1][:y]) + (df[1][:v] ^2 / 2))
@show df
df[1][:c] = @. (((df[1][:x] - XX)^2 + (df[1][:y] - XY)^2) - 0.55)
@show df
m=JuMP.internalmodel(n.ocp.mdl);
c=MathProgBase.getconstrduals(m)

I want to use saveData(n) to save state, control, and costate (if applicable) data (about the collocation points and the Lagrange polynomial that runs through them). And also save the variables in which my Data Frames are written.

Docs: broken links

Hey,
in your docs the links ("This problem can be found here.") of the Beam Problem and HyperSensitive are broken.
HyperSensitive leads to the Brachistochrone Problem (gpops2.com) and the Beam Problem leads to nowhere.

The new link to the Beam Problem is:
https://github.com/jump-dev/JuMP.jl/blob/master/examples/clnlbeam.jl

Could you please state some mathematical explanations to the Beam Problem because its original content is not freely available (paywall).

Thanks!

About the installation

Hi!

I have trouble in using the package. I tried to add it but it failed by using Pkg.add() directly. But I can still add it by using Pkg.clone(). But then I can't clone the VehicleMod
status
successinclone
troubleinvehiclemodels
troubleshooting1
failure_in_using

els package

Example in tutorial.ipynb failed with errors

Hi,

I was trying to run the examples given in the tutorial.ipynb. However, when I try to run the fourth line n=define(de;numStates=3,numControls=1,X0=X0,XF=XF);, it failed with following errors:
ERROR: MethodError: no method matching define(::Array{Expr,1}; numStates=3, numControls=1, X0=[0.0, 0.0, 0.0], XF=[2.0, -2.0, NaN])
Closest candidates are:
define(; numStates, numControls, X0, XF, XL, XU, CL, CU) at C:\Users\XX.julia\v0.6\NLOptControl\src\setup.jl:23

I am using Julia-0.6.4 on Windows 10, and the required packages were installed according to the given instructions.

Any help would be appreciated.

Francis

Defining Dynamics Model

Do the dynamics have to be written as an array of differential equation expressions? I've got a few problems with pretty complex dynamic models that would be much easier to represent in a separate function. GPOPS has been my go to solver thus far, but I'd like to try NLOptControl for the increased speed.

Thanks,

Jackson

Is it working on julia 1.0?

I tried to install it. But it gives me error as below:
(v1.0) pkg> add NLOptControl
Resolving package versions...
ERROR: Unsatisfiable requirements detected for package NLOptControl [290757bd]:
NLOptControl [290757bd] log:
├─possible versions are: 0.1.2-0.1.6 or uninstalled
├─restricted to versions * by an explicit requirement, leaving only versions 0.1.2-0.1.6
├─restricted by compatibility requirements with DataFrames [a93c6f00] to versions: 0.1.4-0.1.6 or uninstalled, leaving only versions: 0.1.4-0.1.6
│ └─DataFrames [a93c6f00] log:
│ ├─possible versions are: [0.1.0, 0.2.0-0.2.5, 0.3.0-0.3.16, 0.4.0-0.4.3, 0.5.0-0.5.12, 0.6.0-0.6.11, 0.7.0-0.7.8, 0.8.0-0.8.5, 0.9.0-0.9.1, 0.10.0-0.10.1, 0.11.0-0.11.7, 0.12.0, 0.13.0-0.13.1, 0.14.0-0.14.1, 0.15.0-0.15.2, 0.16.0, 0.17.0] or uninstalled
│ └─restricted to versions 0.17.0 by an explicit requirement, leaving only versions 0.17.0
└─restricted by julia compatibility requirements to versions: uninstalled — no versions left

Vector-equation dynamics/objective?

Hi,

I think your package looks like one of the best in Julia for doing NLoc but before diving in I wanted to ask you about the potential to define vector equations. I looked through your problems in the latest version of the docs and couldn't find any equations which did matrix multiplication.

Would it be possible to define linear algebra like dx = A*x[:,j] + B*u[:,j] where x[:,j], u[:,j] are vectors of size n and A, B are matrices of size n by n?

Similarly, would it be possible to define the cost function like,
J = x[:,end]'*P*x[:,end] + sum([x[:,k]'*Q*x[:,k] + u[:,k]'*R*u[:,k] for k=1:n])
like for defining an MPC?

I understand JuMP has limits with vector valued functions, but it seems some packages have ways around this, like in NLOpt.jl.

Best,

About nonlinear constrain

Hi!

How can we define a nonlinear constrain and solved it by using NLOptControl?

Can you provide some examples?

Thanks

Failing to precompile with NLOptControl and JuMP

Hi,
I have great interest in your NLOptControl package and am trying it recently. But I encountered some problems while precompiling it.

I can add NLOptControl successfully but I cannot precompile NLOptControl and JuMP contained in it. I guess the reason may be that, it contains an out of date version (v0.18.6) of JuMP. When I try to precompile JuMP v0.18.6, it always shows failure, but the JuMP(v0.21.4) can be precompiled successfully after I remove NLOptControl.

#add NLOptControl:
(@v1.6) pkg> add https://github.com/JuliaMPC/NLOptControl.jl
Updating git-repo https://github.com/JuliaMPC/NLOptControl.jl
Resolving package versions...
Updating C:\Users\13614.julia\environments\v1.6\Project.toml
[4076af6c] ↓ JuMP v0.21.4 ⇒ v0.18.6
[290757bd] + NLOptControl v0.3.0 https://github.com/JuliaMPC/NLOptControl.jl#master
Updating C:\Users\13614.julia\environments\v1.6\Manifest.toml
[336ed68f] + CSV v0.8.5
[442a2c76] + FastGaussQuadrature v0.4.5
[4076af6c] ↓ JuMP v0.21.4 ⇒ v0.18.6
[290757bd] + NLOptControl v0.3.0 https://github.com/JuliaMPC/NLOptControl.jl#master
[89212889] + ReverseDiffSparse v0.8.6
[91c51154] + SentinelArrays v1.3.5
Precompiling project...
✗ JuMP
✗ NLOptControl
0 dependencies successfully precompiled in 27 seconds (296 already precompiled)
2 dependencies errored. To see a full report either run import Pkg; Pkg.precompile() or load the packages

julia> Pkg.precompile()
Precompiling project...
✗ JuMP
✗ NLOptControl

0 dependencies successfully precompiled in 29 seconds (296 already precompiled)

ERROR: The following 2 direct dependencies failed to precompile:

NLOptControl [290757bd-39a7-5095-97bb-ca0f46959724]

WARNING: could not import JuMP.setRHS into NLOptControl
WARNING: could not import JuMP.internalmodel into NLOptControl
ERROR: LoadError: LoadError: UndefVarError: Variable not defined
Stacktrace:
[1] top-level scope
@ C:\Users\13614.julia\packages\Parameters\cGriM\src\Parameters.jl:572
[2] include(mod::Module, _path::String)
@ Base .\Base.jl:386
[3] include(x::String)
@ NLOptControl C:\Users\13614.julia\packages\NLOptControl\Yh2kR\src\NLOptControl.jl:3
[4] top-level scope
@ C:\Users\13614.julia\packages\NLOptControl\Yh2kR\src\NLOptControl.jl:36
[5] include
@ .\Base.jl:386 [inlined]
[6] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base .\loading.jl:1213
[7] top-level scope
@ none:1
[8] eval
@ .\boot.jl:360 [inlined]
[9] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[10] top-level scope
@ none:1
in expression starting at C:\Users\13614.julia\packages\NLOptControl\Yh2kR\src\types.jl:100
in expression starting at C:\Users\13614.julia\packages\NLOptControl\Yh2kR\src\NLOptControl.jl:3

JuMP [4076af6c-e467-56ae-b986-b466b2749572]

ERROR: LoadError: LoadError: UndefVarError: Grisu not defined
Stacktrace:
[1] getproperty(x::Module, f::Symbol)
@ Base .\Base.jl:26
[2] top-level scope
@ C:\Users\13614.julia\packages\JuMP\I7whV\src\writers.jl:6
[3] include(mod::Module, _path::String)
@ Base .\Base.jl:386
[4] include(x::String)
@ JuMP C:\Users\13614.julia\packages\JuMP\I7whV\src\JuMP.jl:11
[5] top-level scope
@ C:\Users\13614.julia\packages\JuMP\I7whV\src\JuMP.jl:947
[6] include
@ .\Base.jl:386 [inlined]
[7] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base .\loading.jl:1213
[8] top-level scope
@ none:1
[9] eval
@ .\boot.jl:360 [inlined]
[10] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[11] top-level scope
@ none:1
in expression starting at C:\Users\13614.julia\packages\JuMP\I7whV\src\writers.jl:5
in expression starting at C:\Users\13614.julia\packages\JuMP\I7whV\src\JuMP.jl:11

Stacktrace:
[1] pkgerror(msg::String)
@ Pkg.Types C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Types.jl:55
[2] precompile(ctx::Pkg.Types.Context; internal_call::Bool, strict::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:1244
[3] precompile
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:920 [inlined]
[4] #precompile#196
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:918 [inlined]
[5] precompile()
@ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:918
[6] top-level scope
@ REPL[43]:1

(@v1.6) pkg> rm NLOptControl
Updating C:\Users\13614\.julia\environments\v1.6\Project.toml
[290757bd] - NLOptControl v0.3.0 https://github.com/JuliaMPC/NLOptControl.jl#master
Updating C:\Users\13614\.julia\environments\v1.6\Manifest.toml
[336ed68f] - CSV v0.8.5
[442a2c76] - FastGaussQuadrature v0.4.5
[290757bd] - NLOptControl v0.3.0 https://github.com/JuliaMPC/NLOptControl.jl#master
[91c51154] - SentinelArrays v1.3.5

(@v1.6) pkg> rm JuMP
Updating C:\Users\13614\.julia\environments\v1.6\Project.toml
[4076af6c] - JuMP v0.18.6
Updating C:\Users\13614\.julia\environments\v1.6\Manifest.toml
[49dc2e85] - Calculus v0.5.1
[4076af6c] - JuMP v0.18.6
[89212889] - ReverseDiffSparse v0.8.6

(@v1.6) pkg> add JuMP
Resolving package versions...
Updating C:\Users\13614\.julia\environments\v1.6\Project.toml
[4076af6c] + JuMP v0.21.4
Updating C:\Users\13614\.julia\environments\v1.6\Manifest.toml
[49dc2e85] + Calculus v0.5.1
[4076af6c] + JuMP v0.21.4

julia> Pkg.precompile()
#Success

Could you please help me and solve this problem?

Problem in running Quick EX#1

I ran the Quick EX#1 wrote on the stable document by the Julia 0.6.4 on MAC OS.

The code is:
using NLOptControl, PrettyPlots
X0=[0.0,0.0,0.0]
XF=[2.,-2.,NaN]
n=define(numStates=3,numControls=1,X0=X0,XF=XF)
states!(n,[:x,:y,:v],descriptions=["x(t)","y(t)","v(t)"])
controls!(n,[:u],descriptions=["u(t)"])
dx=[:(v[j]*sin(u[j])),:(-v[j]cos(u[j])),:(9.81cos(u[j]))]
dynamics!(n,dx)
n.s.ocp.evalCostates = true
configure!(n;(:Nck=>[100]),(:finalTimeDV=>true));
@NLobjective(n.ocp.mdl,Min,n.ocp.tf)
optimize!(n);

Then I got the warning like this:
WARNING: Ipopt finished with status Restoration_Failed
Warning: Not solved to optimality, status: Error
WARNING: The solution is not Optimal
Setting: n.f.mpc.simFailed = [true, n.r.ocp.status]
ERROR: ArgumentError: New columns must have the same length as old columns

And there is no result shown.

Ipopt finished with status Invalid_Number_Detected

I am trying out this package but run into an error which I find hard to debug.
The code below is self contained and runs into

WARNING: Ipopt finished with status Invalid_Number_Detected
WARNING: Not solved to optimality, status: Error

when calling optimize!. Any ideas on the source of the error, bug or my fault?

using Ipopt
using NLOptControl

ni    = 1000
l     = 0.345
lact  = 0.4
g     = 9.81
# m = Model(solver     = solver)
X0  = [-0.8, 0, 0, 0, 0]
XF  = [0, 0, 0, 0, NaN]
CL  = [-100.]
CU  = [100.]

n   = define(numStates = 5, numControls=1, X0=X0, XF=XF, CL=CL, CU=CU)
states!(n,[:p, :pd, :theta, :thetad, :ar],descriptions=["p(t)", "ṗ(t)", "θ(t)","θ̇(t)", "aᵣ(t)"])
controls!(n,[:ard],descriptions=["ȧᵣ(t)"])

# Setup model equations ================================================================
dx    = Array{Expr}(5)
dx[1] = :(pd[j])
dx[2] = :(ar[j])
dx[3] = :(thetad[j])
dx[4] = :(-$g/$l*sin(theta[j])-0.04*thetad[j]+1/$l -$g/$l*sin(theta[j])-0.04*thetad[j]+1/$l*cos(theta[j])*ar[j])
dx[5] = :(ard[j])
dynamics!(n,dx)

# Pendulum constraints
x_p = :(p[j]-$lact*sin(theta[j]))
y_p = :(-$lact*cos(theta[j]))
constraints!(n, [:((($x_p+0.3)/0.05)^2 + (($y_p+0.4)/0.3)^2 >= 1)])

configure!(n; (:Nck=>[ni]), (:finalTimeDV=>true))
@NLobjective(n.mdl, Min, n.tf)
optimize!(n)

package not found with Pkg.add()

Pkg.add("NLOptControl") is not successfully installing the package. Julia 1.0.5 is giving the error

ERROR: The following package names could not be resolved:

  • NLOptControl (not found in project, manifest or registry)
    Please specify by known name=uuid.

Could you give some insight to this?

Tutorial examples are not working

There seems to be problem in calling JuMP for solving optimal control problems. I cannot run any of the provided tutorial examples. For example this is the RobotArm code and error:

using NLOptControl

n=define(numStates=1,numControls=1,X0=[1.5],XF=[1.])
dx=[:(-x1[j]^3+u1[j])]
dynamics!(n,dx)
configure!(n;(:Nck=>[3,3,3,3,3,3,3,3,3,3,3,3]),(:finalTimeDV=>false),(:tf=>10000.0))
obj=integrate!(n,:( 0.5*x1[j]^2 + 0.5*u1[j]^2) )
@NLobjective(n.ocp.mdl,Min,obj);

optimize!(n);
plotSettings(;(:size=>(1200,1200)));
allPlots(n)
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************

┌ Warning: Ipopt finished with status Restoration_Failed
└ @ Ipopt /Users/sadeghi.ma/.julia/packages/Ipopt/bYzBL/src/MPB_wrapper.jl:178
┌ Warning: Not solved to optimality, status: Error
└ @ JuMP /Users/sadeghi.ma/.julia/packages/JuMP/I7whV/src/nlp.jl:1283
┌ Warning: The solution is not Optimal 
│ 
│                 Setting: n.f.mpc.simFailed = [true, n.r.ocp.status] 
└ @ NLOptControl /Users/sadeghi.ma/.julia/packages/NLOptControl/i4KEb/src/utils.jl:406
BoundsError: attempt to access 0-element Array{DataFrames.DataFrame,1} at index [0]

Stacktrace:
 [1] getindex at ./array.jl:809 [inlined]
 [2] statePlot(::NLOptControl.NLOpt{Float64}, ::Int64, ::Int64; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/sadeghi.ma/.julia/packages/NLOptControl/i4KEb/src/PrettyPlots/NLOptControl_plots.jl:88
 [3] statePlot at /Users/sadeghi.ma/.julia/packages/NLOptControl/i4KEb/src/PrettyPlots/NLOptControl_plots.jl:60 [inlined]
 [4] #184 at ./none:0 [inlined]
 [5] iterate at ./generator.jl:47 [inlined]
 [6] collect(::Base.Generator{UnitRange{Int64},NLOptControl.PrettyPlots.var"#184#187"{Int64,Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},NLOptControl.NLOpt{Float64}}}) at ./array.jl:686
 [7] allPlots(::NLOptControl.NLOpt{Float64}; idx::Int64, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/sadeghi.ma/.julia/packages/NLOptControl/i4KEb/src/PrettyPlots/NLOptControl_plots.jl:33
 [8] allPlots(::NLOptControl.NLOpt{Float64}) at /Users/sadeghi.ma/.julia/packages/NLOptControl/i4KEb/src/PrettyPlots/NLOptControl_plots.jl:32
 [9] top-level scope at In[1]:12
 [10] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1091

Explanation please

Trying to understand the acronyms: EP; Internal EP (why is it IPEP); IP; etc. IP Initial problem? Interior point? Could the acronyms be explained in the documentation? Thank you.

A macro-based API

Hey,
Following up from some JuliaCon comments. The expression-based API is interesting, but I was thinking you should add a macro-based API on top of it. Essentially:

de = @ode_system begin
  x2
  u1 - 1.625
end

can create de=[:(x2[j]),:(u1[j]-1.625)] and it would be more natural than the user defining these themselves. It would also hide the implementation detail of the [j]. The lower level API using arrays of expressions would still exist for more advanced users to programmatically create expressions.

Support for supplying initial guesses?

Is there any way to supply an initial guess to this solver? I'm familiar with GPOPS-II in Matlab, and this was a functionality that I found pretty invaluable when attempting to solve certain problems.

ERROR: The following package names could not be resolved

This is the error when I try to install NLOptControl on mac. Any idea how to fix it?

using Pkg
Pkg.add("NLOptControl")


ERROR: The following package names could not be resolved:
 * NLOptControl (not found in project, manifest or registry)
 Stacktrace:
 [1] pkgerror(::String) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Types.jl:52
 [2] ensure_resolved(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}; registry::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Types.jl:837
 [3] add(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}; preserve::Pkg.Types.PreserveLevel, platform::Pkg.BinaryPlatforms.MacOS, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:177
 [4] add(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:139
 [5] #add#21 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:67 [inlined]
 [6] add at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:67 [inlined]
 [7] #add#20 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:66 [inlined]
 [8] add at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:66 [inlined]
 [9] add(::String; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:65
 [10] add(::String) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/API.jl:65
 [11] top-level scope at REPL[3]:1

Key error

I've just installed NLOptControl to Julia 0.6.4 and I am trying out the examples, which seem to run.
However, when I enter

julia> allPlots(n)

I get the error below, for which I have no idea what to do (I installed all 3 plotting backends mentioned in the tutorial).

Thanks.

Error showing value of type Plots.Plot{Plots.PyPlotBackend}:
ERROR: KeyError: key 1 not found
Stacktrace:
[1] getindex(::Dict{String,Any}, ::Int64) at ./dict.jl:474
[2] render(::Juno.PlotPane, ::Plots.Plot{Plots.PyPlotBackend}) at /Users/hteisman/.julia/v0.6/Plots/src/output.jl:330
[3] display(::Media.DisplayHook, ::Plots.Plot{Plots.PyPlotBackend}) at /Users/hteisman/.julia/v0.6/Media/src/compat.jl:9
[4] display(::Plots.Plot{Plots.PyPlotBackend}) at ./multimedia.jl:218
[5] eval(::Module, ::Any) at ./boot.jl:235
[6] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
[7] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
[8] (::Base.REPL.#do_respond#16{Bool,Atom.##150#151,Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646

long precompile times and annoying warnings

Recently, the compile time has gone way up and these warnings are displayed

julia> using NLOptControl
INFO: Recompiling stale cache file /home/febbo/.julia/lib/v0.6/StaticArrays.ji for module StaticArrays.
INFO: Recompiling stale cache file /home/febbo/.julia/lib/v0.6/NLOptControl.ji for module NLOptControl.
WARNING: --output requested, but no modules defined during run
WARNING: The call to compilecache failed to create a usable precompiled cache file for module FFTW. Got:
WARNING: Cache file "/home/febbo/.julia/lib/v0.6/FFTW.ji" not found.
WARNING: eval from module Main to ImageCore:    
Expr(:call, Expr(:., :Base, :include_from_node1)::Any, "/home/febbo/.julia/v0.6/FFTW/src/FFTW.jl")::Any
  ** incremental compilation may be broken for this module **

WARNING: --output requested, but no modules defined during run
WARNING: The call to compilecache failed to create a usable precompiled cache file for module FFTW. Got:
WARNING: Cache file "/home/febbo/.julia/lib/v0.6/FFTW.ji" not found.
WARNING: eval from module Main to FFTViews:    
Expr(:call, Expr(:., :Base, :include_from_node1)::Any, "/home/febbo/.julia/v0.6/FFTW/src/FFTW.jl")::Any
  ** incremental compilation may be broken for this module **

the warning is described here
JuliaMath/FFTW.jl#45
and is unavoidable on 0.6

NLOptControl and KNITRO

I am quite new to Julia and NLOptControl.jl. I am trying to install it on Julia 0.7, but when building the NLOptControl.jl package I get this error.

ERROR: LoadError: Unable to locate KNITRO installation, please check your enviroment variable KNITRODIR.

Is KNITRO required? I thought that IPOPT.jl could be used instead.

Thanks.

How to set the final destination as a hard constrain

Hi!
I got a problem when I am using the dynamic bicycle, when I set the cost function to just final time. The vehicle would not move anymore unless I included the final destination in the cost function. If I wanted to set the destination in the XF and I include a obstacle, the error would show that the new column doesn't have the same length as the old column. why is that

Increasing number of obstacles algorithm can handle?

I'm running the "obstacle_avoidance.jl" script. If I increase the number of obstacles above 1, I get the warning "number of obstacles detected exceeds the number of obstacles the algorithm was designed for! Consider increasing the number of obstacles the algorithm can handle." How do I go about increasing the number of obstacles the algorithm can handle?

Info about upcoming removal of packages in the General registry

As described in https://discourse.julialang.org/t/ann-plans-for-removing-packages-that-do-not-yet-support-1-0-from-the-general-registry/ we are planning on removing packages that do not support 1.0 from the General registry. This package has been detected to not support 1.0 and is thus slated to be removed. The removal of packages from the registry will happen approximately a month after this issue is open.

To transition to the new Pkg system using Project.toml, see https://github.com/JuliaRegistries/Registrator.jl#transitioning-from-require-to-projecttoml.
To then tag a new version of the package, see https://github.com/JuliaRegistries/Registrator.jl#via-the-github-app.

If you believe this package has erroneously been detected as not supporting 1.0 or have any other questions, don't hesitate to discuss it here or in the thread linked at the top of this post.

Simple Optimal control problem

@huckl3b3rry87
I'm able to get NLOptControl.jl to work now. Thank you!

I'm having trouble solving the following seemingly simple problem:
image

using NLOptControl
n=define(
    numStates=1,    # b(t) wealth
    numControls=1,  # c(t) consumption
    X0=[100.0],     # b(0)= 100.0
    XF=[0.0]        # b(10)= 0.0 die w/o assets
    )
states!(n,[:b];descriptions=["b(t)"])
controls!(n,[:c];descriptions=["c(t)"])
dx=[:( (0.05) * b[j] - c[j] )]
dynamics!(n,dx)
configure!(n;(:Nck=>[50]),(:finalTimeDV=>false),(:tf=>10.0));
obj=integrate!(n, :( -1.0 * exp(-.01*j) * log(c[j]) ) )
@NLobjective(n.ocp.mdl,Min,obj)
optimize!(n);
allPlots(n)

#Error message

┌ Warning: Ipopt finished with status Invalid_Number_Detected
└ @ Ipopt ~/.julia/packages/Ipopt/bYzBL/src/MPB_wrapper.jl:178
┌ Warning: Not solved to optimality, status: Error
└ @ JuMP ~/.julia/packages/JuMP/I7whV/src/nlp.jl:1283
┌ Warning: The solution is not Optimal 
│ 
│                 Setting: n.f.mpc.simFailed = [true, n.r.ocp.status] 
└ @ NLOptControl ~/.julia/packages/NLOptControl/i4KEb/src/utils.jl:406

julia> 

# I tried to change the configure options w/o luck
#configure!(n;(:integrationScheme=>:trapezoidal),(:finalTimeDV=>false),(:tf=>10.0));
#configure!(n;(:finalTimeDV=>false),(:tf=>1.0));
#configure!(n;(:tf=>1.0));

Do you know why it's not working?

Julia 1.0+ not supported

This is a great tool and I would like to work on porting this over to the current Julia version, at least 1.0+. I'm new to open source contribution, so hopefully this is the correct pathway. I have created a fork to begin the required changes.

Cannot install the NLOptControl package on Julia 0.6.4

I am trying to install the package according to the installation instructions, but I get this error:

julia> Pkg.clone("https://github.com/JuliaMPC/NLOptControl.jl")
INFO: Initializing package repository /Users/roi/.julia/v0.6
INFO: Cloning METADATA from https://github.com/JuliaLang/METADATA.jl
INFO: Cloning NLOptControl from https://github.com/JuliaMPC/NLOptControl.jl
INFO: Computing changes...
ERROR: fixed packages introduce conflicting requirements for ReverseDiffSparse: 
         NLOptControl requires versions [0.8.6+,∞) [none of the available versions can satisfy this requirement]
       available versions are 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.1.10, 0.1.11, 0.1.12, 0.1.13, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.2.6, 0.2.7, 0.2.8, 0.2.9, 0.2.10, 0.2.11, 0.3.0, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.5.6, 0.5.7, 0.5.8, 0.6.0, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.8.5 and 0.8.6
Stacktrace:
 [1] check_requirements(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{String,Base.Pkg.Types.Fixed}) at ./pkg/query.jl:259
 [2] resolve(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{String,Tuple{VersionNumber,Bool}}, ::Dict{String,Base.Pkg.Types.Fixed}, ::Dict{String,VersionNumber}, ::Set{String}) at ./pkg/entry.jl:498
 [3] resolve(::Dict{String,Base.Pkg.Types.VersionSet}, ::Dict{String,Dict{VersionNumber,Base.Pkg.Types.Available}}, ::Dict{String,Tuple{VersionNumber,Bool}}, ::Dict{String,Base.Pkg.Types.Fixed}) at ./pkg/entry.jl:479
 [4] edit(::Function, ::SubString{String}) at ./pkg/entry.jl:30
 [5] clone(::String, ::SubString{String}) at ./pkg/entry.jl:203
 [6] (::Base.Pkg.Dir.##4#7{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}})() at ./pkg/dir.jl:36
 [7] cd(::Base.Pkg.Dir.##4#7{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}}, ::String) at ./file.jl:70
 [8] #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{String,N} where N) at ./pkg/dir.jl:36
 [9] clone(::String) at ./pkg/pkg.jl:169

Can this be solved?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.