Using Matlab as a solver in LS-OPT

12 Ansichten (letzte 30 Tage)
Adwait
Adwait am 15 Mai 2015
Beantwortet: Adwait am 27 Jun. 2015
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.

Akzeptierte Antwort

Adwait
Adwait am 27 Jun. 2015
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.

Weitere Antworten (2)

Ben
Ben am 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
  1 Kommentar
Adwait
Adwait am 27 Jun. 2015
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.

Melden Sie sich an, um zu kommentieren.


Ben
Ben am 18 Mai 2015
Bearbeitet: Ben am 18 Mai 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...

Kategorien

Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by