optimization in specifc range of boundary variable

1 visualización (últimos 30 días)
mohammed hussein
mohammed hussein el 13 de Feb. de 2017
Editada: mohammed hussein el 14 de Feb. de 2017
Hi
i need some help in my problem . i am working with optimization function (fmincon). i have specific number of boundary value , i do not have range
for example , the range of first variable in this example is form 0 to 1 but in my problem i have [0 1 1.2 1.5 1.7 1.9 2 2.3 ] . also in second variable for this example has from 0 to 2 but in my problem i have [0 1 1.8 1.9 1.99 2 2.5 2.9 ] . how can i do that ?
thank you
fun = @(x)1+x(1)/(1+x(2)) - 3*x(1)*x(2) + x(2)*(1+x(1));
lb = [0,0];
ub = [1,2];
A = [];
b = [];
Aeq = [];
beq = [];
x0 = [0.5,1];
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub)

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Feb. de 2017
fmincon cannot be used for discrete variables.
fun = @(x1, x2) 1 + x1 ./ (1+x2) - 3 * x1 .* x2 + x2 .* (1 + x1);
x1_vals = [0 1 1.2 1.5 1.7 1.9 2 2.3 ];
x2_vals = [0 1 1.8 1.9 1.99 2 2.5 2.9 ];
[X1, X2] = ndgrid(x1_vals, x2_vals);
Z = fun(X1, X2);
[best_Z, idx] = min(Z(:));
x = [X1(idx), X2(idx)];
Now x is the location of the best combination.

Más respuestas (0)

Categorías

Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by