【问题标题】:Multiple linear optimizations多重线性优化
【发布时间】:2014-04-09 09:47:10
【问题描述】:

我有兴趣在 MATLAB 中求解数百个线性系统。目前这是通过linprog的for循环完成的

所使用的向量具有相同的维度,并且是一个矩阵的行。

for combination_id = 1:1000
[tempOperatingPointsVectors,tempTargetValue, exitflag] = ...
   linprog( lo_c(combination_id,:), ...
            [], [], ...
            lo_G(:,:,combination_id), lo_d(:,combination_id), ...
            lo_u(:,combination_id), lo_v(:,combination_id), ...
            x0_in, options);
end

有没有办法将linprog 与整个向量一起使用,而不是选择每一行? 我还尝试了parfor 循环,但由于每个循环中的操作非常小,因此速度没有提高。

【问题讨论】:

  • 一个想法是重新实现算法(例如单纯形)并在合适的地方添加矩阵运算。有人知道在哪里可以找到具有上下边界的 Matlab 单纯形代码吗?

标签: performance matlab mathematical-optimization linear-programming


【解决方案1】:

为什么你不能建立一个大的线性规划,然后一次解决所有的问题?

由于我没有您的数据,我无法测试以下代码,但基本思路应该可以。

xVar = 1:size(lo_c,2);
uBound = lo_u(:, 1);
vBound = lo_v(:, 1);
dMat = lo_d(:, 1);
gMat = lo_G(:,:, 1);
objMat = lo_c(1,:);
x0_inMat = x0_in;

for combination_id = 2:1000
    xVar = [xVar, xVar(end)+1:xVar(end)+size(lo_c,2)];
    uBound = [uBound; lo_u(:, combination_id);
    vBound = [vBound; lo_v(:, combination_id);
    dMat = [dMat; lo_d(:, combination_id);
    gMat = [gMat; lo_G(:,:, combination_id)];
    objMat = [objMat; lo_c(combination_id,:)];
    x0_inMat = [xo_inMat; x0_in];
end
[tempOperatingPointsVectors,tempTargetValue, exitflag] = ...
       linprog( objMat, ...
                [], [], ...
                gMat, dMat, ...
                uBound, vBound, ...
                x0_in, options);

应该做的伎俩。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多