looking for a solution for an optimization problem

hi, I am looking for a solution for an optimization problem,
I have a set of non-linear equations and I am looking for positive results, what is the method to follow? an example if possible.
thanks a lot

 채택된 답변

Alan Weiss
Alan Weiss 2020년 2월 5일

0 개 추천

You might find this example relevant. If you have a recent MATLAB version, then look at this example.
Alan Weiss
MATLAB mathematical toolbox documentation

댓글 수: 4

Thanks, excuse me because I’m a beginner, for exemple: If i look for solving this 3 equations: (X(1)^2)-1=0; (x(2)^2)-4=0; (x(3)^2)-9=0; and i have contrainte: X(1:3)>=0; I maked program:confuneq.m: Function [c, ceq] =confuneq(x) c=-x(1:3); ceq=(X(1)^2)-1=0 (x(2)^2)-4=0 (x(3)^2)-9=0; And exemple.m: X0=[0,0,0]; options=optimoptions('lsqnonlin',FiniteDifferenceType',central'); X=lsqnonlin(@confuneq, x0, [], [], options); The x result [0 0 0]! Spite not satisfate [1 2 3] result why?
The problem is your initial point has gradient 0. Take almost any nonzero initial point.
Alan Weiss
MATLAB mathematical toolbox documentation
Thanks a lot, is there an other program using fmincon for solving this?
I changed the initial value for x0 =[0. 1,0.1,0.1] but the result x =[9.8900e-16,0.1,0.1] not [1 2 3], can you help me please

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Alan Weiss
Alan Weiss 2020년 2월 6일
I think that you need to be more careful when trying to follow the example. EITHER use fmincon OR use lsqnonlin, not both. The fmincon workflow:
fun = @(x)0;
The nonlinear constraint function is nlcon at the end of this example.
Set lower bounds of zero.
lb = zeros(3,1);
Run fmincon starting from [0.1;0.1;0.1];
x0 = 0.1*ones(3,1);
[x,fval,eflag] = fmincon(fun,x0,[],[],[],[],lb,[],@nlcon)
This finds the solution you want.
Alan Weiss
MATLAB mathematical toolbox documentation
function [c,ceq] = nlcon(x)
c = [];
ceq = [x(1)^2 - 1;
x(2)^2 - 4;
x(3)^2 - 9];
end
Zinedine Gueddal
Zinedine Gueddal 2020년 2월 8일

0 개 추천

Thank you very much, it is for the first time I see this excellent idea (flag instead of exitflag)!
Zinedine Gueddal
Zinedine Gueddal 2020년 2월 8일

0 개 추천

I tried this program for fmincon on its market and I found positive results, but I tried another program but I found results at x near zero, how can I find x and not negative ?

댓글 수: 1

I'm sorry, but I do not understand what you are asking. Are you saying that different input data yields different results, and some of those results are not satisfactory? Or are you saying that you tried running another program and it gave better results? Or are you asking something else?
Alan Weiss
MATLAB mathematical toolbox documentation

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

질문:

2020년 2월 5일

댓글:

2020년 2월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by