fminsearch with side conditions

조회 수: 13 (최근 30일)
Marc Laub
Marc Laub 2022년 5월 17일
댓글: Marc Laub 2022년 5월 18일
Hey,
I have a equation where I am looking for the minimum. The equation has 6 variables, but due to interdependencies it can be reduced to 4.
My problem is that there is a side condition which I cannot translate into the function and therefore the results are wrong.
The side condition is that 3 of those variables have to sum up to 1, which I have realized as :
c=1-a-b
and that the sum of a and b ahs to be less or equal to 1.
So it is possible that c is zero, but not less.
And that last side condition wont o into my function. I can surely replace c by 1-a-b, but how do I get the a+b<=1 into my function
Many Thanks in advance and best regards

채택된 답변

John D'Errico
John D'Errico 2022년 5월 17일
편집: John D'Errico 2022년 5월 17일
Generally, the solution is to not use fminsearch. Use a better optimizer instead. It will be faster, and you will get a better answer. What can I say?
FMINCON would be my first recommendation. However, other tools, like LSQLIN or INTLINPROG might be appropriate, since I don't know your actual problem.
CAN you use fminsearch? Well, yes. You could do so. If I were pressed, I would start by replacing c completely in your problem, replacing it with 1-a-b. Then I would use a penalty function approach. Start out with an initial value for fminsearch that satisfies your requirements, that a+b <= 1. INSIDE your objective function, IF fminsearch passes in a set of parameters where a+b is NOT acceptable, then don't even bother trying to evaluate the function, just return inf. Fminsearch will not be fazed by this infinite penalty on the objective, and it should produce a result that satisfies your goals as long as you start with a feasible point.
If you want a better, more complete answer, then I would need to see more information. What is your ACTUAL problem? Perhaps this is a simple linear problem in some way, and a tool such as intlinprog or lsqlin would be sufficient.
  댓글 수: 3
John D'Errico
John D'Errico 2022년 5월 17일
If you have the optimization toolbox, use fmincon as a better choice here. If you don't have that TB then get it, as it is a terribly useful toolbox IMHO. If you cannot get that toolbox, then use fminsearch as I described (or fminsearchbnd, written by some hack who I can't remember his name.)
Marc Laub
Marc Laub 2022년 5월 18일
I have it.
I tried it with fmincon but while trying I figured out mutiple non linear side conditions that also should not be violated. Guess Ill try to solve this with a penalty approach within fmincon, just have to figure out where fmicon evaluates those values.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by