JModelica на Ubuntu 18.04 - PullRequest
       17

JModelica на Ubuntu 18.04

2 голосов
/ 19 марта 2019

Здравствуйте, сообщество JModelica. Мне уже удалось скомпилировать JModelica на CentOS, но я все еще не могу в Ubuntu 18.04. Сама компиляция прошла успешно, но работает

from pyjmi.examples import cstr_casadi
cstr_casadi.run_demo()

терпит неудачу с

---------------------------------------------------------------------------
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'

Я попытался понизить версию нескольких пакетов, но проблема остается. У меня такая же ошибка на Arch Linux между прочим.

Я знаю, что Ubuntu 18.04 официально не поддерживается, но я надеюсь, что кто-то уже нашел решение этой проблемы.

EDIT: Логи от make install и make casadi_interface:

https://pastebin.com/ADRyE7XV

https://pastebin.com/dL4SCWdb

Ответы [ 2 ]

0 голосов
/ 03 июля 2019

Я отвечаю на свой вопрос, чтобы пометить его как решенный.Решение взято из @Vital (см. Комментарии исходного вопроса).

Для того, чтобы JModelica работала на Ubuntu 18.04 или Arch Linux, solver_object.output необходимо заменить на solver_object.getOutput во всех затронутых файлах Python.

0 голосов
/ 21 марта 2019

Кажется, вы загружаете не ту версию Casadi Можете ли вы проверить вывод

from casadi import __version__
print(__version__)

Редактировать

Возможно, проблема связана с версией Swig.

замена solver_object.output на solver_object.getOutput должна помочь! например

primal_opt = N.array(self.solver_object.output(casadi.NLP_SOLVER_X)) 

с

primal_opt = N.array(self.solver_object.getOutput(casadi.NLP_SOLVER_X))

Может быть, чансет: https://trac.jmodelica.org/changeset/8074 полезно для обзора файлов и местоположения.

...