Exporting a section and importing it in another AIMMS project

Sometimes there are parts of a model that you would like to re-use in another AIMMS model. If it is a very generic component, you could choose to create an AIMMS library or an AIMMS module out of it. Please see the chapter “Organizing a Project Into Libraries” in the AIMMS User’s guide for more information about this. In the cases that you only want to quickly export/import a set of identifiers once, you can also use the export/import functionality in AIMMS.

Also, on this blog we will provide the AIMMS code where applicable as .aim files. You  can import these into your existing projects with the instructions found below. In some cases where the whole project is needed (and not only some snippets), we will provide the whole project as an AimmsPack file.

Exporting a section

Before you start exporting, you should place all the identifiers you wish to export from your current model into one section in your AIMMS model. When you have done this, there are two possible ways of exporting this section:

  • Select the section in the model tree and select Export… in the edit menu
  • Use the source attribute of the section identifier to store the section in a separate file

The first option has the advantage that it requires less steps. However, the second approach has the advantage that you can export to .aim files, which is a text based format. This allows you to export something from a newer version of AIMMS and then import it in an older version of AIMMS. This is not possible if you use the export/import functionality under the edit menu, as this works with binary .amb files only, which can only be opened in the same version in which it was created or higher.

To export a section to an .aim file, please follow these steps:

  • Open attribute window of the section you wish to export
  • Select wizard button of the source file attribute
  • Select Write in the menu
  • Select the location you want to store the .aim file
  • Set the “Save as type” to “Text Model Files (*.aim)”
  • Set the filename to what you want and press Save
  • Select wizard button of the source file attributes again
  • Select “Remove (keep subtree)…” in the menu

If you do not perform the last two steps, all identifiers declared in the section will not be stored in the main project file anymore, but separately in the .aim file that you selected.

Importing a section

To import an .aim file or an .amb file, please use the following steps:

  • Create a new section in your model that will hold the identifiers that will be imported
  • Select this section identifier in the model tree
  • In the Edit menu, select Import…
  • Select the .aim or .amb file that you want to import

After this, AIMMS will present you with a dialog that shows which identifiers will be imported and which ones are conflicting with already existing identifiers in your model.

Important note: When using the source file attribute of a section, you can store the contents of the section in a separate file (if you do not use the “Remove (keep subtree)…”). Please note that if you use an .aim file for the source file attribute, changes that are made to this text file with any other program (e.g. a text editor or version management system) while the AIMMS project is open will not be picked up by AIMMS! Only after you close and re-open the project, will these changes be visible in your project.

Related posts:

  1. Quickly get text representation of one or more identifiers
  2. Using command line arguments with your AIMMS project
  3. Deploying a project with AIMMS as a self-contained solution
  4. Determine where each identifier is used in your model
  5. Inspecting SQL statements created by AIMMS

About Guido Diepen

Guido has been working at AIMMS since August 2008. He is part of the Professional Services team that helps customers getting the most out of AIMMS for their problems. His background is Integer Linear Programming and he is now also looking more at Constraint Programming.
This entry was posted in Beginner, Technical and tagged , , . Bookmark the permalink.

Facebook comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">