ContentsIndexHome
PreviousUpNext
Creating Rules

The AIMMS SDK Server allows you to specify your own rules for matching a resource request with a specific AIMMS version to start.

Normally these rule files reside in the subfolder rules of the location in which the config file is stored, see Configuration.

Adding a new AIMMS rule

When adding a new AIMMS rule, e.g. because you installed AIMMS into a non-default location, the easiest way is to just copy the rule (file) that resembles your AIMMS versions the most. Next you start altering the proper fields. If you e.g. installed AIMMS 4.60 x64 into D:\NonDefaultPath\AIMMS then you should alter the PATH environment variable to read:

                ["PATH", "D:\\NonDefaultPath\\AIMMS\\Bin;${Env.PATH}"]

NB: After adding, modifying or deleting rules you should restart the AIMMS SDK Server to let those changes take effect. 

Rule Format

The rule object is in JSON format and consists of 3 parts: a Name, a rule to Match and an Action to execute. The Name field is purely to visually identify the current rule. The Match Field consists of a composite object that at the moment only consists of a Resource field. The Resource field is a string that contains a regular expression. This regular expression (or in this case just a string) is compared with the path part of the URI with which the client connects. For example, when the client connects using tcp://host.example.com:1234/MyPath/To/Something, the path part of this URI is /MyPath/To/Something;that part is compared for each rule until one matches or the rule list is exhausted. If the rule list is exhausted an error is returned to the client that is trying to connect. The rule-list is traversed in alphabetical order. 

The action part of the rule is executed when a rule is matched. At the moment there are only two possible action types: Reject or CreateProcess. All action-types require Options which have specific fields depending on the action type. 

The Reject action Options consist of two fields ErrorCode and ErrorDesc where the first is numeric (integral) field and the second a string. This code and error description are returned to the client and the connection is closed, i.e. rejected. 

The CreateProcess action Options also has three fields:

  • Arguments, a list of strings that specify the process to run. The first strings specifies the executable to run, the other strings are the command-line arguments
  • Environment, a list of key-value pairs that specify the environment variables to set for the new process
  • Requires, a string that specifies the a location to test wether it exists, this can either be a file or a path. If the test fails, the process will not be started and an error generated

The value strings can contain variables that take the form of ${Variable} which are defined by specifying a group name in the URI-path regular expression or are one of the following predefined variables

Variable 
Description 
ServerPath 
Location of the path where the AIMMS SDK Server is installed. 
ImageFolder 
Location of the path where the AIMMS SDK Server should look for AIMMS images 
ListenAddress 
The address determined by the AIMMS SDK Server on which the AIMMS host process is supposed to listen for incoming forwarded connections. At the moment this will always be the local host address (::1 and/or 127.0.0.1). 
ListenPort 
The port determined by the AIMMS SDK Server on which the AIMMS host process is supposed to listen for incoming forwarded connections. This is a seemingly random number between 1024 and 65535. 
Env.* 
A prefix for accessing a specific system Environment variable. 

The CreateProcess action will spawn a new process indicated by the argument list and its environment variables. 

 

The following command-line arguments are available:

Key 
Description 
Default 
logcfg 
String indicating a file that contains the configuration for specialized logging output from the executable to run; typically used for troubleshooting. For its format see Log4jXmlFormat
Empty, no logging. 
listen-uri 
The URI on which to listen for incoming connections. 
tcp:// 

 

Example

As an example take the aimmsifa-x64.rule rule file that comes with the default (Windows) installation has the following content:

{
    "Name" : "AIMMS Install Free x64",
    "Match" : { "Resource" : "/x64/(?<SubFolder>[^/]*)" },
    "Action" : {
        "Type" : "CreateProcess",
        "Options" : {
            "Arguments" : [
                "${ServerPath}\\a3host-x64\\aimmssdk_a3host-${Compiler}_x64_Release.exe",
                "--listenuri",
                "tcp://${ListenAddress}:${ListenPort}"
            ],
            "Environment" : [
                ["PATH", "${ImageFolder}\\x64\\${SubFolder}\\Bin;${Env.PATH}"]
            ] ,
            "Requires" : "${ImageFolder}\\x64\\${SubFolder}\\Bin\\libaimms3.dll"
        }
    }
}