Coder Social home page Coder Social logo

Comments (14)

huckl3b3rry87 avatar huckl3b3rry87 commented on June 12, 2024

from nloptcontrol.jl.

azev77 avatar azev77 commented on June 12, 2024

@huckl3b3rry87
the error message is

┌ 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

from nloptcontrol.jl.

huckl3b3rry87 avatar huckl3b3rry87 commented on June 12, 2024

from nloptcontrol.jl.

azev77 avatar azev77 commented on June 12, 2024

@huckl3b3rry87
I tried constraining c > 0.1.
No luck unfortunately...

from nloptcontrol.jl.

huckl3b3rry87 avatar huckl3b3rry87 commented on June 12, 2024

from nloptcontrol.jl.

huckl3b3rry87 avatar huckl3b3rry87 commented on June 12, 2024

from nloptcontrol.jl.

azev77 avatar azev77 commented on June 12, 2024

The code I tried:

using NLOptControl
n=define(
    numStates=1,    # b(t) wealth
    numControls=1,  # c(t) cons
    X0=[10.0],     # b(0)= 100.0
    XF=[0.0],      # b(tf)= 0.0 die w/o assets
    CL=[1.1],CU=[100.],      # make sure cons is >0
    XL=[-50.0],XU=[50.0]
    )
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=>[1000]),(:finalTimeDV=>false),(:tf=>10.0));
configure!(n;(:integrationScheme=>:trapezoidal),(:finalTimeDV=>false),(:tf=>10.0));
#configure!(n;(:finalTimeDV=>false),(:tf=>1.0));
#configure!(n;(:tf=>1.0));
obj=integrate!(n, :( -1.0 * exp(-.01*j) * log(c[j]) ) )
@NLobjective(n.ocp.mdl, Min, obj)
optimize!(n)

The 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

from nloptcontrol.jl.

huckl3b3rry87 avatar huckl3b3rry87 commented on June 12, 2024

from nloptcontrol.jl.

azev77 avatar azev77 commented on June 12, 2024

Thanks! I was ready to give up, but now it works!

using NLOptControl
n=define(
    numStates=1, numControls=1,    
    X0=[5.0], XF=[0.0],     # b(0)= 100.0
    CL=[0.0], CU=[50.0],      # make sure cons is >0
    XL=[-50.0],XU=[50.0]
    )
states!(n,[:b];descriptions=["b(t)"])
controls!(n,[:c];descriptions=["c(t)"])
dx=[:( (0.01) * b[j] + 10.0 - c[j] )]
dynamics!(n,dx)
configure!(n;(:integrationScheme=>:trapezoidal),(:finalTimeDV=>false),(:tf=>10.0))
obj=integrate!(n, :( exp(-.04 * j) * log(c[j]) ) );
@NLobjective(n.ocp.mdl, Max, obj)
optimize!(n)
allPlots(n)
#
##########

from nloptcontrol.jl.

huckl3b3rry87 avatar huckl3b3rry87 commented on June 12, 2024

from nloptcontrol.jl.

azev77 avatar azev77 commented on June 12, 2024

@huckl3b3rry87

  1. is it possible to set an inequality constraint so that a control is less than or equal to a state var?
    u1[j] <= 0.25 * x2[j]
  2. is it possible to solve an infinite horizon model tf=infinity?

I can't find how in the docs?

from nloptcontrol.jl.

huckl3b3rry87 avatar huckl3b3rry87 commented on June 12, 2024

from nloptcontrol.jl.

azev77 avatar azev77 commented on June 12, 2024

I can't find examples using @NLConstraint in NLOptControl:

using NLOptControl;
n=define(
    numStates=2, numControls=2,
    X0=[5.0,0.0], XF=[0.01,0.0],
    XL=[0.0,NaN], XU=[100.0,NaN],
    CL=[0.01,-7.0], CU=[50.0,NaN]
    )
states!(n,[:k,:b];descriptions=["k(t)","b(t)"])
controls!(n,[:c,:pmt];descriptions=["c(t)","pmt(t)"])
dx=[
    :( (k[j]^(.75)) - 0.3 * k[j] - c[j] - pmt[j] ),
    :( 0.01 * b[j] - pmt[j] )
    ]
dynamics!(n,dx)
configure!(n;
    (:integrationScheme=>:trapezoidal),
    (:finalTimeDV=>false),(:tf=>100.0))
#
@NLconstraint(n.ocp.NLcon, :( b[j]  <= 0.5 * k[j]) )    # ERROR 
#
obj=integrate!(n, :( exp(-.03 * j) * log(c[j]) ) );
@NLobjective(n.ocp.mdl, Max, obj)
optimize!(n)
allPlots(n)

What is the correct syntax for: @NLconstraint(n.ocp.NLcon, :( b[j] <= 0.5 * k[j]) ) ?

from nloptcontrol.jl.

huckl3b3rry87 avatar huckl3b3rry87 commented on June 12, 2024

from nloptcontrol.jl.

Related Issues (20)

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.