Example #1
0
    # boundary conditions
    ocp.bound('pos',(0,0),timestep=0)
    ocp.bound('pos',(5,5),timestep=-1)

    ocp.bound('vel',(0,0),timestep=0)
    ocp.bound('vel',(0,0),timestep=-1)

    ocp.bound('mass',(1,1),timestep=0)

    ocp.guess("pos",0)
    ocp.guess("vel",0)
    ocp.guess("mass",1)
    ocp.guess("thrust",0)

    # lookup states/actions/outputs/params
    thrust4 = ocp.lookup('thrust',timestep=4)
    thrust4 = ocp('thrust',timestep=4)

    # can specify index of collocation point
    posvel4_2 = ocp('posvel',timestep=4, degIdx=2)

    # add nonlinear constraint
    ocp.constrain(thrust4, '<=', posvel4_2**2)

    # fix objective and setup solver
    obj = sum([ocp('thrust',timestep=k)**2
               for k in range(ocp.nk)])
    ocp.setObjective(obj)
#    ocp.setObjective(ocp.lookup('integral vel*vel',timestep=-1))

    callback = rawe.telemetry.startTelemetry(