PytLab / gaft

A Genetic Algorithm Framework in Python (not for production level)
http://gaft.readthedocs.io/
GNU General Public License v3.0
739 stars 218 forks source link

How to use it right #21

Closed StartRightNow926 closed 6 years ago

StartRightNow926 commented 6 years ago

I try it as the tutorial,but I get wrong answer. I print every individual in every generation. the result like this: 0.093015549423 2535.6098254620283 2535.6098254620283 2544.9132766384128 2499.4233745285956 2528.402614792907 2509.3861930920684 2507.066317062549 2530.2371658559478 2530.2371658559478 2535.6098254620283 gaft.ConsoleOutput INFO Generation number: 10 Population number: 10 [7.96875, 10.6875, 0.625, 2.40625, 6.40625, 40.05859375, 2.0, -1.9375, 0.875, 7.96875, 5.40625] [4.53125, 9.75, 0.625, 1.0, 6.71875, 39.671875, 0.375, -1.9375, 0.5, 9.0625, 4.46875] [6.875, 9.59375, 0.75, 2.875, 7.03125, 20.529296875, 1.5, -2.09375, 0.375, 5.625, 7.59375] [7.1875, 2.5625, 0.375, 5.0625, 9.375, 42.572265625, 2.125, -5.375, 1.125, 6.875, 7.59375] [5.78125, 10.375, 0.125, 5.53125, 9.375, 5.25390625, 0.0, -3.5, 2.875, 7.96875, 5.25] [8.4375, 9.75, 0.5, 1.3125, 6.25, 57.07421875, 0.125, -5.375, 2.75, 7.96875, 5.875] [4.0625, 10.375, 0.5, 4.59375, 7.34375, 97.486328125, 1.25, -5.375, 2.0, 9.53125, 5.40625] [4.53125, 10.53125, 0.625, 5.53125, 7.34375, 26.5234375, 3.0, -3.03125, 1.25, 9.0625, 5.875] [4.84375, 9.28125, 0.875, 3.96875, 8.4375, 85.884765625, 2.125, -3.96875, 1.375, 9.84375, 4.46875] [9.84375, 2.71875, 0.75, 3.34375, 7.03125, 79.890625, 0.75, -5.84375, 2.875, 8.125, 4.0] 2544.9132766384128 2528.402614792907 2502.350522767732 2535.6098254620283 2546.7478277014534 2544.9132766384128 2530.2371658559478 2530.2371658559478 2540.1647364377413 2516.84281309958 gaft.ConsoleOutput INFO Generation: 1, best fitness: 2546.748, scaled fitness: 2546.748 [8.28125, 5.0625, 0.75, 2.71875, 8.4375, 75.443359375, 2.625, -2.71875, 0.5, 7.5, 4.46875] [4.53125, 10.53125, 0.625, 5.53125, 7.34375, 26.5234375, 3.0, -3.03125, 1.25, 9.0625, 5.875] [8.4375, 9.75, 0.5, 1.3125, 6.25, 57.07421875, 0.125, -5.375, 2.75, 7.96875, 5.875] [8.59375, 5.84375, 0.875, 5.0625, 7.5, 26.91015625, 2.25, -4.4375, 3.375, 7.96875, 8.84375] [6.25, 4.28125, 0.25, 5.375, 8.4375, 43.92578125, 0.5, -2.875, 1.0, 5.0, 7.4375] [8.4375, 9.75, 0.5, 1.3125, 6.25, 57.07421875, 0.125, -5.375, 2.75, 7.96875, 5.875] [5.3125, 1.78125, 0.75, 2.71875, 9.0625, 30.390625, 0.25, -4.28125, 1.625, 5.78125, 6.1875] [4.6875, 1.15625, 0.375, 3.03125, 8.125, 21.49609375, 0.75, -4.75, 2.125, 8.28125, 4.15625] [5.78125, 10.375, 0.125, 5.53125, 9.375, 5.25390625, 0.0, -3.5, 2.875, 7.96875, 5.25] [5.78125, 10.375, 0.125, 5.53125, 9.375, 5.25390625, 0.0, -3.5, 2.875, 7.96875, 5.25] 2546.7478277014534 2530.2371658559478 2544.9132766384128 2532.6826772228915 2535.6098254620283 2544.9132766384128 2540.707688290086 2546.7478277014534 2546.7478277014534 2546.7478277014534 gaft.ConsoleOutput INFO Generation: 2, best fitness: 2546.748, scaled fitness: 2546.748 [8.59375, 4.59375, 0.625, 3.34375, 8.4375, 12.794921875, 0.875, -5.53125, 3.25, 7.03125, 5.71875] [2.96875, 4.4375, 0.375, 1.46875, 5.78125, 20.72265625, 2.875, -3.03125, 2.75, 8.4375, 6.96875] [9.0625, 10.6875, 0.875, 5.6875, 5.15625, 28.650390625, 0.375, -3.1875, 0.125, 9.375, 5.09375] [8.125, 9.75, 0.625, 1.625, 9.375, 1.38671875, 0.125, -3.5, 2.875, 7.96875, 5.25] [0.15625, 4.59375, 0.375, 4.59375, 8.4375, 45.666015625, 0.375, -4.125, 1.125, 9.0625, 7.28125] [3.4375, 3.5, 0.875, 2.09375, 9.375, 21.49609375, 0.375, -4.125, 2.875, 7.96875, 6.03125] [5.9375, 4.28125, 0.875, 5.84375, 8.75, 6.4140625, 0.0, -4.4375, 1.625, 5.78125, 5.5625] [5.15625, 7.875, 0.0, 2.40625, 9.6875, 29.23046875, 0.25, -3.34375, 2.875, 7.96875, 5.875] [0.46875, 5.53125, 0.75, 2.09375, 8.90625, 91.87890625, 1.375, -2.5625, 1.5, 6.40625, 4.78125] [8.28125, 10.375, 0.625, 5.0625, 6.25, 51.66015625, 0.125, -2.875, 2.75, 7.96875, 5.875] 2546.7478277014534 2517.2646125534816 2520.252725197512 2540.707688290086 2519.0991636165218 2540.707688290086 2546.7478277014534 2540.707688290086 2540.707688290086 2516.84281309958 gaft.ConsoleOutput INFO Generation: 3, best fitness: 2546.748, scaled fitness: 2546.748 [3.4375, 4.75, 0.625, 2.09375, 9.375, 2.93359375, 0.125, -1.625, 2.875, 7.96875, 5.25] [2.8125, 6.15625, 0.5, 1.625, 6.71875, 29.810546875, 3.0, -5.84375, 3.75, 7.34375, 4.9375] [3.75, 10.6875, 0.125, 1.3125, 9.53125, 58.427734375, 2.0, -3.8125, 0.625, 9.53125, 5.25] [4.6875, 5.21875, 0.625, 3.96875, 8.28125, 79.697265625, 2.25, -4.59375, 1.125, 8.90625, 8.21875] [8.59375, 6.3125, 0.25, 4.28125, 5.46875, 65.1953125, 0.0, -3.96875, 2.0, 9.53125, 5.09375] [6.71875, 5.53125, 0.75, 1.9375, 5.15625, 92.072265625, 1.375, -2.5625, 0.0, 8.75, 4.78125] [6.09375, 10.53125, 0.375, 5.0625, 6.875, 65.1953125, 3.875, -1.15625, 1.5, 9.84375, 6.65625] [3.28125, 3.96875, 0.875, 4.75, 7.1875, 9.5078125, 1.75, -3.8125, 0.625, 8.125, 4.15625] [5.9375, 8.5, 0.625, 4.59375, 9.375, 4.48046875, 0.125, -6.0, 2.875, 7.96875, 5.875] [3.28125, 5.375, 0.375, 3.03125, 9.375, 22.26953125, 0.25, -1.625, 2.875, 7.96875, 5.40625] 2546.7478277014534 2513.4885250071575 2555.621778075836 2519.0991636165218 2500.3321512540733 2516.89843710509 2501.602478945066 2516.84281309958 2546.7478277014534 2546.7478277014534 gaft.ConsoleOutput INFO Generation: 4, best fitness: 2555.622, scaled fitness: 2555.622 [3.28125, 5.84375, 0.875, 2.40625, 6.875, 21.8828125, 1.25, -1.625, 0.625, 8.28125, 4.15625] [4.375, 2.875, 0.875, 2.875, 7.03125, 91.87890625, 0.0, -3.1875, 1.0, 5.78125, 4.15625] [3.28125, 6.625, 0.125, 1.3125, 8.4375, 82.404296875, 3.0, -1.78125, 3.125, 5.625, 8.21875] [4.53125, 5.375, 0.875, 3.5, 5.46875, 59.974609375, 2.625, -2.09375, 2.875, 6.71875, 5.5625] [7.03125, 4.90625, 0.75, 4.4375, 5.78125, 2.16015625, 1.875, -1.3125, 0.0, 8.125, 4.15625] [5.625, 7.71875, 0.0, 5.0625, 5.625, 21.8828125, 2.5, -3.5, 2.25, 9.53125, 4.78125] [9.53125, 3.03125, 0.875, 3.03125, 9.84375, 54.560546875, 3.875, -4.125, 0.875, 5.0, 8.6875] [3.28125, 5.375, 0.375, 3.03125, 9.375, 22.26953125, 0.25, -1.625, 2.875, 7.96875, 5.40625] [8.75, 2.5625, 0.625, 3.1875, 5.9375, 87.044921875, 3.5, -2.25, 2.5, 8.4375, 6.8125] [0.0, 10.0625, 0.875, 1.15625, 5.46875, 56.494140625, 0.5, -1.46875, 2.25, 9.53125, 5.71875]

My requirement is that there are ten variables, four of which are enumerated types, looking for global optimal. Who can give me example?

PytLab commented 6 years ago

你好,能否把你的问题描述的更具体一点呢?或者给出一下写的脚本