Exemplo n.º 1
0
ocp.x00[0] = 1
ocp.lbtf[0] = ocp.ubtf[0] = 1000.0
ocp.scale_t = 1 / 1000.0

ocp.validate()

if __name__ == "__main__":
    seg, p = 15, 15
    mpo = mp.mpopt(ocp, seg, p)
    sol = mpo.solve()
    post = mpo.process_results(sol, plot=True)
    mp.plt.title(
        f"non-adaptive solution segments = {mpo.n_segments} poly={mpo.poly_orders[0]}"
    )

    mpo = mp.mpopt_h_adaptive(ocp, seg, p)
    sol = mpo.solve(max_iter=3,
                    mpopt_options={
                        "method": "residual",
                        "sub_method": "merge_split"
                    })
    post = mpo.process_results(sol, plot=True)
    mp.plt.title(
        f"Adaptive solution: merge_split : segments = {mpo.n_segments} poly={mpo.poly_orders[0]}"
    )

    mpo = mp.mpopt_h_adaptive(ocp, seg, p)
    sol = mpo.solve(max_iter=2,
                    mpopt_options={
                        "method": "residual",
                        "sub_method": "equal_area"
Exemplo n.º 2
0
ocp.ubx[0] = [20.0, 20.0]
ocp.lbu[0] = 0
ocp.ubu[0] = 3
ocp.lbtf[0], ocp.ubtf[0] = 3, 5

ocp.validate()

if __name__ == "__main__":
    mpo = mp.mpopt(ocp, 5, 4)
    sol = mpo.solve()
    post = mpo.process_results(sol, plot=True)
    mp.plt.title(
        f"non-adaptive solution segments = {mpo.n_segments} poly={mpo.poly_orders[0]}"
    )

    mpo = mp.mpopt_h_adaptive(ocp, 10, 4)
    sol = mpo.solve(max_iter=3,
                    mpopt_options={
                        "method": "residual",
                        "sub_method": "merge_split"
                    })
    post = mpo.process_results(sol, plot=True)
    mp.plt.title(
        f"Adaptive solution: merge_split : segments = {mpo.n_segments} poly={mpo.poly_orders[0]}"
    )

    mpo = mp.mpopt_h_adaptive(ocp, 10, 4)
    sol = mpo.solve(max_iter=2,
                    mpopt_options={
                        "method": "residual",
                        "sub_method": "equal_area"
Exemplo n.º 3
0
ocp.ubu[0] = 1.0
ocp.lbx[0][1] = -0.25
ocp.lbtf[0] = 10.0
ocp.ubtf[0] = 10.0

ocp.validate()

if __name__ == "__main__":
    mp.post_process._INTERPOLATION_NODES_PER_SEG = 200

    seg, p = 1, 15
    mpo, lgr = mp.solve(ocp, seg, p, "LGR", plot=False)
    mpo, lgl = mp.solve(ocp, seg, p, "LGL", plot=False)
    mpo, cgl = mp.solve(ocp, seg, p, "CGL", plot=False)

    fig, axs = lgr.plot_phases(name="LGR")
    fig, axs = lgl.plot_phases(fig=fig, axs=axs, name="LGL")
    fig, axs = cgl.plot_phases(fig=fig, axs=axs, name="CGL")
    mp.plt.title(
        f"non-adaptive solution segments = {mpo.n_segments} poly={mpo.poly_orders[0]}"
    )

    mph = mp.mpopt_h_adaptive(ocp, 5, 5)
    solh = mph.solve(max_iter=10, mpopt_options={"method": "control_slope"})
    posth = mph.process_results(solh, plot=False)
    fig, axs = posth.plot_phases(fig=None, axs=None)
    mp.plt.title(
        f"Adaptive solution segments = {mph.n_segments} poly={mph.poly_orders[0]}"
    )
    mp.plt.show()
Exemplo n.º 4
0
def van_der_pol_mpo_h_adaptive(van_der_pol_ocp):
    mpo = mp.mpopt_h_adaptive(van_der_pol_ocp, 5, 5, "LGR")
    mpo.validate()

    return mpo
Exemplo n.º 5
0
def hyper_sensitive_mpo_h_adaptive(hyper_sensitive_ocp):
    mpo = mp.mpopt_h_adaptive(hyper_sensitive_ocp, 15, 15)
    mpo.validate()

    return mpo
Exemplo n.º 6
0
def moon_lander_mpo_h_adaptive(moon_lander_ocp):
    mpo = mp.mpopt_h_adaptive(moon_lander_ocp, 10, 4)
    mpo.validate()

    return mpo