Mat*_*Mat 12 php arrays optimization aggregate subset
我有一个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)) )
where x = c(S) = Count(S)和y = m(S) = Min(S[0]/A, S[1]/A, ..., S[n]/A),S是和的一个子集P.子集不必是连续的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 ...
}
}
Run Code Online (Sandbox Code Playgroud)