RSS

Create a copy of a Repast project in Eclipse and run it with another name

07 May

Published on: May 7, 2012
Last Modification: April 16, 2013

Some days ago I needed to make a copy of my current simulation in Eclipse, perform some minor changes in the code and run it to gather new additional data. It seems simple, but of course with Repast is not.

First of all I copied the project that I wanted to duplicate using the right-button menu in Eclipse environment and when I pasted in the same environment, Eclipse showed me a window where I could choose the new name of the project. Something like that:

Form: copy the project

Be careful because the project source should be active, otherwise when we try to copy it, Eclipse shows us an error message:

ErrorProjectClosed

The next step consists of changing the information stored in the launcher file to be able to run the simulation. In order to do that I right-clicked over the project name folder/properties/run-debug settings. This opens a window where we can manage the different launch configurations.

RunSettings

In the case the list of launch configurations appear to be empty, we need to do the following steps manually. In order to do that step over the next paragraphs and go directly to Changing the launcher files manually.

For each of them , we press the edit button. In the main tab, it should be written the name of the current project instead of the previous one. It is possible to change also the name of the option that appear when we try to run the application:

Additionally we should modify the program arguments option located in the argument tab changing the name of the workspace location and the name of the .rs file:

Changing the launcher files manually:

The launcher files are located in the folder project name folder/launchers. First we should change the names of these files. Every time that the file has the name of the former project we should write the name of the new one. Once we do that, the next step consists of double-clicking on each of them, search in the XML file all the occurrences of the former name and change it for the new one. When we finish, if we go to project name folder/properties/run-debug settings and the launcher file should appear on the list.

Later on, I changed the name of the physical file .rs in the file system, the name of the folder where the ModelInitialiser files are stored and the folder within the src folder. The location of these files are: workspace/<project_name>/<project_name>.rs, workspace/<project_name>/bin/<project_name> and workspace/<project_name>/src/<project_name> respectively.

In the next step, we should deal with some configuration files. We should edit the file called user_path.xml located in the folder <name_project>.rs and change the path of the classes and the model name. By the way, user_path.xml is loaded by the ScenarioLoader when the scenario is opened at the beginning of the simulation. The file has the following appearance:

Another important file to change, only in the case that the simulation has implemented displays or/and outputters is to change the file scenario.xml located as well in the folder <name_project>.rs. This file tells Simphony where it can find the ModelInitializer and also supports the creation of the displays each time the model is run.

If you are using model.score file in your project, it would be convenient to change the ID of the project that appears in the root of the XML file. The model.score file serves several purposes, including parsing of annotations, context building, and providing information to the runtime GUI.

Apart from that, the ID gave to the context class when the context is built should be set to whatever the project name is and it should match with the context ID in the context.xml stored in the same folder named <name_project>.rs and the model.score.

public Context build (Context context ) {
context.setId ( "name of the project" );
....

Finally, if the simulation makes use of parameters, the model.score file located in the same folder <name_project>.rs should be edited. This file defines the set of attributes of your simulation. Inside we should change the label and the ID of the score and the basepath (implementation).

One more thing, before you run your project don’t forget to refresh it.

Advertisements
 
3 Comments

Posted by on May 7, 2012 in Eclipse, Repast

 

Tags: ,

3 responses to “Create a copy of a Repast project in Eclipse and run it with another name

  1. elgobiernosecreto

    June 26, 2012 at 1:23 pm

    Great blog Marta.

     
    • Marta Vallejo PhD

      June 26, 2012 at 6:34 pm

      Bueno, considero que el tuyo es muchisimo más interesante, pero gracias por pasarte y echar un vistazo 🙂

       
      • elgobiernosecreto

        June 26, 2012 at 6:38 pm

        Muchísimas gracias. Se hace lo que se puede. Ahora intentaré sacar algún que otro descubrimiento que tengo. Espero que puedas ayudarme a difundirlo… yo puedo hacer lo mismo.

         

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: