To find the minimum of a function which are constrained problems

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

5 件のコメント

Ashly Kurian
Ashly Kurian 2014 年 1 月 26 日
the minimum should be found for both parts of the eqn....
Amit
Amit 2014 年 1 月 26 日
So you're trying to find P such that F(P) + k*F(N*P0-Pk) is minimum?
Ashly Kurian
Ashly Kurian 2014 年 1 月 26 日
s...
Amit
Amit 2014 年 1 月 26 日
what is s...
Ashly Kurian
Ashly Kurian 2014 年 1 月 26 日
sorry...yes

サインインしてコメントする。

 採用された回答

Amit
Amit 2014 年 1 月 28 日

0 投票

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 件のコメント

Ashly Kurian
Ashly Kurian 2014 年 1 月 28 日
Thanks a lot...
Ashly Kurian
Ashly Kurian 2014 年 1 月 29 日
when I run myFunc1 to find minimum following warning occurs
Warning: To use the default trust-region-reflective algorithm you must supply the gradient in the objective function and set the GradObj option to 'on'. FMINCON will use the active-set algorithm instead. For information on applicable algorithms, see Choosing the Algorithm in the documentation. > In fmincon at 520 Warning: Your current settings will run a different algorithm (interior-point) in a future release. > In fmincon at 525
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in feasible directions, to within the default value of the function tolerance, and constraints are satisfied to within the default value of the constraint tolerance.
No active inequalities.
Amit
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
Amit 2014 年 1 月 26 日

0 投票

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 件のコメント

Ashly Kurian
Ashly Kurian 2014 年 1 月 26 日
Po is not 9...it varies from 0 to 12...what is x
Amit
Amit 2014 年 1 月 26 日
X is a simple variable for the function. You said P0 varies from 0 to 12. From that statement, I thought that for a scenario, P0 is constant.
Please state your question clearly. That includes the objective of the problem. Also, MATLAB has a very good help. Try seeing what different function do and how can you use it.
Ashly Kurian
Ashly Kurian 2014 年 1 月 26 日
also P∈₱ where ₱ = [0, Pb) ∪ ( (N*Po) / (k+1) )
Amit
Amit 2014 年 1 月 26 日
Is P0 integer or a real number?
Ashly Kurian
Ashly Kurian 2014 年 1 月 26 日
編集済み: Ashly Kurian 2014 年 1 月 26 日
Considering the equation the first part F(P) .. the function is given as follows
F(P) = 1 − exp(−((2^R – 1)/P)^(β/2))
Here R and β are constant and P belongs to ₱ where ₱ = [0, Pb)∪ ((N*Po)/(k+1))…(that U is referred as union)
Pb=7
k=floor((Po*N)/Pa);
Pa=9; N=2
Po varies from 0 to 12
Considering the second part k* F( (N*Po) − (P*k))……….
F ( NPo − Pk) is also a function as F(P) = 1 − exp(−((2^R – 1)/P)^(β/2)) but instead of P have to substitute NPo − Pk so the function will become as follows
F(NPo − Pk) = 1 − exp(−((2^R – 1)/( NPo − Pk))^(β/2))
Here again R and β are constant again Po varies from 1 to 12 and P is same as mentioned before….
Min value of P should be found from both the parts of the equation and added and should be stored in a variable Pi
Ashly Kurian
Ashly Kurian 2014 年 1 月 26 日
Po is a real no
Amit
Amit 2014 年 1 月 26 日
The way I'll do this problem is like this. I'll make 3 function files.
One for F(P) as I have done in the answer.
Second where input is [P,P0] and output will be Y. You can optimize this using fmincon for the scenario where P belongs to [0,Pb).
Third, for the case where P = N*P0/(k+1). This function will take only 1 input as P0. N*P0/(k+1) is out of [0,Pb) only when P0 >= 10.5. Thus, the P0 bounds in this case will be [10.5,12]. I can optimize this using fminbnd (as this is a single variable function).
Now I can take the minimum of both solution, which will be the value for pi.
Read MATLAB documentation for these function and try it out. If you can't succeed in doing this, I'll help you. But I need to see your effort and the code you tried.
Ashly Kurian
Ashly Kurian 2014 年 1 月 26 日
three different m files?....that previous ans u posted ...i got error
Amit
Amit 2014 年 1 月 26 日
編集済み: Amit 2014 年 1 月 26 日
what error you got?
Try reading this: This might help you in understanding what I meant by 3 function files. http://www.mathworks.com/help/matlab/ref/function.html
Ashly Kurian
Ashly Kurian 2014 年 1 月 26 日
Error using myFunc (line 4)
Not enough input arguments.
Amit
Amit 2014 年 1 月 26 日
That means, you're not entering the right amount of input for the function. Did you see the function link I posted here.
Ashly Kurian
Ashly Kurian 2014 年 1 月 28 日
How to give input to the above mentioned code.....
Ashly Kurian
Ashly Kurian 2014 年 1 月 28 日
編集済み: Ashly Kurian 2014 年 1 月 28 日
Is this code correct?
function Y = myFunc(P)
N = 2;
Pa = 9;
for P0 = 1:1:10
k = floor((P0*N/Pa));
Y = F(P)+k*F(N*P0-P*k)
end
function Fp = F(P)
R = 3;
beta = 8;
Fp = 1 - exp(-((2^R-1)./P).^(beta/2));
Step 2: Minimize it within the bounds:
[Pi, FVal] = fminbnd(@(x) myFunc(x),0,7.1)
Amit
Amit 2014 年 1 月 28 日
See the answer.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeOptimization についてさらに検索

質問済み:

2014 年 1 月 26 日

コメント済み:

2014 年 1 月 30 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by