Tech Blog

Tips and Tricks for AIMMS Users

Author Archives: Deanne Zhang

Deanne Zhang

About Deanne Zhang

Deanne Zhang is an Optimization Specialist at AIMMS.

Execute, a handy function to run an executable program from AIMMS

Posted on February 22, 2017 by Leave a reply

run an executableAIMMS provides a good selection of functions, such as arithmetic functions, string manipulation functions, time functions, distribution functions, file functions, and more, for app developers to build prescriptive analytics applications.

However, if you already have another program for certain tasks that you don’t want to rebuild in AIMMS or if the functionality you need is not available, you can use the Execute function to call the program from AIMMS.

Continue reading »

This entry was posted in AIMMS, App development on by .

Set, Subset, Index and Element Parameter in AIMMS

Posted on September 23, 2016 by Leave a reply


Do you know Set is a god of the desert, storms, disorder, violence and foreigners in ancient Egyptian? So it is totally possible that his disturbance power influenced mathematical world, which is considered employing set theory as foundation system. From 5th century Greek in west India in the east to today’s modern society, there are struggles, debates, paradoxes around set theories. You can find lots of readings about them, or if reading history sounds boring, there will be a little fun video to watch at the end of this blog.

Set in AIMMS can also be confusing for new AIMMS users. We often get questions regarding how to use set, subset, indices, mappings, etc. While working on my own Fantasy Football project, I think it might be helpful to share how I started building one of my models to clarify some of the ambiguity by this example.

Continue reading »

This entry was posted in App development, Beginner, Modeling on by .

How to use the AIMMS Excel Library

Posted on June 07, 2016 by Leave a reply

The AimmsXLLibrary was introduced in AIMMS 4.20. The new library can communicate with Excel files in server environments, where Excel is not installed. For instance, while running AIMMS through a WebUI on PRO or on Linux. Excel is usually not installed in such environments. However, this isn’t a problem. The AimmsXLLibrary doesn’t require Excel to be installed in order to read from or write to an Excel (.xls/.xlsx) file. By using this library, you can deploy your AIMMS project to more platforms with less restrictions.

In order to use the library, you first need to add the system library ‘AIMMSXLLibrary’ to your model. Then, you can use the functions, which start with prefix “axll”(Aimms eXeL Library), provided in the library. This blog post illustrates how these functions work. Let’s take a look.

Continue reading »

This entry was posted in AIMMS, Excel Library on by .

Modeling the forest: Ontario’s Ministry of Natural Resources takes us through decades of effective forest management

Posted on April 01, 2014 by Leave a reply

SCI_MNR_logo_bronzeForest ecosystems are highly complex and influenced by a diversity of factors. Sustainable forest management is therefore an ongoing and constantly evolving process which requires an integrated approach. Government bodies, such as The Ontario Ministry of Natural Resources (OMNR), must conform to provincial policies and standards, while taking economical and ecological considerations into account to arrive at optimal forest management policies. OMNR manages 27 million ha of Ontario’s public forest and has been using an AIMMS-based model for this purpose since 1994. The Strategic Forest Management Model, or SFMM, enables foresters to analyze the relationships between forest condition, silvicultural practices, wood supply and potential wildlife habitat. This analysis enables them to understand how a forest develops through time and explore alternative forest management strategies and trade-offs. Today, nearly 2 decades after its launch, we spoke with Dirk Kloss, OMNR’s Resource Modeling Specialist, to find out where SFMM stands today and what their experience using AIMMS has been like.

Continue reading »

This entry was posted in Modeling on by .

Local Binding vs. Default Binding

Posted on September 13, 2012 by Leave a reply

Assume there are two sets:

   identifier :  RootSet
   index      :  i


   identifier :  MySubSet
   subset of  :  RootSet

What is the difference between expression ( i in MySubSet ) and ( i | i in MySubSet ) ?

Continue reading »

This entry was posted in Advanced on by .

Run batch commands in AIMMS Command Line Tool

Posted on June 22, 2012 by Leave a reply

In the integrated environment or under Linux system,  AIMMS supports a command line tool through which you can control an AIMMS project externally. In the command window, you can start the AIMMS command line tool by running:

AimmsCmd ExampleProject.prj

AIMMS command line tool offers a set of commends, for example,

  • assigning values:
    Let Demand := 100;
  • displaying the contents:
    Display Supply;
  • running procedures:
    Run MainExecution ;

Instead of running each command one by one, you can also run batch commands by writing all the commands you want to execute in a text file. For example, the contents of file “MyComannds.txt” are:

Let Demand := 100;
Display Supply;
Run MainExecution;

By running the following command, you can have them all executed.

AimmsCmd ExampleProject.prj < MyCommands.txt

By doing this, all the running results will be displayed on the command window. If you want to redirect the output to a text file, you can add it to the running command as well.

AimmsCmd ExampleProject.prj < MyCommands.txt > RunLog.txt
This entry was posted in Advanced on by .

Quick Win on AIMMS Data Page

Posted on March 29, 2012 by Leave a reply

AIMMS Data Page facilities directly view of the data associated with a particular identifier. With some clicks, drag & drops, a data page can also be quickly modified to display one or more identifiers in different formats.

A data page can be opened via the Data button, via the right mouse menu, or via shortcut key Ctrl + D for every global identifier.
Continue reading »

This entry was posted in Beginner on by .

Display Multiple Identifiers in a 2D Chart

Posted on February 17, 2012 by Leave a reply

A 2D Chart not only makes it possible to display your AIMMS data in various two-dimensional chart types, such as a plot chart, a bar chart, a pie chart, etc, it also allows displaying multiple identifiers with different measurements and different chart types in the same chart, like the following.

In this charts, “Existing Resources” and “Capacity Deficit” are in MW and displayed as stacking bars; “Demand Growth” and “New Resources Growth” are in percentage and displayed as plot curves. In order to set this chart up, you only need to specify the Y-Axis and Y2-Axis properties in the 2D chart properties dialog as shown below.

The appearance of each identifier, for example, colors, width, labels, etc. can be modified to the desired look in the properties dialog.  For the details, you may check the attached 2D Chart example.

Title: 2D-Chart-Example (0 click)
Filename: 2D-Chart-Example.aimmspack
Size: 40 kB

This entry was posted in Beginner on by .

Tricks to Improve AIMMS Execution Time

Posted on December 21, 2011 by Leave a reply
The time spent by AIMMS applications can be divided into AIMMS execution time ( including evaluation parameters with definition, executing procedures, generate matrix for solvers, etc), the time spent by solvers, and the I/O time.  Here are some coding tricks that help you improve AIMMS execution time.

1. Avoid ‘For’ Loop

Use bulk execution of assignment as much as possible. If a ‘for’ loop is necessary, try to minimize calculation inside the loop. For example,
for (i,j) do
         A(i,j) := B(i,j) + C(i,j)
can be written as the following bulk statement
A(i,j) := B(i,j) + C(i,j);

2. Pay attention to index order

When declaring a parameter with multiple indices, usually index with small cardinality goes first and running index goes last. For example, in the following statement, k is used as running index:

 A(i,j) := Sum[(k), D(i,j,k)];

Another thing to keep in mind is to put the indices in same order. For example the following statement

isActive(p,t,s):= 1 $ (t  >= Begin(p,s) and t < (Begin(p,s)+Duration(t,s)));

runs much faster than

isActive(p,s,t):= 1 $ (t >= Begin(p,s) and t < (Begin(p,s)+Duration(t,s)));

3. Use index domain condition

Domain condition puts restriction on the indices and thus reduces memory and time consumption. Use it whenever possible. The usage of index domain can be found on related posts. One thing to be careful when using domain condition is to avoid sub index expression.

A sub index expression is the expression depend on fewer indices than the entire expression. For example, in the following statement,

F(i,k) := G(i,k) * Sum[j | A(i,j) = B(i,j), H(j)]
the entire expression depends on indices (i,j,k), but expression Sum[j | A(i,j) = B(i,j), H(j)] only has (i,j). During calculating the value of F(i,k),  AIMMS will evaluate the result of sum term for each combination of (i,k), although the its result will be the same of all k. To avoid unnecessary evaluation for k, the one statement can be separated into two statements:
FP(i) := Sum[j | A(i,j) = B(i,j), H(j)] ;
F(i,k) := G(i,k) * FP(i) ;
Another example, although domain condition is added, the following statement is still inefficient:
sum[(t,s,i,j,k) | ElementPara(i,j) = k, …]
Since ElementPara(i,j) = k is a sub index expression, AIMMS will create a temporary identifier index over (t,s,i,j,k) to evaluate the condition over the full domain. And comparison operation is a dense operation, thus the calculation needs to go over every (t,s,i,j,k). The result will be time and memory consuming.
The problem can be solved by introducing a new parameter SumCondition(i,j,k) and having
SumCondition(i,j,k) := (ElementPara(i,j) = k);
sum[(t,sc,i,j,k) | SumCondition(i,j,k), …];
These are some general rules. In practice, lots of the performance improvements are done on by trials and errors.  And AIMMS diagnostic tools, such as Debugger, Profiler, and Identifier Cardinalities Viewer can help with identifying the performance bottleneck. You can refer to AIMMS User's Guide for how to use them. And more insights of AIMMS execution engine can be found in chapter Sparse Execution Engine in AIMMS Language References.
This entry was posted in Beginner, Technical on by .
  • Customer Reviews

    Read more AIMMS reviews
  • Review AIMMS on G2 Crowd
  • Recent Posts

  • Categories

  • Google Analytics