Optimization problem with a function of 2 parameters

I have a function with h, t parameters. And i want to find the values of the parameters that minimise the function. My function is quadratic and i have inequalities for the 2 parameters. h=[1.1;inf]; and t=[1000;10000];
I am trying to use the fmincon function as i have constrained nonlinear multivariable function but i dont find an example of a function with 2 parameters. Can you write an example of fmincon function for a function with 2 parameters? Can you tell me how can i find the 'x0' value?

4 comentarios

Torsten
Torsten el 9 de Mayo de 2019
All the examples given here
are examples with two parameters.
my function is f(h,t). all the examples are f(x). I want to minimize f(h,t) when h=[1.1;inf]; and t=[1000;10000]. is there an example for my problem?
Thank you for the answer.
Stathis
Torsten
Torsten el 9 de Mayo de 2019
Set h = x(1) and t = x(2).
Stathis Kritikos
Stathis Kritikos el 10 de Mayo de 2019
Editada: Stathis Kritikos el 10 de Mayo de 2019
TC=@(h,t) (QC(h)+FC(t)+RC)./E(t)
I have this function. and i want to find h,t when TC is minimized. when h=(1.5*10^-5:2.5*10^-5) and t=(1000 :100000). Which function of the optimization toolbox can i use and how. TC is a big quadratic function.
The paper i am reading says that i have to implement an SQP. But as i said the fynction is too big to find all the matrix in order to formulate sqp.
Thank you

Iniciar sesión para comentar.

 Respuesta aceptada

Torsten
Torsten el 10 de Mayo de 2019
TC = @(x) (QC(x(1))+FC(x(2))+ RC)/E(x(2));
lb = [1.5e-5,1000];
ub = [2.5e-5,100000];
sol = fmincon(TC,[2e-5,10000],[],[],[],[],lb,ub)

10 comentarios

Stathis Kritikos
Stathis Kritikos el 10 de Mayo de 2019
Editada: Stathis Kritikos el 10 de Mayo de 2019
in this way i have to change all the parameters in all the functionsincludes in TC in X(1) and X(2)?
I run it and i have this problem
Index exceeds the number of array elements (1).?What is the problem?
Thank you so much for your help
Torsten
Torsten el 10 de Mayo de 2019
We need to see your code. If QC,FC and E are normal functions accepting a scalar and returning a scalar, all should work fine.
QC=@(y) -k.*DX0.*(MX0+y(1)).*normcdf(((y(1)-MX0)./DX0)+DX0.*MX0.*k.*normcdf(-MX0./DX0)-k.*(DX0.^2+MX0.^2).*normcdf(-MX0./DX0)+k.*(DX0.^2+MX0.^2).*normcdf(((y(1)-MX0)./DX0)+(1-normcdf((X(1)-MX0)./DX0)+normcdf(-MX0./DX0)).*s+CI))
FC=@(y) fC.*(1-(normcdf((H-2.*pi.*c.*mr.*MF.*y(2)))))./(2.*pi.*c.*y(2).*sqrt(dr.^2.*DF.^2+dr.^2.*MF.^2+mr.^2.*DF.^2))./R(1000)
RC=50
E= @(y)(1./R(1000)).*(y(2).*R(y(2))-1000.*R(1000)+integral(FT,1000,y(2)))
TC=@(y) (QC(y(1))+FC(y(2))+RC)/E(y(2))
All the other letters are constant or values been found.
FT is @(y)t.*fT(y) and
fT = @(y)(H./(sqrt(2.*pi).*b.*y(2).^2)).*exp((-1).*((H-a.*y(2)).^2)./(2.*b.^2.*y(2).^2)).
In the beggining i used h,t till you told me to use y, y(1)=h and y(2)=t. the problem is in the optimization and i dont know how to fix it.
Torsten
Torsten el 10 de Mayo de 2019
Editada: Torsten el 10 de Mayo de 2019
You don't need to rewrite QC, FC and E in y. Just leave them as they were before.
E.g.
QC=@(h) -k.*DX0.*(MX0+h).*normcdf(((h-MX0)./DX0)+DX0.*MX0.*k.*normcdf(-MX0./DX0)-k.*(DX0.^2+MX0.^2).*normcdf(-MX0./DX0)+k.*(DX0.^2+MX0.^2).*normcdf(((h-MX0)./DX0)+(1-normcdf((X(1)-MX0)./DX0)+normcdf(-MX0./DX0)).*s+CI))
FC = @(t) fC.*(1-(normcdf((H-2.*pi.*c.*mr.*MF.*t))))./(2.*pi.*c.*t.*sqrt(dr.^2.*DF.^2+dr.^2.*MF.^2+mr.^2.*DF.^2))./R(1000)
etc.
i run it succesfully. Thank you so much for your help.
A few answers would be useful for me instead.
Looking the code you send me.
TC = @(x) (QC(x(1))+FC(x(2))+ RC)/E(x(2));
lb = [1.5e-5,1000];
ub = [2.5e-5,100000];
sol = fmincon(TC,[2e-5,10000],[],[],[],[],lb,ub)
The [2e-5,10000] is the x0? x0 means the starting values of h and t?
Thank you
Torsten
Torsten el 10 de Mayo de 2019
Two times yes.
ΟΚ. Finally the code you rote me is an SQP method right?
Torsten
Torsten el 10 de Mayo de 2019
You can choose the algorithm under "options" :
https://de.mathworks.com/help/optim/ug/fmincon.html#busow0u-1_1
If i choose the code you wrote me before,i have a problem?fmincon is not an sqp method?
Matlab shows to me a result of this format at the end of optimization. what does it mean?
sol =
1.0e+04 *
0.0000 9.9927
Which is the x1 and which is the x2?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Quadratic Programming and Cone Programming en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 9 de Mayo de 2019

Comentada:

el 11 de Mayo de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by