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.
Using Matlab as a solver in LS-OPT
13 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
More Answers (2)
Ben
on 18 Jun 2015
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
Ben
on 18 May 2015
Edited: Ben
on 18 May 2015
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...
0 Comments
See Also
Categories
Find more on Get Started with Optimization Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!