当前位置:网站首页>Pymoo learning (6): termination conditions
Pymoo learning (6): termination conditions
2022-07-25 19:06:00 【Inji】
List of articles
1 default setting
about Multiobjective optimization , The default settings include :
from pymoo.util.termination.default import MultiObjectiveDefaultTermination
termination = MultiObjectiveDefaultTermination(
x_tol=1e-8, # Motion in design space
cv_tol=1e-6, # The convergence
f_tol=0.0025, # Target space value
nth_gen=5, # Check the termination condition every several generations
n_last=30, # The number of last generations that should be considered in the calculation
n_max_gen=1000, # Maximum number of offspring
n_max_evals=100000 # Maximum number of evaluations
)
about Single objective optimization , The default settings include :
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 Evaluation quantity (n_eval)
from pymoo.algorithms.moo.nsga2 import NSGA2` Insert a code chip here `
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)
Output is as follows :
============================================================
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 The number of iterations (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)
Output is as follows :
============================================================
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 (time)
The format of the time-based termination criteria should be set to be similar to get_termination(“time”, “01:30:00”), Said to run 1 Hours 30 minute :
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 Design space tolerance (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 Target space tolerance (f_tol)
This is a widely used standard :
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()
Output is as follows :
reference
边栏推荐
- What is hpapaas platform?
- 【云原生之kubernetes】kubernetes集群下Secret存储对象的管理
- 如何创建一个有效的帮助文档?
- 阿里云技术专家邓青琳:云上跨可用区容灾和异地多活最佳实践
- 【DETR用于3D目标检测】3DETR: An End-to-End Transformer Model for 3D Object Detection
- I3 status configuration
- 接口自动化测试平台FasterRunner系列(四)- 持续集成、解决多域名
- How to prohibit the use of 360 browser (how to disable the built-in browser)
- 【Web技术】1391- 页面可视化搭建工具前生今世
- Youth, oh, youth
猜你喜欢

Common development software download addresses

华为交换机系统软件升级和安全漏洞修复教程

Ultimate doll 2.0 | cloud native delivery package

Youth, oh, youth

Pymoo学习 (5):收敛性分析

聊聊sql优化的15个小技巧

Huawei switch system software upgrade and security vulnerability repair tutorial

Share six practical applet plug-ins

How to change the chords after the tune of the song is changed

【iniparser】项目配置工具iniparser的简单使用
随机推荐
Talk about 15 tips of SQL optimization
Cross Site Request Forgery in PHP
Osmosis extends its cross chain footprint to poca through integration with axelar and moonbeam
【小程序开发】宿主环境详解
F5: Six capabilities required for enterprise digital transformation
Circulaindicator component, which makes the indicator style more diversified
虚拟机vmware安装步骤(如何在虚拟机安装软件)
【云原生之kubernetes】kubernetes集群下Secret存储对象的管理
PHP等于==和恒等于===的区别
Youfu network was invited to attend the 2022 national CIO conference and won the title of "CIO trusted brand"
600000 pieces of data are made from March 1 to March 31. Videodate requires starting time from 00:00 to 24:00 on March 1 to 31, which is only for notes
果链“围城”:傍上苹果,是一场甜蜜与苦楚交错的旅途
Deng Qinglin, a technical expert of Alibaba cloud: Best Practices for disaster recovery and remote multi activity across availability zones on cloud
2022 robocom provincial competition solution
A brief history from object detection to image segmentation
Software testing process (mind map)
GDB help
弱网测试工具-QNET
Alibaba cloud technology expert haochendong: cloud observability - problem discovery and positioning practice
Interface automation test platform fasterrunner series (II) - function module