Surrogate optimization with different size constraints
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!
Accepted Answer
More Answers (0)
Categories
Find more on Solver Outputs and Iterative Display 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!