Python遗传算法使用Pygad库
我有一个我想最大化其价值的函数。
但是我不太了解如何使用小瓜库。我在某些站点上看到的是,他们始终使用默认函数,例如W1x1 + W2x2 + W3x3 + W4x4 + W5x5 + 6wx6
。其中(x1,x2,x3,x4,x5,x6)=(4,-2,3.5,5,-11,-4.7)
。 在那里他们编写代码而不写入函数的代码,
function_inputs = [4,-2,3.5,5,-11,-4.7] # Function inputs.
desired_output = 44 # Function output.
并添加其他参数
,如果我们想使用多项式函数,例如w1^3.x1 + w2^2.x2 + w3.x3 + w4。 x4 + w5.x5 + w6.x6
?
I have a function that I want to maximize its value.
But I don't know much how to use PyGad library. What I see on some sites is that they always use default functions like w1x1 + w2x2 + w3x3 + w4x4 + w5x5 + 6wx6
. Where (x1,x2,x3,x4,x5,x6)=(4,-2,3.5,5,-11,-4.7)
.
And there they write the code without write the function just like :
function_inputs = [4,-2,3.5,5,-11,-4.7] # Function inputs.
desired_output = 44 # Function output.
And add the other parameters
So what if we want to use a polynomial function like w1^3.x1 + w2^2.x2 + w3.x3 + w4.x4 + w5.x5 + w6.x6
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很简单。只需在Python中写下您的功能即可。
为了完整的示例,请使用此示例。
感谢您使用 pygad !
It is simple. Just write your function in Python.
For the complete example, please use the next fitness function instead of the function used in this example.
Thanks for using PyGAD!