python - 如何让 JModelica 保持安静?

标签 python jmodelica

我正在运行以下 JModelica 脚本:

#!/usr/local/jmodelica/bin/jm_python.sh
import pyjmi
op = pyjmi.transfer_optimization_problem("BatchReactor", "model.mop")

opt_opts                                 = op.optimize_options()
opt_opts['n_e']                          = 40 # Number of elements
opt_opts['IPOPT_options']['tol']         = 1e-10
opt_opts['IPOPT_options']['print_level'] = 0

res = op.optimize(options=opt_opts)

我原以为将 print_level 设置为 0 意味着 JModelica 和 IPOPT 会保持安静。这绝对有帮助!但我不断得到这样的输出:

time spent in eval_f: 0.00135 s. (26 calls, 0.0519231 ms. average)
time spent in eval_grad_f: 0.001719 s. (27 calls, 0.0636667 ms. average)
time spent in eval_g: 0.001636 s. (26 calls, 0.0629231 ms. average)
time spent in eval_jac_g: 0.002491 s. (28 calls, 0.0889643 ms. average)
time spent in eval_h: 0.003868 s. (26 calls, 0.148769 ms. average)
time spent in main loop: 0.055749 s.
time spent in callback function: 0 s.
time spent in callback preparation: 0.000459 s.

Total time: 0.46 seconds
Pre-processing time: 0.38 seconds
Solution time: 0.06 seconds
Post-processing time: 0.02 seconds

如何抑制这种输出?

最佳答案

您可以使用以下命令隐藏以 time gone 开头的行:

opt_opts['IPOPT_options']['print_time']   = False

关于python - 如何让 JModelica 保持安静?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32029017/

相关文章:

python - 如何使用哪个函数运行 django cron 作业

python - Django cron 运行多次,但它不应该

python - 将 Numpy 数组转换为 Pandas DataFrame

modelica - 在 Dymola/Modelica 中访问经过验证的函数库(例如贝塞尔函数)

modelica - 不同的 Modelica 模拟环境之间有什么区别?

python - Ubuntu 18.04 上的 JModelica

python - JModelica 和并发 future

python - Numpy 函数查找重叠向量的索引

python - 获取 Pandas 的错误消息/异常的值

modelica - 确定线性系统下的矩阵奇异不可解