approaching goal attaining optimization problem

I have a equation, I'm trying to aim for certrain fixed output but I have single equation and two variables to change. i'm trying achieve fixed sigma value. L0, t01 are optimized output values for fixed sigma values. I have no clue, how to approach this problem, I tried few things but they did't work out. Could someone help me with my problem? Thank you in advance.
%Below Rt and N are user defined
%T is fixed as well
% L0 upperbound 200
%t01 upperbound 28
j = sym('j');
Area= eval((L0*t01*symsum((4^(j+1))*((0.5)^j)*(Rt^j),j,0,N-1))-((t01^2)*symsum(2^(2*j+1)*(Rt^((2*j)-1)),j,1,N-1))-((t01^2)*symsum(2^(2*j+2)*Rt^(2*j),j,0,N-1)));
Sigma= (Area/T^2)*100;
x0=[200 20];
A = []; Aeq = []; Beq = []; B=[];
options = optimoptions(@fmincon,'Algorithm','trust-region-reflective','TolFun',1e-14,'TolX',1e-14,'MaxFunEvals',10000,'MaxIter',10000,'Display','iter');
lb=[180 20]
ub=[200 28]
sigma
fun = @(L0,t01)(Sigma-(Area/T^2)*100);
[fval1,fval2]=fmincon(@fun,x0,A,B,Aeq,Beq,lb,ub,@confunc)

11 件のコメント

Torsten
Torsten 2022 年 1 月 13 日
編集済み: Torsten 2022 年 1 月 13 日
What is N ?
What is Rt ?
Where is confunc ?
You set Sigma = Area/T^2 * 100 . So what does
fun = @(L0,t01)(Sigma-(Area/T^2)*100);
mean - it's always =0 ?
Please describe in more detail what you try to do.
Chandra Sekhar Kommineni
Chandra Sekhar Kommineni 2022 年 1 月 13 日
N(no of iterations: 3) and Rt(0.4) are two user defined variables. I wrote a function to calculate Sigma using N,Rt, L0 and t01. but I'm working on specific problem where I need to fix sigma and find out L0, t01.
Sigma = Area/T^2 * 100, so here I want fix a value for sigma and find out L0 and t01 .
I'm sorry there is no confunc, I copied some code from online.
Torsten
Torsten 2022 年 1 月 14 日
So for given values of N, Rt and T you want to determine L0 and t01 such that Area/T^2*100 equals a prescribed value of sigma ?
Chandra Sekhar Kommineni
Chandra Sekhar Kommineni 2022 年 1 月 14 日
Yes, Exactly. Could you please explain how to appraoch the problem?
Chandra Sekhar Kommineni
Chandra Sekhar Kommineni 2022 年 1 月 14 日
I wrote below script, but it is not working. I'm receiving following error, Failure in initial objective function evaluation. Optimization cannot continue.
goal=33;
weight=0.2;
x0=[150 10 0.3];
lb=[150 10 0.3];
ub=[220 30 0.5];
x = fgoalattain(@myfun,x0,goal,weight,[],[],[],[],lb,ub);
function Sigma= myfun(L0,t01,Rt)
T=320;
N=3;
j = sym('j');
Area= eval((L0*t01*symsum((4^(j+1))*((0.5)^j)*(Rt^j),j,0,N-1))-((t01^2)*symsum(2^(2*j+1)*(Rt^((2*j)-1)),j,1,N-1))-((t01^2)*symsum(2^(2*j+2)*Rt^(2*j),j,0,N-1)));
Sigma= (Area/T^2)*100;
end
Torsten
Torsten 2022 年 1 月 14 日
x = fgoalattain(@(x)myfun(x(1),x(2),x(3)),x0,goal,weight,[],[],[],[],lb,ub);
Chandra Sekhar Kommineni
Chandra Sekhar Kommineni 2022 年 1 月 14 日
Thank you for your help, but I'm getting wrong results. I'm getting lb values as output
Torsten
Torsten 2022 年 1 月 14 日
編集済み: Torsten 2022 年 1 月 14 日
And you are sure that the problem you formulated is really what you want to solve ? Because you said Rt is also given - now it turns out that it is a solution variable, too. And you said you prescribe a sigma and try to adjust L0 and t01 such that Area/T^2 * 100 approximates sigma best possible. But where is this sigma in your problem formulation ?
What you now try to solve is
min: gamma
such that
Area/T^2 * 100 - gamma*0.2 <= 33
something quite different, I guess.
Chandra Sekhar Kommineni
Chandra Sekhar Kommineni 2022 年 1 月 14 日
I wanted tried with Rt also variable.
can you please explain what is this ? Area/T^2 * 100 - gamma*0.2 <= 33 ?
Chandra Sekhar Kommineni
Chandra Sekhar Kommineni 2022 年 1 月 14 日
i tried using fmicon, but similar results(output as lower bound values, I'm getting fval negative). I don't know, I'm missing something.
x0=[1 1 0.1];
lb=[ 150 10 0.1];
ub=[210 30 0.5];
[x,fval] = fmincon(@ (x) myfun (x (1), x (2), x (3)),x0,[],[],[],[],lb,ub);
function Sigma= myfun(L0,t01,Rt)
T=320;
N=2;
j = sym('j');
Area= ((L0*t01*symsum((4^(j+1))*((0.5)^j)*(Rt^j),j,0,N-1))-((t01^2)*symsum(2^(2*j+1)*(Rt^((2*j)-1)),j,1,N-1))-((t01^2)*symsum(2^(2*j+2)*Rt^(2*j),j,0,N-1)));
%Sigma=double((Area/T^2))*100
Sigma= double(Area/T^2 * 100) -33;
end
Chandra Sekhar Kommineni
Chandra Sekhar Kommineni 2022 年 1 月 14 日
I did tweaks to the above code, somewhat I achieved the goal. I added "options" to fgoalattain, its working sometimes, sometimes error is more. Can you please tell whats happening in optimset? is there anything else to improve the code
clc;clear all;
goal=29;
weight=0.0001;
x0=[1.0 1.0 0.1];
lb=[204 18 0.4];
ub=[230 26 0.48];
options = optimset( 'Display' , 'iter' , ...
'GoalsExactAchieve' ,2);
%options = optimoptions(@lsqnonlin,'Algorithm','trust-region-reflective','TolFun',1e-14,'TolX',1e-14,'MaxFunEvals',10000,'MaxIter',10000,'Display','iter');
[x, feval]= fgoalattain(@ (x) myfun (x(1), x(2), x(3)), x0, goal, weight, [], [], [], [],lb,ub,[],options);

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

回答 (1 件)

Aman
Aman 2024 年 1 月 23 日

0 投票

Hi Chandra,
As per my understanding, you are trying to solve the multi-objective goal attainment problem and are facing issues with that.
For "fgoalattain", the recommended optimization option is "optimoptions", so instead of using "optimset", you can use "optimoptions" and try setting tolerance flag options such as "OptimalityTolerance", which sets termination tolerance for first-order optimality. Please refer to the below link to learn more about "optimoptions".
I hope it helps!

製品

リリース

R2021b

質問済み:

2022 年 1 月 13 日

回答済み:

2024 年 1 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by