Run Batch Commands with AIMMS Command Line Tool

Note

This article was originally posted to the AIMMS Tech Blog.

In the integrated environment, or on a Linux system, you can control an AIMMS project externally using a command line tool.

To start using the command line tool open the terminal and run AimmsCmd ExampleProject.aimms.

Basic commands available

AIMMS command line tool offers a the following commands.

  • Assigning values:

    1
    Let Demand := 100;
    
  • Displaying the contents:

    1
    Display Supply;
    
  • Running procedures:

    1
    Run MainExecution ;
    
  • Exiting the tool

    1
    Quit ;
    

Running batch commands

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, let’s say the file cmds.txt contains the following code.

1
2
3
4
Let p_Demand := 100;
Display p_Revenue;
Run MainExecution;
Quit ;

You can run the following command in the terminal to execute all the commands contained in the file.

1
AimmsCmd ExampleProject.aimms < cmds.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.

1
AimmsCmd ExampleProject.aimms < cmds.txt > log.txt

Note

Windows powershell doesn’t support the < operator to redirect input. You can get around that using:

1
Get-Content cmds.txt | AimmsCmd.exe ExampleProject.aimms > log.txt

Download example

The example model used in this article can be downloaded below:

Further reading

Last Updated: August, 2019