FMINCON does not optimize error function

조회 수: 9 (최근 30일)
Manni0404
Manni0404 2017년 3월 16일
편집: Walter Roberson 2017년 3월 16일
I am trying to minimize the error between two price functions using the mean squared error. I want to minimize the error by changing five variables used in the first price function. After the optimization ran, the new error I get is huge (in the millions, I would expect getting a small decimal number) and the problem does not seem to be optimized at all. Someone please tell me what's wrong.
This is my code:
Z = [a, b, c, d, e];
MSE = @(Z) (immse(price1(Z(1),Z(2),Z(3),Z(4),Z(5)),price2));
initial =[0.1, 0.1, 0.1, 0.1, 0.1];
lb = [0, 0, 0, 0, 0];
ub = [1, 1, 1, 1, 1];
nonlcon = @myconstraint;
Z1 = fmincon(MSE,initial,[],[],[],[],lb,ub,nonlcon)

채택된 답변

Alan Weiss
Alan Weiss 2017년 3월 16일
Without seeing your pricee1 function or your price2 vector or your nonlinear constraint function, it is impossible to guess what is going on.
What do you get when you evaluate MSE(initial) and [c,ceq] = myconstraint(initial)? That might give you an idea about what is happening. But again, without seeing your functions, I have no idea what is happening.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 1
John D'Errico
John D'Errico 2017년 3월 16일
편집: John D'Errico 2017년 3월 16일
+1. A rule that I strongly suggest for optimization have is ALWAYS test/verify your objective function. Evaluate it at the start point. Verify that if you try different values, you get different results. Is the objective function returning something that seems reasonable? Do the same for your constraint function. Think about what you see. Only then should you throw it at an optimizer.
Next, the first time through an optimization, turn the display flag to show as much output as possible. Again, verify that it is doing something that seems intelligent to you.
Even if for some unknown reason you did not do these things before you saw a problem, then it is even more reason to have done these tests. Is it possible to do something more than always?
One other thing to consider: is your start point a feasible one? Or does it fail to satisfy the constraints? If they are not satisfied, then fmincon will need to look for a point that is feasible, and it may need to go a long way.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by