Why fmincon gives different objfun values with the same values of variables?

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)

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

Hi Walter, Thank you for your reply. Yes, I tested that and still found that the x values were same while there is a big difference in the fval. I also manually checked these x-values and came up with a favl, which is different to the values given by fmincon, but one of the many values calculated by fmincon. So, part of my question was also why fmincon evaluate the objective function a number of times with the same x-values? Below is a part of the excel file containing the x and fval. You can see that same x-values but different values of fval.
Any suggestions would be highly appreciated.
Many thanks again.
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
Edit: this is an option in Excel.Home tab - Number column, click on Increase decimal icon.
Can you show me this please, Mr. Mario. I haven't done yet this.
If you are using the variable browser, then you can drag the boundaries of each column.

Sign in to comment.

Categories

Asked:

on 28 Aug 2015

Edited:

on 7 Oct 2020

Community Treasure Hunt

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

Start Hunting!