minimum value of one inequality
Mostrar comentarios más antiguos
i need to calculate n which should give minimum even value from the expression. what function should i use to code this.
1/(2^(n/2)) + (r/s)*(1 - 1/(2^(n/2)))<=0.1
if the value of r is known (say=0.001) and s=7;
then if i calculate manually i am getting n>=6.64
but i need minumum even integer so i should get n=8.
want to know how to code these kind of inequality
p.s: i am a beginner
Respuesta aceptada
Más respuestas (1)
Ameer Hamza
el 24 de Sept. de 2020
One way is to use optimization toolbox
fmincon(@(n) n, 0, [], [], [], [], [], [], @nlcon)
function [c, ceq] = nlcon(n)
r = 0.001;
s = 7;
c = 1/(2^(n/2)) + (r/s)*(1 - 1/(2^(n/2))) - 0.05;
ceq = [];
end
4 comentarios
danish ansari
el 24 de Sept. de 2020
Bruno Luong
el 24 de Sept. de 2020
fmincon is not applicable for integer optimization.
John D'Errico
el 24 de Sept. de 2020
GA would work.
Ameer Hamza
el 24 de Sept. de 2020
Oh! I missed the part about the solution being an integer. Yes, ga() will work here.
n = ga(@(n) n, 1, [], [], [], [], [], [], @nlcon, 1);
function [c, ceq] = nlcon(n)
r = 0.001;
s = 7;
c = 1/(2^(n/2)) + (r/s)*(1 - 1/(2^(n/2))) - 0.05;
ceq = [];
end
Categorías
Más información sobre Solver Outputs and Iterative Display 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!