Open Alves663 opened 4 years ago
Here is the complete error message:
---------------------------------------------------------------------------
TemplateExpressionError Traceback (most recent call last)
<ipython-input-17-427db2c6e237> in <module>
----> 1 tsim, profiles = sim.simulate(numpoints=200,integrator = 'idas')
c:\users\kfed\venv_dtso\lib\site-packages\pyomo\dae\simulator.py in simulate(self, numpoints, tstep, integrator, varying_inputs, initcon, integrator_options)
910 self._simulate_with_casadi_no_inputs(initcon, tsim,
911 integrator,
--> 912 integrator_options)
913
914 self._tsim = tsim
c:\users\kfed\venv_dtso\lib\site-packages\pyomo\dae\simulator.py in _simulate_with_casadi_no_inputs(self, initcon, tsim, integrator, integrator_options)
954
955 odealltemp = [convert_pyomo2casadi(self._rhsdict[i])
--> 956 for i in self._derivlist]
957 odeall = casadi.vertcat(*odealltemp)
958 dae = {'x': xall, 'ode': odeall}
c:\users\kfed\venv_dtso\lib\site-packages\pyomo\dae\simulator.py in <listcomp>(.0)
954
955 odealltemp = [convert_pyomo2casadi(self._rhsdict[i])
--> 956 for i in self._derivlist]
957 odeall = casadi.vertcat(*odealltemp)
958 dae = {'x': xall, 'ode': odeall}
c:\users\kfed\venv_dtso\lib\site-packages\pyomo\dae\simulator.py in convert_pyomo2casadi(expr)
377 "expression to a Casadi expression.")
378 visitor = Convert_Pyomo2Casadi_Visitor()
--> 379 return visitor.dfs_postorder_stack(expr)
380
381
c:\users\kfed\venv_dtso\lib\site-packages\pyomo\core\expr\visitor.py in dfs_postorder_stack(self, node)
579 _sub = _argList[_idx]
580 _idx += 1
--> 581 flag, value = self.visiting_potential_leaf(_sub)
582 if flag:
583 _result.append( value )
c:\users\kfed\venv_dtso\lib\site-packages\pyomo\dae\simulator.py in visiting_potential_leaf(self, node)
331
332 if not node.is_expression_type():
--> 333 return True, value(node)
334
335 return False, None
pyomo\core\expr\numvalue.pyx in pyomo.core.expr.numvalue.value()
pyomo\core\expr\numvalue.pyx in pyomo.core.expr.numvalue.value()
c:\users\kfed\venv_dtso\lib\site-packages\pyomo\core\expr\template_expr.py in __call__(self, exception)
416 raise TemplateExpressionError(
417 self, "Evaluating uninitialized IndexTemplate (%s)"
--> 418 % (self,))
419 return None
420 else:
TemplateExpressionError: Evaluating uninitialized IndexTemplate ({x})
Looks like a bug in the Simulator. I'm currently working on some other updates to the Simulator so I'll try to fix this as part of an upcoming PR.
Encountered the same problem. Waiting for the update.
@blnicho Found the same problem for another example. Happy to test if you have a solution. Edit: Or contribute a new Pyomo.dae test.
I want to use Pyomo + Casadi to simulate an ODE system. The problem is that my ODE has a cosine of a continuous set.
If I use Scipy the simulator works but if I use Casadi it gives me an error:
TemplateExpressionError: Evaluating uninitialized IndexTemplate ({x})
I need to use Casadi because I have algebraic equations in my model. Somebody could help me?