首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ubuntu18.04上的JModelica

Ubuntu18.04上的JModelica
EN

Stack Overflow用户
提问于 2019-03-18 21:06:08
回答 3查看 600关注 0票数 3

你好,JModelica社区。我已经在CentOS上编译了CentOS,但在Ubuntu18.04上仍然失败。编译本身是成功的,但是正在运行

代码语言:javascript
复制
from pyjmi.examples import cstr_casadi
cstr_casadi.run_demo()

失败与

代码语言:javascript
复制
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-33de447ae4ee> in <module>()
----> 1 cstr_casadi.run_demo()

/opt/JModelica.org/Python/pyjmi/examples/cstr_casadi.pyc in run_demo(with_plots)
    179 
    180     # Solve the optimal control problem
--> 181     res = op.optimize(options=opt_opts)
    182 
    183     # Extract variable profiles

/opt/JModelica.org/Python/pyjmi/casadi_interface.pyc in optimize(self, algorithm, options)
    446                              "algorithm.")
    447         return self._exec_algorithm('pyjmi.jmi_algorithm_drivers',
--> 448                                     algorithm, options)
    449 
    450     # Make solve synonymous with optimize

/opt/JModelica.org/Python/pyjmi/common/core.pyc in _exec_algorithm(self, module, algorithm, options)
    166         alg = algorithm(self, options)
    167         # solve optimization problem/initialize
--> 168         alg.solve()
    169         # get and return result
    170         return alg.get_result()

/opt/JModelica.org/Python/pyjmi/jmi_algorithm_drivers.pyc in solve(self)
    351         Solve the optimization problem using ipopt solver.
    352         """
--> 353         self.nlp.solve_and_write_result()
    354 
    355     def get_result(self):

/opt/JModelica.org/Python/pyjmi/optimization/casadi_collocation.pyc in solve_and_write_result(self)
    995         t0 = time.clock()
    996         # todo: account for preprocessing time within solve_nlp separately?
--> 997         self.times['sol'] = self.solve_nlp()
    998         self.result_file_name = self.export_result_dymola(self.result_file_name)
    999         self.times['post_processing'] = time.clock() - t0 - self.times['sol'] - self.extra_update

/opt/JModelica.org/Python/pyjmi/optimization/casadi_collocation.pyc in solve_nlp(self)
    610 
    611         # Get the result
--> 612         primal_opt = N.array(self.solver_object.output(casadi.NLP_SOLVER_X))
    613         self.primal_opt = primal_opt.reshape(-1)
    614         if self.order != "default":

/opt/JModelica.org/Python/casadi/casadi_core.pyc in <lambda>(self, name)
  30560     for _s in [Function]:
  30561         __swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))
> 30562     __getattr__ = lambda self, name: _swig_getattr(self, NlpSolver, name)
  30563     __repr__ = _swig_repr
  30564 

/opt/JModelica.org/Python/casadi/casadi_core.pyc in _swig_getattr(self, class_type, name)
     78     if method:
     79         return method(self)
---> 80     raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
     81 
     82 

AttributeError: 'NlpSolver' object has no attribute 'output'

我试着降低了几个软件包的评级,但问题仍然存在。我在上也有同样的错误。

我知道Ubuntu18.04没有得到官方的支持,但我希望有人已经找到了解决这个问题的方法。

编辑:来自make installmake casadi_interface的日志

https://pastebin.com/ADRyE7XV

https://pastebin.com/dL4SCWdb

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2019-07-03 12:50:44

我正在回答我自己的问题,把它标记为已解决。解决方案来自@Vital (见对原始问题的评论)。

为了让JModelica在Ubuntu18.04或Arch上工作,solver_object.output需要在所有受影响的solver_object.getOutput文件中被solver_object.getOutput取代。

票数 1
EN

Stack Overflow用户

发布于 2019-03-21 10:22:37

好像你加载了错误的卡萨迪版本。你能检查一下输出吗?

代码语言:javascript
复制
from casadi import __version__
print(__version__)

编辑

也许这个问题与酒杯版本有关。

将solver_object.output替换为solver_object.getOutput应该会有帮助!例如:

代码语言:javascript
复制
primal_opt = N.array(self.solver_object.output(casadi.NLP_SOLVER_X)) 

使用

代码语言:javascript
复制
primal_opt = N.array(self.solver_object.getOutput(casadi.NLP_SOLVER_X))

也许变更集:https://trac.jmodelica.org/changeset/8074有助于概述文件和位置。

票数 0
EN

Stack Overflow用户

发布于 2019-08-22 10:41:36

我创建了一个Linux安装脚本,它是基于Stackoverflow和最初的JModelica用户指南的贡献创建的。此安装脚本托管在jmodelica/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55230042

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档