cstr_casadi AttributeError

2 posts / 0 new
Last post
yannick
Offline
Joined: 2017-06-26
cstr_casadi AttributeError

I just compiled JModelica 2.0 on my Arch Linux system and executed the testing
examples. bouncing_ball runs with no errors, but cstr_casadi throws the error

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

The last output was

EXIT: Optimal Solution Found.
time spent in eval_f: 0.000403 s. (29 calls, 0.0138966 ms. average)
time spent in eval_grad_f: 0.000569 s. (30 calls, 0.0189667 ms. average)
time spent in eval_g: 0.000491 s. (29 calls, 0.016931 ms. average)
time spent in eval_jac_g: 0.000658 s. (31 calls, 0.0212258 ms. average)
time spent in eval_h: 0.001232 s. (29 calls, 0.0424828 ms. average)
time spent in main loop: 0.047866 s.
time spent in callback function: 0 s.
time spent in callback preparation: 8.6e-05 s.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-e1b5179bd717> in <module>()
----> 1 cstr_casadi.run_demo()

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

/home/yannick/Dokumente/JModelica/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

/home/yannick/Dokumente/JModelica/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()

/home/yannick/Dokumente/JModelica/Python/pyjmi/jmi_algorithm_drivers.py 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):

/home/yannick/Dokumente/JModelica/Python/pyjmi/optimization/casadi_collocation.py 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

/home/yannick/Dokumente/JModelica/Python/pyjmi/optimization/casadi_collocation.py 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":

/home/yannick/Dokumente/JModelica/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

/home/yannick/Dokumente/JModelica/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'

Does anyone have an idea whats wrong with my installation?

yannick
Offline
Joined: 2017-06-26
Docker

Update: I managed to create a Dockerfile, which provides an image with a working installation of JModelica included in a Jupyter Notebook.

Login or register to post comments