Help regarding simple, linear minimization problem
8 次查看(过去 30 天)
显示 更早的评论
Dear all,
I am relatively new to MATLAB, so first of all I would like to thank you in advance for your active participation and support in this forum. I have been coding in R and Python and I switched to MATLAB last week, so I'm confident with the coding, though sometimes I have some hard time to cope with understanding some specific packages like the optimization one. I would really appreciate your help in my problem which I state in what follows:
I have two variables, called ' μ' and ' σ' and I would like to solve the following minimization problem. So, in these variables (μ,σ) for a unit (say 'io') I would like to find what is the minimum value δ in order for the equation (1) to apply, so that given the variables α,β which can vary (with α,β>0 and a+b=1) α*μ io+β*σ io + δ to be equal or larger than α*μ i-β*σ i (for every i~=io).
min δ α*μ io+β*σ io + δ >= α*μ i-β*σ i (for every i~=io) s.t α,β>0 α+β=1
I know that this is possible and I assume that it is very easy, but looking at MATLAB's documentation regarding the linprog command, I was lost with how to place these equations and the constraints e.g. A, b, Aeq beq etc. in that form.
Understandably, I would like to run this problem for every i, but I can do that in a loop afterwards. It's the problem formulation that I find hard to do in a recognizable way for linprog.
I would like to thank you all very much in advance once more and I'm looking forward to your comments!
All the best, M.
0 个评论
采纳的回答
John D'Errico
2017-7-23
Sorry, but your question is not very clear. Partly because you are being sloppy in your notation. You have a,b,alpha,beta. Sometimes you use a, sometimes alpha. Are a and alpha the same? I assume so, the same for b, beta.
Are u and sigma vectors? I'd probably assume they are vectors, both of length n.
Now it sounds like for some given index j, you want to find alpha,beta,delta, that satisfy a given set of inequalities. So there are three unknowns, alpha,beta,delta? One linear constraint? So start with
Aeq = [1 1 0];
beq = 1;
Your objective f is the vector
f = [0 0 1];
So when linprog takes the dot product of f with the unknowns [alpha,beta,delta], it gets delta.
Lower bounds?
lb = [0 0 0];
Upper bounds?
ub = [1 1 inf];
Now, assume that u and sigma are column vectors. Given i0, this should get you close:
i = setdiff(1:n,i0);
A = [u(i) - u(i0),sigma(i0) - sigma(i),ones(n-1,1)];
b = zeros(n-1,1);
abd = linprog([0 0 1],A,b,Aeq,beq,lb,ub);
Without any vectors u and sigma as an example, its hard to help you more.
6 个评论
John D'Errico
2017-7-23
deltaopt = zeros(10,1);
alphaopt = zeros(10,1);
for i0 = 1:10
i = setdiff(1:n,i0);
A = [u(i) - u(i0),sigma(i0) - sigma(i),-ones(n-1,1)];
b = zeros(n-1,1);
abd = linprog([0 0 1],A,b,Aeq,beq,lb,ub);
deltaopt(i0) = abd(3);
alphaopt(i0) = abd(1);
end
[(1:10)',alphaopt,deltaopt]
ans =
1 -1.5744e-16 0.031932
2 0 0.032023
3 0 0.001141
4 1 0
5 -2.2681e-16 0.065464
6 0.081644 0.007302
7 0 0
8 1.9025e-16 0.058261
9 -1.1493e-16 0.060317
10 1.615e-16 0.051278
So alpha was not always 0 at the optimum.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

