AIMMS Knowledge Base Article - KB00008
Running out of memory
Solving very large problems can result in running out of memory.
There are several ways to handle these kind of problems.
When you run your model, the following error message might occur:
Memory limit exceeded
Other symptoms of reaching the memory limits of your machine can be:
- It takes a long time to load or save a case,
- It takes a long time to open a page,
- AIMMS is running very slow,
- Your computer is thrashing (excessive swapping), which you can see at the Processes tab of your Task Manager.
AIMMS uses computer memory for many tasks; but mostly to store generated mathematical programs and and to store the data in sets, parameters, variables and constraints. When you store too much, you will run out of memory.
There are two approaches:
The first approach is to increase the available (virtual) memory. A disadvantage of virtual memory is that your computer needs to swap files from the virtual RAM to the real RAM.
The second approach is to reduce the memory requirements of your application.
Step 1 of the second approach is to check the amount of memory in generated mathematical programs. The predeclared set AllGeneratedMathematicalPrograms contains the names of the generated mathematical programs. You can use the intrinsic function GMP::Instance::GetMemoryUsed for each of the elements. You can use GMP::Instance::Delete to delete generated mathematical programs.
Step 2 of the second approach is the check the amount of memory in sets, parameters, variables and constraints. You can use the diagnostic tool "Identifier Cardinalities" to obtain an overview. If you have a lot of inactive data, you can reduce memory by using the CleanUp statement. AIMMS creates permutations of the data of identifier on a need be basis. It may make sense to use a Rebuild statement to remove permutations that became obsolete.
For those identifiers that use a lot of memory you should try to decrease the memory usage by:
- Specify (tight) domain restrictions where possible,
- Deleting identifiers that were only added for testing purposes,
- Not saving identifiers in a case that do not need to be saved, using the ‘NoSave’ property, or by specifying and using case types that do not include these identifiers,
- Using expressions instead of large identifiers on pages that take a long time to open, because then the expressions are only evaluated when necessary. This is especially useful when only a slice of a multi-dimensional identifier is shown.
You can prevent running into memory problems by regularly checking during model development whether there are identifiers with unexpectedly many non-zeros using the Identifier Cardinalities tool.
For more information, please contact us at email@example.com.