To find the minimum of a function which are constrained problems
13 次查看(过去 30 天)
显示 更早的评论
Pi = arg min F(P) + k* F( NPo − Pk)
P∈₱
with ₱ = [0, Pb) ∪ ( (N*Po) / (k+1) )
Pb=7;
F(P) = 1 − exp(−( (2^R – 1) / P ) ^ ( β/2) )
R =3;
β=8;
N=2;
k=floor((Po*N)/Pa);
Pa=9;
Po varies from 0 to 12
find the minimum value for Pi .....
pls suggest a code for this
采纳的回答
Amit
2014-1-28
Good that you tried it now. Lets see the problem again:
You want to find minimum value for the expression, where P belongs to an interval or a point dependent on P0. Thus you need to minimize twice and then find the minima between those.
irst lets define your function F, which I posted before but I'll post again.
function Fp = F(P)
R = 3;
beta = 8;
Fp = 1 - exp(-((2^R-1)./P).^(beta/2));
Now second, as P and P0 both can vary, we need to find a minima while optimizing the values of both P and P0. Here P belong to 0 to Pb and P0 belong to 0 to 12. fminbnd cannot solve this, however fmincon can. First we'll write the function that we need to minimize. The function myFunc1 is that function. It takes a 2 variable vector where the first element is P and second element is P0.
function Y = myFunc1(P)
% P is [P P0]
N = 2;
Pa = 9;
k = floor((P(2)*N/Pa));
Y = F(P(1))+k*F(N*P(2)-P(2)*k);
There is another place where P can belong to that P = ((N*Po)/(k+1)). This value of P can lie inside and outside of [0 Pb]. So we'll separately solve this for one variable P0 (as P is dependent on P0 here). The function myFunc2 does that (written below):
function Y = myFunc2(P0)
N = 2;
Pa = 9;
k = floor((P0*N/Pa));
P = N*P0/(k+1);
Y = F(P)+k*F(N*P0-P0*k);
Now lets start minimization:
First for the region where P belongs to (0 Pb)
[X1,Fval1]= fmincon(@myFunc1,rand(1,2),[],[],,[],[],[0 0],[7 12]);
% where [0 0] is lower bounds of [P P0] and [7 12] upper bounds
% Fval is the minimum value found in this region.
Second for the case where P = ((N*Po)/(k+1))
[X2,Fval2] = fminbnd(@myFunc2,0,12);
In the end, you objective is Pi which is the minimum between both optimizations. Thus Pi wil lbe
Pi = min(Fval1,Fval2);
3 个评论
Amit
2014-1-30
The warning is self explanatory. Fmincon's default algorithm requires gradient which is not there. The gradient is not a requirement though as fmincon has other solvers that it will choose in that.
The warning is just to tell you that automatically different algorithm is selected. See afterwards, it even says 'local minima found' and blah.
更多回答(1 个)
Amit
2014-1-26
Step 1: Make you function
function Y = myFunc(P,P0)
N = 2;
Pa = 9;
k = floor((P0*N/Pa));
Y = F(P)+k*F(N*P0-P*k);
function Fp = F(P)
R = 3;
beta = 8;
Fp = 1 - exp(-((2^R-1)./P).^(beta/2));
Step 2: Minimize it within the bounds:
P0 = 9;
[Pi, FVal] = fminbnd(@(x) myFunc(x,P0),0,7);
14 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!