Grasshopper

algorithmic modeling for Rhino

Hi everyone,

I've been stuck for a while on a problem, and can't for the life of me figure out how to solve it! I think this is one for VB/C#, but happy to hear of any method.

So the thing is I am cycling through many (many, many) solutions, and am only interested in keeping the best 'X' number of them (say the top 100). In my case, a lower number is a better solution.

Since there are so many, I can't just use a Data Recorder to log them all, sort them and pick the top 100, because it would eventually be too long a list.

My idea is to log only the first 100 values that come in, and after that, only record a value if it is better (lower) than the worst (highest) value in the current log.

By "trapping" the better values as they come in, I will generate a list which slowly improves with time, while never having a super-heavy component.

Since this is a recursive function (one has to know things about the recorder before deciding whether to record or not), I have tried using Anemone, but it hasn't worked... (see image)

I would be really grateful if anyone could help me with this one, I'm stumped!

Cheers,

john

Edit:

If it's any help, in my research I have found these two other discussions about data recorders:

http://www.grasshopper3d.com/forum/topics/data-recorder-reset

http://www.grasshopper3d.com/forum/topics/data-recorder-with-boolea...

Views: 4733

Attachments:

Replies to This Discussion

i am not sure if  understand you well, 

why do u use data recorder list length if you can use counter on anemone start component ?

and why do u need data recorder, if anemone already record data/ data *n?

 

 

Hi Mohamed,

thanks, I am pretty new to Anemone so maybe I'm not using it right!And perhaps I should have explained my screen capture better, here goes:

The data will be coming from where the slider is now (from a different Anemone, in fact), I am using the slider for the moment to wiggle it up and down to imitate the stream of data that will be coming in later.

My idea for the Anemone component is that I only need it to activate once per change of data, to analyse whether to send data to the recorder or not (using those two rules: whether the Recorder is Maxed Out, and whether the Incoming Solution is Better).

Once I have the logic for whether to record or not, I send it back through Anemone and, using the stream filter, only send the data to the recorder if the decision was "True." Otherwise, I don't want to record anything, which is why the stream filter for 0 is empty.

I suspect the reason why it doesn't work is in the order of events - by the time I have the logic for whether to record or not, the data has already been recorded, I am too late...

The number of repeats is huge (in the millions), but they are mostly very bad solutions, which is why I would rather keep only the good ones (top 100, for example).

and for your data stream, what is the other option for data?

and for the number of repeat, its usually a large number(100)?

So here's a quick and dirty solution, may not stand up to stupid-large data-sets though:
First Recorder records all data ever, everything gets sorted, second Recorder has a record limit of 100 (you can right click the Recorder to set this) and currently takes the last 100 numbers (which when sorted this way, gives the smallest 100 numbers).

At an admittedly stupid-large 2mil data-set, it takes 2.4 seconds on my pc to sort each iteration though, so really depends on your use-case

Attachments:

Thanks Vongsawat,

unfortunately I do have a stupid-large data set... In fact, that's why I'm feeding the information in sequence, as opposed to all at once - it would crash the computer otherwise.

At the moment it's very speedy, as it is just a single integer coming through the pipes - if that went up to a couple of seconds per calculation... it would be very impractical

But you might have a point that I may need several Data Recorders in combination... hmmm...

Hi John, please test if this works for you :

Attachments:

Pieter thanks so much this is *perfect*!!

Really should be getting into VB...

Pieter, sorry to bother you again -

I have run into another problem I hadn't thought of initially. My data is coming in at different paths, and ideally I would like to store each incoming integer in its original path.

Ideally the Recording Limit "N" would apply to each of them (so branch 0;0 would have a limit of 100, as would 0;1, etc.)

Similar to how the out-of-the-box recorder works, in terms of paths.

Have tried fiddling with your code, and working around it using Grasshopper, but I haven't managed to solve it....

Hope I'm not asking too much, could you please help me out?

Many thanks,

john

Maybe... If you could upload your definition, so we can see exactly how you want to feed the component with the data to record.

Thanks Pieter, I have attached a definition which simulates data as it would happen in the definition (Can't upload the original since the data originates from a very large external file)

Wouldn't want to abuse your generosity, but I'm really stuck on this one!

Many thanks,

john

Attachments:

Maybe not~ ... my knowledge is too limited to decide on what's the smartest way to approach this. Hopefully some clever coder can step up here...
The least I can do is pseudo-bump this thread for you:)

haha thanks for the bump :) well for anyone reading...

I have zero experience with VB, so have boiled it down to the point where I think I could do it with Grasshopper components, except for one in VB/C#...

Basically it would be a component which would record the largest number ever to pass through 'x'. I've tried coding it myself, but doesn't work for some reason... Never mind the problem with paths, it doesn't work with single integers... Any ideas?:

Dim Lrgst As Integer

If x > Lrgst Then

Lrgst = x

End If

For some reason the 'IF' statement is always True, so 'Lrgst' is always 'x'.

And if that could be done for different 'x' coming in on different paths, that would be fantastic. Would I have to record all the values in an array? I have no idea

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service