当前位置:网站首页>Pymoo学习 (6):终止条件
Pymoo学习 (6):终止条件
2022-07-25 18:59:00 【因吉】
1 默认设置
对于多目标优化,默认设置包括:
from pymoo.util.termination.default import MultiObjectiveDefaultTermination
termination = MultiObjectiveDefaultTermination(
x_tol=1e-8, # 设计空间中的运动
cv_tol=1e-6, # 收敛性
f_tol=0.0025, # 目标空间值
nth_gen=5, # 每多少代检查一次终止条件
n_last=30, # 计算过程中应当被考虑的最后几代数量
n_max_gen=1000, # 最大后代数量
n_max_evals=100000 # 最大评估次数
)
对于单目标优化,默认设置包括:
from pymoo.util.termination.default import SingleObjectiveDefaultTermination
termination = SingleObjectiveDefaultTermination(
x_tol=1e-8,
cv_tol=1e-6,
f_tol=1e-6,
nth_gen=5,
n_last=20,
n_max_gen=1000,
n_max_evals=100000
)
2 评估数量 (n_eval)
from pymoo.algorithms.moo.nsga2 import NSGA2`在这里插入代码片`
from pymoo.factory import get_problem, get_termination
from pymoo.optimize import minimize
problem = get_problem("zdt3")
algorithm = NSGA2(pop_size=100)
termination = get_termination("n_eval", 300)
res = minimize(problem,
algorithm,
termination,
pf=problem.pareto_front(),
seed=1,
verbose=True)
输出如下:
============================================================
n_gen | n_eval | igd | gd | hv
============================================================
1 | 100 | 1.304648356 | 1.530191068 | 0.00000E+00
2 | 200 | 1.304200356 | 1.517648901 | 0.00000E+00
3 | 300 | 0.988539101 | 1.378914374 | 0.00000E+00
3 迭代次数 (n_gen)
from pymoo.algorithms.moo.nsga2 import NSGA2
from pymoo.factory import get_problem, get_termination
from pymoo.optimize import minimize
problem = get_problem("zdt3")
algorithm = NSGA2(pop_size=100)
termination = get_termination("n_gen", 10)
res = minimize(problem,
algorithm,
termination,
pf=problem.pareto_front(),
seed=1,
verbose=True)
输出如下:
============================================================
n_gen | n_eval | igd | gd | hv
============================================================
1 | 100 | 1.304648356 | 1.530191068 | 0.00000E+00
2 | 200 | 1.304200356 | 1.517648901 | 0.00000E+00
3 | 300 | 0.988539101 | 1.378914374 | 0.00000E+00
4 | 400 | 0.920567183 | 1.351594290 | 0.00000E+00
5 | 500 | 0.920567183 | 1.282794381 | 0.00000E+00
6 | 600 | 0.894035691 | 1.360904372 | 0.00000E+00
7 | 700 | 0.817395517 | 1.280727114 | 0.00000E+00
8 | 800 | 0.802167697 | 1.189542707 | 0.00000E+00
9 | 900 | 0.730335663 | 0.993344639 | 0.002211246
10 | 1000 | 0.699750404 | 0.851632873 | 0.002211246
4 时间 (time)
基于时间的终止标准的格式应当设置为类似于get_termination(“time”, “01:30:00”),表示运行1个小时30分钟:
from pymoo.algorithms.moo.nsga2 import NSGA2
from pymoo.factory import get_problem, get_termination
from pymoo.optimize import minimize
problem = get_problem("zdt3")
algorithm = NSGA2(pop_size=100)
termination = get_termination("time", "00:00:03")
res = minimize(problem,
algorithm,
termination,
pf=problem.pareto_front(),
seed=1,
verbose=False)
print(res.algorithm.n_gen)
5 设计空间容忍度 (x_tol)
from pymoo.algorithms.moo.nsga2 import NSGA2
from pymoo.factory import get_problem
from pymoo.optimize import minimize
from pymoo.util.termination.x_tol import DesignSpaceToleranceTermination
problem = get_problem("zdt3")
algorithm = NSGA2(pop_size=100)
termination = DesignSpaceToleranceTermination(tol=0.0025, n_last=20)
res = minimize(problem,
algorithm,
termination,
pf=problem.pareto_front(),
seed=1,
verbose=False)
print(res.algorithm.n_gen)
6 目标空间容忍度 (f_tol)
这是一个用的很多的标准:
from pymoo.algorithms.moo.nsga2 import NSGA2
from pymoo.factory import get_problem
from pymoo.optimize import minimize
from pymoo.util.termination.f_tol import MultiObjectiveSpaceToleranceTermination
from pymoo.visualization.scatter import Scatter
problem = get_problem("zdt3")
algorithm = NSGA2(pop_size=100)
termination = MultiObjectiveSpaceToleranceTermination(tol=0.0025,
n_last=30,
nth_gen=5)
res = minimize(problem,
algorithm,
termination,
pf=True,
seed=1,
verbose=False)
print("Generations", res.algorithm.n_gen)
plot = Scatter(title="ZDT3")
plot.add(problem.pareto_front(use_cache=False, flatten=False), plot_type="line", color="black")
plot.add(res.F, facecolor="none", edgecolor="red", alpha=0.8, s=20)
plot.show()
输出如下:
参考文献
边栏推荐
- 单臂路由实验演示(Huawei路由器设备配置)
- The understanding of domain adaptation in transfer learning and the introduction of three technologies
- With 8 years of product experience, I have summarized these practical experience of continuous and efficient research and development
- Project: serial port receiving RAM storage TFT display (complete design)
- 分享六个实用的小程序插件
- 优维低代码:Use Resolves
- 【云原生之kubernetes】kubernetes集群下Secret存储对象的管理
- Osmosis通过与Axelar和Moonbeam的集成将跨链足迹扩展至波卡
- Pyqt5 click qtableview vertical header to get row data and click cell to get row data
- There are several browser cores. How to upgrade if the browser version is too low
猜你喜欢

终极套娃 2.0 | 云原生交付的封装

优秀的测试/开发程序员突破,不忘初心,方得始终......

HTTP缓存通天篇,可能有你想要的

分享六个实用的小程序插件
![[encryption weekly] has the encryption market recovered? The cold winter has not thawed yet! Check the major events in the encryption market last week!](/img/6d/b037208996ce52016d014062deaa1f.jpg)
[encryption weekly] has the encryption market recovered? The cold winter has not thawed yet! Check the major events in the encryption market last week!

The understanding of domain adaptation in transfer learning and the introduction of three technologies

房企打响“保交战”

MES管理系统有什么应用价值

Northeast people know sexiness best

The auction house is a VC, and the first time it makes a move, it throws a Web3
随机推荐
[help center] provide your customers with the core options of self-service
果链“围城”:傍上苹果,是一场甜蜜与苦楚交错的旅途
GDB help
JMeter performance test actual video (what are the common performance test tools)
The Yellow Crane Tower has a super shocking perspective. You've never seen such a VR panorama!
人人可参与开源活动正式上线,诚邀您来体验!
[translation] logstash, fluent, fluent bit, or vector? How to choose the right open source log collector
F5:企业数字化转型所需六大能力
ES6 implements the observer mode through proxy and reflection
有孚网络受邀参加2022全国CIO大会并荣获“CIO信赖品牌”称号
21 days proficient in typescript-4 - type inference and semantic check
Gan, why ".Length! == 3??
Common file operations
优维低代码:Use Resolves
Interface automation test platform fasterrunner series (IV) - continuous integration and solution of multi domain names
Typescript reflection object reflection use
【云原生之kubernetes】kubernetes集群下Secret存储对象的管理
Typescript对象代理器Proxy使用
2022 IAA industry category development insight series report - phase II
Interface automation test platform fasterrunner series (III) - operation examples