简体   繁体   English

在 matlab 的同一线性规划中制定最大值和最小值

[英]formulate max and min in the same linear programing in matlab

I am programing a "customer satisfaction" model which I should use max and min in one linear programing.我正在编写一个“客户满意度”model,我应该在一个线性规划中使用最大值和最小值。 How can I do that?我怎样才能做到这一点? I have this Idea to use max term as a "subtraction" so it's get minimize in the code line;我有这个想法使用最大术语作为“减法”,所以它在代码行中得到最小化; am I doing right?我做得对吗?

I have another question too, how can I formulate a sigma such as picture in matlab whithout getting error?我还有另一个问题,如何在不出错的情况下制定一个 sigma,例如 matlab 中的图片?

在此处输入图像描述

as you seem we have Qst and Xst but three sigma (s, r and t), I wonder if my model has problem and I don't know how program this.如您所见,我们有 Qst 和 Xst,但只有三个西格玛(s、r 和 t),我想知道我的 model 是否有问题,我不知道如何编程。 can you help me please?你能帮我吗?

I don't quite understand what you are describing in your first question, but you can calculate your MinZ1 using nested loops:我不太明白你在第一个问题中描述的内容,但你可以使用嵌套循环计算你的 MinZ1 :

s = randi(5);
r = randi(5);
t = randi(5);

Q = rand([s,r]);
X = rand([s,t]);
L = rand([r,s,t]);
M = rand([r,s,t]);
C = rand([s,r]);

S = rand(1);
P = rand(1);
R = rand(1);

MinZ1 = 0;
for si = 1:s
    for ri = 1:r
        for ti = 1:t
            MinZ1 = MinZ1 + Q(si,ri)*X(si,ti);
        end
    end
end
for si = 1:s
    for ri = 1:r
        for ti = 1:t
            MinZ1 = MinZ1 + S*L(ri,si,ti)*(P*M(ri,si,ti)+R*C(si,ri));
        end
    end
end
end

disp(MinZ1)

If you don't like nested loops, you can achieve the same result by generating all indices combinations and passing the result to the sum function.如果您不喜欢嵌套循环,您可以通过生成所有索引组合并将结果传递给总和 function 来获得相同的结果。

[si,ri,ti] = ndgrid(1:s,1:r,1:t);

MinZ1 = sum(Q(sub2ind(size(Q),si,ri)).*X(sub2ind(size(X),si,ti)),'all') + sum(S.*L(sub2ind(size(L),ri,si,ti)).*(P.*M(sub2ind(size(M),ri,si,ti))+R.*C(sub2ind(size(C),si,ri))),'all');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM