Grasshopper

algorithmic modeling for Rhino

hello

i need a kind of solver to add a list of number toghader in order to reach a goal or to get as close as possible . for example: here is the list of number (2,3,4,7,20,25) goal = 105 out put number shoud be like this (25,25,25,25,4). it always start from the biggest number in the list and use then  and add them up in order get more than given value, so it will choose the next digit  to test . 

best

maysan

Views: 822

Replies to This Discussion

A little bit too many loops and conditionals to do it comfortably in GH.

I ended up writing a small VB component:

--

David Rutten

david@mcneel.com

Attachments:

That is wonton of usefulness!

I think we've sorted out the icon for this component...

--

David Rutten

david@mcneel.com

It's the little things...

thank you David.

Why should the result not be: 25,20,20,20,20?

Bigger numbers get preference.

--

David Rutten

david@mcneel.com

Trying to reach the goal value with as few as possible numbers, or as few as possible different values, or as closely as possible given the initial values, or other constraints will require a totally different algorithm.

--

David Rutten

david@mcneel.com

Yes, I understand that the approach is important, this is why I raised the question. In this particular example, I would expect that the '25-20-20-20-20-solution' is best, looking at the constraints that you mentioned above.

Though, ultimately this relies on the preference of the user.

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