optimization in specifc range of boundary variable
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
mohammed hussein
il 13 Feb 2017
Modificato: mohammed hussein
il 14 Feb 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 Commenti
Risposta accettata
Walter Roberson
il 13 Feb 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 Commento
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!