Function to optimize doesn't converge in conjugate gradient and quasi newton

Hi all
I have a function as :
f(x) = x1^2 + x2^2 + 2x3^2 - x4^2 - 5x1 - 5x2 -21x3 + 7x4 +100
subject to
x1^2 + x2 ^2+x3 ^2 +x4 ^2 +x1-x2+x3-x4 - 100 <= 0
x1 ^2+2 x2 ^2+ x3^2+ 2 x^4 - x1 - x4 -10 <= 0
2x1 ^2 + x2 ^2 + x3^2 + 2x1 - x2 - x4 - 5 <=0
-100 <= xi <= 100 , i = 1,2,3,4
I tried with quasi newton and Conjugate gradient, but I don't succeed.
How could I improve it and what is the problem ? I attached my codes too

10 commentaires

Anyone could check the code? any point I'm missing ?
Your conjugate gradient code needs comments; the role of the various functions and variables is not obvious.
Your quasi-newton is not configured for the same problem, and not for any of the constraints.
In the conjugate code, fm is the function I brought in the question. hm seems to be a function that should be defined for conjugate gradient method based on the main function. dfm and dhm are their derivatives.
yes the constraints are not brought cause the problem converges without them , but not with them. and it converges with small amounts of the coefficient of dhm(x0) in line 23 which here is chosen as 10. if I chose it bigger, it won't converge even without constriants.
the other code, I should check.
I will have another look once you post a commented version of the code. Comments about the variables. Comments about the functions. Comments about the algorithm, such as a link to that particular kind of cg algorithm.
Documentation is part of any programming project.
hm seems to be
That is the kind of statement I would more expect from someone who has not written the code in question. If you wrote the code, you would be certain of hm's intended role.
Ok this is the alghorithm theory.
Commented. Code.
Not an image of an algorithm that has nothing to do with the code.
ok I will do that. I was afraid commenting would make it more confusing, because I have not written it and doubt it will not help. tomorrow I will do it
Just looking quickly at your objective...
You have a non-convex function. The -x4^2 term suggests that any solution will probably fall on a boundary, though I will not assert that to be fact without considerably more thought invested. Your boundaries are simple ones that will look like hyper-ellipses, so the intersection of those boundaries tells me the solution will be well posed. But, as I said, the solution wil probably be on a boundary. That means at least one or more of those constraints will be active.
When you say it is not converging, what does that mean to you? Why do you think it is not converging?
Since it converges without the boundaries with a certain step size I thought it's due to the boundaries

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Question posée :

le 29 Mar 2021

Commenté :

le 1 Avr 2021

Community Treasure Hunt

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

Start Hunting!

Translated by