Skip to main content

The other day a customer was asking about the statements empty, cleanup, cleandepedents, and rebuild.  In addition, that customer wanted advice on memory management when running multiple data instances for the operations research problem at hand.

These two questions will be handled in two subsections below.

Quick overview of some data management functions.

 

If S is a set, index i in S, and parameters P(i), Q(i,j) exist,
then the statement
Empty S ;
will remove all data from S, P, and Q.

There is a variant of the Empty statement that operates on
subsets of AllIdentifiers
Let the set sIds, subset of AllIdentifiers, be { P, Q }.
Then the statement:
Empty sIds ;
is implemented as emptying the data of P and Q, not of sIds.

Additionally, if S used to be data { a, b }, but is now { b },
and P used to have data { a : 1, b : 2 }
then:
('a':1 ) is called an inactive element of P.

To remove the inactive data in P, there are two alternatives:

Alternative 1. The statement
Cleanup P ;
will remove the inactive data from P, here the element ('a':1 ).

Alternative 2. The statement
CleanDependents S ;
will remove the inactive data from P, and remove the name 'a'
from the element space of S.

The statement
Rebuild ;
The permutation oi,j] is the main permutation for Q.
But the permutation oj,i] may also exist, because it is efficient
in a computation using Q.
The rebuild statement will remove the permutation from Q.

You may also be interested in GarbageCollectStrings, see
https://documentation.aimms.com/functionreference/elementary-computational-operations/string-manipulation-functions/garbagecollectstrings.html

 

Freeing up memory for the next data instance.

In the above, removing means moving the memory allocated
for the purpose at hand to memory reserves.
Examples of "the purpose at hand" are: representing data or facilitating sparse
execution by a permutated copy of the data.
The memory reserves are used first when new memory is needed during the
execution of your application.

I assume here that "All data" refers to the data of the sets
and parameters for your business logic, and not to the parameters
used to handle the logic of instance switching or to the UI support, or to ..

Therefore I would approach "removing all data” as follows:

First specify which identifiers are actually part of

  • the business logic / modeling of the real world, and 
  • the application behavior, including data presentation, dialogs, meta-information.

1) Create a subset of AllIdentifiers, say s_businessLogic and define it as
s_mainModelIds + s_lib1Ids + ... ;
where
s_mainModelIds := sectionBusinessLogic ;
and so on.

2) To remove all data for the business logic:

! Remove old Generated Mathematical Programs:
while card(AllGeneratedMathematicalPrograms) do
     ep_gmp := first( AllGeneratedMathematicalPrograms );
     gmp::instance::delete(ep_gmp);
     AllGeneratedMathematicalPrograms -= ep_gmp ;
endwhile ;
! Empty the identifiers pertaining to the business logic.
Empty s_businessLogic ;

! Brush the strings tables removing strings no longer in use.
GarbageCollectStrings();

Be the first to reply!

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator