Closed charlierix closed 1 year ago
+1, i am stuck on the "below zero 64 bit required" problem right now too. I will try it with if(num < 0) bitsneeded = 64, but i do not know how that will affect the performance
You'll be better off shifting the min to zero and shifting your values in/out of genetic sharp
(-12 to 12 would be 0 to 24)
@charlierix, please make a pull request your fix replacing the FloatingPointChromosome implementation.
Thanks.
Closing due to inactivity. Feel free to create the PR and reopen this issue.
Is your feature request related to a problem? Please describe. It was difficult to calculate the number of bits needed. I looked into GeneticSharp's source to see how it did it and made a helper method
While researching that, it looks like negative numbers aren't handled very optimally. Once a negative min value is needed, Convert.ToString(longValue, 2) uses 64 bits with most of the left ones as 1's. Then in EnsureMinMax, it clamps to min, so most randomly chosen values would end up being min
So it looks like the best use of bits is to always have min be zero and go to some max
Describe the solution you'd like I made a FloatingPointChromosome2 that internally has min and max go between 0 and external's max minus min
It then transforms the values on the way in/out so the user can work with their native values
It also calculates the number of bits for the user (I had to create a static Create method because the base class's constructor takes total bits)
Describe alternatives you've considered My intermediate attempt was to use the helper methods and manually transform the values in and out of FloatingPointChromosome. It worked, but was tedious
Additional context I'm including the FloatingPointChromosome2.cs and helper functions cs
I tested it a little bit and it seems to be working. Here is the code that calls it (search for FloatingPointChromosome2) https://github.com/charlierix/PartyPeople/blob/master/Math_WPF/Mathematics/Math2D_wpf.cs
If you want to download the source and test, this is the tester that the code in math2d comes from. Load one of the json files (which are logs of me swinging my arms around), then hit Calculate Plane 3 https://github.com/charlierix/PartyPeople/blob/master/bepu/Testers/AnalyzeVRPoints.xaml neutral arcs.zip FloatingPointChromosome2.zip