Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

遗传算法的交叉概率默认是多少,可以调吗? #79

Closed
CarrotC opened this issue Sep 13, 2020 · 9 comments
Closed

遗传算法的交叉概率默认是多少,可以调吗? #79

CarrotC opened this issue Sep 13, 2020 · 9 comments
Labels

Comments

@CarrotC
Copy link

CarrotC commented Sep 13, 2020

No description provided.

@guofei9987
Copy link
Owner

默认算子是全部交叉的,可以只定义算子去调整

@bencq
Copy link

bencq commented Jan 2, 2021

可以贡献代码吗?我感觉这个库还有很多东西需要补全的. 比如交叉概率等.

默认算子是全部交叉的,可以只定义算子去调整

@guofei9987
Copy link
Owner

可以贡献代码吗?我感觉这个库还有很多东西需要补全的. 比如交叉概率等.

默认算子是全部交叉的,可以只定义算子去调整

可以

@abc-hy
Copy link

abc-hy commented Jun 17, 2021

请问这个调交叉率的代码在哪里呢?能共享一下吗?

@guofei9987
Copy link
Owner

from sko.GA import GA
from sko.operators import crossover

ga = GA(func=lambda x: x[0] ** 2 + (x[1] - 0.05) ** 2 + (x[2] - 0.5) ** 2
        , n_dim=3, size_pop=100, max_iter=500, lb=[-1, -10, -5], ub=[2, 10, 2],
        precision=[1e-7, 1e-7, 1])

ga.register(operator_name='crossover', operator=crossover.crossover_2point_prob, crossover_prob=0.5)

best_x, best_y = ga.run()
print('best_x:', best_x, '\n', 'best_y:', best_y)

@abc-hy
Copy link

abc-hy commented Jul 1, 2021 via email

@guofei9987
Copy link
Owner

谢谢。还有一个问题想问下,这个算法可以导出每一代的最优值吗?如何实现呢?

On Mon, Jun 28, 2021 at 7:34 AM 郭飞 @.***> wrote: from sko.GA import GA from sko.operators import crossover ga = GA(func=lambda x: x[0] ** 2 + (x[1] - 0.05) ** 2 + (x[2] - 0.5) ** 2 , n_dim=3, size_pop=100, max_iter=500, lb=[-1, -10, -5], ub=[2, 10, 2], precision=[1e-7, 1e-7, 1]) ga.register(operator_name='crossover', operator=crossover.crossover_2point_prob, crossover_prob=0.5) best_x, best_y = ga.run() print('best_x:', best_x, '\n', 'best_y:', best_y) — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#79 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/APF2ZCSG4VKXT7FJLXZACZDTVBT4JANCNFSM4RKQBE6Q .

https://github.com/guofei9987/scikit-opt/blob/master/examples/demo_ga.py

@abc-hy
Copy link

abc-hy commented Jul 7, 2021 via email

@guofei9987
Copy link
Owner

我在代码里输入了这个来设置交叉率,但是报错。请问是什么问题呢? [image: image.png] [image: image.png]

On Fri, Jul 2, 2021 at 8:39 AM 郭飞 @.> wrote: 谢谢。还有一个问题想问下,这个算法可以导出每一代的最优值吗?如何实现呢? … <#m_-4931148214033621750_> On Mon, Jun 28, 2021 at 7:34 AM 郭飞 @.> wrote: from sko.GA import GA from sko.operators import crossover ga = GA(func=lambda x: x[0] ** 2 + (x[1] - 0.05) ** 2 + (x[2] - 0.5) ** 2 , n_dim=3, size_pop=100, max_iter=500, lb=[-1, -10, -5], ub=[2, 10, 2], precision=[1e-7, 1e-7, 1]) ga.register(operator_name='crossover', operator=crossover.crossover_2point_prob, crossover_prob=0.5) best_x, best_y = ga.run() print('best_x:', best_x, '\n', 'best_y:', best_y) — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#79 (comment) <#79 (comment)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/APF2ZCSG4VKXT7FJLXZACZDTVBT4JANCNFSM4RKQBE6Q . https://github.com/guofei9987/scikit-opt/blob/master/examples/demo_ga.py — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#79 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/APF2ZCWOVITL54TGS66AE4LTVW6SFANCNFSM4RKQBE6Q .

pip install --upgrade scikit-opt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants