how to use fmincon to optimize a functio with more than one control vector where the control vectors used in constrains also?

1 view (last 30 days)
I have three unknown vectors, matrices p, X, L with which I have to optimize a function norm(sp) [s is known] and these vectors are used in constraints also,
I cannot figured it out how to write p X L in one vector as in fmincon only one input vector is allowed.
Thank you so much for your help

Accepted Answer

Matt J
Matt J on 11 Jan 2025
Edited: Matt J on 11 Jan 2025
Use the problem-based optimization framework to launch fmincon. It will look approximately like,
p=optimvar('p',pi,pj);
X=optimvar('X',Xi,Xj);
L=optimvar('L',Li,Lj);
objfun=fcn2optimexpr(@(pp) norm(s*pp) , p);
nlcon=fcn2optimexpr(@(pp,XX,LL) nlconFcn(pp,XX,LL) , p, X, L);
prob = optimproblem('Objective',objfun,'Constraints',nlcon)
Initial.p=__
Initial.X=__
Initial.L=___
Final=solve(prob,Initial,'Solver','fmincon')

More Answers (1)

Torsten
Torsten on 11 Jan 2025
Edited: Torsten on 11 Jan 2025
If all three vectors/matrices are to be treated as solution variables for "fmincon", use
v = [p(:);X(:);L(:)]
It's useful to transfer the sizes of the three components of the vector v to the functions used by "fmincon" in order to recover p, X and L from v.
  1 Comment
Parna
Parna on 7 Feb 2025
Edited: Parna on 7 Feb 2025
I tried this method previously but this method is very confusing in case of orders of the matrices. problem based Optimization Framework worked for me.
Thank you.

Sign in to comment.

Categories

Find more on Problem-Based Optimization Setup in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!