The Aimms link was written for a client who wished to connect to AIMMS from a Fortran application.
It is a C interface offering the basic functionality: assign data to sets and identifiers, run procedures, and retrieve the identifier data.
However, since the amount of data to be transported would be quite large, the performance demands were at the highest level. Therefore, a level-based approach was chosen to iterate through the data.
The Aimms link also provides an error handling approach, including an implementation of the ICallback, in which messages of more than one ISession can be stored. The messages can be retrieved by the client code by the function "AimmsGetLastErrorMessage".
The complete source (C++) is available in %AIMMS_SDK_HOME%/use-cases.
1: #ifndef _AIMMS_LINK_H 2: #define _AIMMS_LINK_H 3: 4: #ifdef AIMMSLINK_EXPORTS 5: #define AIMMSLINK_API __declspec(dllexport) 6: #else 7: #define AIMMSLINK_API __declspec(dllimport) 8: #endif 9: 10: // aimmsLink.h declares the external C interface for use with Fortran 11: extern "C"{ 12: /* all functions return 0 if no error occured, an error code 13: otherwise. If an error occured the 'AimmsGetLastErrorMessage' 14: can be used to retrieve an description of the specified error. */ 15: 16: 17: /* AimmsOpenProject establishes the connection with AIMMS, opens the 18: project and associates a handle with the project. */ 19: AIMMSLINK_API int AimmsOpenProject( 20: const char* aimmsFolder, 21: const char* projectName, 22: int* projectHandle, 23: int timeOut, 24: int maxFlushInBackground, 25: int maxMemoryFlushInBackground, 26: int maxBufferSize ); 27: 28: /* AimmsCloseProject closes the project associated with the projectHandle 29: and terminates the connection with AIMMS. */ 30: AIMMSLINK_API int AimmsCloseProject( 31: int projectHandle ); 32: 33: /* AimmsRunProcedure runs the specified AIMMS procedure and receives the 34: return code in the out-argument 'returnCode'. */ 35: AIMMSLINK_API int AimmsRunProcedure( 36: int projectHandle, 37: const char* procedureName, 38: int* returnCode ); 39: 40: /* AimmsAssignSet adds the labels to the named set. 41: In case the set is a subset and labels do not yet exist in its super 42: set, they are added there as well. Labels already existing in the set 43: are skipped. The boolean clearFirst should be set to true if 44: the set is to be emptied before adding the specified elements. 45: An error is returned if the setName does not exist in the model, or 46: does not refer to a set. */ 47: AIMMSLINK_API int AimmsAssignSet( 48: int projectHandle, 49: const char* setName, 50: int card, 51: const char* const* labels, 52: bool clearFirst); 53: 54: 55: 56: /* for all identifier functions, there is an Int and an Ord variant. 57: Int variants: the positions are interpreted as integer values. 58: All indexdomains of the identifier must be subsets of 59: the rootset "Integers". 60: Ord variants: the set positions are interpreted as ordinals of the 61: indexdomains of the identifier. 62: */ 63: 64: 65: /* Assign Identifier assigns the specified data to the named identifier. 66: An error is returned if the AIMMS identifier is not real valued, or if 67: its dimension does not correspond to the number of sets. 68: Assumed is a column major ordering. */ 69: AIMMSLINK_API int AimmsIntAssignIdentifier( 70: int projectHandle, 71: const char* identifierName, 72: int dimension, 73: int* firsts, 74: int* lasts, 75: float* identifier); 76: 77: AIMMSLINK_API int AimmsIntAssignIdentifierDouble( 78: int projectHandle, 79: const char* identifierName, 80: int dimension, 81: int* firsts, 82: int* lasts, 83: double* identifier); 84: 85: AIMMSLINK_API int AimmsOrdAssignIdentifier( 86: int projectHandle, 87: const char* identifierName, 88: int dimension, 89: int* cards, 90: float* identifier); 91: 92: AIMMSLINK_API int AimmsOrdAssignIdentifierDouble( 93: int projectHandle, 94: const char* identifierName, 95: int dimension, 96: int* cards, 97: double* identifier); 98: 99: /* Assign Identifier Slice assigns the data slice to the named identifier. 100: An error is returned if the AIMMS identifier is not real valued, or if 101: its dimension does not correspond to the number of sets. 102: Assumed is a column major ordering. */ 103: AIMMSLINK_API int AimmsIntAssignIdentifierSlice( 104: int projectHandle, 105: const char* identifierName, 106: int dimension, 107: int* firsts, 108: int* lasts, 109: float* identifier, 110: int** slices=0, 111: int* sliceCardinalities=0); 112: 113: AIMMSLINK_API int AimmsIntAssignIdentifierSliceDouble( 114: int projectHandle, 115: const char* identifierName, 116: int dimension, 117: int* firsts, 118: int* lasts, 119: double* identifier, 120: int** slices=0, 121: int* sliceCardinalities=0); 122: 123: AIMMSLINK_API int AimmsOrdAssignIdentifierSlice( 124: int projectHandle, 125: const char* identifierName, 126: int dimension, 127: int* cards, 128: float* identifier, 129: int** slices=0, 130: int* sliceCardinalities=0); 131: 132: AIMMSLINK_API int AimmsOrdAssignIdentifierSliceDouble( 133: int projectHandle, 134: const char* identifierName, 135: int dimension, 136: int* cards, 137: double* identifier, 138: int** slices=0, 139: int* sliceCardinalities=0); 140: 141: /* Retrieve Identifier retrieves the data of the specified AIMMS identifier 142: An error is returned if the parameter is not double valued, and if the 143: dimension of the AIMMS identifier does not correspond to the number of 144: sets. Assumed is a column major ordering. */ 145: AIMMSLINK_API int AimmsIntRetrieveIdentifier( 146: int projectHandle, 147: const char* identifierName, 148: int dimension, 149: int* firsts, 150: int* lasts, 151: float* identifier); 152: 153: AIMMSLINK_API int AimmsIntRetrieveIdentifierDouble( 154: int projectHandle, 155: const char* identifierName, 156: int dimension, 157: int* firsts, 158: int* lasts, 159: double* identifier); 160: 161: AIMMSLINK_API int AimmsOrdRetrieveIdentifier( 162: int projectHandle, 163: const char* identifierName, 164: int dimension, 165: int* cards, 166: float* identifier); 167: 168: AIMMSLINK_API int AimmsOrdRetrieveIdentifierDouble( 169: int projectHandle, 170: const char* identifierName, 171: int dimension, 172: int* cards, 173: double* identifier); 174: 175: /* Retrieve Identifier Slice retrieves the data of a slice of the specified 176: AIMMS identifier. 177: An error is returned if the parameter is not double valued, and if the 178: dimension of the AIMMS identifier does not correspond to the number of 179: sets. 180: Assumed is a column major ordering. */ 181: AIMMSLINK_API int AimmsIntRetrieveIdentifierSlice( 182: int projectHandle, 183: const char* identifierName, 184: int dimension, 185: int* firsts, 186: int* lasts, 187: float* identifier, 188: int** slices=0, 189: int* sliceCardinalities=0); 190: 191: AIMMSLINK_API int AimmsIntRetrieveIdentifierSliceDouble( 192: int projectHandle, 193: const char* identifierName, 194: int dimension, 195: int* firsts, 196: int* lasts, 197: double* identifier, 198: int** slices=0, 199: int* sliceCardinalities=0); 200: 201: AIMMSLINK_API int AimmsOrdRetrieveIdentifierSlice( 202: int projectHandle, 203: const char* identifierName, 204: int dimension, 205: int* cards, 206: float* identifier, 207: int** slices=0, 208: int* sliceCardinalities=0); 209: 210: AIMMSLINK_API int AimmsOrdRetrieveIdentifierSliceDouble( 211: int projectHandle, 212: const char* identifierName, 213: int dimension, 214: int* cards, 215: double* identifier, 216: int** slices=0, 217: int* sliceCardinalities=0); 218: 219: /* AimmsGetLastErrorMessage writes the last error message to the buffer if 220: it is large enough. 'textBufferLen' is an in-out argument, which should 221: hold the length of the provided buffer, and receives the length of the 222: last error message. */ 223: AIMMSLINK_API int AimmsGetLastErrorMessage( 224: int* textBufferLen, 225: char* textBuffer ); 226: 227: } 228: #endif //end #ifndef _AIMMS_LINK_H