Equation Solver - a scandalously VEXy asset

   7345   16   4
User Avatar
Member
1743 posts
Joined: March 2012
Offline
This may be the most ridiculous use of about 3000 lines of VEX, but I've made an equation evaluator / solver / fitter asset, and I'm wondering if there are any obvious use cases it should support but doesn't before I post it to Orbolt. For example, function minimization would be easy to add, but I'm not sure on how the UI should behave for it. Would anyone find the parsed equation info useful? Etc.

Anyway, the default shows it can recognize that “0.27 sin tau (1.3x + 0.4time)” means the same thing as “y = 0.27*sin(6.283185307*(1.3*P.x + 0.4*time))”, and yes, it'll accept that too. (Note: tau is 2pi [youtube.com].)

It supports so much stuff that I won't try to jam everything in here, but as an example of the non-linear solver, you can type in “0 = (1-x0)^2 + 100(y0-x0^2)^2” (the Rosenbrock banana function) and set Solver to “Always non-linear”, and it'll solve for the x0 and y0 that get closest to solving the equation, (in this case, x0=1 and y0=1).

I always forget the basis functions for representing a cubic function in terms of 2 values and 2 derivatives, but I remember how to get it down to solving a system of linear equations for each, so I've tested that out using 4 equations and 4 unknowns. Just make sure the unknowns aren't named any already-defined keywords or attributes, like x, y, z, P, e, or i. The linear solver is much faster than the non-linear solver, but only works if all equations are linear in the unknowns; (they can be non-linear in the input values, like x, y, etc).

If you have input data and you want to find the values of unknowns that make an equation best fit the data, you can put the data into the first input, type in the equation with unknowns, and choose the solver. For example, to fit a sum of two exponentials to some data, you can use “y = a0 exp(g0 x) + a1 exp(g1 x)”. If the data have different confidence levels in an attribute “errorbar”, you can append “+/- errorbar”, and it will take that into account, which can be quite useful, since least-squares regression (whether linear or non-linear) is quite susceptible to outliers. If you have animated data and don't want the equation to be re-parsed on every frame, there's a way around that too with the last input.

It supports vectors and complex numbers, and will treat float and float attributes as them automatically. To create a vector, use “vector(a,b,c)”, and for complex numbers, “complex(r,i)”. You can access components with square brackets or “.x” etc. There are also related functions, dot, cross, length, length2, conj, re, im. e^(i tau x) will correctly give a complex number with unit length and phase tau*x. It doesn't support vector or complex unknowns, but if you're using the non-linear solver, you can do things like “complex(unknownReal,unknownImag)”.

Anyway, I'm especially looking forward to using this with the Load Data Table asset [orbolt.com], (like the Table Import SOP, but beefier), as well as making animated function plots, and I'll be putting this on Orbolt too… maybe after writing some help for it, though. :wink:
Edited by - Jan. 14, 2016 08:50:23

Attachments:
EquationSolverDefault.png (147.2 KB)
EquationSolverSumExponential.png (157.5 KB)
equation.hda (69.0 KB)

Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
4270 posts
Joined: July 2005
Offline
This is some top tier hackery. I full approve.


ps - it crashes H14.
if(coffees<2,round(float),float)
User Avatar
Member
1743 posts
Joined: March 2012
Offline
Wolfwood
ps - it crashes H14.
It's probably the new for-loops. The non-linear solver needs loops 3 levels deep, so the old for-loops would have been a bit awkward. I don't get a crash in H14, though, just an error message on instantiation. :?

I also added “error” and “warning” VEX functions to H15 a couple months ago, (and Report Error VOP in head), for runtime error/warning reporting from VEX, which would have been useful for reporting equation format issues, but I decided not to use them, so that it'd work in any version of H15. There were something like 4 RFEs for them, including one from me, and the VEX functions turned out to be very easy to add, once I found the right place to change. If you'd like them in 14, that could probably be arranged.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
4549 posts
Joined: Feb. 2012
Offline
Wow amazing tool! Will it be added to H16?

Does it have some presets included inside the HDA?
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
1743 posts
Joined: March 2012
Offline
pusat
Will it be added to H16?
Nope. It works in H15 and it'll be on Orbolt, though… after I've made some tangible progress on one of my other side projects, that is. (It's been over 2 years since the last new episode of You Can Solve the Schrödinger Equation. )

Does it have some presets included inside the HDA?
Ah, right! Thank-you! Presets are definitely something I should add to this. It'd make it much easier to use and figure out if there were a bunch of preset examples, especially to demonstrate the solver/regression capabilities.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
4549 posts
Joined: Feb. 2012
Offline
ndickson
pusat
Will it be added to H16?
Nope. It works in H15 and it'll be on Orbolt, though… after I've made some tangible progress on one of my other side projects, that is. (It's been over 2 years since the last new episode of You Can Solve the Schrödinger Equation. )

Does it have some presets included inside the HDA?
Ah, right! Thank-you! Presets are definitely something I should add to this. It'd make it much easier to use and figure out if there were a bunch of preset examples, especially to demonstrate the solver/regression capabilities.

Awesome man, can't wait for these. I will post here if I can see any features that would be good to have
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
260 posts
Joined: July 2006
Offline
for me its back to the math books then
Head of CG @ MPC
CG Supervisor/ Sr. FX TD /
https://gumroad.com/timvfx [gumroad.com]
www.timucinozger.com
User Avatar
Member
1743 posts
Joined: March 2012
Offline
It's live on Orbolt [orbolt.com]!

I added about 20 presets, an example file going over most of the presets and a bit more, and a huge help file. I also fixed a ton of bugs and a few missing things as I was testing everything for the help file. It supports 34 functions and about 20 operators. Oh, and I ended up adding keywords to optionally minimize or maximize functions instead of just solving equations. I'm glad it's finally done. *whew*
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
4549 posts
Joined: Feb. 2012
Offline
Thanks for the legendary effort Neil
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
148 posts
Joined: March 2016
Offline
I am finishing up a plugin that connects the Wolfram Research Mathematica system to Houdini. I have already done this for Maya. This provides the full power of the Mathematica kernel to Houdini.
Lars Wood
Future Vision Guide
Advanced Research And Development
User Avatar
Member
453 posts
Joined: Feb. 2013
Offline
Cool stuff!
User Avatar
Member
1743 posts
Joined: March 2012
Offline
FVGDOTCOM
I am finishing up a plugin that connects the Wolfram Research Mathematica system to Houdini. I have already done this for Maya. This provides the full power of the Mathematica kernel to Houdini.
Woohoo! That's so sweet! 8)

I'd considered doing something analytical with equations, instead of just numerical, but I figured it'd take a monumental effort to do even basic analytical stuff, and I wouldn't be able to do anything nearly as useful as Mathematica. It's good to know that I won't have to now! (…as long as people have a Mathematica license, unless the plugin has a Wolfram Alpha tie-in.) :wink:

Is it both directions? i.e. Does it both let Houdini access Mathematica and let Mathematica access Houdini via Houdini Engine? Or, is it just one direction?
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
148 posts
Joined: March 2016
Offline
ndickson
FVGDOTCOM
I am finishing up a plugin that connects the Wolfram Research Mathematica system to Houdini. I have already done this for Maya. This provides the full power of the Mathematica kernel to Houdini.
Woohoo! That's so sweet! 8)

I'd considered doing something analytical with equations, instead of just numerical, but I figured it'd take a monumental effort to do even basic analytical stuff, and I wouldn't be able to do anything nearly as useful as Mathematica. It's good to know that I won't have to now! (…as long as people have a Mathematica license, unless the plugin has a Wolfram Alpha tie-in.) :wink:

Is it both directions? i.e. Does it both let Houdini access Mathematica and let Mathematica access Houdini via Houdini Engine? Or, is it just one direction?

Wow! Very sorry I missed your reply, I would have responded right away if I had not missed it. So the answer is it does use Wolfram Alpha, enables both symbolic (analytical) input and it goes both ways. Houdini is perfect for this, I am coming in through the HOM via the HDK currently but that is just the beginning. I am developing HDK interfaces that are automatically selected by the Mathematica system to manipulate VEX too. Here is an explanation of what I am doing an an a simple example. Once I get things to work the way I want I will transition to a more sophisticated VFX problem, possibly where accurate fluid dynamics calculations are baked into a simulation to be used as a rendered sequence output. http://fvg.com/isis-vfx.html [fvg.com]

I have created new Houdini nodes so you can access Mathematica su-kernels from Houdini including Mathematica GPU processing on distributed sub-kernels. My objective as stated in the link is behavioral VFX synthesis from a high level specification. This is targeted at technical directors since they deal in VFX that requires systems level planning etc.

My current focus is Houdini with Behavioral VFX synthesis and this is due to the highly developed node based architecture, which makes it a natural implementation for behavioral VFX synthesis. One of the user interfaces is Wolfram Alpha, which is extended for this purpose. Since your familiar with Wolfram Alpha you can imagine where this can go.

Autodesk is starting to create a procedural approach but they are so far behind at this point I don't see how they can possibly catch up to Houdini. Notwithstanding, Houdini has a very light footprint whereas Maya the opposite. One of the areas I am concentrating on is where Houdini starts to get crushed from a processing or memory perspective and offloading the calculations and data to distributed Mathematica Kernels (the Houdini Mathematica plugin can start up multiple distributed Mathematica sub kernels with SIMD GPU)

This is working out much faster than I originally expected but there is still lots of work to do. Ultimately, I will be looking for volunteers to test it on a real VFX challenge.

Tonight I am working on getting the kinks out of the Wolfram Alpha Houdini node parameter interface. This will enable complex free formatted requests to Mathematica sub kernels with no Mathematica Front End. In this instance of the technology Houdini nodes are the front end to as many Mathematica sub kernels as you want, including distributed multi-core distributed parallel processing and GPU SIMD parallel processing. The Houdini mathematica node does its calculation, say for accurate fluid dynamics or to incorporate machine learning into a VFX animation (where the VFX can change based on what else is in the scene!!). I want to take this idea of adaptive Houdini nodes much further. Effectively this enables Houdini intelligent nodes that can be setup to recognize and adapt to different inputs that pass through them to other things like shader networks for example. Houdini was made for behavioral VFX synthesis. Using the hardware VLSI metaphor, Houdini is like logic synthesis and what I am doing layers behavioral synthesis on top. Its exactly the same approach as used in hardware behavioral synthesis adapted here to VFX. This can easily be extended even further to intelligent character synthesis within Houdini. At the simplest level, lets say an artist creates a character in ZBrush and brings it into Houdini. Now you are ready to rig and animate the character. The new trick is hooking your rig and/or your animation up to an intelligent Houdini node that is driven by Mathematica, which results in character animations that may not be possible to do now with current technology! Anyway I am very excited about this as you can see.

VR

Lars
Lars Wood
Future Vision Guide
Advanced Research And Development
User Avatar
Member
655 posts
Joined: Feb. 2006
Offline
Not to ruin the party but the name “ISIS” may not be a very wise one…


FVGDOTCOM
ndickson
FVGDOTCOM
I am finishing up a plugin that connects the Wolfram Research Mathematica system to Houdini. I have already done this for Maya. This provides the full power of the Mathematica kernel to Houdini.
Woohoo! That's so sweet! 8)

I'd considered doing something analytical with equations, instead of just numerical, but I figured it'd take a monumental effort to do even basic analytical stuff, and I wouldn't be able to do anything nearly as useful as Mathematica. It's good to know that I won't have to now! (…as long as people have a Mathematica license, unless the plugin has a Wolfram Alpha tie-in.) :wink:

Is it both directions? i.e. Does it both let Houdini access Mathematica and let Mathematica access Houdini via Houdini Engine? Or, is it just one direction?

Wow! Very sorry I missed your reply, I would have responded right away if I had not missed it. So the answer is it does use Wolfram Alpha, enables both symbolic (analytical) input and it goes both ways. Houdini is perfect for this, I am coming in through the HOM via the HDK currently but that is just the beginning. I am developing HDK interfaces that are automatically selected by the Mathematica system to manipulate VEX too. Here is an explanation of what I am doing an an a simple example. Once I get things to work the way I want I will transition to a more sophisticated VFX problem, possibly where accurate fluid dynamics calculations are baked into a simulation to be used as a rendered sequence output. http://fvg.com/isis-vfx.html [fvg.com]

I have created new Houdini nodes so you can access Mathematica su-kernels from Houdini including Mathematica GPU processing on distributed sub-kernels. My objective as stated in the link is behavioral VFX synthesis from a high level specification. This is targeted at technical directors since they deal in VFX that requires systems level planning etc.

My current focus is Houdini with Behavioral VFX synthesis and this is due to the highly developed node based architecture, which makes it a natural implementation for behavioral VFX synthesis. One of the user interfaces is Wolfram Alpha, which is extended for this purpose. Since your familiar with Wolfram Alpha you can imagine where this can go.

Autodesk is starting to create a procedural approach but they are so far behind at this point I don't see how they can possibly catch up to Houdini. Notwithstanding, Houdini has a very light footprint whereas Maya the opposite. One of the areas I am concentrating on is where Houdini starts to get crushed from a processing or memory perspective and offloading the calculations and data to distributed Mathematica Kernels (the Houdini Mathematica plugin can start up multiple distributed Mathematica sub kernels with SIMD GPU)

This is working out much faster than I originally expected but there is still lots of work to do. Ultimately, I will be looking for volunteers to test it on a real VFX challenge.

Tonight I am working on getting the kinks out of the Wolfram Alpha Houdini node parameter interface. This will enable complex free formatted requests to Mathematica sub kernels with no Mathematica Front End. In this instance of the technology Houdini nodes are the front end to as many Mathematica sub kernels as you want, including distributed multi-core distributed parallel processing and GPU SIMD parallel processing. The Houdini mathematica node does its calculation, say for accurate fluid dynamics or to incorporate machine learning into a VFX animation (where the VFX can change based on what else is in the scene!!). I want to take this idea of adaptive Houdini nodes much further. Effectively this enables Houdini intelligent nodes that can be setup to recognize and adapt to different inputs that pass through them to other things like shader networks for example. Houdini was made for behavioral VFX synthesis. Using the hardware VLSI metaphor, Houdini is like logic synthesis and what I am doing layers behavioral synthesis on top. Its exactly the same approach as used in hardware behavioral synthesis adapted here to VFX. This can easily be extended even further to intelligent character synthesis within Houdini. At the simplest level, lets say an artist creates a character in ZBrush and brings it into Houdini. Now you are ready to rig and animate the character. The new trick is hooking your rig and/or your animation up to an intelligent Houdini node that is driven by Mathematica, which results in character animations that may not be possible to do now with current technology! Anyway I am very excited about this as you can see.

VR

Lars
User Avatar
Member
148 posts
Joined: March 2016
Offline
jordibares
Not to ruin the party but the name “ISIS” may not be a very wise one…

Notwithstanding ancient Egypt, I have used the terminology Intelligent Synthesis and Integration System (ISIS) for a long time and not about to change due to name hijackers LOL. http://fvg.com/isis-vfx.html [fvg.com]


VR

Lars
Lars Wood
Future Vision Guide
Advanced Research And Development
User Avatar
Member
655 posts
Joined: Feb. 2006
Offline
:-) Fair point. Super-interesting work by the way, have been very fond of Mathematica for long time.


FVGDOTCOM
jordibares
Not to ruin the party but the name “ISIS” may not be a very wise one…

Notwithstanding ancient Egypt, I have used the terminology Intelligent Synthesis and Integration System (ISIS) for a long time and not about to change due to name hijackers LOL. http://fvg.com/isis-vfx.html [fvg.com]


VR

Lars
User Avatar
Member
148 posts
Joined: March 2016
Offline
jordibares
:-) Fair point. Super-interesting work by the way, have been very fond of Mathematica for long time.


FVGDOTCOM
jordibares
Not to ruin the party but the name “ISIS” may not be a very wise one…

Notwithstanding ancient Egypt, I have used the terminology Intelligent Synthesis and Integration System (ISIS) for a long time and not about to change due to name hijackers LOL. http://fvg.com/isis-vfx.html [fvg.com]


VR

Lars

Thanks for the interest, VFX behavioral synthesis is my passion.

Hijacking of anything is based on fear, i.e. no fear, no hijacking.

UPDATE

Wife and best friend and my long time business partner (21 years) does not like the name ISIS and wife is more powerful than name hijackers, so no more ISIS name, ha ha!


VR

Lars
Lars Wood
Future Vision Guide
Advanced Research And Development
  • Quick Links