Optimize with handling an objective function as "Black Box"

조회 수: 5 (최근 30일)
Ilias Seferlis
Ilias Seferlis 2018년 2월 1일
댓글: Ilias Seferlis 2018년 2월 1일
Is there a way to optimize a costrained objective function without really knowing its expression? For example, say we have :
% main.m %
% starting point and costraints all previously defined
[Xopt,Fval] = fmincon(@obj,x0,A,B,Aeq,Beq,lb,ub,[],options);
% End of main.m %
% Objective Function obj.m %
function [F] = obj(X)
% Write Data into File for exe
fopen('X.dat','w');
dlmwrite('X.dat',X);
fclose('all');
% Run Black Box exe
system('BB.exe') % where the expression of the objective function is(unknown to us)
% Read Results from exe
F = importdata('Fval.dat')
% End of obj.m %
The above example does not work,but gives the general idea The code is also attached (Run main.m) with a very simple objective function.

채택된 답변

Sean de Wolski
Sean de Wolski 2018년 2월 1일
편집: Sean de Wolski 2018년 2월 1일
The pattern you have there looks like it should work and the idea is fine.
Though I would probably recommend patternsearch over fmincon since you likely cannot guarantee that BB.exe returns smooth continuous values.
Also note that F has to be a scalar. So maybe at the end:
F = norm(F)
  댓글 수: 2
Ilias Seferlis
Ilias Seferlis 2018년 2월 1일
that works perfectly! thanks a lot!
Ilias Seferlis
Ilias Seferlis 2018년 2월 1일
Is there any way to make it work with "fmincon"? I can't make it to work as explained above.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by