필터 지우기
필터 지우기

Surrogate optimization with different size constraints

조회 수: 3 (최근 30일)
David Franco
David Franco 2021년 3월 1일
댓글: David Franco 2021년 3월 1일
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!

채택된 답변

Alan Weiss
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
  댓글 수: 2
David Franco
David Franco 2021년 3월 1일
You're right, Alan. I found on the page Solve Feasibility Problem the answer:
c(:,1:2) = [sum(x) - 140 - tol, sum(-x) + 140 - tol];
c(:,3:D+2) = (sum(A,2) - b)';
Each column in the structure field Ineq is a constraint.
Write each inequality as a function c(x), meaning the inequalities c(x) ≤ 0.
Thank you!
David Franco
David Franco 2021년 3월 1일
Interesting that both GA and Surrogate in Matlab gave me a worse response than GA in Excel. And Surrogate was much slower.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surrogate Optimization에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by