Grasshopper

algorithmic modeling for Rhino

Hi All,

I want to make a Gradient Descent algorithm which iteratively performs small steps in the direction of the negative gradient towards a (local) minimum (like a drop of water on a surface, flowing downwards from a given point in the steepest descent direction). Does anyone know how to do this?


http://en.wikipedia.org/wiki/Gradient_descent

http://www.20sim.com/webhelp/toolboxes/time_domain_toolbox/optimiza...

Views: 11851

Replies to This Discussion

Hi Richard,

One Quick Question the script in your built:
I wonder how this is working mathmatically:

GradDir = New On3dVector(ddu.x * ddu.z + ddv.x * ddv.z, ddu.y * ddu.z + ddv.y * ddv.z, 0)
it seems this does the "rotate normal along product" step very quickly.

Thanks
Long time ago ...


ddu , ddv Vektors of the lope in u /v direction

ddu , ddv define a plane

GradDir seams to be Vektor on the plane without a slope

the math looks like a dot produkt of some sort ...

hope that helps...
Ups now I remember ...

GradDir is no the Vektor with no slope but the Direktion of the steepest slope of that plane....

I would also like to see how it works and possibly use it in the landscape architecture studio I'm in. Could you share it?

Thank you!
heyo

here is a c# def i wrote following davids second set of instructions at the beggining of the forum..

it works great on the attached file, but i cannot figure out why my rhino crashes when i try to apply it to another surface. ..?
Looking into this now.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Well, I haven't found the problem yet, but I'm pretty sure that it's to do with the recursive nature of the code. Recursion is a fantastic way to get massive, immediate crashes with zero information and zero chance of rescue.

I'll let you know when I find the problem.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks David,

I also just wrote a recursive pathfinding code and Im having a similar issue. Is there something Im missing that may catch the error or prevent the crashing? Even when i change a variable slightly sometimes it will crash. I think if i can get over this hump I wont have to bother anyone on the forum much more. ;) Thanks for your time.
Since you don't need recursion here (a drop of water never splits into two streams, so this is a perfect iterative process), I suggest you don't use it.

I attached a script with an iterative method and also a bunch of extra error trapping.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Attachments:
thanks a lot david, this helps so much.
I"m trying to run the script, but the output is still Null on the curves, And i've follow the line of codes from the previous versions of this and i'm still not sure why exactly the output would be null in this case.  Any idea?

Hi David,

The result is null for lots of points.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service