필터 지우기
필터 지우기

Using Matlab as a solver in LS-OPT

조회 수: 11 (최근 30일)
Adwait
Adwait 2015년 5월 15일
답변: Adwait 2015년 6월 27일
Hi,
I am trying to optimize a function in Matlab using LS-OPT, a design optimization tool. I am trying to implement this problem as a test case using Matlab instead of perl as the solver: http://www.lsoptsupport.com/examples-4.0/optimization-example
Eventually, I will replace the Matlab script with another script that runs a finite element model that takes about 15 minutes to run (one iteration).
I am having trouble integrating Matlab as the user-defined solver in LS-OPT. I am able to parameterize the Matlab script and get the script to terminate normally and compute the response f normally, but I'm not able to get the response back into LS-OPT to move to the next iteration. So LS-OPT thinks there is an error termination.
Any ideas on how to do get the response back to LS-OPT? Any help on integrating with LS-OPT would be appreciated.
PS: LS-OPT has a robust global optimization algorithm that uses response surface methodology for functions with long runtimes, so I chose this over Matlab's optimization commands.

채택된 답변

Adwait
Adwait 2015년 6월 27일
As Ben mentioned above, the user defined solver must output 'N o r m a l' to the standard output (Windows command line, not Matlab command window) after a successful run for Matlab to proceed to the next iteration. This can be done by running a dummy batch file that runs the Matlab script and then outputs to standard output (echo N o r m a l). Alternatively, the system command can be used in Matlab to execute echo N o r m a l on the Windows command line.

추가 답변 (2개)

Ben
Ben 2015년 6월 18일
Sorry for getting back to you this late, I was on a business trip.
It is most likely that LS-OPT is not continuing to the next iteration because the stage where your matlab script was running did not terminate properly. Remember that once your script is executed you need to terminate it with either 'N o r m a l' or 'E r r o r', else LS-OPT will not continue to the next stage.
You can include such a response in MATLAB in the following way:
if exist('output', 'file')
disp('N o r m a l');
else
disp('E r r o r');
end
where output.txt is any file which includes your response.
I hope this helpes you solve your problem!
Kind regards
Ben
  댓글 수: 1
Adwait
Adwait 2015년 6월 27일
Thanks for your response. I was able to solve the problem.
Initially, I tried disp('N o r m a l') as you suggested. However, this outputs to the Matlab command window. LS-OPT looks for 'N o r m a l' in standard output, which is the Windows command line. I got around this by running a batch file in the command field of LS-OPT that then runs the Matlab script and prints 'N o r m a l' to the command line using the echo command:
matlab -nodesktop -nosplash -wait -r UVA_LX_opt_mbp_new
echo N o r m a l
An easier way to do this would be to use the system command in Matlab, but I haven't tested this with LS-OPT.

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


Ben
Ben 2015년 5월 18일
편집: Ben 2015년 5월 18일
Often this problem is related to wrong referencing of the output file. I recommend checking the response command. If this does not help, I recommend contacting your local dynamore support.
Good Luck and kind regards
Ben
Edit: At the moment I am working on a similar problem. I will update this thread if I can provide further information that will help you...

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by