How do I use multi-parameters in my optimization problem for fminunc?

7 vues (au cours des 30 derniers jours)
Satyajit Ghosh
Satyajit Ghosh le 9 Oct 2021
Commenté : Satyajit Ghosh le 26 Oct 2021
So, right now, I am performing an optimization with respect to all elements of 'A' matrix using below command.
[Aopt,fopt]=fminunc(@(A)myObjective(A,N33,p1,v,limit,n),A0,options);
But now I want an extra parameter (x) to be used for optimization also. This will be a scalar. Is the code will look like this?
[Aopt,fopt]=fminunc(@(A,x)myObjective(A,x,N33,p1,v,limit,n),A0,x0,options);
Thanks in advance.

Réponse acceptée

Matt J
Matt J le 10 Oct 2021
Modifié(e) : Matt J le 10 Oct 2021
You can do something like that in the problem-based framework.
A=optimvar('A',N,3);
x=optimvar('x',1);
fun=fcn2optimexpr( @(A,x)myObjective(A,x,N33,p1,v,limit,n) , A x)
sol0.A=... %initial A0
sol0.x=... %initial x0
sol=solve( optimproblem('Objective',fun) , sol0,options);
  1 commentaire
Satyajit Ghosh
Satyajit Ghosh le 26 Oct 2021
After implementing above code segment, I am getting this error.
Error using optim.internal.problemdef.ProblemImpl/solveImpl
Expected a string scalar or character vector for the parameter name
Error in optim.problemdef.OptimizationProblem/solve
Error in Optimization_FINAL.m (line 145)
sol=solve(optimproblem('Objective',fun),sol0,options);

Connectez-vous pour commenter.

Plus de réponses (1)

John D'Errico
John D'Errico le 9 Oct 2021
No. It won't look like that. fminunc cannot somehow magically know how you intend the inputs to be used. Computers cannot read your mind. Well, not yet, but the mind reading toolbox is still under beta test.
Functions assume the input paraneters are as they are defined in the help.
If you want to optimize both A and x, then you need to treat all parameters in one vector (or array). Split them apart inside your objective function.

Catégories

En savoir plus sur Get Started with Optimization Toolbox dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by