Data Tree with Duplicated item Even or Odd

Hi guys,
I come back to you again and I ask for your help.
Here I have a data tree whose branches contain at least one duplicated item with another branch (numbers 100…900).I want to shift one of branches that contain duplicated items so that these items are even or odd. The attached image explains the expected result. I noted the branches which contain duplicated items and I compared their idexes (odd or even), if they are the same I made a shift to the second branch. but the result is not correct. what is wrong.
Thank you

DataTree_Duplicated_Item_Even_Or_Odd.gh (19.4 KB)

Hi @Fazloullah,

Based on the image, I think python will have to be employed as the changes need to be done recursively.
Can you post your grasshopper file with the relevant tree?

Also for the green circle, why is {0;1} shifted rather than {0;5}

and what happens if there is a clash?

{0;0}
odd 100
even 300
{0;2}
odd 700
odd 300
{0;3}
odd 800
odd 700
{0;4}
odd 800
odd 100

this means {0;4} would have to shift so that 100 is even compared to the odd in {0;1}
the {0;4} 800 then becomes even, which leaves {0;3} as is, causing {0;2} to shift which would cause {0;0} to shift and then loop by shifting {0;4}

From,
Chris

1 Like

Thank you @christopher.ho for your reply.

the attached file is not the correct one ?

I understand that this can cause conflicts.
I’m in the grasshopper learning phase and I’m looking for a solution without scripting. But if necessary … :upside_down_face:
I am looking at duplicated item indexes to do some mathematical operations but I don’t see any issue yet.

Thank you again Chris

Ok got a solution through brute force and galapagos.
DataTree_Duplicated_Item_Even_Or_Odd (1).gh (13.2 KB)
The gene pool needs to have the same number of paths as what you have and the solver is set to minimise.
Run until it stops and reinstate the minimum solution.

1 Like

Thank you very much @christopher.ho for all the time you spent. it works perfectly :heart_eyes:.

As you say I have checked with other data with a different number of branches and indeed it does not work .
I have to spend even more time on your definition to learn how to use these wonderful components.

is it difficult to make a generic solution for any number of branches ?

Thank you again
:pray: :pray: :pray:

Hi Chris,
if I understand you did this manually. I’m talking about “Gen Count” and “Gen values”.

by manually analyzing values in Data Tree I found the same configuration.
0
1
1
0
1
0
I thought at the start that this configuration was automatically generated by the Gen Pool component. :blush:
Thanks Chris for your response

The number of genes in genepool needs to be set manually, but the galapagos solver moves the sliders until it solves it.

The only way to solve it would be to brute force it. I’ll have a look later tonight to see if this is possible with just base rhino or if you need plugins like anemone. It will probably involve tree manipulation.

1 Like

You will need Anemone for the following script to work, but it shows a list of possible list shifts that will result in what you want. If the final list at the end has no options, then it isn’t possible to get a result.

DataTree_Duplicated_Item_Even_Or_Odd (1) (1).gh (15.4 KB)

1 Like

Thank you very much @christopher.ho for all the time you have spent.

I tested it on other data trees which contain more branches, some items are not corrected with the first list and also with the second (but just one or two points). I think I will spend more time on your definition to better understand the logic that you have adopted.
Most of it has been done.

I learned a lot by looking at your definitions :heart:
Thank you so much
:pray: :pray: :pray:

PS (Edit)
I post here 3 examples it works for the first two but not for the third (with coordinates instead of numbers)

DataTree_Duplicated_Item_Even_Or_Odd_6_Branches.gh (22.6 KB)
DataTree_Duplicated_Item_Even_Or_Odd_8_Branches.gh (22.6 KB)
DataTree_Duplicated_Item_Even_Or_Odd_8_Branches_2.gh (23.4 KB)

For your co-ordinates. the reason it doesn’t work is the overlap:
image
There is no way to get it to alternate in a pattern because of this point.
If it is two separate lines, then it will work.

1 Like

I did not pay attention it’s a scenario that has no solution and will never happen :upside_down_face:
thank you so much
Have a nice day
:pray: :pray: :pray: