Equality contrains ignored by fmincon

I use fmincon to minize a function with 250 variables. Some variables are dependent, but the degree of freedom is still very high. I put equality constrains to fix some varibles to constants. When I run fmincon, I received the following error from Matlab
"Solver stopped prematurely.
fmincon stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 3.000000e+03."
I checked the premature x variable. It did not meet the equality constrains at all. The elements that were set to zeros all are non-zero number. I am wondering what would be possible causes? The equality constrains seem so straight forward, but still ignored by fmincon. Could someone advise me please?

댓글 수: 8

darova
darova 2020년 4월 20일
Can you equations?
John Hoop
John Hoop 2020년 4월 20일
What do you mean by equations?
darova
darova 2020년 4월 20일
I mean can you show? THe equations?
I hope u can use this code, i too have the same problem while solving the problem with 130 variables and nearly 200 constraints, but when i used this it worked fine with me... if u want further details, u cann contact me through watsapp +91 7893397808 or try it by urself. It will work for sure
opts = optimoptions('fmincon','Display','iter','MaxFunctionEvaluations',10e+10);
problem = createOptimProblem('fmincon','objective',obj2,'x0',your_initial_point,'lb',LB,'ub',UB,'nonlcon',constraints1,'options',opts);
ms = GlobalSearch;
[x,f] = run(ms,problem);
Walter Roberson
Walter Roberson 2020년 4월 20일
if you have elements constrained to be a constant then you should rewrite the system to remove them as variables and use the constants. This is easier with Problem Based approach.
John Hoop
John Hoop 2020년 4월 20일
Hi Darova, the function I tried to minimize is a matlab m-function with many calculations inside, but with a scalar output. Below an example of the equality constrains where the first 100 elements of x are set to zero. So I would expect that fmincon will set these to be constants first, and then only optimize the remaining variables x101,...,x250. It seems that fmincon does not work like this way!
%x=(x1,x2,....,x250)
Aeq=zeros(250,250);beq=zeros(250,1);
% to set x1,...,x100 to zero
for i=1:100
Aeq(i,i)=1;
end
John Hoop
John Hoop 2020년 4월 20일
Hi Walter, Thank you very much for your suggestion. I thought about this. But, I would like to keep these variables in the system, because I eventually want to use all as optimization variables. For now, I fix these only for testing purposes.
This looks strange. Just 100 zero variables? What is the point?
for i=1:100
Aeq(i,i)=1;
end

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

답변 (2개)

BALAJI KARTHEEK
BALAJI KARTHEEK 2020년 4월 20일

0 개 추천

I hope u can use this code, i too have the same problem while solving the problem with 130 variables and nearly 200 constraints, but when i used this it worked fine with me... if u want further details, u cann contact me through watsapp +91 7893397808 or try it by urself. It will work for sure
opts = optimoptions('fmincon','Display','iter','MaxFunctionEvaluations',10e+10);
problem = createOptimProblem('fmincon','objective',obj2,'x0',your_initial_point,'lb',LB,'ub',UB,'nonlcon',constraints1,'options',opts);
ms = GlobalSearch;
[x,f] = run(ms,problem);

댓글 수: 1

John Hoop
John Hoop 2020년 4월 20일
Hi Balaji, thank you very much for suggestions. I am going to have some tries and may contact you via whatapp. Cheers, Jun

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

Matt J
Matt J 2020년 4월 20일

0 개 추천

You cannot use the Aeq, beq constraint parameters to force exact equality. You could instead try setting the upper and lower bounds,
lb(1:100)=0;
ub(1:100)=0;
but if you are reaching the function evaluation limit, it may be that a feasible solution with the parameters you've set to zero simply does not exist.

댓글 수: 2

John Hoop
John Hoop 2020년 4월 20일
Hi Matt, Thank you very much. This is very good to know. Equality constrains are a bit misleading.
Matt J
Matt J 2020년 4월 20일
You should be mindful that all of the constraints (except usually the bounds) are subject to the ConstraintTolerance parameter listed here,

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

질문:

2020년 4월 20일

댓글:

2020년 4월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by