# Tech Blog

### Quickly expanding all identifiers in the model tree

As most AIMMS users will know (or maybe should know ), the position where you double-click on an identifier (i.e. the icon or the text) in the model tree leads to different outcomes. If you double-click on the name of the identifier, you will always open the attribute form for the selected identifier.

If you double-click on the icon of the identifier that supports child identifiers (e.g. Section, Declaration Section, etc.), AIMMS will open the identifier node in the tree and show the child identifiers. In case of double-clicking on the icon of an identifier that does not support an underlying sub-tree, AIMMS will just open the attribute form (e.g. double-clicking on the [P] icon of a parameter identifier will just open the attribute form of the parameter).

This entry was posted in Beginner .

### Little trick to call AIMMS API from within AIMMS

For an internal project I was working on, I had to determine whether a given procedure (provided by an element parameter in the predefined set AllProcedures) had a certain prototype (i.e. number/types of the arguments). In this particular case, I wanted to check whether the given procedure had exactly one argument, which was a string parameter with the Input property.

Recursion: See Recursion

Unfortunately, within the AIMMS language there is no direct way of obtaining the number of arguments of a procedure or the type. Luckily, the AIMMS API does provide this functionality. One of the features of AIMMS is that you can call methods in a DLL by introducing external procedure identifiers in your AIMMS project. By introducing an external procedure that uses the libaimms.dll, you can actually call the AIMMS API functions directly from within your project again. So from within AIMMS, you call the AIMMS API again.

This entry was posted in Advanced .

### Using LoopCount instead of explicit counting parameter in loops

There are cases where you want to execute some set of statements in an AIMMS procedure a couple of times. If you want to execute the statements $n$ times, the trivial (but not very smart) way would be to just copy the statements $n$ times.

This entry was posted in Beginner .

Default splashscreen for AIMMS Developer

After you are finished with creating your AIMMS application, you can deploy it to the people who will use your application. Instead of using the standard AIMMS splashscreen displayed on the right, you have the option to provide your own custom splashscreen.
Please note that the splashscreen depicted is the splashscreen of the developer version of AIMMS. If the user of your application has an AIMMS end-user license, the purple background color will actually be green.

Gate Assignment splashscreen

You can instruct AIMMS to not display the standard splashscreen, but a custom one by creating a BMP file with the same name as the project file (i.e. the .prj file). If you open the Gate Assignment example from the index of all examples, you will see that splashscreen depicted on the left is.

The name of the .prj file of the gate assignment project is “Gate Assignment.prj”. By saving the above picture as “Gate Assignment.bmp” in the same folder as the “Gate Assignment.prj” file, AIMMS will now display the new splashscreen. Please note that you must use the bitmap (BMP) format, as AIMMS will only look for this extension (and not other image file formats).

This entry was posted in Beginner .

### Quick Win on AIMMS Data Page

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.

This entry was posted in Beginner .

### Minimizing objective containing a min-operator

During the last couple of months I saw the exact same question from different customers, namely that they wanted to minimize an objective that contained a binary min operator. For example, the minimization objective contained the following term:

50 * min( aParameter, aVariable).

The idea of using this binary min operator was to introduce a ceiling to the contribution of a variable to the objective. Recently, I also saw a similar topic being discussed by Erwin Kalvelagen in his max tricks blog post.

This entry was posted in Beginner .

### Starting AimmsInterrupt tool from installation-free AIMMS

Screenshot AimmsInterrupt

In some of the posts I have mentioned the AimmsInterrupt tool already. If you install a recent version of AIMMS, this tool will also be installed and is made available for starting via the Start Menu.

However, if you only make use of installation-free versions of AIMMS, nothing is added to the Start Menu, meaning there is no direct way to start the tool. Luckily, it is still possible to start the AimmsInterrupt tool from within AIMMS itself. If you start an installation-free version of AIMMS you can put the following statement in a procedure:

`execute("c:\\Program Files\\Paragon Decision Technology\\Common\\Bin\\AimmsInterrupt.exe") ;`

When you execute this procedure, the AimmsInterrupt tool will be started, from which you can now interrupt any of the AIMMS sessions that is running.

This entry was posted in Beginner .

### Interrupting only solve or execution of whole procedure

In a previous post, I explained how you can interrupt the execution of AIMMS by either using the keyboard shortcut Ctrl-Shift-S or the AimmsInterrupt tool.

When you make use of the Ctrl-Shift-S keyboard shortcut, after pressing this combination AIMMS will show you the following dialog message:

Interrupt solve or complete execution

As you can see in the screenshot, there is the possibility to check “Only interrupt the current solve”. When this option is checked, only the solve statement that is currently executing will be interrupted. All the statements that follow the solve statement will still be executed. If the option is not checked, you do not only interrupt the solve, but you halt the execution of the whole procedure.

Suppose you have a procedure with the following two statements

```solve SomeMathProgram ; DialogMessage("Finished solving") ;```

If you press Ctrl-Shift-S while AIMMS is executing the solve statement, the status of the check mark will have the following effect:

• Check mark checked: AIMMS will interrupt the solve, retrieve the variable values from the solver, evaluate the values of the inline variables and continue with the next statement (i.e. it will display the dialog message “Finished solving”;
• Check mark not checked: AIMMS will interrupt the solve and retrieve the variable values from the solver. After this, AIMMS will completely stop the execution of further actions (including calculation of values for inline variables). This means that in this situation you will not see the dialog message anymore.
• This entry was posted in Beginner .

### Using command line arguments with your AIMMS project

Most programs allow users to provide additional information by means of supplying command line arguments when starting the program. AIMMS itself also accepts some command line arguments, e.g. to start a specific .prj file, provide user/password information or to select a specific license. For more information about which specific command line arguments AIMMS accepts, please see the section “Calling AIMMS” in the AIMMS User’s guide.

Additionally, AIMMS will also allow you to provide command line arguments that will be available in your project. All the non-AIMMS command line arguments that are provided when starting the project can be accessed via the SessionArgument function in AIMMS. Below I will give a short demonstration how this function can be used.

The identifiers that are needed in the code are:

```STRING PARAMETER: identifier : stringToBeDisplayed   PARAMETER: identifier : argumentIdx   STRING PARAMETER: identifier : argumentValue```

These identifiers can be declared under a globally available declaration section, or can be declared via a local declaration under the procedure in which you want to use the following code that will use them.

```!Initialize the string that will be displayed stringToBeDisplayed := "User provided the following arguments:\n" ;   !Start with the first argument argumentIdx := 1 ;   !As long as SessionArgument returns 1, it means that there !exists an additional command line argument. After the call !the value will be available in the string parameter !argumentValue while SessionArgument( argumentIdx, argumentValue ) do stringToBeDisplayed += argumentIdx + ": " + argumentValue + "\n" ;   argumentIdx += 1 ; endwhile ;   !This means that no arguments were supplied if (argumentIdx = 1) then stringToBeDisplayed := "No arguments were supplied" ; endif ;   !And display it to the end-user DialogMessage( stringToBeDisplayed ) ;```

You can now create a windows shortcut to start your application:

SessionArguments Demo - Shortcut to application with command line arguments

The target of the shortcut is set to:

```"Aimms.exe" "Demo SessionArguments.prj" argument1 "Argument2 with spaces"
```

where you have to ensure that before Aimms.exe you have put the full path to Aimms.exe on your computer. As you can see, besides providing Aimms.exe with the project to open as an argument, I also provide two additional arguments: one without spaces and one with spaces.

If you now start the AIMMS project via this shortcut and run the procedure that contains the code I provided above, you will see the following output:

SessionArguments Demo - DialogMessage output

As you can see, the argument “Argument2 with spaces” is seen as one argument. This is because of the quotes around it. If you leave out the quotes, each separate word would be an additional argument (i.e. with would be third argument and spaces would be the 4th argument).

This entry was posted in Advanced .

### Solving MINLP problems with AIMMS Outer Approximation

For solving Mixed Integer Nonlinear Programming (MINLP) problems AIMMS offers, besides the solvers BARON and KNITRO, the AIMMS Outer Approximation algorithm, or AOA for short.

There exist two versions of the AOA algorithm in AIMMS. The old version is available as a solver which calls the module OuterApproximation and was developed before GMP functionality was added to AIMMS. The new version uses GMP functions and has been implemented in the module GMPOuterApproximation. You can install this system module via Menu > Settings > Install System Module and select the GMP Outer Approximation Module to be installed. GMP-AOA is not a solver and cannot be called using the normal ‘solve’ statement. Instead you should use:

```! First we must generate the GMP for our MathProgram.
myGMP := GMP::Instance::Generate( myMP ) ;

! The GMP is passed as argument to the main procedure of GMP-AOA.
GMPOuterApprox::DoOuterApproximation( myGMP );
```

An example can be found in this ZIP file.

There are several reasons why you should use GMP-AOA instead of old AOA. First, the GMP-AOA algorithm offers more possibilities to customize the algorithm to your needs, for example by using functions from the GMP library.

Second, the GMP version can be used in combination with the nonlinear presolver which may reduce the size of the model and tighten the variable bounds which likely help the AOA algorithm to find a better solution or improve its performance. From AIMMS 3.12 onwards GMP-AOA by default starts by calling the nonlinear presolver.

Third, for non-convex problems AOA might sometimes have difficulties in finding a good feasible solution. In that case it might help to combine the AOA with the multi-start algorithm. The way to do this has been explained in a white paper that describes GMP-AOA. This paper is available from our web site: