Guy,

We're working on the same problem for sympy.physics.mechanics. Matthew
Rocklin added support for matrix conversions in the theano code that is in
SymPy and I used that, but found that theano was slower that lambdify for
most of my cases (I only have two cores, so I'm not taking advantage of the
Theano parallel stuff). I think writing specific code gen for ode
integration is going to be the best bet. I'm happy to collaborate on this
with you.


Jason
moorepants.info
+01 530-601-9791


On Mon, Aug 5, 2013 at 3:13 PM, Guy Parsey <guy.par...@gmail.com> wrote:

> Hello Everyone,
> Thank you in advance for reading through my problem and for any input you
> may have. I must say that I still feel like a novice programmer and my
> problems may be easily solvable from a different mindset. My present
> project entails time-integration of extremely stiff and non-linear ODEs
> with regards to chemical kinetics (one derivative equation for each
> variable species) and energy equations. Initially we were planning on using
> the sympy.lambdify function to create callable functions for the main
> function along with the jacobian and passing said functions to
> scipy.integrate.odeint, however this method only works for easier test
> cases (fewer species and/or no energy equations) before being limited by
> either the list recursion limit or segfaulting due to the limited stack
> size. I know that both of these limits can be edited, but that fact that I
> am reaching them makes me feel as though I am doing something extremely
> inefficiently. Outside of the documentation of SymPy and Theano, I have
> also been heavily using the BlogPost by Matthew Rocklin
> http://matthewrocklin.com/blog/work/2013/03/19/SymPy-Theano-part-1/ .
>
> Presently I am trying to use the mapping between Theano and SymPy
> (sympy.printing.theanocode theano_function) to make my callable functions
> and take advantage of the optimization routines. I have two major problems
> and a few questions:
>
> 1st major problem: Though piecewise functions exist in SymPy
> (sympy.functions.elementary.piecewise) there is no counterpart in Theano.
> Looking at the source of the inspiration for theanocode (
> https://github.com/nouiz/theano_sympy/    graph_translation.py) I see
> that some of the SymPy equivalents were defined as lambda functions. Is
> there an equivalent way to add Theano conditional expressions wrapped into
> a function to add to the mapping dictionary in theanocode.py?
>
> 2nd major problem: Similar to the problem above in that I am not sure that
> the Theano counterpart is; some of the terms that I use are interpolated
> functions (with one ODE variable as input) that we have wrapped
> symbolically while providing a numerical implementation (so that symbolic
> derivatives can be made, resulting in their own interpolations). Is it
> possible to recreate the interpolation function as a Theano operation for
> use within the system of ODEs?
>
> Remain questions:
> I presently have to flatten my input to theano_function to a list of
> expressions and then wrap to return to a form (Jacobian is a matrix not a
> vector); is it possible to have a matrix of different expressions as an
> input to theano_function with a vector output?
>
> I know that a huge amount of Theano speed up is due to parallelization of
> matrix operations (which I do not have), should I be focusing on SymPy
> Autowrap/Ufuncify or my own code generation instead of trying to get Theano
> to play nicely?
>
> Stupid questions:
> Does sympy.printing.theanocode.theano_function automatically optimize the
> compiled graph?
>
> Minor comment:
> Perhaps unnecessary for most uses of the theano_function, but I needed to
> modify function inputs so as to be able to use the keyword argument
> 'on_unused_input=ignore' as opposed to 'raise' so that I did not need to
> have all symbols in all equations. This may be avoided by having the unused
> symbols somehow (I don't know how) included in each expression.
>
> Thank you again for your time in reading my problems and any potential
> help you may think of. I can attach code if necessary, I just didn't want
> to make my post more confusing.
> Have an excellent day.
> Sincerely,
> Guy Parsey
>
>  --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to