How can I write summationn constraints for an optimization problem?
Mostrar comentarios más antiguos
Good morning,
I would like to optimize the following equation:
min
with the following contraints:
x>0
Where
is a known set of values,
is equal to a [288x1] vector and
is also known as a [288x1] vector.
How can I add those constraints? I am trying to use x=fmincon(fun,x0,A,b,Aeq,beq);
Thanks!
1 comentario
Ricardo López
el 29 de Sept. de 2020
Respuesta aceptada
Más respuestas (1)
Ameer Hamza
el 29 de Sept. de 2020
Something like this
price = rand(288, 1); % example value
c = rand(288, 1); % example value
sum_c = sum(c);
x0 = rand(288, 1); % initial guess
fmincon(@(x) price.'*x, x0, [], [], [], [], [], [], @(x) nlcon(x, sum_c)) % price.'*x is same as sum(price.*x)
function [cneq, ceq] = nlcon(x, sum_c)
cneq = [];
ceq = sum(x) - sum_c;
end
Categorías
Más información sobre Quadratic Programming and Cone Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!