gpt4 book ai didi

php - 使用复合聚合函数的数组子集优化

转载 作者:行者123 更新时间:2023-12-03 01:50:48 24 4
gpt4 key购买 nike

我有一个数组P = [1, 5, 3, 6, 4, ...]尺寸N和平均值A .

我想找到最有效的方法来最大化以下 3D 功能:

f(x, y) = 1 / ( (1+e^(-6(x-2))) * (1+e^(-6(y-2))) * (1+e^(-0.1x-0.3y+1.5)) )

Function gcontour plot

哪里x = c(S) = Count(S)y = m(S) = Min(S[0]/A, S[1]/A, ..., S[n]/A) ,和SP 的子集。子集不必在 P 中连续。 .

我有一种感觉,这可能可以简化为子集和问题的某种变体,但我真的不知道除了排序之外从哪里开始 P 。目标是在 PHP 中实现该算法,但实际上任何伪代码都会有很大帮助。

最佳答案

如果您正在寻找巧妙的数学简化方法,请同意其他人的观点,这个地方就是数学交流。否则,从 Math_Combinatorics 开始图书馆。然后您应该能够磨练 S 的所有独特组合:

require_once 'Math/Combinatorics.php';
$combos = new Math_Combinatorics;

$P = [1, 5, 3, 6, 4, ...];
for ($n = 1; $n <= count($P); $n++) {
foreach ($combos->combinations($P, $n) as $S) {
... your calculations on S go here ...
}
}

关于php - 使用复合聚合函数的数组子集优化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51334320/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com