当前位置: 首页>>代码示例>>Python>>正文


Python Simulator.mpc方法代码示例

本文整理汇总了Python中simulator.Simulator.mpc方法的典型用法代码示例。如果您正苦于以下问题:Python Simulator.mpc方法的具体用法?Python Simulator.mpc怎么用?Python Simulator.mpc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在simulator.Simulator的用法示例。


在下文中一共展示了Simulator.mpc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_mpc

# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import mpc [as 别名]
def run_mpc(n_delay=1, M_weight=1e-3):
    # Create models for simulation and planning
    model = new_model(n_delay=n_delay)
    model_p = new_model(n_delay=n_delay, M_weight=M_weight)

    # Run MPC
    X_all, U_all, Z_all, B_all, EB_all = Simulator.mpc(model, model_p)

    # Cast simulation results for ease of use
    x_all = model.x.repeated(X_all)
    u_all = model.u.repeated(U_all)
    z_all = model.z.repeated(Z_all)
    b_all = model.b.repeated(B_all)

    # Plot full simulation
    plot_full(x_all, z_all, b_all)

    # Plot heuristics
    # model = new_model()
    # fig = Plotter.plot_heuristics(model, x_all, u_all)
    # plt.show()

    return X_all, U_all, Z_all, B_all, EB_all, model
开发者ID:b4be1,项目名称:easy_catch,代码行数:25,代码来源:launcher.py

示例2: new_model

# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import mpc [as 别名]
# ax_3D = fig_3D.add_subplot(111, projection='3d')
# Plotter.plot_trajectory_3D(ax_3D, x_all)
#
# plt.show()


# ============================================================================
#                         Model predictive control
# ============================================================================
# ----------------------------- Simulation --------------------------------- #
# Create models for simulation and planning
model = new_model()
model_p = new_model()

# Run MPC
X_all, U_all, Z_all, B_all, EB_all = Simulator.mpc(model, model_p)

# Cast simulation results for ease of use
x_all = model.x.repeated(X_all)
u_all = model.u.repeated(U_all)
z_all = model.z.repeated(Z_all)
b_all = model.b.repeated(B_all)


# ---------------------- Step-by-step plotting ----------------------------- #
fig, axes = plt.subplots(1, 2, figsize=(20, 8))
fig.tight_layout()
xlim = (-5, 35)
ylim = (-5, 20)
Plotter.plot_mpc(fig, axes, xlim, ylim,
                 model, X_all, Z_all, B_all, EB_all)
开发者ID:b4be1,项目名称:easy_catch,代码行数:33,代码来源:main.py


注:本文中的simulator.Simulator.mpc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。