Hello,
I am trying to use fmincon. For some reason the variables provided to the routine that calculates the goal function are the same as the inititial values in all iterations.
I check to see if the initial values are different forn the lb and ub vectors and they are.
I understand the without seeing the coede would be difficult to advise but the code is very complex and I don't want to impose, still, any ideas?
Spent like a full day trying to debug this. I could really use a 'step back' debugging option, but I understand that's not possible in Matlab.
Thank you

3 commentaires

Torsten
Torsten le 15 Fév 2022
Did you check the value returned by the objective function for the initial values you provided ? ?
John D'Errico
John D'Errico le 15 Fév 2022
You really need to show the actual problem for use to help more.
NAFTALI HERSCOVICI
NAFTALI HERSCOVICI le 15 Fév 2022
i understand. I need to simplify it and get rid of chunks that require additional apps

Connectez-vous pour commenter.

 Réponse acceptée

NAFTALI HERSCOVICI
NAFTALI HERSCOVICI le 16 Fév 2022

0 votes

I already set a breakpoint in the objective function. I already checked and saw that the variables provifded by Fmincon to the objective function are the same for all iterations

7 commentaires

NAFTALI HERSCOVICI
NAFTALI HERSCOVICI le 16 Fév 2022
I also checked the x0,lb,ub in the main script calling the fmincon, and they are Ok (ie. different and lb<x0<ub), so I need to trace back (or forward).
Do you have
format long g
in effect so you can check extended digits?
Have you tried using global or assignin to take a binary copy of the values for one pass, and then next call, recall it and subtract to see if there are differences?
Walter Roberson
Walter Roberson le 16 Fév 2022
Are you working with values greater than about 1e16 for all of your variables? During the initial gradient estimate, matlab adds a value to each variable in turn, one by one. Potentially if your values are large enough, then the result of the addition might be exactly the same value.
I would have to have another look at the code. My memory at the moment is that if upper and lower bounds are finite that it uses the difference to calculate the increment for gradient estimation, but if they are infinite (absent is the same as infinite) then a constant gets used.
NAFTALI HERSCOVICI
NAFTALI HERSCOVICI le 16 Fév 2022
I simply use disp() in the goal function to print to the screen the variables and goal function values. they are all the same for 10 iterations. After 10 iterarions I break it.
my values (variables and goal functions) are roughly betwwen 0 and 20
NAFTALI HERSCOVICI
NAFTALI HERSCOVICI le 16 Fév 2022
I uploaded the project files. the goal function (Kirilenko_HFSS11_7.m) won't run because it needs ANSYS HFSS, but the functionality pertinent to Fmincon is there.
Are you using
format long g
in order to be able to see more than 4 digits?
NAFTALI HERSCOVICI
NAFTALI HERSCOVICI le 16 Fév 2022
not yet, will try

Connectez-vous pour commenter.

Plus de réponses (2)

Steven Lord
Steven Lord le 15 Fév 2022

0 votes

Are the points provided to your function exactly the same as the initial guess or do they differ by a very small amount, small enough that the difference doesn't change how the points are displayed?
NAFTALI HERSCOVICI
NAFTALI HERSCOVICI le 16 Fév 2022

0 votes

can anyone point me to the location in Fmincon where the gol function is called?
I figure if I set a break point I can at least check what is the variabke set sent to the goal function.
This way I can find out if the problem is in the setup of the run or in the goal function
Thank you

2 commentaires

Torsten
Torsten le 16 Fév 2022
Modifié(e) : Torsten le 16 Fév 2022
Why do you want to set a breakpoint in fmincon and not in the objective function you supply ?
John D'Errico
John D'Errico le 16 Fév 2022
Modifié(e) : John D'Errico le 16 Fév 2022
Please don't ask a question by using an answer.
As Torsten says though, there is nothing stopping you from setting a breakpoint in your objective function itself. Then you know exactly what got passed in.
There will be multiple lines in fmincon where the objective function is called, so looking for ONE line in fmincon is wrong. Anyway, you can find each of those lines yourself with a search.

Connectez-vous pour commenter.

Produits

Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by