Unexpected behavior at "Difference node" for set type

Hello.

I’m generating a list of integers to compute probabilities. Therefore, have a TempGenerator set that holds a bunch of integers, from this list I create many others, getting numbers from it. To be more specific I loop six times and I generate 3 lists that should get unique elements from TempGenerator.

So, in each interaction I get a number x of integers from TempGenerator and set it into a list, after I need to remove those numbers from the set TempGenerator. That’s when things started to get weird. On the first Loop it works using Difference to get a set of number that are in A (TempGenerator) but not in B (TempList) and setting the output into TempGenerator again as shown bellow;

Using the remove items it works perfect!! So, after doing a bunch of tests I couldn’t make sense of what could be wrong. That’s why I think there is some bug on Difference when is used within a loop.

Hello junqfisica,

I ran a few tests on our end the the difference node appears to be working as intended. However, I would like to point out that the difference node will only return the numbers that appear in Set A that are not in Set B. I have provided an example below using your variable names above. I hope that this information helps.

Example:

Make it a great day

Hello . Thanks a lot for the answer, but the error still persist, and the case u are showing me is not exactly what I have. This case do not represent very well what I’ve report.

What I’m doing is something like this:

// First Loop

TempGen = {10,34,65…} , size = 100 with unique integers numbers

ForEachElementInTableDo{ Here I loop 6 times.

TempArray = TempGen.toArray … here I just convert the list to array

// Second Loop

do (i=0,i=n,++) { where n is equal an integer that changes with the probability, so its accumulative value is never bigger than 100

// Create a list with unique values from the TempGen

TempList.Add (Array(i))

}

//Finish first loop

Do stuff…

TempGen = Difference(TempGen,TempList) // This work on the first time only

Clear(TempList)

Clear(TempArray)

}

//Finish Second loop

So, I’m not sure why this error happen, as I told you when I use remove items instead, then it works fine.
I’m sending my log.

I guess it’s something related with the index of the list on the return value from the Difference.

Thanks once more!!

130189-workingnode.png

Thanks for the additional information however, could you elaborate on how exactly the result you are getting is at an inverse to the result you are getting?

Quick questions:

  1. Can you reproduce this issue in a clean project?
  2. Could you provide a detailed list of step to reproduce this issue on our end?

Hello ,

So to your questions.

1 - Yes I reproduce that in a clean BP project, and the behavior persist, no clue way.

2 - Step 1: I create a BP actor, the I create a function SetList, which is called on BeginPlay.

 Step2: Then I create a List call Generator with the numbers {5,1,6,2,20} as default values.

 Step3: The function SetList: 

  List TempList;
  TArray TempArray;

for ( int j = 0; j <= 1; ++ ) {

TempArray = Generator.ToArray();

for ( int i = 0; i <= 1; ++ ) {

TempList.Add(TempArray(i)); // Set the first 2 elements from TempArray to TempList

}

Generator = Diffrence(Generator,TempList);
TempList.Clear();
TempArray.Clear();
}

Ps: This is only to illustrate the steps, I don’t know by heart the c++ synthases.

Result - On the first time TempList gets the elements 5 and 1 from Generator and the new Generator is {6,2,20} as expected. However, at the second iteration TempList gets the numbers 6 and 2 from the Generator and the new Generator is still {6,2,20} instead of only 20. That’s very weird, probably there is something wrong of how difference is allocating memory at the second time within the loop.

I’m sending my log and the BP pictures.

[link text][1]

Hello junqfisica,

After further investigation I was able to reproduce the issue that you are seeing on our end. I have written up a report and I have submitted it to the developers for further consideration. I have provided a link to the public tracker. Please feel free to use the link for future updates. I have also provided a possible workaround that may be viable.

Link: Unreal Engine Issues and Bug Tracker (UE-42993)

Workaround:

I found that using a clear node on the difference node will clear out the cached data. In your example you could clear the difference node right after setting “Generate”. I hope that this information helps.

Make it a great day

Hello ,

Thanks for your attention. Your workaround is very helpful, another option is to use the “remove items”, which works fine!!

Have a great day!!

Thiago