Class JmtBackend

java.lang.Object
jline.solvers.wrappers.jmt.JmtBackend

public class JmtBackend extends Object
Backend dispatch for the JMT command line. One analysis of jmt.commandline.Jmt is run on a model file and the result is left where the JMT CLI itself would leave it, that is at <model>-result.jsim for mode "sim" and <model>-result.jmva for mode "mva". Every backend satisfies that contract, so the result parsers do not know or care which one ran. Backend selection, in order:
  1. options.restUrl non-empty: POST to a JMT REST server (the imperialqore/jmt-rest container). Nothing is executed locally.
  2. a local JVM plus common/JMT.jar: the default, unchanged.
  3. no local JVM, but Docker is usable: ask once per session whether to pull and use the JMT image, and dispatch through it.
see _kb/06-solver-catalog.md (Wrappers: three ways to reach an external binary)
  • Field Details

    • DEFAULT_IMAGES

      public static final String[] DEFAULT_IMAGES
      Docker images tried, in order, when none is named by the options.
  • Method Details

    • resultPath

      public static String resultPath(String modelPath, String mode)
      Returns the path JMT writes its result to for this model and mode.
      Parameters:
      modelPath - path of the model file handed to JMT
      mode - "sim" or "mva"
      Returns:
      the result path
    • hasJava

      public static boolean hasJava()
      Reports whether a JVM is on the path. Probed once per session: the check costs a process launch, and a JVM does not appear or vanish mid-session.
      Returns:
      true if "java -version" runs and exits zero
    • localCommand

      public static String localCommand(String jmtPath, String mode, String modelPath, int seed)
      Builds the shell command that runs one JMT analysis locally.
      Parameters:
      jmtPath - path of JMT.jar
      mode - "sim" or "mva"
      modelPath - path of the model file
      seed - simulation seed, ignored by the JMVA engine
      Returns:
      the command line, as passed to SysUtils.system
    • privateTmpDirFlag

      public static String privateTmpDirFlag(String modelPath)
      The -Djava.io.tmpdir switch that keeps one run's JMT scratch private. NOT A TIDINESS MEASURE: without it two JMT runs on one host corrupt each other. jmt.commandline.Jmt hands the engine a copy of the model under java.io.tmpdir, and XMLSimulationOutput.writeAllMeasures then writes the measures to <that dir>/res_sim_<the sim's name attribute>, copies that file to <model>-result.jsim and DELETES it. Every LINE-written model carries the same name attribute, "model.jsim" from getJSIMTempPath and its MATLAB/python/C++ twins, so with a shared /tmp every concurrent run fights over one path, /tmp/res_sim_model.jsim. Two outcomes, both seen in the 2026-09-11 suite: the other run deletes the file first and this one dies "FileNotFoundException ... at jmt.commandline.Jmt.copyFile", or it copies the OTHER run's measures and reports another model's numbers as its own. The model already sits in a directory of its own, so pointing the JVM's temp dir at it makes every scratch file this run creates private to it.
      Parameters:
      modelPath - path of the model file JMT is to read
      Returns:
      the quoted -Djava.io.tmpdir switch
    • runRemote

      public static boolean runRemote(String mode, String modelPath, int seed, SolverOptions options)
      Runs one JMT analysis through the backend the options select, when that backend is not the local JVM.
      Parameters:
      mode - "sim" or "mva"
      modelPath - path of the model file
      seed - simulation seed, ignored by the JMVA engine
      options - solver options, read for restUrl and container
      Returns:
      true if a non-local backend ran the analysis and wrote its result file; false if the caller should run the local command
      Throws:
      RuntimeException - if no backend can run JMT, or a remote one failed
    • resolveDockerImage

      public static String resolveDockerImage(SolverOptions options)
      Resolves the JMT Docker image to dispatch through, with user consent. The decision is remembered for the session: a sweep over many models must not ask once per model.
      Parameters:
      options - solver options, read for the container override
      Returns:
      the image name, or null when Docker is unusable, no image can be obtained, or the user declines