Gradient Descent

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...
Load Previous Replies
  • up

    Jørgen Holo

    Ah, here we are again :)

    I trimmed down the scritp to only include the random distribution. Each point is positioned randomly within it's separate square.



    Dim strObject, arrBox, dblX, dblY, strDensity, n, x, y, dblRan1, dblRan2, arrResults
    strObject = Rhino.GetObject("Select a surface",8,,True)
    If Issurface(strObject) Then
    strDensity=1
    arrBox=Rhino.boundingbox(strObject)

    '-------------------------------- Adding and projecting data
    dblX=Round(Rhino.Distance (arrBox(0), arrBox(1)),0)/strDensity
    dblY=Round(Rhino.Distance (arrBox(0), arrBox(3)),0)/strDensity
    Dim ArrPoints()
    n=0
    For x=0 To dblX
    For y=0 To dblY
    Randomize
    dblRan1=rnd
    Randomize
    dblRan2=rnd
    ReDim Preserve arrPoints(n)
    arrPoints(n) = array((arrbox(0)(0)+x*strDensity)+(dblRan1*strDensity),(arrbox(0)(1)+y*strDensity)+(dblRan2*strDensity),(arrbox(7)(2)+10))
    n=n+1
    Next
    Next
    arrResults = Rhino.ProjectPointToSurface(arrPoints, strObject, Array(0,0,-1))
    Rhino.addpoints arrResults
    End If
    • up

      Richard Schaffranek

      Sorry had some errors in the math ....

      Here the corrected Script
      3
      • up

        Pablo Resende

        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!
        8