Using Matlab as a solver in LS-OPT

6 次查看(过去 30 天)
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