Tech Blog

Tips and Tricks for AIMMS Users

Quickly get text representation of one or more identifiers

When you need to share some identifiers with another person (e.g. on the AIMMS Google group or during contact with AIMMS Support), most of the times you can just copy the definition field of a parameter/variable/constraint. However, sometimes you must not only share the definition, but the values of all attributes, including the index domain/unit/etc.
Continue reading »

This entry was posted in Beginner on by .

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).
Continue reading »

This entry was posted in Beginner on by .

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

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.
Continue reading »

This entry was posted in Advanced on by .

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 [latex]n[/latex] times, the trivial (but not very smart) way would be to just copy the statements [latex]n[/latex] times.
Continue reading »

This entry was posted in Beginner on by .

Adding a custom splashscreen to your AIMMS application

Default splashscreen for AIMMS Developer

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

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 on by .

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.
Continue reading »

This entry was posted in Beginner on by .

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.
Continue reading »

This entry was posted in Beginner on by .

Starting AimmsInterrupt tool from installation-free AIMMS

Screenshot AimmsInterrupt

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 on by .

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

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 on by .

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:

   identifier :  stringToBeDisplayed

   identifier :  argumentIdx

   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
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

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

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 on by .
  • Customer Reviews

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

  • Categories

  • Google Analytics