Crash of a single case terminates the whole optimization process

1 回表示 (過去 30 日間)
Sercan Acarer
Sercan Acarer 2015 年 2 月 9 日
コメント済み: Sercan Acarer 2015 年 2 月 9 日
Hello all,
We want to couple an in-house flow solver with an in-house optimization code, both written in Matlab as m-files (both have many subroutines and a main function). This is to optimize some geometric parameters.
Once a single flow solution case is crashed (e.g. in one of solver subroutines), the whole optimization process is crashed (the main flow solver m-file is defined as a function in the main optimization m-file).
Our aim is to continue the flow solution cases after one case is crashed (e.g. due to NaN error, etc.).
Is there a way to accomplish this without adding complex and numerous controls to the solver code? (e.g. to terminate the main solver m-file without terminating the main optimization m-file).
By the way crashes occur in the subroutines of the flow solver, not in the main flow solver m-file.
Best Regards,
Sercan

採用された回答

A Jenkins
A Jenkins 2015 年 2 月 9 日
You can use a try block around your code.
for idx=1:n
try
solver_that_might_crash(idx)
catch
disp('warning, case failed, moving on...')
end
end
  1 件のコメント
Sercan Acarer
Sercan Acarer 2015 年 2 月 9 日
Thank you very much. This seems to solve the problem.

サインインしてコメントする。

その他の回答 (0 件)

製品

Community Treasure Hunt

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

Start Hunting!

Translated by