algorithmic modeling for Rhino
Hi Everybody,
I think I have a "rookie" mistake, but I can´t find the way to fix it. I am just trying to do an iterative process, which involves a function that I have create it to solve a non-linear system of equations (Conjugate Gradient Method).
The point is, that I am trying to make an iterative process to find a solution, which involves invoking this function in a for loop. When I do this, the program saves the new values on my previous variable for the solution, although I have created a new variable to save the new solution.
I attach the code as a text file. In this case (is a simplification of what I want to do) I have two vectors of forces (b and f, with their respectives components X,Y and Z) and two solutions "one" and "two" (with their respectives components X,Y,Z). When I try to recover the value of "one", the program gives me the value of "two".
If someone can help me I will really appreciate it. I know that is a "rookie" mistake and it has something to do with the declaration of variables, but I can´t find the solution (I am not a programmer).
Thank you in advance.
Tags:
Hi Jose,
you're using Array as a parameter type*, your functions don't have a return type code** and your variables have really awkward names such as n_row, aux_1, iai, iai1, Dp, pDp, b_x, b_y, c, x_rel, x_sol etc. You'll have to clean up your code until the function and variables names are either self-documenting or have documentation comments associated with them. My brain refuses to parse code like this.
* Don't use Array as a function argument unless you absolutely have to. Double() or Int32() is to be preferred.
** Your functions should always include an As clause with return type code.
--
David Rutten
david@mcneel.com
Tirol, Austria
Hi David,
thank you for your advices. It is a really awkward code, I know. I just try to prove that the method works and I have a lot of work to do cleaning it. I will try to follow your indications. I am very new on coding, so I expect to improve it.
Thank you again.
Hi David,
I just realized that I have some problems to deal qith the variables of VB. Can you recommend me a manual to learn the basics? I would really appreciate that. I don´t really understand why it is prefereable not to use Arrays. My program deals with some vectors and matrices and I thought that was the proper way to store the information, but surely I am wrong.
Thank you again for the tips!
Regards.
While in RhinoCommon, there are specific types for points and vectors and they are not based on arrays. Matrices often are, and of course you can represent points and vectors as arrays, but it is not a good idea to use the Array type directly. It's not type-safe. Use Double() instead since it specifically represents an Array of Doubles.
Here are my rules for declaring and using variables in VB.NET. Some of them are personal preference, others are widely accepted standards:
There's probably more but I can't think of any right now.
--
David Rutten
david@mcneel.com
Tirol, Austria
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by