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.

 Akzeptierte Antwort

Torsten
Torsten am 15 Okt. 2015

0 Stimmen

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

3 Kommentare

Heborvi
Heborvi am 15 Okt. 2015
Bearbeitet: Heborvi am 15 Okt. 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 am 15 Okt. 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 am 15 Okt. 2015
Thank you so much

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 15 Okt. 2015

Kommentiert:

am 15 Okt. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by