# How does using same variables for both objective and constraints affect optimization results?

1 visualización (últimos 30 días)
Mitsu el 15 de Jul. de 2022
Editada: Mitsu el 17 de Jul. de 2022
I am running problems with fmincon.
I usually work with 3 variables ceq = [a,b,c] as constraints that I want to be zero. While trying multiple combinations, I also ran a case where in addition to those constraints, I set f = sum([a,b,c].^2) as the function to minimize.
In this scenario, the problem would try to reduce the value of abc to meet constraints, and then in the minimization part, would try to minimize abc again to minimize them as much as possible.
Unexpectedly, I found that this configuration sometimes gives better results than leaving the objective empty (f=0).
Since the values of abc are already taken care of as constraints, why does this "redundant" setup provide different (better, usually) results?
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Alan Weiss el 15 de Jul. de 2022
By changing the objective you also change the steps that fmincon takes to solve your problem. You should not be surprised that the solution changes. If you also multiply the objective or the constraint function by 100 you might find that the solution changes again. If you change the options to have different tolerances for the constraint function you might find again that the solution changes. If you change the initial point x0 you might find that the solution changes.
In other words, changing anything about the problem or the steps fmincon takes can affect the solution.
Alan Weiss
MATLAB mathematical toolbox documentation
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Mitsu el 17 de Jul. de 2022
Editada: Mitsu el 17 de Jul. de 2022
Thank you. I was asking in terms of improvement, not just change per se. Minimizing the same values for both objective and constraints seem to yield results that improve by several orders of magnitude. I am trying to understand the reason behind it.
That is, why is there such a large change (relatively speaking, from 1e-6 to 1e-15 in the satisfaction of constraints or in the objective)?
Why is it easier for an SQP algorithm to constrain and minimize [a,b,c] at the same time, as opposed to only trying to constrain them?

Iniciar sesión para comentar.

### Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by