Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#5656 closed enhancement (worksforme)

Allow step-by-step translation and simulation with scripting API

Reported by: robert.sandmann@… Owned by: somebody
Priority: high Milestone: 1.16.0
Component: Interactive Environment Version: v1.14.0-dev-nightly
Keywords: translate simulate build Cc:

Description

Dear developers,

currently, it is not possible to simulate a model without translating it at the same time. That means that if a translated model is available in the working directory, a call to simulate translates the model again.

To be able to compare timing statistics of the separate steps check, translate and simulate, it would be great to be able to only simulate a model without translating it at the same time using the scripting API (also via the Python interface).

I thank you in advance for looking into this.

Kind regards, Robert

Change History (5)

comment:1 by massimo ceraolo, 5 years ago

OMEdit already does accurate timing measures, which are accessible using OMC. For instance in par. 1.2.5 of OpenModelicaUserGuide.pdf the following very detailed timing report is shown:

timeFrontend = 0.779514857,
timeBackend = 0.014971491,
timeSimCode = 0.01987463,
timeTemplates = 0.013570249,
timeCompile = 0.566615807,
timeSimulation = 0.013022339,
timeTotal = 1.407719324
end SimulationResult;

Unfortunately the same level of detail is not accessible from OMEdit GUI.
There should be also an open ticket asking for having a similar timing report also when simulations are run from OMEdit, but I cannot find it today.
I suppose that if these figures are made available (something that I strongly hope) to OMEdit GUI, and therefore reported at the end of every simulation, your timing requirements are satisfied.

Version 0, edited 5 years ago by massimo ceraolo (next)

comment:2 by Francesco Casella, 5 years ago

Component: *unknown*Interactive Environment
Milestone: Future2.0.0

comment:3 by Andreas Heuermann, 5 years ago

I'm not sure if this solves your issue but you can use API function OpenModelica.Scripting.system to call your executable directly. See also the API-documentation
So for simulating a model bouncingBall.mo you could do something like this mos-Script

// Load your Modelica model
loadFile("bouncingBall.mo"); getErrorString();

// Get time informations for build process
setCommandLineOptions("-d=execstat"); getErrorString();

// Check and translate and build model
buildModel(bouncingBall); getErrorString();

// Simulate model
// with some example flags
system(realpath(".") + "/bouncingBall -lv=LOG_INIT,LOG_STATS_V -override stopTime=2.0", "bouncingBall.log"); getErrorString();

On Linux systems you don't need to save the output to some log file, but on Windows you do and then can read the file with OpenModelica.Scripting.readFile.

comment:4 by Martin Sjölund, 5 years ago

Resolution: worksforme
Status: newclosed

You can also do translateModel, which will not compile the code. Or use execstat in the scripting API to get timing (or access the timers directly like the library testing scripts do).

comment:5 by Francesco Casella, 5 years ago

Milestone: 2.0.01.16.0
Note: See TracTickets for help on using tickets.