fminunc on multiple variables

4 visualizaciones (últimos 30 días)
Asad
Asad el 13 de Dic. de 2013
Comentada: Shivani Chepuri el 11 de Ag. de 2020
Hi,
I am new to using fminunc and have looked quite a bit into it but couldn't find what I was looking for. If I have a function like: myFun(x,y,z,a,b,c), how can i use fminunc to optimize over x,y and z simlutaneously.
REGARDS
  1 comentario
Shivani Chepuri
Shivani Chepuri el 11 de Ag. de 2020
Hi, Can you specify how to write lower and upper bound constraints for x,y,z variables here, using fminunc and fmincon? Also, all x,y,z are vectors. Thanks

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 13 de Dic. de 2013
Editada: Walter Roberson el 13 de Dic. de 2013
@(X) myFun(X(1), X(2), X(3), a, b, c)
  4 comentarios
Louis Perriens
Louis Perriens el 24 de En. de 2020
Very solid!! thank you!!
Shivani Chepuri
Shivani Chepuri el 11 de Ag. de 2020
Hi, Can you specify how to write lower and upper bound constraints for x,y,z variables here, using fminunc and fmincon? Also, all x,y,z are vectors. Thanks

Iniciar sesión para comentar.


Sean de Wolski
Sean de Wolski el 13 de Dic. de 2013
Objective functions expect all of the variables being optimized to be in "x"
myfun(x,a,b,c)
Where x is now a 1x3 vector. Then inside of myfun:
Use x(1) to refer to the first element, x(2) for y and x(3) for z. To pass in other variables, look at:
  4 comentarios
Asad
Asad el 13 de Dic. de 2013
I am trying to do unconstrained optimization to calculate location of 3D points, planes and camera matrices.
Sean de Wolski
Sean de Wolski el 16 de Dic. de 2013
So you are basically trying to optimize over n dimensions where n is the total number of elements in all of your matrices.
You can do this the same way Walter and I have suggested: essentially pass in a 1xn vector x and then split it into its matrices etc. inside of the objective function.
Since I would expect fminunc to have trouble with a problem like this due to many local minima and discontinuities, you might want to try using patternsearch in the Global Optimization toolbox. This solver is much better able to handle the above. You might also choose to constrain you search wherever possible. The constraints might not be obvious but some things to think about: are some variables positive? are some within a range? Do some of their value depend on others or for example a row of your matric must sum to x? etc.

Iniciar sesión para comentar.

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by