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!