lbl-srg / GenOpt

GenOpt - Generic Optimization program
http://simulationresearch.lbl.gov/GO
20 stars 14 forks source link

GenOpt using Dymola or OpenModelica #13

Closed AHaumer closed 3 months ago

AHaumer commented 3 months ago

@mwetter I have a few questions, then I could correct my enclosed description and run optimizations with translated / executable model not only compiled with Dymola but also with OpenModelica. GenOpt-DymolaOpenModelica.pdf I created a setup where:

mwetter commented 3 months ago

@AHaumer : For text files, it is OK to "misuse" the Template and Input section, but as you wrote, I don't think that works for binary files. For binary files, you could try a "trick" in writing a batch file that copies

copy \"%Simulation.Files.Template.Path1%\\JacA.bin\" .
copy \"%Simulation.Files.Template.Path1%\\MyModel.exe\" .
... // repeat for each binary file.
// And then call the executable
MyModel.exe

This batch file becomes an input template file for GenOpt. Then, GenOpt will replace %Simulation.Files.Template.Path1% with the corresponding location, copy the file to the temporary directory, change the current directory to the temporary directory and execute the batch file. Because the file is executed from the temporary directory, copying to . should work.

AHaumer commented 3 months ago

Thanks @mwetter sounds good - I'll try that and adjust my description. Are you interested in getting my small "how-to" along with the examples?

mwetter commented 3 months ago

@AHaumer : Thanks for your offer. I think it would be nice to put your "how-to", or a link to it, at https://simulationresearch.lbl.gov/GO/download.html

AHaumer commented 3 months ago

I had to adjust your proposal a little bit but now it works! We don't need the replacement done by GenOpt. The batch file DoOM.bat now is simply: @echo off SET PATH=C:/OM/v1_22_3/bin/;%PATH%; SET ERRORLEVEL= copy ..\MyModel_JacA.bin . copy ..\MyModel.exe . CALL MyModel.exe SET RESULT=%ERRORLEVEL% EXIT /b %RESULT% and the command in SimulationStart in GenOpt's cfg is just: Command = "DoOM.bat"; I have to enhance my description, then I'll provide it along with an example. @mwetter thanks a lot!