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)
Show older comments
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
0 Comments
Accepted Answer
Matt J
on 11 Jan 2025
Edited: Matt J
on 11 Jan 2025
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
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.
See Also
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!