Minimize multivariable function with multivariable nonlinear constraints in MATLAB
Afficher commentaires plus anciens
Hi !
So I'm trying to :
- minimize a function (non linear and multivariable)
- with constraints also non linear, multivariable and with inequations (maybe we can use slack variables) and equations
And for now I've tried this
x=[H, P, L, A, B, M]; %name of my variables
fun=@(x) (x(1)*x(3)*cos(x(4))); %function to minimize
nonlcon = % ??????
x0=[0,0 ,0 ,0 ,0 ,0] %I will have to find a first solution
A=[x(3)*cos(x4), x(6)*cos(x5),x(3)*sin(x4)+ x(6)*sin(x5)]; %constraints with inequality
b=[12.5, 12.5,25]; %boundary for constraints with inequality
Aeq=[x(1)*cos(x(2)), x(3)*cos(x(4))]; %constraints with equality
beq=[x(1)-14,x(6)*cos(x5)]; %boundary for constraints with inequality
x = fmincon(fun,x0,A,b,Aeq,beq);
but this only works for linear constraint and can't understand how works nonlcon in
Can you help, thanks :)
1 commentaire
Torsten
le 23 Oct 2023
I'm not sure which nonlinear constraints you try to set with your A, b, Aeq and beq.
A and Aeq must have 6 columns and b and beq must have as many rows as A resp. Aeq in order that
A*x <= b or Aeq*x = beq
make sense.
Réponses (2)
x0 = [0;0;0;0;0;0];
x = fmincon(@mycost,x0,[],[],[],[], [],[],@mycon)
function f = mycost(x)
f = (x(1)*x(3)*cos(x(4)));
end
function [c,ceq] = mycon(x)
A=[x(3)*cos(x(4));
x(6)*cos(x(5));
x(3)*sin(x(4))+ x(6)*sin(x(5))];
b = [12.5; 12.5; 25];
c = A-b;
Aeq=[x(1)*cos(x(2));
x(3)*cos(x(4))]; %constraints with equality
beq=[x(1)-14;
x(6)*cos(x(5))];
ceq = Aeq-beq;
end
The problem is unbounded. Consider x=[ 14, pi/2, x3,0,0,x6]. Then the problem reduces to the linear program,

This imposes no lowerbound on
, so just send it to
to push the objective to
as well.
Catégories
En savoir plus sur Systems of Nonlinear Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!