Why fmincon gives different objfun values with the same values of variables?
Show older comments
Dear all, I am trying to use fmincon to maximize an objective function, which includes a system of odes to be solved. I tried to store the x values (x is a vector of 3 elements) and fval values at every iteration. Below is the part of the message that fmincon gave me:
Local minimum possible. Constraints satisfied. fmincon stopped because the size of the current step is less than the default value of the step size tolerance and constraints are satisfied to within the default value of the constraint tolerance. criteria details
x: [4x3 double]
fval: [4x1 double]
iterations: 4
funcCount: 68
constrviolation: 0
stepsize: 2.4333e-10
algorithm: 'interior-point'
firstorderopt: 1.6806e+09
cgiterations: 39
message: 'Local minimum possible. Constraints satisfied.
fmincon s...'

>>My question is why the last two values of fval are different while the values of x are identical (shown in the table). I also checked the intermediate values (values at each funevaluations), and found that the objective function was called for a number of times with the same set of x vales!!!!
Could anyone please explain the possible reasons??
Many many thanks in advance.
Best regards Mahmudul
Answers (1)
Walter Roberson
on 28 Aug 2015
Before you display the values for that table, give the command
format long g
and then look at the values again. You will probably find that the values differ after the 5th decimal point.
6 Comments
Mahmudul Hasan
on 29 Aug 2015
Edited: Mahmudul Hasan
on 29 Aug 2015
Walter Roberson
on 29 Aug 2015
Widen the columns to 16 digits
Mi Tung
on 7 Oct 2020
Hi Mr. Walter Roberson. Can you explain me for this "Widen the columns to 16 digits"? I got the same situation like Muhamad. Many thanks
Mario Malic
on 7 Oct 2020
Edited: Mario Malic
on 7 Oct 2020
Edit: this is an option in Excel.Home tab - Number column, click on Increase decimal icon.
Mi Tung
on 7 Oct 2020
Can you show me this please, Mr. Mario. I haven't done yet this.
Walter Roberson
on 7 Oct 2020
If you are using the variable browser, then you can drag the boundaries of each column.
Categories
Find more on Get Started with Optimization Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!