MATLAB/NOMAD for global optima?
22 次查看(过去 30 天)
显示 更早的评论
Here comes my nonsmooth nonconvex MINLP, in fact this is a maximization problem. MATLAB/NOMAD from opti toolbox does not find the global optima? Do you have any idea why?
tnank you very much, basak
clc
fun=@(x)((((x(4)*(174.9333+23.3750*x(2)+3.6250*x(3)-19.0000*x(2)*x(3)-185)/(190-185))+...
((1-x(4))*(174.9333+23.3750*x(2)+3.6250*x(3)-19.0000*x(2)*x(3)-195)/(190-195)))*...
(x(5)*((154.8571+8.5000*x(1)+30.6250*x(2)+7.8750*x(3)-12.8571*x(1)^2+11.2500*x(1)*x(2)-185)/(190-185))+...
(1-x(5))*((154.8571+8.5000*x(1)+30.6250*x(2)+7.8750*x(3)-12.8571*x(1)^2+11.2500*x(1)*x(2)-195)/(190-195)))*...
(x(6)*((140.2333+ 5.3437*x(1)+18.2500*x(2)+19.5938*x(3)-170)/(185-170))+...
(1-x(6))*((140.2333+ 5.3437*x(1)+18.2500*x(2)+19.5938*x(3)-195)/(185-195))))^(1/3))
x0 = [1.0000 0.8629 0.5863 0 0 0]';
lb = [-1;-1;-1;0;0;0];
ub = [1;1;1;1;1;1];
xtype='CCCBBB';
opts=optiset('solver','nomad','display','iter','solverOpts',nomadset('direction_type','lt 2n'))
Opt=opti('fun',fun,'bounds',lb,ub,'xtype',xtype,'options',opts)
[x,fval,exitflag,info] = solve(Opt,x0)
2 个评论
Walter Roberson
2022-9-15
编辑:Walter Roberson
2022-9-15
NOMAD appears to refer to the third party toolbox, one source of which is at https://github.com/jonathancurrie/OPTI
Note that third party toolboxes are not created by Mathworks, and volunteers here might not be familiar with them.
回答(2 个)
Abdolkarim Mohammadi
2020-7-20
Your problem is a bound-constrained problem with five decision variables. I think many solvers in the Global Optimization toolbox like GA and surrogate optimization can handle such problems efficiently.
4 个评论
Walter Roberson
2022-9-15
NOMAD is third party code. The volunteers generally do not know anything about it.
I see that the third-party toolbox historically had a user forum. However, that appears to be closed now, as the toolbox is no longer being developed.
Walter Roberson
2022-9-15
Your function can return complex values. The ^(1/3) generates a complex result when the base expression is negative.
format long g
fun=@(x)((((x(4)*(174.9333+23.3750*x(2)+3.6250*x(3)-19.0000*x(2)*x(3)-185)/(190-185))+...
((1-x(4))*(174.9333+23.3750*x(2)+3.6250*x(3)-19.0000*x(2)*x(3)-195)/(190-195)))*...
(x(5)*((154.8571+8.5000*x(1)+30.6250*x(2)+7.8750*x(3)-12.8571*x(1)^2+11.2500*x(1)*x(2)-185)/(190-185))+...
(1-x(5))*((154.8571+8.5000*x(1)+30.6250*x(2)+7.8750*x(3)-12.8571*x(1)^2+11.2500*x(1)*x(2)-195)/(190-195)))*...
(x(6)*((140.2333+ 5.3437*x(1)+18.2500*x(2)+19.5938*x(3)-170)/(185-170))+...
(1-x(6))*((140.2333+ 5.3437*x(1)+18.2500*x(2)+19.5938*x(3)-195)/(185-195))))^(1/3))
x0 = [1.0000 0.8629 0.5863 0 0 0]';
lb = [-1;-1;-1;0;0;0];
ub = [1;1;1;1;1;1];
ga_opts = optimoptions('ga', 'HybridFcn', 'fmincon')
[ga_x, ga_fval, ga_exitflag, ga_info] = ga(fun, length(x0), [], [], [], [], lb, ub, [], ga_opts)
[fmc_x, fmc_fval, fmc_exitflag, fmc_info] = fmincon(fun, x0, [], [], [], [], lb, ub, [], [])
5 个评论
Walter Roberson
2022-9-15
You can see from the below that if you permit continuous variables, then there are positions well within the bounds (not just right at the bounds) that produce complex results from the function. In my tests, roughly 45.3 % of all random configurations in-bounds produce complex results.
format long g
lb = [-1;-1;-1;0;0;0];
ub = [1;1;1;1;1;1];
N = 100;
M = length(lb);
trials = rand(M, N) .* (ub - lb) + lb;
fun=@(x)((((x(4)*(174.9333+23.3750*x(2)+3.6250*x(3)-19.0000*x(2)*x(3)-185)/(190-185))+...
((1-x(4))*(174.9333+23.3750*x(2)+3.6250*x(3)-19.0000*x(2)*x(3)-195)/(190-195)))*...
(x(5)*((154.8571+8.5000*x(1)+30.6250*x(2)+7.8750*x(3)-12.8571*x(1)^2+11.2500*x(1)*x(2)-185)/(190-185))+...
(1-x(5))*((154.8571+8.5000*x(1)+30.6250*x(2)+7.8750*x(3)-12.8571*x(1)^2+11.2500*x(1)*x(2)-195)/(190-195)))*...
(x(6)*((140.2333+ 5.3437*x(1)+18.2500*x(2)+19.5938*x(3)-170)/(185-170))+...
(1-x(6))*((140.2333+ 5.3437*x(1)+18.2500*x(2)+19.5938*x(3)-195)/(185-195))))^(1/3))
results = zeros(1, N);
for K = 1 : N
results(K) = fun(trials(:,K));
end
mask = imag(results) ~= 0;
tp = trials(:,mask).';
x1 = tp(:,1); x2 = tp(:,2); x3 = tp(:,3); x4 = tp(:,4); x5 = tp(:,5); x6 = tp(:,6);
fval = results(mask);
fval_real = real(fval(:)); fval_imag = imag(fval(:));
T = table(fval_real, fval_imag, x1, x2, x3, x4, x5, x6);
if height(T) == 0
fprintf('Excellent, %d trials produced no complex results!\n', N);
else
fprintf('Opps, %d trials produced %d complex results!\n', N, height(T));
T
end
Walter Roberson
2022-9-15
If you interpret the lb = 0 ub = 1 as being the locations of binary variables, and assume the -1 to 1 locations are continuous, then half of the random configurations lead to complex results.
format long g
lb = [-1;-1;-1;0;0;0];
ub = [1;1;1;1;1;1];
N = 1000;
M = length(lb);
trials = rand(M, N) .* (ub - lb) + lb;
trials(4:6, :) = randi([0 1], 3, N);
fun=@(x)((((x(4)*(174.9333+23.3750*x(2)+3.6250*x(3)-19.0000*x(2)*x(3)-185)/(190-185))+...
((1-x(4))*(174.9333+23.3750*x(2)+3.6250*x(3)-19.0000*x(2)*x(3)-195)/(190-195)))*...
(x(5)*((154.8571+8.5000*x(1)+30.6250*x(2)+7.8750*x(3)-12.8571*x(1)^2+11.2500*x(1)*x(2)-185)/(190-185))+...
(1-x(5))*((154.8571+8.5000*x(1)+30.6250*x(2)+7.8750*x(3)-12.8571*x(1)^2+11.2500*x(1)*x(2)-195)/(190-195)))*...
(x(6)*((140.2333+ 5.3437*x(1)+18.2500*x(2)+19.5938*x(3)-170)/(185-170))+...
(1-x(6))*((140.2333+ 5.3437*x(1)+18.2500*x(2)+19.5938*x(3)-195)/(185-195))))^(1/3))
results = zeros(1, N);
for K = 1 : N
results(K) = fun(trials(:,K));
end
mask = imag(results) ~= 0;
tp = trials(:,mask).';
x1 = tp(:,1); x2 = tp(:,2); x3 = tp(:,3); x4 = tp(:,4); x5 = tp(:,5); x6 = tp(:,6);
fval = results(mask);
fval_real = real(fval(:)); fval_imag = imag(fval(:));
T = table(fval_real, fval_imag, x1, x2, x3, x4, x5, x6);
if height(T) == 0
fprintf('Excellent, %d trials produced no complex results!\n', N);
else
fprintf('Opps, %d trials produced %d complex results!\n', N, height(T));
T
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!