Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm MATLAB:一阶多项式x,y的可行域在[-1,1]中系数未知的有效方法_Algorithm_Matlab_Mathematical Optimization_Linear Programming - Fatal编程技术网

Algorithm MATLAB:一阶多项式x,y的可行域在[-1,1]中系数未知的有效方法

Algorithm MATLAB:一阶多项式x,y的可行域在[-1,1]中系数未知的有效方法,algorithm,matlab,mathematical-optimization,linear-programming,Algorithm,Matlab,Mathematical Optimization,Linear Programming,如标题所示,在MATLAB中,我需要 及 其中所有未知的e_i都在间隔[-1,1]内。我希望解决方案不依赖于非标准的第三方功能 下面是我快速而肮脏的尝试,但复杂性增加到O(2^n),其中n是ei的数量。有什么想法吗 x0 = 3; x = [1; -3; 0]; y0 = -1; y = [3; -2; 4]; % Get all permutations of noise symbol extremities terms = size(x, 1); xx = zeros(2^terms, 1

如标题所示,在MATLAB中,我需要

其中所有未知的
e_i
都在间隔
[-1,1]
内。我希望解决方案不依赖于非标准的第三方功能

下面是我快速而肮脏的尝试,但复杂性增加到O(2^n),其中n是
ei
的数量。有什么想法吗

x0 = 3;
x = [1; -3; 0];
y0 = -1;
y = [3; -2; 4];

% Get all permutations of noise symbol extremities
terms = size(x, 1);
xx = zeros(2^terms, 1);
yy = zeros(2^terms, 1);
for j = 1:2^terms
    e = double(bitget(j - 1, 1:terms))';
    e(e == 0) = -1;
    xx(j) = x0 + sum(x .* e);
    yy(j) = y0 + sum(y .* e);
end

k = convhull(xx, yy);
plot(xx(k), yy(k));
您可以阅读有关函数的更多信息
de2bi

求绝对最小和最大界限的方法如下:

max_e = double(x >= 0);
min_e = double(~max_e);
max_e(max_e == 0) = -1;
min_e(min_e == 0) = -1;
absMax = x0 + sum(x .* max_e);
absMin = x0 + sum(x .* min_e);

同样,您也可以为y做些什么

谢谢。我刚刚尝试了一下,并获得了一点加速,但我仍然有大n的问题,因为运行时复杂性仍然是O(2^n)。此外,当像这样预分配时,我现在也有一个很大的O(2^n)内存复杂性!实际上,n通常是~100,因此您可以想象这会造成多大的问题。例如,你知道有哪一种线性优化程序,它能让事情变得不那么粗暴,更具分析性?谢谢。我不确定所有的值,但是有一种方法可以很容易地找到绝对最大值和最小值。我将把它添加到我的答案中。我能想到的另一个优化是不为0系数生成e_I。这将使n减少0个术语。
x0 = 3;
x = [1; -3; 0];
y0 = -1;
y = [3; -2; 4];

% Get all permutations of noise symbol extremities
terms = size(x, 1);
xx = zeros(2^terms, 1);
yy = zeros(2^terms, 1);
for j = 1:2^terms
    e = double(bitget(j - 1, 1:terms))';
    e(e == 0) = -1;
    xx(j) = x0 + sum(x .* e);
    yy(j) = y0 + sum(y .* e);
end

k = convhull(xx, yy);
plot(xx(k), yy(k));
% First generate all possible permutations for [-1, 1] for n terms. This is similar to what you have done but uses a matlab function
all_e = de2bi(0:(2^terms-1), terms).';
all_e(all_e == 0) = -1;
% Multiply corresponding values of x and y with those of e
xx = x0 + arrayfun(@(z) sum(x .* all_e(:, z)), 1:(2^terms));
yy = x0 + arrayfun(@(z) sum(y .* all_e(:, z)), 1:(2^terms));
max_e = double(x >= 0);
min_e = double(~max_e);
max_e(max_e == 0) = -1;
min_e(min_e == 0) = -1;
absMax = x0 + sum(x .* max_e);
absMin = x0 + sum(x .* min_e);