Skip to content

似乎无法基于先验解继续寻优 #364

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

Open
ludedage99 opened this issue May 29, 2024 · 5 comments
Open

似乎无法基于先验解继续寻优 #364

ludedage99 opened this issue May 29, 2024 · 5 comments

Comments

@ludedage99
Copy link

开发者您好,我在计算时输入的prophetChrom是比较优的解,但是为什么保留不下来,不能基于其再寻优呢?无论是哪个进化算法似乎都在重新搜索而产生比先验解更差的解。

@geatpy-dev
Copy link
Owner

请根据代码自行检查修改框架代码。Geatpy主要只提供和维护EA算子。

@ludedage99
Copy link
Author

请根据代码自行检查修改框架代码。Geatpy主要只提供和维护EA算子。

好的,谢谢您的回复。可能是算法机制的导致先验解无法保留,应该不是函数没有起作用

@ludedage99
Copy link
Author

ludedage99 commented May 31, 2024

请根据代码自行检查修改框架代码。Geatpy主要只提供和维护EA算子。

进一步测试发现原因在于算法的调用方式。使用[Best, population] = myAlgorithm.run(prophetPop)的方式调用算法模板不会丢失先验解,而使用res = ea.optimize(myAlgorithm, prophets=prophetPop)的调用方式会丢失,可能是es.optimize调用方式中的prophets=prophetPop未起作用

@HaoRiTian
Copy link

请根据代码自行检查修改框架代码。Geatpy主要只提供和维护EA算子。

进一步测试发现原因在于算法的调用方式。使用myAlgorithm.call_aimFunc(prophetPop)的方式调用算法模板不会丢失先验解,而使用res = ea.optimize(myAlgorithm, prophets=prophetPop)的调用方式会丢失,可能是es.optimize调用方式中的prophets=prophetPop未起作用

您好,最后是怎么实现基于先验解来继续寻优的呢?

@ludedage99
Copy link
Author

ludedage99 commented Jan 22, 2025

请根据代码自行检查修改框架代码。Geatpy主要只提供和维护EA算子。

进一步测试发现原因在于算法的调用方式。使用_myAlgorithm.call_aimFunc(prophetPop)_【有误,应改为**[Best, population] = myAlgorithm.run(prophetPop)** 】的方式调用算法模板不会丢失先验解,而使用res = ea.optimize(myAlgorithm, prophets=prophetPop)的调用方式会丢失,可能是es.optimize调用方式中的prophets=prophetPop未起作用

您好,最后是怎么实现基于先验解来继续寻优的呢?

抱歉先前回答有误。
基于先验解来继续寻优我的做法是:手动创建先验种群,调用run重新执行算法模板。以下代码供你参考

"""===============================1.根据先验知识创建先知种群============================="""
prophetChroms=Pra.get_PC(NIND, var)
prophetPop = ea.Population(Encoding, Field, NIND, prophetChrom)
myAlgorithm.call_aimFunc(prophetPop) # 计算先验种群目标函数值 可能似乎不必要,未测试
"""===============================2.调用算法模板进行种群进化============================="""
# 调用方法1:prophets=prophetPop似乎不起作用,一些算法也可能产出比先验差的解
# res = ea.optimize(myAlgorithm)
# 调用方法2:调用run执行算法模板,得到最优解Best以及最后一代种群。Best是一个种群类Population的对象。
# Best.ObjV为最优解个体的目标函数值;Best.Phen为对应的决策变量值。
[Best, population] = myAlgorithm.run(prophetPop) # 执行算法模板,得到最优解以及最后一代种群
# # [Best, population] = myAlgorithm.run() # 不使用先验种群计算

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

No branches or pull requests

3 participants