optimization in specifc range of boundary variable
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
mohammed hussein
le 13 Fév 2017
Modifié(e) : mohammed hussein
le 14 Fév 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)
0 commentaires
Réponse acceptée
Walter Roberson
le 13 Fév 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.
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!