Surrogate optimization with different size constraints
3 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Alan Weiss
on 1 Mar 2021
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
2 Comments
More Answers (0)
See Also
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!