需要帮助解决遗传算法问题

发布于 2024-10-03 04:50:10 字数 1913 浏览 6 评论 0原文

我有这个程序可以模拟两支球队之间的足球点球。

- 球门尺寸为 24 x 8,坐标 (0,0) 位于左下角。

- 每队有 5 名踢球手和 1 名守门员(为了方便起见,我将这 2 队称为 A 队和 B 队)

- A 队 - 踢球手有 5 种策略(每人一种),并且有 5 种踢球策略守门员(因为他需要为 B 队中的每个踢球者制定策略)

-B 队 - 踢球者有 5 种策略(每人一个),守门员有 5 种策略(因为他需要为球队中的每个踢球者制定策略) A)

  • 踢球者的策略是坐标 (x,y) 和力量值。坐标是踢球的位置,力量是踢球的强度。 (稍后我将详细解释 Power 属性)。例如,每个踢球者输入策略将如下所示: (1,2) 100 或 (24,7) 25

  • 守门员的策略是一个坐标以及 +Width 和 +Height 值。这 守门员覆盖区域是一个矩形,其左下角为(x,y)位置,右上角为(x+宽度,y+高度)。例如,(3,4) 5 5 他的左下坐标位于 (3,4),(3+5,4+5) 是他的矩形(覆盖区域)的右上角。

  • 覆盖区域的最大范围是目标区域的 25%(程序将检查这一点)

  • 功率:0- 24;踢球不会有错误;踢球击中守门员覆盖区域 100% 扑救 力量:24-49 踢球会有 10% 误差(-/+10% 坐标宽);节省 90% 力量:50-75踢会有20%的误差;节省 80% 力量:76-100踢会有30%的误差;节省 50%

示例输入:功率必须为 0-100,所有其他值必须为 0-(2^7-1) 的正整数 A队 踢球手:(14,3) 25 守门员:(2,3) 4 4 (3,5) 50 守门员:(1,1) 5,5 等等...

B队: 踢球手:(9,3) 75 守门员:(1,2) 5 5 (3,13) 100 守门员:(2,3) 6 6(假设这不会超过球门区域的 25% 等等...

好吧,这就是模拟器程序。

现在我需要创建一个 GA,为模拟器提供最佳团队策略。

让我们简化问题,以便每个人都可以将其概念化:

输入: -population(随机创建n队,例如n=5,则随机创建5队,每队属性包括5个踢球手属性,5个守门员属性)

输出: -最佳团队策略(每个团队将互相比赛,并选择最好的团队进行下一次迭代,记住每个团队有 5 个踢球手策略,5 个守门员策略)

所以我最终在 n 个人口的领域中寻找 1 个解决方案

我的问题是如何开始对解决方案进行编码。我应该将解决方案编码为团队还是球员/守门员对?

例如,将其编码为 team: 染色体:= [player1,player2,player3,player4,player5,守门员1,守门员2,守门员3,守门员4,守门员5]

class Player {
 int
 int
 int
}

class Goalkeeper {
 int
 int
 int
 int
}

或将其编码为球员/守门员对:

 Chromosome:= [player, goalkeeper] = [x,y,power,x,y,weight,height]

我这样编码的问题是我必须得到5个最好的球员/守门员在最后配对组成一个团队。

另一个问题是二进制和值编码。假设我要与球员/守门员对一起使用,则值编码如下 [x,y,power,x,y,weight,height] = [2,3,100,3,3,4,5]< /code> 比二进制表示更有意义 [0010, 0011, 1100100, 0011, 0011, 0100, 0101] = [0010 0011 1100100 0011 0011 0100 0101]. 我认为交叉更容易突变将其表示为二进制,不是吗?

我只是想收集想法,这样我就有了开始的地方。

提前致谢

I have this program that simulate a soccer penalty kick between 2 teams.

-The goal is 24 x 8 with coordinate (0,0) at the bottom left corner.

-Each team has 5 kickers and 1 goalkeeper (for convenience, I'll call the 2 team Team A and Team B)

-Team A - there are 5 strategies for the kickers (one for each), and there are 5 strategies for the goalkeeper (because he need a strategy for each kicker on team B)

-Team B - there are 5 strategies for the kickers (one for each), and there are 5 strategies for the goalkeeper (because he need a strategies for each kicker in team A)

  • Strategy for the kicker is the coordinate (x,y) and power value. The coordinate is the location of the kick and the power is how strong the kick is. ( I will explain more on the Power attribute later). For example each kicker input strategy would be like this: (1,2) 100 or (24,7) 25

  • Strategy for the goalkeeper is a coordinate and a +Width and +Height values. The
    goalkeeper coverage region is a rectangle whose bottom left corner is the (x,y) position and the top right corner is (x+width, y+height). For example, (3,4) 5 5 His bottom left coor is at (3,4) and (3+5,4+5) is his top right corner of the rectangle (coverage area).

  • MAX RANGE OF COVERAGE AREA IS 25% OF GOAL AREA (the program will check this)

  • Power: 0-24; kick will have no error; kick hit goalkeeper coverage area 100% save
    Power: 24-49 kick will have 10% error (-/+10% wide of coor); 90% save
    Power: 50-75 kick will have 20% error; 80% save
    Power: 76-100 kick will have 30% error; 50% save

EXAMPLE INPUT: power must be 0-100, all other values must be positive integer with 0-(2^7-1)
TEAM A
kicker: (14,3) 25 goalkeeper: (2,3) 4 4
(3,5) 50 goalkeeper: (1,1) 5,5
and so on ...

TEAM B:
Kicker: (9,3) 75 goalkeeper: (1,2) 5 5
(3,13) 100 goalkeeper: (2,3) 6 6 (assuming this won't go over 25% of goal area
and so on ....

Ok that was the simulator program

Now I need to create a GA that come up with the best team strategy for the simulator.

Let simplify the problem so everyone can conceptionalize it:

Inputs:
-population (random creation of n team, for ex. if n=5, 5 random teams are created with each team's attribute include 5 kickers' strats, 5 goalkeeper strats)

Output:
-best team strategy (each team will play each other and the best is selected for the next iteration, remember each team has 5 kickers' strats, 5 goalkeeper strats)

So I am looking for 1 solution afterall in a field of n population

My problem is how to start encoding the solutions. Should I encode the solution as team or as player/goalkeeper pair?

for example, encoding it as team:
Chromosome:= [player1, player2, player3, player4, player5, goalkeeper1, goalkeeper2, goalkeeper3, goalkeeper4, goalkeeper5]

class Player {
 int
 int
 int
}

class Goalkeeper {
 int
 int
 int
 int
}

Or encoding it as player/goalkeeper pair:

 Chromosome:= [player, goalkeeper] = [x,y,power,x,y,weight,height]

The problem I have with encoding like this is I have to get 5 best player/goalkeeper pair at the end to make up a team.

Another question is binary and value encoding. Lets say I were to go with player/goalkeeper pair, would value encoding like this [x,y,power,x,y,weight,height] = [2,3,100,3,3,4,5] make more sense than binary representation [0010, 0011, 1100100, 0011, 0011, 0100, 0101] = [0010 0011 1100100 0011 0011 0100 0101]. I would figure it's easier to do crossover and mutation represent it as binary, no?

I am just trying to gather ideas so I have somewhere to start.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

枕花眠 2024-10-10 04:50:10

我是否正确地假设这是一个学术项目?在这种情况下,我会同时执行这两项操作,将整个团队编码在一条染色体中,并以每个球员/守门员为基础。这样您就可以检查这两种方法,看看哪一种会产生更好的结果。由于整个团队编码最终会出现在一系列不同的(获胜)球员/守门员中,因此您还可以将它们与每个球员编码产生的个人进行比较。

至于值的表示,我喜欢按照您的建议以二进制格式对它们进行编码,因为这种方式突变更直接一些。当然,如果您使用实数而不是 0 和 1,您也可以使用随机突变方法。同样,如果这是一个学术项目,您可以同时使用这两种方法并在分析中比较它们。

希望有帮助!

Do I assume correctly that this is for an academic project? In that case I would do both, encoding the whole team in one chromosome and also on a per-player/keeper basis. That way you can examine both approaches and see which one will produce better results. And since the whole-team-encoding will end up in a range of different (winning) players/keepers, you can also compare them with those individuals resulting from the per-player-encoding.

As for the representation of the values, I like to encode them in binary format as you have suggested, since mutation is a bit more straight forward that way. But of course you can also use a random mutation approach if you use real numbers instead of 0 and 1. Again, if this is for an academic project, you can do both approaches and compare them in your analysis.

Hope that helps!

他夏了夏天 2024-10-10 04:50:10

我没有给你完整的答复,但它可能是......

我会同意将所有内容编码为二进制。如果您实际上没有将其存储为位字符串,则应该确保它很容易转换为位字符串。正如您所指出的,如果您的数据被编码为位字符串,则交叉和变异是微不足道的。

至于你的染色体结构,我认为如果你选择球员/守门员对,你可能会进入毛茸茸的领域。只有将团队视为一个整体,健身才有意义。即使你找到了一对出色的搭档,如果你所有的球员表现都相似,你的球队也会很糟糕。您的健身功能需要考虑玩家动态。

希望有帮助...

I don't have a full response for you, but it may be something...

I'd say yes to encoding everything as binary. If you don't actually store it as a bit string, you should make sure that it's easy to convert to one. Like you point out, if your data is encoded as bit strings, crossover and mutation are trivial.

As for the structure of your chromosomes, I think you may be headed into hairy territory if you go for player/keeper pairs. Fitness will only make sense if you look at teams as a whole. Even if you find a great pair, you'll have a pretty poor team if all of your players behave alike. Your fitness function needs to account for player dynamics.

Hope that helps...

温柔戏命师 2024-10-10 04:50:10

首先,你在寻找什么?对于踢球者或守门员来说有什么好的策略吗?

如果对于两者来说,这听起来是共同进化的理想场景。

是的,将所有内容编码为二进制文件,如果您找不到这样做的充分理由,请不要使您的生活复杂化。

First of all, what are you looking for? Good strategies for kickers or for keepers?

If for both, this sounds to be an ideal scenario for co-evolution.

Yes to encoding everything as binaries, do not complicate your life if you cannot find a good reason to do so.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文