open-simulation-platform / cosim-cli

Command-line interface for libcosim
https://open-simulation-platform.github.io/cosim
Mozilla Public License 2.0
10 stars 4 forks source link

New subcommand: run #3

Closed kyllingstad closed 5 years ago

kyllingstad commented 5 years ago

This builds on the work in PR #1 and adds a new subcommand: run. It works pretty much as specified in Confluence, but with slightly more comprehensive documentation printed by help.

What is still missing compared to the specification is the ability to specify an algorithm and a step size. The reason is that cse::load_ssp() currently prevents us from doing that.

~I've targeted this on the PR #1 branch so that all you see is the stuff I've added. I'll retarget it on master once #1 is merged.~

Here is some example output:

> cse help run
NAME
  cse run - Runs a simulation

SYNOPSIS
  cse run <ssp_dir> [options...]

DESCRIPTION
  This command runs a simulation based on an SSP configuration that specifies which
  models to include and the connections between them.

  The simulation can be synchronised with real time by using the the '--real-time'
  option, optionally specifying a target real-time factor (RTF).  The RTF is defined
  as 'elapsed logical time divided by elapsed real time in seconds'.  In other words:

  * RTF < 1 means slower than real time
  * RTF = 1 means real time
  * RTF > 1 means faster than real time

  Whether the target RTF can actually be reached depends on the simulation setup,
  most importantly the models being simulated, and the machine(s) on which the
  simulation is being executed.

  If '--real-time' is not specified, the default is to run as fast as possible,
  unconstrained by real time.

PARAMETERS
  ssp_dir               The path to an SSP directory, i.e., a directory that
                        contains an SSD file named 'SystemStructure.ssd'.

OPTIONS
  -b [ --begin-time ] arg (=0)  The logical time at which the simulation should
                                start.
  -d [ --duration ] arg (=1)    The duration of the simulation, in logical time.
                                Excludes -e/--end-time.
  -e [ --end-time ] arg         The logical end time of the simulation.  Excludes
                                -d/--duration.
  --output-dir arg (=.)         The path to a directory for storing simulation
                                results.
  --real-time [=target_rtf(=1)] Enables real-time-synchronised simulations.  A
                                target RTF may optionally be specified, with a
                                default value of 1.
  --help                        Display a help message and exit.
  --version                     Display program version information and exit.
> cse run cse-core/test/data/ssp/demo -b 2 -d 2
10% complete, t=2.200000
20% complete, t=2.400000
30% complete, t=2.600000
40% complete, t=2.800000
50% complete, t=3.000000
60% complete, t=3.200000
70% complete, t=3.400000
80% complete, t=3.600000
90% complete, t=3.800000
100% complete, t=4.000000
kyllingstad commented 5 years ago

@ljamt:

We need an option for configuring the log verbosity. When running ´cse-core/test/data/ssp/demo´ it spends 30 seconds printing FMI Library debug messages.

Working on it. :)

kyllingstad commented 5 years ago

@ljamt:

I've experienced several times that simulation doesn't start when running without specifing begin-time nor duration

Weird! I'll investigate.

kyllingstad commented 5 years ago

@ljamt:

I've experienced several times that simulation doesn't start when running without specifing begin-time nor duration

I'm unable to reproduce this. I've tried running the dp-ship demo that you used as an example several times, and it always works. Are you still, and consistently, experiencing this problem?

kyllingstad commented 5 years ago

Warning: I've rebased this branch on master to resolve conflicts. (I know I said I wouldn't do that anymore, but due to the dependency of #4 on #3 it was the cleanest way.)

ljamt commented 5 years ago

@ljamt:

I've experienced several times that simulation doesn't start when running without specifing begin-time nor duration

I'm unable to reproduce this. I've tried running the dp-ship demo that you used as an example several times, and it always works. Are you still, and consistently, experiencing this problem?

I experienced this like 20% of the times when I tested last time. Now, I'm not able to reproduce this at all, so let's conclude that it is good.