Implicit Constraints using fmincon

Hello,
I have the following otpimzation problem: The objective function is given by: f(x)=x_1+...+x_n+x_{n+1}+...x_{n+d} And the constraints are given by: -x_i-x_j- sqrt(x_{n+1}+...+x_{n+d}) for 1<=i<j<=n. My question is how i can define the matrix of constraints A using fmincon.
Can someone help me to do this? Thanks in advance.

 Respuesta aceptada

Torsten
Torsten el 15 de Oct. de 2015

0 votos

Use the nonlinear constraint c(x)<=0 instead of the linear constraint A*x<=b.
Best wishes
Torsten.

3 comentarios

Heborvi
Heborvi el 15 de Oct. de 2015
Editada: Heborvi el 15 de Oct. de 2015
Thanks for ur answer. in fact i define my objective function as:
function f = objfun(r)
S=0;
n=3;
dimension=2;
for i=1:n
S=S+r(i);
end
for d=1:dimension
S=S+r(n+d);
end
f=S;
and the constraints as:
function [c, ceq] = confun(r)
% Nonlinear inequality constraints
n=4;
c=zeros(n*(n-1)/2,1);
for i=1:n
for j=i+1:n
c(i)=r(i)+r(j)-1;
end
end
% Nonlinear equality constraints
ceq = [];
and i got this error:
Attempted to access r(3); index out of bounds because numel(r)=2.
Do you have any idea?
Thanks again.
Torsten
Torsten el 15 de Oct. de 2015
You seem to have a solution vector with two elements, but you address r(3),r(4) and r(5) in the two routines from above - elements which do not exist.
Best wishes
Torsten.
Heborvi
Heborvi el 15 de Oct. de 2015
Thank you so much

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 15 de Oct. de 2015

Comentada:

el 15 de Oct. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by