geatpy-dev / geatpy Goto Github PK
View Code? Open in Web Editor NEWEvolutionary algorithm toolbox and framework with high performance for Python
Home Page: http://www.geatpy.com
License: GNU Lesser General Public License v3.0
Evolutionary algorithm toolbox and framework with high performance for Python
Home Page: http://www.geatpy.com
License: GNU Lesser General Public License v3.0
我现在遇到一个无人机路径优化问题,但麻烦的是路径经过的点的个数是不确定的,这种需要可变长度的编码吗?有其他解决方案吗?
我只是看了几个demo,首先这个运行速度是真的非常快,比自己写的要好很多,不过对于选择和交叉有几个疑问。
首先是选择的时候我发现了重复选取某个个体,就是选择之后的种群中的某几个个体可能时来源于同一个个体,请问这样会造成局部最优解吗,就是感觉可能减少了全局搜索的广度。
第二个交叉,不是太清楚交叉时是哪两个个体进行交叉的
另外,请问方便给linux版本的geatpy吗,毕竟windows下很容易打游戏了,我的邮箱是[email protected],是一位来自**石油大学的小生
Hey, guys! I'm really willing to try this new "seeming wonderful" toolbox, but it turned me down while I found the modules all folded by .pyd files.
Feel sad about it.
Really hope there could be mac version or linux version. If it happens someday, I will really appreciate!
在多目标求解的结果中,如何输出帕累托最优解对应的各个决策变量的值。
运行quickstart_demo后提示:
FieldD = ga.crtfld(ranges,borders,precisions,codes,scales) # 调用函数创建区域描述器
AttributeError: module 'geatpy' has no attribute 'crtfld'
Hi, I'm trying to explore the pattern of the objective value by doing multiple runs of the main file, fixing NIND = 10 and gradually increasing MAXGEN.
However, since there's random factor in the algorithm, I'm thinking about adding a random seed, but don't know how. How can I add a random seed? Thanks!
I was running an optimization problem with 7 objective functions without any constraints using NSGA2. After running the model, I get the image of pareto front, but find it hard to interpret.
x-axis = Dimension of Number (# of objective functions in my point of view)
y_axis = Function Value
There are 7 lines in the image, the lines are close to each other but they don't coincide.
Can anyone help me interpreting the pareto front image? Or is it possible for the crew in geatpy to add a demo of multiple objective function with more than 3 dimension? Thanks!

Under geatpy 1.1.5 python 3.7 run quickstart_demo.py show error :
AttributeError: module 'geatpy' has no attribute 'crtfld'
Under spider to run line by line OK.
Why?
I know about 'maxormin' in geatpy, but how to use it correctly?
When I learn to use awGA-function, should I multiply ‘ObjV' by this 'maxormin' before?
It's quite hard for me to learn your Chinese tutorials, please explain detaily.
What should I do if the decision variable is an array?
我在运行快速入门中的带约束的多目标优化问题时出现错误提示:
TypeError: init() takes 1 positional argument but 10 were given
请问有解吗?
在进行多目标问题时,如问题规模变大需要则并行计算来提高运行效率。据我所知新版本的geatpy支持并行计算。可否添加一个附带并行计算代码的例子供大家参考学习?谢谢!
你好,我在使用soea_DE_rand_1_L_templet运行一个单目标多限制条件的最优化问题。
我的变量一共有14位
Vars = pop.Phen #决策变量矩阵 m1 = Vars[:,[0]] m2 = Vars[:,[1]] delta_d = {'AR1_1':Vars[:,[2]], 'AR1_2':Vars[:,[3]], 'AR2_1':Vars[:,[4]], 'AR2_2':Vars[:,[5]], 'AR3_1':Vars[:,[6]], 'AR3_2':Vars[:,[7]], 'AP1_1':Vars[:,[8]], 'AP1_2':Vars[:,[9]], 'AP2_1':Vars[:,[10]], 'AP2_2':Vars[:,[11]], 'AP3_1':Vars[:,[12]], 'AP3_2':Vars[:,[13]]}
模型给出的结果为 [5,10,-1,0,2,0,-4,0,-1,-3,0,-2,0,-2]。
我的限制条件共有36项,为
sum_adj = abs(delta_d['AR1_1'])+abs(delta_d['AR1_2'])+abs(delta_d['AR2_1'])+abs(delta_d['AR2_2'])+abs(delta_d['AR3_1'])+ abs(delta_d['AR3_2'])+ abs(delta_d['AP1_1'])+ abs(delta_d['AP1_2'])+abs(delta_d['AP2_1'])+ abs(delta_d['AP2_2'])+ abs(delta_d['AP3_1'])+ abs(delta_d['AP3_2'])
qualification_list = [ sum_adj - int(self.params['ADJUST_TOTAL'][0]), m1+1-m2, 1-self.redmpt['AR1'] - delta_d['AR1_1'], 1-self.redmpt['AR1']-delta_d['AR1_1']-delta_d['AR1_2'], 1-self.redmpt['AR2'] - delta_d['AR2_1'], 1-self.redmpt['AR2']-delta_d['AR2_1']-delta_d['AR2_2'], 1-self.redmpt['AR3'] - delta_d['AR3_1'], 1-self.redmpt['AR3']-delta_d['AR3_1']-delta_d['AR3_2'], 1-self.redmpt['AP1'] - delta_d['AP1_1'], 1-self.redmpt['AP1']-delta_d['AP1_1']-delta_d['AP1_2'], 1-self.redmpt['AP2'] - delta_d['AP2_1'], 1-self.redmpt['AP2']-delta_d['AP2_1']-delta_d['AP2_2'], 1-self.redmpt['AP3'] - delta_d['AP3_1'], 1-self.redmpt['AP3']-delta_d['AP3_1']-delta_d['AP3_2'], -delta_d['AR1_1']*delta_d['AR1_2'], -delta_d['AR2_1']*delta_d['AR2_2'], -delta_d['AR3_1']*delta_d['AR3_2'], -delta_d['AP1_1']*delta_d['AP1_2'], -delta_d['AP2_1']*delta_d['AP2_2'], -delta_d['AP3_1']*delta_d['AP3_2'], delta_d['AR1_1']+delta_d['AR1_2']-self.AR1_REDEMPT_RANGE_up, self.AR1_REDEMPT_RANGE_down-delta_d['AR1_1']-delta_d['AR1_2'], delta_d['AR2_1']+delta_d['AR2_2']-self.AR2_REDEMPT_RANGE_up, self.AR2_REDEMPT_RANGE_down-delta_d['AR2_1']-delta_d['AR2_2'], delta_d['AR3_1']+delta_d['AR3_2']-self.AR3_REDEMPT_RANGE_up, self.AR3_REDEMPT_RANGE_down-delta_d['AR3_1']-delta_d['AR3_2'], delta_d['AP1_1']+delta_d['AP1_2']-self.AP1_REDEMPT_RANGE_up, self.AP1_REDEMPT_RANGE_down-delta_d['AP1_1']-delta_d['AP1_2'], delta_d['AP2_1']+delta_d['AP2_2']-self.AP2_REDEMPT_RANGE_up, self.AP2_REDEMPT_RANGE_down-delta_d['AP2_1']-delta_d['AP2_2'], delta_d['AP3_1']+delta_d['AP3_2']-self.AP3_REDEMPT_RANGE_up, self.AP3_REDEMPT_RANGE_down-delta_d['AP3_1']-delta_d['AP3_2'] , -sumr1+sumar1+15, -sumr2+sumar2+20, -sumr2+sumar2+10, -sumap1 - sumap2 -sumap3 + sumc1 -30]
pop.CV = np.hstack(qualification_list)
其中,int(self.params['ADJUST_TOTAL'][0]) = 15,self.redmpt['AR1'] = 3, self.redmpt['AR2'] = 6,self.redmpt['AR3'] = 6, self.redmpt['AP1'] = 4, self.redmpt['AP2'] =4, self.redmpt['AP3'] = 4,self.AR1_REDEMPT_RANGE_up = 2,self.AR1_REDEMPT_RANGE_down = -4,其他AR AP的REDMPT_RANGE与以上相同。
以下为population中与var_trace[best_gen]相同的解对应的CV:
如果手工按照限制条件计算,第四个限制条件应该与第三个限制条件值相等 = -1。除了第四个限制条件外有些其他限制条件的CV值也与手工计算年的值不符合。请问这是什么原因导致的呢? 谢谢
请问您的论文大概什么时候能够发表,想看源代码,555555
如题:
if shift_h <= 30 and shift_v <= 30:
cv_value = -100
else:
cv_value = 100
cv.append(cv_value)
pop.Cv = np.array([cv]).T
我已经将对应解得cv置为正数了,结果中还是出现不满足约束的解,而且保存的cv文件中全为0.
请问这是怎么回事?
不知能否增加一个混合编码的demo
以这几行为例:
x1 = [-3, 5] # 自变量1的范围
x2 = [2, 10] # 自变量2的范围
b1 = [1, 0] # 自变量1的边界
b2 = [1, 1] # 自变量2的边界
codes = [0, 1] # 各变量的编码方式, 2个变量均使用格雷编码
precisions = [0, 0] # 各变量的精度, 0表示精确到个位
scales = [1, 0] # 采用算术刻度
ranges = np.vstack([x1, x2]).T # 生成自变量的范围矩阵
borders = np.vstack([b1, b2]).T # 生成自变量的边界矩阵
b1 是不是应该为[1,1], 因为上下界都存在?
codes=[1,1] 如果两个都是格雷编码?
scales = [1, 1] , 如果都采用算术精度?
when use sga_code_templet in my code, report index error in line 139:
var_trace[gen,:] = variable[bestIdx, :] # 记录当代最优的控制变量值.
Debug geatpy\source-code\templets\sga_code_templet.py, in line 179:
variable = ga.bs2int(SelCh, FieldD).astype('int64')
maybe it should be:
variable = ga.bs2int(Chrom, FieldD).astype('int64')
cause the index in line 139 is acquired from objv in line 130, and objv has changed in line 171 function ga.reins, so the dimensions of Objv and Selch are different.
thanks for apply.
Are there timeline or roadmap about geatpy 2.0?
Very looking forward to the latest version.
Thank you for your awesome work.
我注意到算法结束后可以给计算过程绘图,但是试用中发现比较在乎的还是能够实时看到计算过程,特别是计算问题比较大比较慢的时候。所以是否有可能在遗传算法过程中增加一个监控变量变化规律的功能?
I am very excited about the Geatpy2 release.
I am always confused about handling the constraints, which is the key point to the application of EA.
The punishing function method is quite simple, but once the built-in Constraint-Handling Method does not has good performance, the satisfactory optimization result will not be obtained.
Could you please give some suggestions or introductions about the combination of usual Constraint-Handling Technology with Geatpy2 in the Geatpy Tutorials?
Thanks for your excellent work.
按照网站提示安装了github上的最新版本还是报这个错
我遇到的问题解空间太大,如果随机尝试解,不能找到符合约束条件的解,因此必须产生大量的随机的有效解,如何设置呢?
已经给[email protected]发过邮件了,暂时没有回复,不知道是不是这个邮箱地址变了2333,另外tutorial写的很好,建议直接在网页端展示,pdf看起来切换不是很方便
看到您的核心代码是pyd格式,能否得到py文件
I was trying to solve a small optimization problem using NSGA2.
In MyProblem.py, I defined the aimFuc function as the following:
My input format is:
x1 = Vars[:,[0]]
x2 = Vars[:,[1]]
My output is of the format:
obj =np.array( [[a],[b],[c]] ) #where a,b,c are integers and the len(obj) = len(Vars).
When I was running my main file, I ran across the following error saying my obj shape is wrong:
RuntimeError: error in moeaplot: The number of ObjVs columns must not be 1. (使用frontplot绘图函数时,ObjV的列数不能为1。)
Can anyone help me with this one? Thanks : )
我运行如下代码:
...
[pop_trace, var_trace, times] = ga.sga_real_templet(AIM_M, 'aimfuc',
None, None, FieldDR, problem = 'I', maxormin =1, MAXGEN = 64,
NIND = 32, SUBPOP = 1, GGAP = 0.85, selectStyle = 'sus',
recombinStyle = 'xovdp', recopt = 0.85, pm = 0.2, distribute =
True, drawing = 1)
print('目标函数最大值:',np.max(pop_trace[:, 1])) # 输出目标函数最大值
print("10 win:", heapq.nsmallest(10,pop_trace[:, 1]))
a=np.reshape(pop_trace[:,1], (-1,1))
b=pd.DataFrame(np.hstack((var_trace,a)))
b.to_csv('output/ipga_result.csv')
print(Top_10_lst)
np.save("top10_result.npy",Top_10_lst)
Top_10=pd.DataFrame(Top_10_lst)
Top_10.to_csv('output/top10_result.csv')
print("end!")
尊敬的作者,看到官网有2.0版本的通知,不知何时发布
Hi, I'm writing program that involves a conditional constraint:
if abs(x1-c) = 0, then x2 = 0,
where x1 and x2 are decision variables.
I heard that there are ways to express this using big M method, but is there any bettter way to formulate this constriant in geatpy?
Thanks
Traceback (most recent call last):
File "Untitled 5.py", line 1, in
import geatpy as ea
File "/anaconda3/lib/python3.7/site-packages/geatpy/init.py", line 42, in
from awGA import awGA
ImportError: cannot import name 'awGA' from 'awGA' (unknown location)
Mac python3.7
您好,是否存在NSGA3或者MOEA/D?
当我在mac os x中利用pip安装好geatpy后,在import geatpy as ga语句执行时报出no mudule named awGA 这个错误 我的python版本是3.7
执行 ../demo/soea_demo/soea_demo1/main.py 就报错,提示 AttributeError: module 'geatpy' has no attribute 'Problem'
你好,框架中提供的非支配排序方法参考的文献是哪一篇?能提供一下吗?
When my installing:
Exception:
Traceback (most recent call last):
File "/home/server5/anaconda3/envs/tf19/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 179, in main
status = self.run(options, args)
File "/home/server5/anaconda3/envs/tf19/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 393, in run
use_user_site=options.use_user_site,
File "/home/server5/anaconda3/envs/tf19/lib/python3.6/site-packages/pip/_internal/req/init.py", line 57, in install_given_reqs
**kwargs
File "/home/server5/anaconda3/envs/tf19/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 913, in install
use_user_site=use_user_site, pycompile=pycompile,
File "/home/server5/anaconda3/envs/tf19/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 445, in move_wheel_files
warn_script_location=warn_script_location,
File "/home/server5/anaconda3/envs/tf19/lib/python3.6/site-packages/pip/_internal/wheel.py", line 607, in move_wheel_files
generated=generated, lib_dir=lib_dir,
File "/home/server5/anaconda3/envs/tf19/lib/python3.6/site-packages/pip/_internal/wheel.py", line 275, in get_csv_rows_for_installed
for row in old_csv_rows:
File "/home/server5/anaconda3/envs/tf19/lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 4333: invalid continuation byte
I do not know what caused this and how to figure it out
在使用的过程中发现一个疑问,望指教。
NIND = 100 # Set the number of individuals.
设置种群数量为100个,但是在测试问题中的aimFuc(self, Vars, CV)函数中ObjV维度是<class 'tuple'>: (91, 3),不应该是(100, 3)吗?
执行的pip install geatpy自动安装了2.0.0,按照官网简介,应该是有2.1.0.
还没办法更新到2.1.0。
2.0.0有如下报错!
from awGA import awGA
ImportError: cannot import name 'awGA' from 'awGA' (unknown location)
geatpy能否提供类似Gurobi,Cplex优化器那样的接口,可以先读取lp或MPS类型的模型文件,然后求解问题;
如read(test.lp),读取对应的模型文件,然后使用geatpy的遗传算法进行求解!谢谢!
I was running the main of soea_demo2. I ran into the following problem:
problem = MyProblem() # 生成问题对象
ea.Problem.init(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin)
TypeError: init() takes 1 positional argument but 10 were given
I didn't make any changes to the code. Is there anything wrong with the code?
Thanks!
我在网上没有找到相关资料,时间又比较急没法从头把相关算法全学一遍。
请问什么时候可以支持linux
hello, I got an error when running all the demos, The error was showed that ValueError: left cannot be >= right,the details were as followed.
Traceback (most recent call last):
File "E:/Test/GA/demo/quickstart_demo/quickstart_demo.py", line 74, in
ga.trcplot(pop_trace, [['种群个体平均目标函数值', '种群最优个体目标函数值']], ['demo_result'])
File "geatpy\trcplot.py", line 76, in trcplot.trcplot
File "D:\Anaconda3\envs\tensorflow\lib\site-packages\matplotlib\pyplot.py", line 253, in show
return _show(*args, **kw)
File "D:\PyCharm 2018.2.1\helpers\pycharm_matplotlib_backend\backend_interagg.py", line 25, in call
manager.show(**kwargs)
File "D:\PyCharm 2018.2.1\helpers\pycharm_matplotlib_backend\backend_interagg.py", line 107, in show
self.canvas.show()
File "D:\PyCharm 2018.2.1\helpers\pycharm_matplotlib_backend\backend_interagg.py", line 62, in show
self.figure.tight_layout()
File "D:\Anaconda3\envs\tensorflow\lib\site-packages\matplotlib\figure.py", line 2276, in tight_layout
self.subplots_adjust(**kwargs)
File "D:\Anaconda3\envs\tensorflow\lib\site-packages\matplotlib\figure.py", line 2088, in subplots_adjust
self.subplotpars.update(*args, **kwargs)
File "D:\Anaconda3\envs\tensorflow\lib\site-packages\matplotlib\figure.py", line 241, in update
raise ValueError('left cannot be >= right')
ValueError: left cannot be >= right
And i do not know how to deal with it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.