jEPlus API Examples

[This page is under construction ]

Command-line usage

The shell command:

java -jar jEPlus.jar -help

gives you the following instuctions:

jEPlus (version 1.2) for Windows XP (C) 2010, 2011, Yi Zhang,

    GUI mode:   java [-Xmx1000m] -jar jEPlus.jar
    Batch mode: java [-Xmx1000m] -jar jEPlus.jar -batch {project_file_name.jep} [n random jobs]
    Job mode:   java [-Xmx1000m] -jar jEPlus.jar -job {project_file_name.jep} 
                    -index|-value|-id|-file {job_string_1;...|job_id_1;...|job_file_name}

    {...} required arguement, to be replaced with your own values;
    [...] optional arguement, to be replaced with your own values;
    '|'   separates alternative options.

For example,
    "java -Xmx1000m -jar jEPlus.jar -batch my_project.jep 1000"  
               executes 1000 randomly selected jobs of the project in my_project.jep;

    "java -jar jEPlus.jar -job my_project.jep -id 
               executes 2 selected jobs (with the job IDs)of the project;

    "java -jar jEPlus.jar -job my_project.jep -index 
               creates three jobs with alt_value indexes and run them;

    "java -jar jEPlus.jar -job my_project.jep -value 
               creates one jobs with the specified parameter value and run it.

    "java -jar jEPlus.jar -job my_project.jep -file my_job_list.txt"  
               creates and executes jobs from the job strings list in the specified file. 
               The job strings in the file must be in -value format and separated by either 
               ';' or end-of-line.

Text in ‘{ … }’ should be replaced with the actual jEPlus project file name and the job strings. The formats of job string will be explained in the next section; different job strings are separated by ‘;’.

On this command, jEPlus starts simulations immediately. When all jobs are completed, extracted results are collected into the ‘SimResults.csv’ file in the output directory specified in the project file. jEPlus then exists normally with a value ‘0’.

Example DOS and Shell scripts

Calling jEPlus from a Java program

The following example shows how to use the jEPlus programming interface in Java language:

  // ... ...
  // load project file
  JEPlusProject Project = new JEPlusProject (/* "project.jep" */);
  // create simulation manager
  EPlusBatch SimManager = new EPlusBatch (null, Project);
  // Set simulation agent
  SimManager.setAgent(new EPlusAgentLocal ( Project.getExecSettings()));
  // specify jobs
  String [][] jobs = /* array of job strings */;
  // execute jobs – job string contains values
  // or if job string contains indexes
  // SimManager.runJobSet2(jobs);
  // wait for jobs to finish
  try {
      do {
      }while (SimManager.isSimulationRunning());
  }catch (InterruptedException iex) {
  // collect simulation results
  HashMap<String, ArrayList<double []>> Results = 
  // ... ...

Here, simulation results can be retrieved directly from the simulation manager instance as a map indexed by the job IDs. A job ID is a unique string that a user must assign to each job as the first part of the job string.

Calling jEPlus from Matlab

Calling jEPlus from Genopt