Allenfenqu/miannnnnnnn.py

25 lines
979 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
"""该案例展示了一个离散决策变量的最小化目标的双目标优化问题的求解。问题的定义详见MyProblem.py."""
from mypromble import MyProblem # 导入自定义问题接口
import geatpy as ea # import geatpy
if __name__ == '__main__':
# 实例化问题对象
problem = MyProblem()
# 构建算法
algorithm = ea.moea_NSGA2_templet(
problem,
ea.Population(Encoding='BG', NIND=50),
MAXGEN=200, # 最大进化代数
logTras=0) # 表示每隔多少代记录一次日志信息0表示不记录。
algorithm.mutOper.Pm = 0.2 # 修改变异算子的变异概率
algorithm.recOper.XOVR = 0.9 # 修改交叉算子的交叉概率
# 求解
res = ea.optimize(algorithm,
verbose=False,
drawing=1,
outputMsg=True,
drawLog=False,
saveFlag=False)
print(res)