Surrogate optimization with different size constraints
4 次查看(过去 30 天)
显示 更早的评论
I have this problem for optimization (22-dimensional):
Min sum(t1/x1,t2/x2,...,t22/x22)
Subject to:
x1 + x2 + ... + x22 -140 - tol <= 0
-x1 - x2 - ... - x22 +140 - tol <= 0
-x1 <= -1
-x2 <= -1
...
-x22 <= -1
In surrogate optimization I have to add the constraints into the objective function handle, like this:
function F = transport(x)
% transporte is a 22-D problem
D = 22;
t = [3717,4982,3688,4337,6405,3769,3968,4900,5746,5753,7388,2832,4182,3618,4009,5291,5710,3742,3875,3436,5167,3950];
z = sum(t./x);
tol = 1e-3;
c1 = [sum(x) - 140 - tol;sum(-x) + 140 - tol];
A = ones(1,D)*(-1);
A = diag(A);
b = ones(D,1)*(-1);
c2 = A - b;
c = [c1 c2];
F.Fval = z;
F.Ineq = c;
end
I get this error, because c1 and c2 have different sizes:
Dimensions of arrays being concatenated are not consistent.
How can I create this constraints and pass to surrogate model?
My script:
% Mixed Integer Surrogate Optimization
clear all %#ok
close all
clc
rng default
D = 22;
lb = ones(1,D);
ub = ones(1,D)*10;
IntCon = 1:D;
options = optimoptions('surrogateopt','ConstraintTolerance',1e-6,'ObjectiveLimit',1e-6);
[xmin,fval,exitflag,output] = surrogateopt(@transport,lb,ub,IntCon,options);
Thanks a lot!
0 个评论
采纳的回答
Alan Weiss
2021-3-1
Your problem is this line:
c = [c1 c2];
The variable c1 is a 2-by-1 column. c2 is, I think, a 22-by-22. Maybe a 22-by-1. In any case, they cannot be concatenated like this.
Alan Weiss
MATLAB mathematical toolbox documentation
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!