Grasshopper

algorithmic modeling for Rhino

Hello everyone,

I am working on something that should be automatically activated if it was not activated by other means in the previous 2 hours. I have tried to do it in grasshopper with no success.

For example, having the following list with 5 booleans:

0 | 0

1 | 0

2 | 0

3 | 1

4 | 0

The definition should do something like this:

Item0 + item1 = 0, then item2 = 1 (true);

Item1 + item2 = 1, then item3 = item3 (leave it as it is);

Item2 + item3 = 2, then item4 = item4 (leave it as it is).

And the result should be the following list:

0 | 0

1 | 0

2 | 1

3 | 1

4 | 0

Keep in mind that my goal is to do it with the 8760 hours of the typical year.

I hope the problem is clear.

Thanks,

Jorge

Views: 527

Replies to This Discussion

Hola Jorge,

para mi no está clara la pregunta. 

Item0 + item1 = 0, then item2 = 1; por qué 0+0=0 pasa a ser verdadero ó 1?

Si quieres hacer: B(i) = B(i-2)+B(i-1), entonces tienes que hacerlo iterativamente y dado que gh es acíclico por naturaleza (a día de hoy) tendrás que recurrir a Anemone o hacerlo desde código.

No obstante, apostaría una cerveza a que hay una forma más sencilla de resolver el asunto que quieres resolver con esto.

Hola Daniel,

Gracias por tu respuesta. Explicado de otra forma, lo que quiero conseguir es que nunca haya tres 0 consecutivos en la lista.

En el ejemplo que escribo 0+0=1 porque los dos anteriores son 0. La idea es que la definición de gh lea la lista de dos en dos y, en caso de que su suma sea =0, convierta el siguiente item en 1. Si la suma de los dos elementos previos es distinta de 0, deja la lista como está.

Espero que se entienda más claro ahora. Y sí, no sabiendo demasiado del tema, creo que necesitaría algo cíclico.

¿Alguna idea?

-----------------------------------------------------

Hi Daniel,

Thanks for your reply. In other words, what I want to achieve is that there is never three consecutive 0 in the list.

In the example given, 0+0=1 because the previous two items are =0. The idea is that the gh definition reads the list two by two and, in case they sum =0, change the next item to 1. If the sum of the previous two elements is different from 0, then leave the next item as it is.

I hope it is clearer now. And yes, I think that It needs something cyclic.

Any ideas?

La diferencia para necesitar o no hacerlo en bucle es si cuando cambias de 0 a 1 un valor porque los dos anteriores eran 0, quieres que sea ese nuevo valor el que se use para analizar los siguientes elementos, es decir:

If B(i-2) = 0 AndAlso B(i-1) = 0 then B(i) = 1.

If B(i-1) = 0 AndAlso B(i) = ? then ... qué valor requiere B(i)? 1 o su valor inicial?

Si se requiere el nuevo valor, entonces si es necesario recurrir a un bucle usando Anemone o desde código, si no, se puede hacer con gh como con la definición adjunta.

Attachments:

Daniel,

La idea es que B(i) tenga el valor una vez modificado (en tu ejemplo, 1), por lo que sí necesitaría bucle.

Nunca he usado Anemone y tampoco tengo conocimientos de programación, así que a unas malas podría dar por buena tu definición como aproximación a la solución.

Gracias por tu tiempo!

-------------------------------------------------

Daniel,

The idea is that B(i) takes the value of the modified list (1 in your example), so it would need a loop.

I have never used Anemone and I do not have experience with programming, so in the worst case scenario I could accept your definition as an approximation to the solution.

Thanks for your time!

De nada ^^. Pues desde código es mucho más fácil de hacer, aquí lo tienes. 

Espero que te sirva!

Attachments:

Eso es justo lo que buscaba! Le echaré un ojo al script a ver si aprendo poco a poco a hacerlos yo mismo.

Ya me he quedado sin palabras de agradecimiento... :)

-----------------------------------

That is just what I was looking for! I will take a look at the script to start learning how to do these things myself.

Thanks again!

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service