"Sargondjani" wrote in message <jugktq$aot$
1...@newscl01ah.mathworks.com>...
>
>
>
> @ Matt: Yes, X is bounded to >0
===========
No, the constraints in your code bound X to >=0, which is an important distinction for what we're talking about.
> 1) It was a bit difficult to post results, and i know enough already :-)
==============
But you've asked us to comment on your results. We can't do that unless you share them with us :-)
> 2) i wanted fmincon to handle the linear constraint as a non-linear one, because in my real problem it will be a non-linear constraint. It is an inequality constraint, but i know it will always be binding. i just ran some tests and it seems that it is then better to insert it as an equality constraint. (can you confirm this?)
===========
How can I confirm that it is better? Again, I can't run your code so I don't know what you are seeing. Is it "better" in terms of speed? In terms of accuracy? I can imagine it would improve both since informing FMINCON that the constraints should be binding helps it narrow its search.
> 3) with X>0 the function sqrt(X) is differentiable, no?
==========
The constraints are X>=0, so no. The gradient contains terms 1/2/sqrt(X(i)) which are undefined wherever any X(i)=0.
In any case, as long as the iterations of FMINCON are lucky enough not to go toward the boundary {X(i)=0}, this should be of no consequence.
> 4) in your 'pet example' the scaling did improve convergence (as reflected in the condition number), so i was expecting some similar improvement if i scaled my problem,
> but it turns out that scaling makes getting the finite differences right much more difficult (in this particular case at least).
===============
Then you've been ignoring what I've been saying about FMINCON already doing the condition number normalization for you. Normalizing something twice doesn't make it more normalized!
In any case, the scaling you've chosen 1./S is not a good choice. You can check this by calculating the Hessian of the objective function (which is the same as the Hessian of the Lagrange function in this case) at the desired solution X=1 both with and without this scaling and you will see that it leaves the condition number unchanged.
Without scaling, the Hessian is H=.75*diag(S) and so cond(H)=1e6
With scaling, the Hessian becomes H=.75*diag(1./S) and so cond(H) is still 1e6.
The scaling that you really want is sqrt(1./S)
Note that because the binding constraints are linear, their contribution to the Hessian of the overall Lagrange function is zero. So, I disagree with Bruno that the constraint Hessian is what matters in this particular case.