guofei9987 / guofei9987/scikit-opt

GA中严格限制解中的每个数的范围,应该怎么做

Open
#194 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
6.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

问题:
解是一个三维向量 x=[x1, x2, x3](都是整数),它的下界为[1,1,1], 上界为[1,2,20]。也就是说 x1只能是1,x2可以是1或2,x3可以是1到20。想用GA的话,precision设置为1,上界是设置为ub=[2,3,21]吗?这样设置的话,[这里](https://github.com/guofei9987/scikit-opt/blob/508b60977f52419e0588017f2d21d2864a92d251/sko/GA.py#L204)计算出来的解会取到ub,在这一问题中是不允许的(计算适应度值时对解的范围有严格要求,超出范围则无法计算)。但是如果上界ub设置为[1,2,20],在[计算lind_raw](https://github.com/guofei9987/scikit-opt/blob/508b60977f52419e0588017f2d21d2864a92d251/sko/GA.py#L161)的时候就会报错,比如x1对应的lind_raw是0。
请问对于我这样的问题应该怎么编码,上界应该怎么取?或许我应该用整数编码?想听听大佬的意见,感激不尽。

Contributor guide

Open the contributing guide

Research direction

Start by reading the bounds and encoding logic in sko/GA.py around lind_raw at line 161 and solution calculation at line 204. Reproduce the reported behavior with integer vectors and inclusive bounds [1,1,1] to [1,2,20], then determine whether the supported encoding can represent those ranges without producing invalid fitness inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.